Skip to content

Commit e952f0d

Browse files
Sateesh ChodapuneediVijayendra Bhamidipati
authored andcommitted
CS-15010 Nexus vSwitch: Advanced Zone - System VMs failed to deploy due to Start Command Failure
CS-15016 SSH connections to VSM are not cleared [Once the connections are exceeded it failed to connect to VSM] Conflicts: core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
1 parent b28568a commit e952f0d

5 files changed

Lines changed: 38 additions & 35 deletions

File tree

core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4022,14 +4022,19 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
40224022
_morHyperHost.setType(hostTokens[0]);
40234023
_morHyperHost.set_value(hostTokens[1]);
40244024

4025-
VmwareContext context = getServiceContext();
4026-
try {
4027-
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
4028-
mgr.setupResourceStartupParams(params);
4029-
4030-
CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager());
4025+
VmwareContext context = getServiceContext();
4026+
try {
4027+
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
4028+
mgr.setupResourceStartupParams(params);
4029+
4030+
CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager());
40314031
cfmMo.ensureCustomFieldDef("Datastore", CustomFieldConstants.CLOUD_UUID);
4032-
cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC);
4032+
if (mgr.getNexusVSwitchGlobalParameter()) {
4033+
cfmMo.ensureCustomFieldDef("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP);
4034+
} else {
4035+
cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC);
4036+
}
4037+
40334038
cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_UUID);
40344039
cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_NIC_MASK);
40354040

vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
public interface CustomFieldConstants {
1616
public final static String CLOUD_UUID = "cloud.uuid";
1717
public final static String CLOUD_GC = "cloud.gc";
18+
public final static String CLOUD_GC_DVP = "cloud.gc.dvp";
1819
public final static String CLOUD_NIC_MASK = "cloud.nic.mask";
1920
}

vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -444,31 +444,6 @@ public ManagedObjectReference getDvSwitchMor(ManagedObjectReference dvPortGroupM
444444

445445
public String getDvSwitchUuid(ManagedObjectReference dvSwitchMor) throws Exception {
446446
assert (dvSwitchMor != null);
447-
PropertySpec pSpec = new PropertySpec();
448-
pSpec.setType("DistributedVirtualSwitch");
449-
pSpec.setPathSet(new String[] { "uuid" });
450-
451-
ObjectSpec oSpec = new ObjectSpec();
452-
oSpec.setObj(dvSwitchMor);
453-
oSpec.setSkip(Boolean.FALSE);
454-
oSpec.setSelectSet(new SelectionSpec[] {});
455-
456-
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
457-
pfSpec.setPropSet(new PropertySpec[] { pSpec });
458-
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
459-
460-
ObjectContent[] ocs = _context.getService().retrieveProperties(
461-
_context.getServiceContent().getPropertyCollector(),
462-
new PropertyFilterSpec[] { pfSpec });
463-
464-
if (ocs != null) {
465-
for (ObjectContent oc : ocs) {
466-
DynamicProperty[] props = oc.getPropSet();
467-
if (props != null) {
468-
return (String) props[0].getVal();
469-
}
470-
}
471-
}
472-
return null;
447+
return (String) _context.getServiceUtil().getDynamicProperty(dvSwitchMor, "uuid");
473448
}
474449
}

vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ public static void createPortProfile(VmwareContext context, String ethPortProfil
176176
} catch (CloudRuntimeException e) {
177177
msg = "Failed to modify ethernet port profile " + ethPortProfileName + " with parameters " + params.toString();
178178
s_logger.error(msg);
179+
if(netconfClient != null) {
180+
netconfClient.disconnect();
181+
s_logger.debug("Disconnected VSM session.");
182+
}
179183
throw new CloudRuntimeException(msg);
180184
}
181185
}
@@ -188,13 +192,19 @@ public static void createPortProfile(VmwareContext context, String ethPortProfil
188192
s_logger.info("Adding port profile configured over VLAN : " + vlanId.toString());
189193
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue());
190194
}
195+
191196
} catch (CloudRuntimeException e) {
192197
msg = "Failed to add vEthernet port profile " + networkName + ". Exception: " + e.toString();
193198
s_logger.error(msg);
194199
if(vlanId == null) {
195200
s_logger.warn("Ignoring exception : " + e.toString());
196201
// throw new CloudRuntimeException(msg);
197202
}
203+
} finally {
204+
if(netconfClient != null) {
205+
netconfClient.disconnect();
206+
s_logger.debug("Disconnected VSM session.");
207+
}
198208
}
199209
}
200210

@@ -224,11 +234,16 @@ public static void updatePortProfile(VmwareContext context, String ethPortProfil
224234
params.add(new Pair<OperationType, String>(OperationType.addvlanid, vlanId.toString()));
225235

226236
try {
227-
netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.access, params);
237+
netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.trunk, params);
228238
} catch(CloudRuntimeException e) {
229239
msg = "Failed to modify ethernet port profile " + ethPortProfileName + " with parameters " + params.toString();
230240
s_logger.error(msg);
231241
throw new CloudRuntimeException(msg);
242+
} finally {
243+
if(netconfClient != null) {
244+
netconfClient.disconnect();
245+
s_logger.debug("Disconnected VSM session.");
246+
}
232247
}
233248
}
234249

@@ -339,7 +354,8 @@ public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPort
339354

340355
if(createGCTag) {
341356
NetworkMO networkMo = new NetworkMO(hostMo.getContext(), morNetwork);
342-
networkMo.setCustomFieldValue(CustomFieldConstants.CLOUD_GC, "true");
357+
networkMo.setCustomFieldValue(CustomFieldConstants.CLOUD_GC_DVP, "true");
358+
s_logger.debug("Added custom field : " + CustomFieldConstants.CLOUD_GC_DVP);
343359
}
344360

345361
return new Pair<ManagedObjectReference, String>(morNetwork, networkName);

vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ public List<NetworkDetails> getNetworksWithDetails() throws Exception {
650650

651651
int gcTagKey = getCustomFieldKey("Network", CustomFieldConstants.CLOUD_GC);
652652

653+
if(gcTagKey == 0) {
654+
gcTagKey = getCustomFieldKey("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP);
655+
s_logger.debug("The custom key for dvPortGroup is : " + gcTagKey);
656+
}
657+
653658
PropertySpec pSpec = new PropertySpec();
654659
pSpec.setType("Network");
655660
pSpec.setPathSet(new String[] {"name", "vm", String.format("value[%d]", gcTagKey)});
@@ -696,6 +701,7 @@ else if(prop.getName().startsWith("value[")) {
696701

697702
networks.add(details);
698703
}
704+
s_logger.debug("Retrieved " + networks.size() + " networks with key : " + gcTagKey);
699705
}
700706

701707
return networks;

0 commit comments

Comments
 (0)