mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-14956 Support for rate limiting policies in Nexus dvSwith feature for CloudStack
Removed global parameters that are not required. Cleanup. Reviewed-by: Devdeep Not sure why but changes in VmwareServerDiscoverer.java were not picked up when cherry-picking from 3.0.x. Putting them in this separate commit.
This commit is contained in:
parent
4ad8845b28
commit
90b87585e7
@ -10,9 +10,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
|
||||
package com.cloud.hypervisor.vmware;
|
||||
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
@ -73,14 +72,12 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
@Inject ClusterDao _clusterDao;
|
||||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject AlertManager _alertMgr;
|
||||
@Inject VMTemplateDao _tmpltDao;
|
||||
@Inject VMTemplateDao _tmpltDao;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||
@Inject
|
||||
NetworkManager _netmgr;
|
||||
@ -102,7 +99,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
@ -116,15 +113,13 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
String publicTrafficLabel = null;
|
||||
String guestTrafficLabel = null;
|
||||
Map<String, String> vsmCredentials = null;
|
||||
|
||||
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
|
||||
if (privateTrafficLabel != null) {
|
||||
s_logger.info("Detected private network label : " + privateTrafficLabel);
|
||||
}
|
||||
|
||||
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
|
||||
if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter() != null && _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);
|
||||
}
|
||||
}
|
||||
|
||||
DataCenterVO zone = _dcDao.findById(dcId);
|
||||
NetworkType zoneType = zone.getNetworkType();
|
||||
if (zoneType != NetworkType.Basic) {
|
||||
@ -144,11 +139,10 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
VmwareContext context = null;
|
||||
try {
|
||||
context = VmwareContextFactory.create(url.getHost(), username, password);
|
||||
if (privateTrafficLabel != null)
|
||||
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
|
||||
|
||||
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
|
||||
if (_vmwareMgr.getPrivateVSwitchTypeGlobalParameter().equalsIgnoreCase("nexus")) {
|
||||
if (privateTrafficLabel != null)
|
||||
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
|
||||
}
|
||||
if (vsmCredentials != null) {
|
||||
s_logger.info("Stocking credentials of Nexus VSM");
|
||||
context.registerStockObject("vsmcredentials", vsmCredentials);
|
||||
@ -238,95 +232,95 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||
_clusterDao.update(clusterId, cluster);
|
||||
|
||||
return resources;
|
||||
return resources;
|
||||
} catch (DiscoveredWithErrorException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
|
||||
return null;
|
||||
} finally {
|
||||
if(context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List<ManagedObjectReference> morHosts) throws Exception {
|
||||
if(morCluster == null) {
|
||||
for(ManagedObjectReference morHost : morHosts) {
|
||||
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
||||
if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
for(ManagedObjectReference morHost : morHosts) {
|
||||
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
||||
if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
||||
return false;
|
||||
|
||||
if(!morParent.get_value().equals(morCluster.get_value()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDiscovery(List<HostVO> hosts, long msId) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchHypervisor(String hypervisor) {
|
||||
if(hypervisor == null)
|
||||
return true;
|
||||
|
||||
return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hypervisor.HypervisorType getHypervisorType() {
|
||||
return Hypervisor.HypervisorType.VMware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
|
||||
|
||||
super.configure(name, params);
|
||||
|
||||
ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
|
||||
if (configDao == null) {
|
||||
throw new ConfigurationException("Unable to get the configuration dao.");
|
||||
}
|
||||
|
||||
createVmwareToolsIso();
|
||||
|
||||
if(s_logger.isInfoEnabled()) {
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
|
||||
return null;
|
||||
} finally {
|
||||
if(context != null)
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List<ManagedObjectReference> morHosts) throws Exception {
|
||||
if(morCluster == null) {
|
||||
for(ManagedObjectReference morHost : morHosts) {
|
||||
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
||||
if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
for(ManagedObjectReference morHost : morHosts) {
|
||||
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
||||
if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
||||
return false;
|
||||
|
||||
if(!morParent.get_value().equals(morCluster.get_value()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDiscovery(List<HostVO> hosts, long msId) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchHypervisor(String hypervisor) {
|
||||
if(hypervisor == null)
|
||||
return true;
|
||||
|
||||
return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hypervisor.HypervisorType getHypervisorType() {
|
||||
return Hypervisor.HypervisorType.VMware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
|
||||
|
||||
super.configure(name, params);
|
||||
|
||||
ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
|
||||
if (configDao == null) {
|
||||
throw new ConfigurationException("Unable to get the configuration dao.");
|
||||
}
|
||||
|
||||
createVmwareToolsIso();
|
||||
|
||||
if(s_logger.isInfoEnabled()) {
|
||||
s_logger.info("VmwareServerDiscoverer has been successfully configured");
|
||||
}
|
||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createVmwareToolsIso() {
|
||||
String isoName = "vmware-tools.iso";
|
||||
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
|
||||
Long id;
|
||||
if (tmplt == null) {
|
||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
|
||||
TemplateType.PERHOST, null, null, true, 64,
|
||||
Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
|
||||
_tmpltDao.persist(template);
|
||||
} else {
|
||||
id = tmplt.getId();
|
||||
tmplt.setTemplateType(TemplateType.PERHOST);
|
||||
tmplt.setUrl(null);
|
||||
_tmpltDao.update(id, tmplt);
|
||||
}
|
||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createVmwareToolsIso() {
|
||||
String isoName = "vmware-tools.iso";
|
||||
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
|
||||
Long id;
|
||||
if (tmplt == null) {
|
||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
|
||||
TemplateType.PERHOST, null, null, true, 64,
|
||||
Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
|
||||
_tmpltDao.persist(template);
|
||||
} else {
|
||||
id = tmplt.getId();
|
||||
tmplt.setTemplateType(TemplateType.PERHOST);
|
||||
tmplt.setUrl(null);
|
||||
_tmpltDao.update(id, tmplt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -365,6 +359,6 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
public boolean stop() {
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
return super.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user