diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index dc2a9fc3ec2..d7a7c581663 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -4020,8 +4020,12 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa mgr.setupResourceStartupParams(params); CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager()); - cfmMo.ensureCustomFieldDef("Datastore", CustomFieldConstants.CLOUD_UUID); - cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC); + cfmMo.ensureCustomFieldDef("Datastore", CustomFieldConstants.CLOUD_UUID); + if (mgr.getNexusVSwitchGlobalParameter()) { + cfmMo.ensureCustomFieldDef("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP); + } else { + cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC); + } cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_UUID); cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_NIC_MASK); diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java index 016b04c3b96..84f72fd0d70 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java @@ -15,5 +15,6 @@ package com.cloud.hypervisor.vmware.mo; public interface CustomFieldConstants { public final static String CLOUD_UUID = "cloud.uuid"; public final static String CLOUD_GC = "cloud.gc"; + public final static String CLOUD_GC_DVP = "cloud.gc.dvp"; public final static String CLOUD_NIC_MASK = "cloud.nic.mask"; } diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java index 4dd3f8c9097..c753fb793dc 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java @@ -443,31 +443,6 @@ public class DatacenterMO extends BaseMO { public String getDvSwitchUuid(ManagedObjectReference dvSwitchMor) throws Exception { assert (dvSwitchMor != null); - PropertySpec pSpec = new PropertySpec(); - pSpec.setType("DistributedVirtualSwitch"); - pSpec.setPathSet(new String[] { "uuid" }); - - ObjectSpec oSpec = new ObjectSpec(); - oSpec.setObj(dvSwitchMor); - oSpec.setSkip(Boolean.FALSE); - oSpec.setSelectSet(new SelectionSpec[] {}); - - PropertyFilterSpec pfSpec = new PropertyFilterSpec(); - pfSpec.setPropSet(new PropertySpec[] { pSpec }); - pfSpec.setObjectSet(new ObjectSpec[] { oSpec }); - - ObjectContent[] ocs = _context.getService().retrieveProperties( - _context.getServiceContent().getPropertyCollector(), - new PropertyFilterSpec[] { pfSpec }); - - if (ocs != null) { - for (ObjectContent oc : ocs) { - DynamicProperty[] props = oc.getPropSet(); - if (props != null) { - return (String) props[0].getVal(); - } - } - } - return null; + return (String) _context.getServiceUtil().getDynamicProperty(dvSwitchMor, "uuid"); } } diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java index 44e97c110f5..1c739370e74 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -168,6 +168,10 @@ public class HypervisorHostHelper { } catch (CloudRuntimeException e) { msg = "Failed to modify ethernet port profile " + ethPortProfileName + " with parameters " + params.toString(); s_logger.error(msg); + if(netconfClient != null) { + netconfClient.disconnect(); + s_logger.debug("Disconnected VSM session."); + } throw new CloudRuntimeException(msg); } } @@ -180,6 +184,7 @@ public class HypervisorHostHelper { s_logger.info("Adding port profile configured over VLAN : " + vlanId.toString()); netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue()); } + } catch (CloudRuntimeException e) { msg = "Failed to add vEthernet port profile " + networkName + ". Exception: " + e.toString(); s_logger.error(msg); @@ -187,6 +192,11 @@ public class HypervisorHostHelper { s_logger.warn("Ignoring exception : " + e.toString()); // throw new CloudRuntimeException(msg); } + } finally { + if(netconfClient != null) { + netconfClient.disconnect(); + s_logger.debug("Disconnected VSM session."); + } } } @@ -216,11 +226,16 @@ public class HypervisorHostHelper { params.add(new Pair(OperationType.addvlanid, vlanId.toString())); try { - netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.access, params); + netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.trunk, params); } catch(CloudRuntimeException e) { msg = "Failed to modify ethernet port profile " + ethPortProfileName + " with parameters " + params.toString(); s_logger.error(msg); throw new CloudRuntimeException(msg); + } finally { + if(netconfClient != null) { + netconfClient.disconnect(); + s_logger.debug("Disconnected VSM session."); + } } } @@ -331,7 +346,8 @@ public class HypervisorHostHelper { if(createGCTag) { NetworkMO networkMo = new NetworkMO(hostMo.getContext(), morNetwork); - networkMo.setCustomFieldValue(CustomFieldConstants.CLOUD_GC, "true"); + networkMo.setCustomFieldValue(CustomFieldConstants.CLOUD_GC_DVP, "true"); + s_logger.debug("Added custom field : " + CustomFieldConstants.CLOUD_GC_DVP); } return new Pair(morNetwork, networkName); diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java index ba7f003bc68..3319e928db6 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -648,7 +648,12 @@ public class VirtualMachineMO extends BaseMO { public List getNetworksWithDetails() throws Exception { List networks = new ArrayList(); - int gcTagKey = getCustomFieldKey("Network", CustomFieldConstants.CLOUD_GC); + int gcTagKey = getCustomFieldKey("Network", CustomFieldConstants.CLOUD_GC); + + if(gcTagKey == 0) { + gcTagKey = getCustomFieldKey("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP); + s_logger.debug("The custom key for dvPortGroup is : " + gcTagKey); + } PropertySpec pSpec = new PropertySpec(); pSpec.setType("Network"); @@ -694,8 +699,9 @@ public class VirtualMachineMO extends BaseMO { (morVms != null ? morVms.getManagedObjectReference() : null), gcTagValue); - networks.add(details); - } + networks.add(details); + } + s_logger.debug("Retrieved " + networks.size() + " networks with key : " + gcTagKey); } return networks;