You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ko...@apache.org on 2013/03/20 10:40:46 UTC
[2/5] git commit: refs/heads/cisco-vnmc-api-integration - Creating
vservice node and associating it with port profile in nexus for guest VMs
Creating vservice node and associating it with port profile in nexus for guest VMs
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/2ce7cdc7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/2ce7cdc7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/2ce7cdc7
Branch: refs/heads/cisco-vnmc-api-integration
Commit: 2ce7cdc756bd43adec006b877cb41da6f3e9dd57
Parents: 387545c
Author: Koushik Das <ko...@citrix.com>
Authored: Sun Mar 17 17:02:25 2013 +0530
Committer: Koushik Das <ko...@citrix.com>
Committed: Sun Mar 17 17:02:25 2013 +0530
----------------------------------------------------------------------
.../src/com/cloud/hypervisor/guru/VMwareGuru.java | 18 ++++++++--
.../hypervisor/vmware/resource/VmwareResource.java | 27 ++++++++-------
.../hypervisor/vmware/mo/HypervisorHostHelper.java | 16 ++++++--
3 files changed, 41 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2ce7cdc7/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
index bb7c297..dcee367 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
@@ -49,7 +49,9 @@ import com.cloud.hypervisor.HypervisorGuru;
import com.cloud.hypervisor.HypervisorGuruBase;
import com.cloud.hypervisor.vmware.manager.VmwareManager;
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
+import com.cloud.network.Network.Provider;
import com.cloud.network.NetworkModel;
+import com.cloud.network.Network.Service;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkVO;
@@ -140,13 +142,23 @@ public class VMwareGuru extends HypervisorGuruBase implements HypervisorGuru {
}
details.put(VmDetailConstants.ROOK_DISK_CONTROLLER, _vmwareMgr.getRootDiskController());
}
-
+
+ List<NicProfile> nicProfiles = vm.getNics();
+
+ for(NicProfile nicProfile : nicProfiles) {
+ if(nicProfile.getTrafficType() == TrafficType.Guest) {
+ if(_networkMgr.isProviderSupportServiceInNetwork(nicProfile.getNetworkId(), Service.Firewall, Provider.CiscoVnmc)) {
+ details.put("ConfigureVServiceInNexus", Boolean.TRUE.toString());
+ }
+ break;
+ }
+ }
+
to.setDetails(details);
if(vm.getVirtualMachine() instanceof DomainRouterVO) {
- List<NicProfile> nicProfiles = vm.getNics();
- NicProfile publicNicProfile = null;
+ NicProfile publicNicProfile = null;
for(NicProfile nicProfile : nicProfiles) {
if(nicProfile.getTrafficType() == TrafficType.Public) {
publicNicProfile = nicProfile;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2ce7cdc7/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
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 4839b35..22e59d3 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
@@ -200,6 +200,7 @@ import com.cloud.network.HAProxyConfigurator;
import com.cloud.network.LoadBalancerConfigurator;
import com.cloud.network.Networks;
import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.network.Networks.TrafficType;
import com.cloud.network.rules.FirewallRule;
import com.cloud.resource.ServerResource;
import com.cloud.serializer.GsonHelper;
@@ -1318,7 +1319,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
NicTO nicTo = cmd.getNic();
VirtualDevice nic;
- Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
+ Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, false);
if (mgr.getNexusVSwitchGlobalParameter()) {
String dvSwitchUuid;
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
@@ -1556,7 +1557,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout, true);
} else {
networkInfo = HypervisorHostHelper.prepareNetwork(this._publicNetworkVSwitchName, "cloud.public",
- vmMo.getRunningHost(), vlanId, null, null, this._ops_timeout);
+ vmMo.getRunningHost(), vlanId, false, null, null, this._ops_timeout);
}
int nicIndex = allocPublicNicIndex(vmMo);
@@ -2264,7 +2265,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
for (NicTO nicTo : sortNicsByDeviceId(nics)) {
s_logger.info("Prepare NIC device based on NicTO: " + _gson.toJson(nicTo));
- Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
+ boolean configureVServiceInNexus = (nicTo.getType() == TrafficType.Guest) && (vmSpec.getDetails().containsKey("ConfigureVServiceInNexus"));
+ Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo, configureVServiceInNexus);
if (mgr.getNexusVSwitchGlobalParameter()) {
String dvSwitchUuid;
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
@@ -2463,22 +2465,21 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
return defaultVlan;
}
- private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo) throws Exception {
+ private Pair<ManagedObjectReference, String> prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo, boolean configureVServiceInNexus) throws Exception {
- Pair<String, String> switchName = getTargetSwitch(nicTo);
+ Pair<String, String> switchName = getTargetSwitch(nicTo);
String namePrefix = getNetworkNamePrefix(nicTo);
Pair<ManagedObjectReference, String> networkInfo = null;
s_logger.info("Prepare network on vSwitch: " + switchName + " with name prefix: " + namePrefix);
- if(!_nexusVSwitch) {
- networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
- nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
+ if (!_nexusVSwitch) {
+ networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
+ nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout,
!namePrefix.startsWith("cloud.private"));
- }
- else {
- networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
- nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
+ } else {
+ networkInfo = HypervisorHostHelper.prepareNetwork(switchName.first(), namePrefix, hostMo, getVlanInfo(nicTo, switchName.second()),
+ configureVServiceInNexus, nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(), _ops_timeout);
}
return networkInfo;
@@ -2966,7 +2967,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
NicTO[] nics = vm.getNics();
for (NicTO nic : nics) {
// prepare network on the host
- prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic);
+ prepareNetworkFromNicInfo(new HostMO(getServiceContext(), _morHyperHost), nic, false);
}
String secStoreUrl = mgr.getSecondaryStorageStoreUrl(Long.parseLong(_dcId));
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2ce7cdc7/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
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 50f9541..3867881 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -158,7 +158,7 @@ public class HypervisorHostHelper {
}
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName,
- Integer vlanId, Integer networkRateMbps, long peakBandwidth, long burstSize) throws Exception {
+ Integer vlanId, Integer networkRateMbps, long peakBandwidth, long burstSize, boolean configureVServiceInNexus) throws Exception {
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
String vsmIp = vsmCredentials.get("vsmip");
String vsmUserName = vsmCredentials.get("vsmusername");
@@ -229,7 +229,15 @@ public class HypervisorHostHelper {
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, 0);
} else {
s_logger.info("Adding port profile configured over VLAN : " + vlanId.toString());
- netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue());
+ if (!configureVServiceInNexus) {
+ 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");
+ netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue(), vdc, esp);
+ }
}
} catch (CloudRuntimeException e) {
msg = "Failed to add vEthernet port profile " + networkName + "." + ". Exception: " + e.toString();
@@ -394,7 +402,7 @@ public class HypervisorHostHelper {
*/
public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPortProfileName, String namePrefix,
- HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs)
+ HostMO hostMo, String vlanId, boolean configureVServiceInNexus, Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs)
throws Exception {
ManagedObjectReference morNetwork = null;
VmwareContext context = hostMo.getContext();
@@ -459,7 +467,7 @@ public class HypervisorHostHelper {
boolean bWaitPortGroupReady = false;
if (!dataCenterMo.hasDvPortGroup(networkName)) {
s_logger.info("Port profile " + networkName + " not found.");
- createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize);
+ createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps, peakBandwidth, burstSize, configureVServiceInNexus);
bWaitPortGroupReady = true;
} else {
s_logger.info("Port profile " + networkName + " found.");