CumulusVlanHelper { protected Configuration updateVlanConfiguration( SwitchVlan vlan, Configuration configuration ) throws HmsOobNetworkException { Bridge vRackBridge = configuration.bridges.get( 0 ); List<SwitchPort> taggedPorts = configuration.convertToSwitchPorts( vlan.getTaggedPorts() ); if ( vRackBridge.vlans == null ) vRackBridge.vlans = new ArrayList<>(); if ( !vRackBridge.vlans.contains( vlan.getId() ) ) vRackBridge.vlans.add( vlan.getId() ); if ( taggedPorts != null ) { for ( SwitchPort taggedPort : taggedPorts ) { if ( taggedPort.vlans == null ) taggedPort.vlans = new ArrayList<>(); if ( !taggedPort.vlans.contains( vlan.getId() ) ) taggedPort.vlans.add( vlan.getId() ); if ( configuration.getConfigBlock( taggedPort.name ) == null ) configuration.switchPorts.add( taggedPort ); taggedPort.setParentBridge( vRackBridge ); if ( !vRackBridge.members.contains( taggedPort ) ) vRackBridge.members.add( taggedPort ); } } CumulusSviHelper.updateVlanInConfiguration( vRackBridge.name, vlan, configuration ); return configuration; } CumulusVlanHelper( CumulusTorSwitchService service ); List<String> getSwitchVlans( SwitchNode switchNode ); SwitchVlan getSwitchVlan( SwitchNode switchNode, String vlanName ); List<SwitchVlan> getSwitchVlansBulk( SwitchNode switchNode ); boolean createVlan( SwitchNode switchNode, SwitchVlan vlan ); boolean updateVlan( SwitchNode switchNode, String vlanName, SwitchVlan vlan ); boolean updateLAGOnSwitchPorts( SwitchNode switchNode, SwitchLacpGroup lacpGroup ); boolean deletePortFromVlanConfiguration( SwitchNode switchNode, String vlanId, String port ); boolean deleteVlan( SwitchNode switchNode, String vlanName ); Configuration deleteVlan( SwitchVlan vlan, Configuration configuration );  }
@Test public void testAddVlanToSwitchPort() { Configuration configuration = Configuration.parse( interfacesFile ); CumulusVlanHelper helper = new CumulusVlanHelper( null ); SwitchVlan vlan = new SwitchVlan(); vlan.setId( "1200" ); vlan.setTaggedPorts( new HashSet<String>() ); vlan.getTaggedPorts().add( "swp2" ); vlan.getTaggedPorts().add( "swp4" ); try { helper.updateVlanConfiguration( vlan, configuration ); } catch ( HmsOobNetworkException e ) { e.printStackTrace(); } System.out.println( configuration.getString() ); }