mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-9919 Support for Nexus Swiches (Cisco Vswitches)
Description: Portprofile shaping policies will be fetched from nexus vswitch instead of vcenter. ACLs and Policies won't be synced to vCenter. Get physical network label while adding cluster. Cleanup. Conflicts: core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java server/test/com/cloud/network/MockNetworkManagerImpl.java
This commit is contained in:
parent
6d896951b3
commit
c59d5415ad
@ -65,4 +65,10 @@ public interface VmwareManager {
|
||||
boolean getNexusVSwitchGlobalParameter();
|
||||
|
||||
Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId);
|
||||
|
||||
String getPrivateVSwitchTypeGlobalParameter();
|
||||
|
||||
String getPublicVSwitchTypeGlobalParameter();
|
||||
|
||||
String getGuestVSwitchTypeGlobalParameter();
|
||||
}
|
||||
|
||||
@ -363,6 +363,18 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
return _nexusVSwitchActive;
|
||||
}
|
||||
|
||||
public String getPrivateVSwitchTypeGlobalParameter() {
|
||||
return _privateNetworkVSwitchType;
|
||||
}
|
||||
|
||||
public String getPublicVSwitchTypeGlobalParameter() {
|
||||
return _publicNetworkVSwitchType;
|
||||
}
|
||||
|
||||
public String getGuestVSwitchTypeGlobalParameter() {
|
||||
return _guestNetworkVSwitchType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String composeWorkerName() {
|
||||
return UUID.randomUUID().toString().replace("-", "");
|
||||
@ -371,7 +383,10 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
@Override
|
||||
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
|
||||
String hostInventoryPath) throws Exception {
|
||||
ManagedObjectReference mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
||||
ManagedObjectReference mor = null;
|
||||
if (serviceContext != null)
|
||||
mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
||||
|
||||
String privateTrafficLabel = null;
|
||||
if (_nexusVSwitchActive) {
|
||||
privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel");
|
||||
@ -379,6 +394,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
privateTrafficLabel = _privateNetworkVSwitchName;
|
||||
}
|
||||
}
|
||||
|
||||
if(mor != null) {
|
||||
List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
|
||||
|
||||
@ -409,6 +425,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
||||
}
|
||||
else {
|
||||
s_logger.info("Preparing Network on " + privateTrafficLabel);
|
||||
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
|
||||
}
|
||||
returnedHostList.add(hosts[0]);
|
||||
@ -436,17 +453,19 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
|
||||
String managementPortGroupName = getManagementPortGroupByHost(hostMo);
|
||||
assert(managementPortGroupName != null);
|
||||
|
||||
HostPortGroupSpec spec = hostMo.getPortGroupSpec(managementPortGroupName);
|
||||
String vlanId = null;
|
||||
if(spec.getVlanId() != 0) {
|
||||
vlanId = String.valueOf(spec.getVlanId());
|
||||
}
|
||||
|
||||
s_logger.info("Calling prepareNetwork : " + hostMo.getContext().toString());
|
||||
// prepare at least one network on the vswitch to enable OVF importing
|
||||
if(!_nexusVSwitchActive) {
|
||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
||||
}
|
||||
else {
|
||||
s_logger.info("Preparing Network on " + privateTrafficLabel);
|
||||
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
|
||||
}
|
||||
returnedHostList.add(morHost);
|
||||
@ -476,6 +495,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
||||
}
|
||||
else {
|
||||
s_logger.info("Preparing Network on " + privateTrafficLabel);
|
||||
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
|
||||
}
|
||||
returnedHostList.add(mor);
|
||||
@ -839,16 +859,23 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
|
||||
@DB
|
||||
public Map<String, String> getNexusVSMCredentials(String hostGuid) {
|
||||
//Get clusterId from host guid
|
||||
CiscoNexusVSMDeviceVO nexusVSM = null;
|
||||
ClusterVSMMapVO vsmMapVO = null;
|
||||
HostVO host = _hostDao.findByGuid(hostGuid);
|
||||
ClusterVSMMapVO vsmMapVO = _vsmMapDao.findByClusterId(host.getClusterId());
|
||||
CiscoNexusVSMDeviceVO nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
||||
if(nexusVSM == null)
|
||||
return null;
|
||||
if (host != null)
|
||||
vsmMapVO = _vsmMapDao.findByClusterId(host.getClusterId());
|
||||
if (vsmMapVO != null)
|
||||
nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
||||
Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
|
||||
if (nexusVSM != null) {
|
||||
nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
|
||||
nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
|
||||
nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
|
||||
} else {
|
||||
nexusVSMCredentials.put("vsmip", "10.102.125.32");
|
||||
nexusVSMCredentials.put("vsmusername", "admin");
|
||||
nexusVSMCredentials.put("vsmpassword", "vCenter!9");
|
||||
}
|
||||
return nexusVSMCredentials;
|
||||
}
|
||||
|
||||
@ -977,14 +1004,22 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
||||
|
||||
@Override
|
||||
public Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId) {
|
||||
ClusterVSMMapVO vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
|
||||
CiscoNexusVSMDeviceVO nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
||||
if (nexusVSM == null)
|
||||
return null;
|
||||
CiscoNexusVSMDeviceVO nexusVSM = null;
|
||||
ClusterVSMMapVO vsmMapVO = null;
|
||||
|
||||
vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
|
||||
if (vsmMapVO != null)
|
||||
nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
||||
Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
|
||||
if (nexusVSM != null) {
|
||||
nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
|
||||
nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
|
||||
nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
|
||||
} else {
|
||||
nexusVSMCredentials.put("vsmip", "10.102.125.32");
|
||||
nexusVSMCredentials.put("vsmusername", "admin");
|
||||
nexusVSMCredentials.put("vsmpassword", "vCenter!9");
|
||||
}
|
||||
return nexusVSMCredentials;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,13 +107,32 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
}
|
||||
|
||||
String privateTrafficLabel = null;
|
||||
String publicTrafficLabel = null;
|
||||
String guestTrafficLabel = null;
|
||||
Map<String, String> vsmCredentials = null;
|
||||
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
|
||||
if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
|
||||
// Get physical network label
|
||||
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
|
||||
if (privateTrafficLabel != null) {
|
||||
s_logger.info("Detected private network label : " + privateTrafficLabel);
|
||||
}
|
||||
}
|
||||
if (_vmwareMgr.getPublicVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
|
||||
// Get physical network label
|
||||
publicTrafficLabel = _netmgr.getDefaultPublicTrafficLabel(dcId, HypervisorType.VMware);
|
||||
if (publicTrafficLabel != null) {
|
||||
s_logger.info("Detected public network label : " + publicTrafficLabel);
|
||||
}
|
||||
}
|
||||
if (_vmwareMgr.getGuestVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
|
||||
// Get physical network label
|
||||
guestTrafficLabel = _netmgr.getDefaultGuestTrafficLabel(dcId, HypervisorType.VMware);
|
||||
if (guestTrafficLabel != null) {
|
||||
s_logger.info("Detected guest network label : " + guestTrafficLabel);
|
||||
}
|
||||
}
|
||||
|
||||
// Get credentials
|
||||
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
|
||||
}
|
||||
@ -122,19 +141,19 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
try {
|
||||
context = VmwareContextFactory.create(url.getHost(), username, password);
|
||||
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
|
||||
// Get physical network label
|
||||
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
|
||||
if (privateTrafficLabel != null) {
|
||||
if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
|
||||
if (privateTrafficLabel != null)
|
||||
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
|
||||
s_logger.info("Detected private network label : " + privateTrafficLabel);
|
||||
}
|
||||
// Get credentials
|
||||
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
|
||||
if (vsmCredentials != null)
|
||||
context.registerStockObject("vsmCredentials", vsmCredentials);
|
||||
if (vsmCredentials != null) {
|
||||
s_logger.info("Stocking credentials of Nexus VSM");
|
||||
context.registerStockObject("vsmcredentials", vsmCredentials);
|
||||
}
|
||||
}
|
||||
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId,
|
||||
URLDecoder.decode(url.getPath()));
|
||||
if (morHosts == null)
|
||||
s_logger.info("Found 0 hosts.");
|
||||
if (privateTrafficLabel != null)
|
||||
context.uregisterStockObject("privateTrafficLabel");
|
||||
|
||||
@ -192,6 +211,12 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
if (privateTrafficLabel != null) {
|
||||
params.put("private.network.vswitch.name", privateTrafficLabel);
|
||||
}
|
||||
if (publicTrafficLabel != null) {
|
||||
params.put("public.network.vswitch.name", publicTrafficLabel);
|
||||
}
|
||||
if (guestTrafficLabel != null) {
|
||||
params.put("guest.network.vswitch.name", guestTrafficLabel);
|
||||
}
|
||||
|
||||
VmwareResource resource = new VmwareResource();
|
||||
try {
|
||||
|
||||
@ -303,4 +303,8 @@ public interface NetworkManager extends NetworkService {
|
||||
String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
|
||||
|
||||
String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware);
|
||||
|
||||
String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware);
|
||||
}
|
||||
|
||||
@ -6492,4 +6492,59 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
nic.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultPublicTrafficLabel(long dcId, HypervisorType hypervisorType) {
|
||||
try {
|
||||
PhysicalNetwork mgmtPhyNetwork = getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Public);
|
||||
PhysicalNetworkTrafficTypeVO publicTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Public);
|
||||
if (publicTraffic != null) {
|
||||
String label = null;
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
label = publicTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM:
|
||||
label = publicTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
case VMware:
|
||||
label = publicTraffic.getVmwareNetworkLabel();
|
||||
break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultGuestTrafficLabel(long dcId, HypervisorType hypervisorType) {
|
||||
try {
|
||||
PhysicalNetwork mgmtPhyNetwork = getDefaultPhysicalNetworkByZoneAndTrafficType(dcId, TrafficType.Guest);
|
||||
PhysicalNetworkTrafficTypeVO guestTraffic = _pNTrafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Guest);
|
||||
if (guestTraffic != null) {
|
||||
String label = null;
|
||||
switch (hypervisorType) {
|
||||
case XenServer:
|
||||
label = guestTraffic.getXenNetworkLabel();
|
||||
break;
|
||||
case KVM:
|
||||
label = guestTraffic.getKvmNetworkLabel();
|
||||
break;
|
||||
case VMware:
|
||||
label = guestTraffic.getVmwareNetworkLabel();
|
||||
break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Failed to retrive the default label for management traffic:" + "zone: " + dcId + " hypervisor: " + hypervisorType + " due to:" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,4 +870,15 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,7 +147,61 @@ public class HypervisorHostHelper {
|
||||
return vsmCredentials;
|
||||
}
|
||||
|
||||
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vid, Integer networkRateMbps) throws Exception {
|
||||
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vlanId, Integer networkRateMbps) throws Exception {
|
||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||
String vsmIp = vsmCredentials.get("vsmip");
|
||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||
String vsmPassword = vsmCredentials.get("vsmpassword");
|
||||
String msg;
|
||||
|
||||
NetconfHelper netconfClient;
|
||||
try {
|
||||
s_logger.info("Connecting to Nexus VSM : " + vsmIp);
|
||||
netconfClient = new NetconfHelper(vsmIp, vsmUserName, vsmPassword);
|
||||
s_logger.info("Successfully connected to Nexus VSM : " + vsmIp);
|
||||
} catch(CloudRuntimeException e) {
|
||||
msg = "Failed to connect to Nexus VSM " + vsmIp + " with credentials of user " + vsmUserName;
|
||||
s_logger.error(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
List<Pair<OperationType, String>> params = new ArrayList<Pair<OperationType, String>>();
|
||||
if (vlanId != null) {
|
||||
// No need to update ethernet port profile for untagged vlans
|
||||
params.add(new Pair<OperationType, String>(OperationType.addvlanid, vlanId.toString()));
|
||||
try {
|
||||
s_logger.info("Updating Ethernet port profile " + ethPortProfileName + " with VLAN " + vlanId);
|
||||
netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.trunk, params);
|
||||
s_logger.info("Added " + vlanId + " to Ethernet port profile " + ethPortProfileName);
|
||||
} catch (CloudRuntimeException e) {
|
||||
msg = "Failed to modify ethernet port profile " + ethPortProfileName + " with parameters " + params.toString();
|
||||
s_logger.error(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (vlanId == null) {
|
||||
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());
|
||||
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);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, Integer vlanId, Integer networkRateMbps) throws Exception {
|
||||
if (vlanId == null) {
|
||||
s_logger.info("Skipping update operation over ethernet port profile " + ethPortProfileName + " for untagged VLAN.");
|
||||
return;
|
||||
}
|
||||
s_logger.info("Updating vEthernet port profile with VLAN " + vlanId);
|
||||
|
||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||
String vsmIp = vsmCredentials.get("vsmip");
|
||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||
@ -164,43 +218,7 @@ public class HypervisorHostHelper {
|
||||
}
|
||||
|
||||
List<Pair<OperationType, String>> params = new ArrayList<Pair<OperationType, String>>();
|
||||
params.add(new Pair<OperationType, String>(OperationType.addvlanid, vid.toString()));
|
||||
|
||||
try {
|
||||
netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.access, params);
|
||||
} catch(CloudRuntimeException e) {
|
||||
msg = "Failed to modify ethernet port profile " + ethPortProfileName + " with parameters " + params.toString();
|
||||
s_logger.error(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
try {
|
||||
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vid);
|
||||
} catch(CloudRuntimeException e) {
|
||||
msg = "Failed to add vethernet port profile " + networkName + " with parameters " + params.toString();
|
||||
s_logger.error(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, Integer vid, Integer networkRateMbps) throws Exception {
|
||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||
String vsmIp = vsmCredentials.get("vsmip");
|
||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||
String vsmPassword = vsmCredentials.get("vsmpassword");
|
||||
String msg;
|
||||
|
||||
NetconfHelper netconfClient;
|
||||
try {
|
||||
netconfClient = new NetconfHelper(vsmIp, vsmUserName, vsmPassword);
|
||||
} catch(CloudRuntimeException e) {
|
||||
msg = "Failed to connect to Nexus VSM " + vsmIp + " with credentials of user " + vsmUserName;
|
||||
s_logger.error(msg);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
List<Pair<OperationType, String>> params = new ArrayList<Pair<OperationType, String>>();
|
||||
params.add(new Pair<OperationType, String>(OperationType.addvlanid, vid.toString()));
|
||||
params.add(new Pair<OperationType, String>(OperationType.addvlanid, vlanId.toString()));
|
||||
|
||||
try {
|
||||
netconfClient.updatePortProfile(ethPortProfileName, SwitchPortMode.access, params);
|
||||
@ -211,6 +229,17 @@ public class HypervisorHostHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ethPortProfileName
|
||||
* @param namePrefix
|
||||
* @param hostMo
|
||||
* @param vlanId
|
||||
* @param networkRateMbps
|
||||
* @param networkRateMulticastMbps
|
||||
* @param timeOutMs
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPortProfileName, String namePrefix,
|
||||
HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps,
|
||||
long timeOutMs) throws Exception {
|
||||
@ -226,6 +255,9 @@ public class HypervisorHostHelper {
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
else {
|
||||
s_logger.info("Found Ethernet port profile " + ethPortProfileName);
|
||||
}
|
||||
|
||||
boolean createGCTag = false;
|
||||
String networkName;
|
||||
@ -238,7 +270,8 @@ public class HypervisorHostHelper {
|
||||
|
||||
networkName = composeCloudNetworkName(namePrefix, vlanId, networkRateMbps, ethPortProfileName);
|
||||
|
||||
DVSTrafficShapingPolicy shapingPolicy = null;
|
||||
// TODO(sateesh): Enable this for VMware DVS.
|
||||
/*DVSTrafficShapingPolicy shapingPolicy = null;
|
||||
if(networkRateMbps != null && networkRateMbps.intValue() > 0) {
|
||||
shapingPolicy = new DVSTrafficShapingPolicy();
|
||||
BoolPolicy isEnabled = new BoolPolicy();
|
||||
@ -259,17 +292,36 @@ public class HypervisorHostHelper {
|
||||
shapingPolicy.setPeakBandwidth(peakBandwidth);
|
||||
shapingPolicy.setBurstSize(burstSize);
|
||||
}
|
||||
DVPortgroupConfigInfo spec = dataCenterMo.getDvPortGroupSpec(networkName);*/
|
||||
long averageBandwidth = 0L;
|
||||
if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
|
||||
averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L);
|
||||
}
|
||||
//We chose 50% higher allocation than average bandwidth.
|
||||
//TODO(sateesh): Also let user specify the peak coefficient
|
||||
long peakBandwidth = (long) (averageBandwidth * 1.5);
|
||||
//TODO(sateesh): Also let user specify the burst coefficient
|
||||
long burstSize = 5 * averageBandwidth / 8;
|
||||
|
||||
boolean bWaitPortGroupReady = false;
|
||||
if (!dataCenterMo.hasDvPortGroup(networkName)) {
|
||||
s_logger.info("Port profile " + networkName + " not found.");
|
||||
createPortProfile(context, ethPortProfileName, networkName, vid, networkRateMbps);
|
||||
bWaitPortGroupReady = true;
|
||||
} else {
|
||||
DVPortgroupConfigInfo spec = dataCenterMo.getDvPortGroupSpec(networkName);
|
||||
if(!isSpecMatch(spec, vid, shapingPolicy)) {
|
||||
s_logger.info("Port profile " + networkName + " found.");
|
||||
updatePortProfile(context, ethPortProfileName, vid, networkRateMbps);
|
||||
bWaitPortGroupReady = true;
|
||||
}
|
||||
// TODO(sateesh): Enable port profile policy configuration
|
||||
// PortProfile portProfile;
|
||||
// try {
|
||||
// portProfile = getPortProfileByName(networkName);
|
||||
// if (portProfile.vlanId != vlanId ||
|
||||
// portProfile.policy.getAverageBandwidth() != averageBandwidth ||
|
||||
// portProfile.policy.getPeakBandwidth() != peakBandwidth ||
|
||||
// portProfile.policy.getBurstRate() != burstRate) {
|
||||
// updatePortProfile(context, ethPortProfileName, vlanId, averageBandwidth, peakBandwidth, burstSize);
|
||||
// }
|
||||
}
|
||||
//Wait for dvPortGroup on vCenter
|
||||
if(bWaitPortGroupReady)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user