}
}
}
// First create a DVSconfig spec.
VMwareDVSConfigSpec dvsSpec = new VMwareDVSConfigSpec();
// Next, add the required primary and secondary vlan config specs to the dvs config spec.
if (!vlanmap.containsKey(vid)) {
VMwareDVSPvlanConfigSpec ppvlanConfigSpec = createDVPortPvlanConfigSpec(vid, vid, PvlanType.promiscuous, PvlanOperation.add);
dvsSpec.getPvlanConfigSpec().add(ppvlanConfigSpec);
}
if ( !vid.equals(spvlanid) && !vlanmap.containsKey(spvlanid)) {
VMwareDVSPvlanConfigSpec spvlanConfigSpec = createDVPortPvlanConfigSpec(vid, spvlanid, PvlanType.isolated, PvlanOperation.add);
dvsSpec.getPvlanConfigSpec().add(spvlanConfigSpec);
}
if (dvsSpec.getPvlanConfigSpec().size() > 0) {
// We have something to configure on the DVS... so send it the command.
// When reconfiguring a vmware DVSwitch, we need to send in the configVersion in the spec.
// Let's retrieve this switch's configVersion first.
String dvsConfigVersion = dvSwitchMo.getDVSConfigVersion(morDvSwitch);
dvsSpec.setConfigVersion(dvsConfigVersion);
// Reconfigure the dvs using this spec.
try {
dvSwitchMo.updateVMWareDVSwitchGetTask(morDvSwitch, dvsSpec);
} catch (AlreadyExistsFaultMsg e) {