From 48cbf34d3bf44a5601842fa8bbc41be6beea3b07 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Wed, 27 Mar 2013 02:20:45 +0530 Subject: [PATCH] Passing correct gateway ip while creating vservice node and guest port profile in Nexus --- .../hypervisor/vmware/resource/VmwareResource.java | 4 ++-- .../hypervisor/vmware/mo/HypervisorHostHelper.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 98847c1851b..be683a04244 100755 --- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -1570,7 +1570,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true); } else { networkInfo = HypervisorHostHelper.prepareNetwork(this._publicTrafficInfo.getVirtualSwitchName(), "cloud.public", - vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, vSwitchType, _portsPerDvPortGroup, false); + vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, vSwitchType, _portsPerDvPortGroup, null, false); } int nicIndex = allocPublicNicIndex(vmMo); @@ -2517,7 +2517,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa } else { networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()), - nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType, _portsPerDvPortGroup, configureVServiceInNexus); + nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout, switchType, _portsPerDvPortGroup, nicTo.getGateway(), configureVServiceInNexus); } return networkInfo; 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 fa6938a6fe6..7f323c5e400 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -163,7 +163,8 @@ public class HypervisorHostHelper { } public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, - Integer vlanId, Integer networkRateMbps, long peakBandwidth, long burstSize, boolean configureVServiceInNexus) throws Exception { + Integer vlanId, Integer networkRateMbps, long peakBandwidth, long burstSize, + String gateway, boolean configureVServiceInNexus) throws Exception { Map vsmCredentials = getValidatedVsmCredentials(context); String vsmIp = vsmCredentials.get("vsmip"); String vsmUserName = vsmCredentials.get("vsmusername"); @@ -233,14 +234,16 @@ public class HypervisorHostHelper { s_logger.info("Adding port profile configured over untagged VLAN."); netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, 0); } else { - s_logger.info("Adding port profile configured over VLAN : " + vlanId.toString()); if (!configureVServiceInNexus) { + s_logger.info("Adding port profile configured over VLAN : " + vlanId.toString()); netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue()); } else { String tenant = "vlan-" + vlanId.intValue(); String vdc = "root/" + tenant + "/VDC-" + tenant; String esp = "ESP-" + tenant; - netconfClient.addVServiceNode(vlanId.toString(), "10.1.1.1"); + s_logger.info("Adding vservice node in Nexus VSM for VLAN : " + vlanId.toString()); + netconfClient.addVServiceNode(vlanId.toString(), gateway); + s_logger.info("Adding port profile with vservice details configured over VLAN : " + vlanId.toString()); netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue(), vdc, esp); } } @@ -410,7 +413,7 @@ public class HypervisorHostHelper { public static Pair prepareNetwork(String physicalNetwork, String namePrefix, HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, - VirtualSwitchType vSwitchType, int numPorts, boolean configureVServiceInNexus) throws Exception { + VirtualSwitchType vSwitchType, int numPorts, String gateway, boolean configureVServiceInNexus) throws Exception { ManagedObjectReference morNetwork = null; VmwareContext context = hostMo.getContext(); ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter(); @@ -524,7 +527,7 @@ public class HypervisorHostHelper { if (!dataCenterMo.hasDvPortGroup(networkName)) { s_logger.info("Port profile " + networkName + " not found."); - createPortProfile(context, physicalNetwork, networkName, vid, networkRateMbps, peakBandwidth, burstSize, configureVServiceInNexus); + createPortProfile(context, physicalNetwork, networkName, vid, networkRateMbps, peakBandwidth, burstSize, gateway, configureVServiceInNexus); bWaitPortGroupReady = true; } else { s_logger.info("Port profile " + networkName + " found.");