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: Retreving physical network configuration from database. Passing configuration down to resource. Cleanup. Conflicts: core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
This commit is contained in:
parent
8d1b9c2477
commit
b6687faf89
@ -16,7 +16,6 @@ import java.io.File;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
//import com.cloud.cluster.CheckPointManager;
|
|
||||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
@ -62,4 +61,8 @@ public interface VmwareManager {
|
|||||||
void endExclusiveOperation();
|
void endExclusiveOperation();
|
||||||
|
|
||||||
Map<String, String> getNexusVSMCredentials(String hostGuid);
|
Map<String, String> getNexusVSMCredentials(String hostGuid);
|
||||||
|
|
||||||
|
boolean getNexusVSwitchGlobalParameter();
|
||||||
|
|
||||||
|
Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,6 @@ import com.cloud.hypervisor.vmware.manager.VmwareStorageMount;
|
|||||||
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
|
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
|
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostVirtualNicType;
|
|
||||||
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
||||||
import com.cloud.hypervisor.vmware.mo.TaskMO;
|
import com.cloud.hypervisor.vmware.mo.TaskMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||||
@ -69,6 +68,7 @@ import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
|||||||
import com.cloud.hypervisor.vmware.resource.SshHelper;
|
import com.cloud.hypervisor.vmware.resource.SshHelper;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||||
|
import com.cloud.network.NetworkManager;
|
||||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||||
import com.cloud.org.Cluster.ClusterType;
|
import com.cloud.org.Cluster.ClusterType;
|
||||||
@ -91,7 +91,6 @@ import com.cloud.utils.script.Script;
|
|||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.vmware.apputils.vim25.ServiceUtil;
|
import com.vmware.apputils.vim25.ServiceUtil;
|
||||||
import com.vmware.vim25.AboutInfo;
|
|
||||||
import com.vmware.vim25.HostConnectSpec;
|
import com.vmware.vim25.HostConnectSpec;
|
||||||
import com.vmware.vim25.HostPortGroupSpec;
|
import com.vmware.vim25.HostPortGroupSpec;
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
@ -110,6 +109,8 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
private String _instance;
|
private String _instance;
|
||||||
|
|
||||||
@Inject AgentManager _agentMgr;
|
@Inject AgentManager _agentMgr;
|
||||||
|
@Inject
|
||||||
|
protected NetworkManager _netMgr;
|
||||||
@Inject HostDao _hostDao;
|
@Inject HostDao _hostDao;
|
||||||
@Inject ClusterDao _clusterDao;
|
@Inject ClusterDao _clusterDao;
|
||||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||||
@ -132,7 +133,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
String _privateNetworkVSwitchType;
|
String _privateNetworkVSwitchType;
|
||||||
String _publicNetworkVSwitchType;
|
String _publicNetworkVSwitchType;
|
||||||
String _guestNetworkVSwitchType;
|
String _guestNetworkVSwitchType;
|
||||||
Boolean _nexusVSwitchActive;
|
boolean _nexusVSwitchActive;
|
||||||
String _serviceConsoleName;
|
String _serviceConsoleName;
|
||||||
String _managemetPortGroupName;
|
String _managemetPortGroupName;
|
||||||
String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
|
String _defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
|
||||||
@ -358,6 +359,10 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getNexusVSwitchGlobalParameter() {
|
||||||
|
return _nexusVSwitchActive;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String composeWorkerName() {
|
public String composeWorkerName() {
|
||||||
return UUID.randomUUID().toString().replace("-", "");
|
return UUID.randomUUID().toString().replace("-", "");
|
||||||
@ -367,6 +372,13 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
|
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId,
|
||||||
String hostInventoryPath) throws Exception {
|
String hostInventoryPath) throws Exception {
|
||||||
ManagedObjectReference mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
ManagedObjectReference mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
||||||
|
String privateTrafficLabel = null;
|
||||||
|
if (_nexusVSwitchActive) {
|
||||||
|
privateTrafficLabel = serviceContext.getStockObject("privateTrafficLabel");
|
||||||
|
if (privateTrafficLabel == null) {
|
||||||
|
privateTrafficLabel = _privateNetworkVSwitchName;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(mor != null) {
|
if(mor != null) {
|
||||||
List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
|
List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
|
||||||
|
|
||||||
@ -392,12 +404,12 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
if(spec.getVlanId() != 0) {
|
if(spec.getVlanId() != 0) {
|
||||||
vlanId = String.valueOf(spec.getVlanId());
|
vlanId = String.valueOf(spec.getVlanId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!_nexusVSwitchActive) {
|
if(!_nexusVSwitchActive) {
|
||||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000);
|
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
|
||||||
}
|
}
|
||||||
returnedHostList.add(hosts[0]);
|
returnedHostList.add(hosts[0]);
|
||||||
return returnedHostList;
|
return returnedHostList;
|
||||||
@ -435,7 +447,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000);
|
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
|
||||||
}
|
}
|
||||||
returnedHostList.add(morHost);
|
returnedHostList.add(morHost);
|
||||||
}
|
}
|
||||||
@ -464,7 +476,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000);
|
HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
|
||||||
}
|
}
|
||||||
returnedHostList.add(mor);
|
returnedHostList.add(mor);
|
||||||
return returnedHostList;
|
return returnedHostList;
|
||||||
@ -962,4 +974,17 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
public int getRouterExtraPublicNics() {
|
public int getRouterExtraPublicNics() {
|
||||||
return this._routerExtraPublicNics;
|
return this._routerExtraPublicNics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getNexusVSMCredentialsByClusterId(Long clusterId) {
|
||||||
|
ClusterVSMMapVO vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
|
||||||
|
CiscoNexusVSMDeviceVO nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
||||||
|
if (nexusVSM == null)
|
||||||
|
return null;
|
||||||
|
Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
|
||||||
|
nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
|
||||||
|
nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
|
||||||
|
nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
|
||||||
|
return nexusVSMCredentials;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
// Automatically generated by addcopyright.py at 04/03/2012
|
// Automatically generated by addcopyright.py at 04/03/2012
|
||||||
package com.cloud.hypervisor.vmware;
|
|
||||||
|
package com.cloud.hypervisor.vmware;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
@ -35,22 +36,22 @@ import com.cloud.exception.DiscoveredWithErrorException;
|
|||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor;
|
import com.cloud.hypervisor.Hypervisor;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
||||||
import com.cloud.hypervisor.vmware.mo.ClusterMO;
|
import com.cloud.hypervisor.vmware.mo.ClusterMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||||
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
||||||
import com.cloud.hypervisor.vmware.resource.VmwareResource;
|
import com.cloud.hypervisor.vmware.resource.VmwareResource;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
|
import com.cloud.network.NetworkManager;
|
||||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||||
import com.cloud.resource.Discoverer;
|
import com.cloud.resource.Discoverer;
|
||||||
import com.cloud.resource.DiscovererBase;
|
import com.cloud.resource.DiscovererBase;
|
||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.resource.ResourceStateAdapter;
|
import com.cloud.resource.ResourceStateAdapter;
|
||||||
import com.cloud.resource.ServerResource;
|
import com.cloud.resource.ServerResource;
|
||||||
import com.cloud.resource.UnableDeleteHostException;
|
import com.cloud.resource.UnableDeleteHostException;
|
||||||
import com.cloud.resource.ResourceStateAdapter.DeleteHostAnswer;
|
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
import com.cloud.storage.Storage.TemplateType;
|
import com.cloud.storage.Storage.TemplateType;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
@ -61,20 +62,22 @@ import com.cloud.utils.component.ComponentLocator;
|
|||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
import com.vmware.vim25.ClusterDasConfigInfo;
|
import com.vmware.vim25.ClusterDasConfigInfo;
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
|
|
||||||
@Local(value=Discoverer.class)
|
@Local(value=Discoverer.class)
|
||||||
public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
|
public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
|
||||||
private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
|
private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
|
||||||
|
|
||||||
@Inject ClusterDao _clusterDao;
|
@Inject ClusterDao _clusterDao;
|
||||||
@Inject VmwareManager _vmwareMgr;
|
@Inject VmwareManager _vmwareMgr;
|
||||||
@Inject AlertManager _alertMgr;
|
@Inject AlertManager _alertMgr;
|
||||||
@Inject VMTemplateDao _tmpltDao;
|
@Inject VMTemplateDao _tmpltDao;
|
||||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||||
@Inject HostDao _hostDao;
|
@Inject HostDao _hostDao;
|
||||||
@Inject ResourceManager _resourceMgr;
|
@Inject ResourceManager _resourceMgr;
|
||||||
|
|
||||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||||
|
@Inject
|
||||||
|
NetworkManager _netmgr;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
|
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
|
||||||
@ -102,80 +105,110 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new DiscoveredWithErrorException(msg);
|
throw new DiscoveredWithErrorException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
VmwareContext context = null;
|
String privateTrafficLabel = null;
|
||||||
try {
|
Map<String, String> vsmCredentials = null;
|
||||||
|
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
|
||||||
|
// Get physical network label
|
||||||
|
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
|
||||||
|
if (privateTrafficLabel != null) {
|
||||||
|
s_logger.info("Detected private network label : " + privateTrafficLabel);
|
||||||
|
}
|
||||||
|
// Get credentials
|
||||||
|
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
|
||||||
|
}
|
||||||
|
|
||||||
|
VmwareContext context = null;
|
||||||
|
try {
|
||||||
context = VmwareContextFactory.create(url.getHost(), username, password);
|
context = VmwareContextFactory.create(url.getHost(), username, password);
|
||||||
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId,
|
if (_vmwareMgr.getNexusVSwitchGlobalParameter()) {
|
||||||
|
// Get physical network label
|
||||||
|
privateTrafficLabel = _netmgr.getDefaultManagementTrafficLabel(dcId, HypervisorType.VMware);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId,
|
||||||
URLDecoder.decode(url.getPath()));
|
URLDecoder.decode(url.getPath()));
|
||||||
if(morHosts == null) {
|
if (privateTrafficLabel != null)
|
||||||
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
context.uregisterStockObject("privateTrafficLabel");
|
||||||
return null;
|
|
||||||
}
|
if(morHosts == null) {
|
||||||
|
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
||||||
ManagedObjectReference morCluster = null;
|
return null;
|
||||||
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
}
|
||||||
if(clusterDetails.get("url") != null) {
|
|
||||||
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
ManagedObjectReference morCluster = null;
|
||||||
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
||||||
|
if(clusterDetails.get("url") != null) {
|
||||||
if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
||||||
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
||||||
return null;
|
|
||||||
} else {
|
if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
||||||
ClusterMO clusterMo = new ClusterMO(context, morCluster);
|
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
||||||
ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
|
return null;
|
||||||
if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
|
} else {
|
||||||
clusterDetails.put("NativeHA", "true");
|
ClusterMO clusterMo = new ClusterMO(context, morCluster);
|
||||||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
|
||||||
}
|
if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
|
||||||
}
|
clusterDetails.put("NativeHA", "true");
|
||||||
}
|
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||||
|
}
|
||||||
if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
|
}
|
||||||
if(morCluster == null)
|
}
|
||||||
s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
|
|
||||||
else
|
if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
|
||||||
s_logger.warn("The discovered host does not belong to the cluster");
|
if(morCluster == null)
|
||||||
return null;
|
s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
|
||||||
}
|
else
|
||||||
|
s_logger.warn("The discovered host does not belong to the cluster");
|
||||||
Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
|
return null;
|
||||||
for(ManagedObjectReference morHost : morHosts) {
|
}
|
||||||
Map<String, String> details = new HashMap<String, String>();
|
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
|
||||||
|
for(ManagedObjectReference morHost : morHosts) {
|
||||||
HostMO hostMo = new HostMO(context, morHost);
|
Map<String, String> details = new HashMap<String, String>();
|
||||||
details.put("url", hostMo.getHostName());
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
details.put("username", username);
|
|
||||||
details.put("password", password);
|
HostMO hostMo = new HostMO(context, morHost);
|
||||||
String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
|
details.put("url", hostMo.getHostName());
|
||||||
details.put("guid", guid);
|
details.put("username", username);
|
||||||
|
details.put("password", password);
|
||||||
params.put("url", hostMo.getHostName());
|
String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
|
||||||
params.put("username", username);
|
details.put("guid", guid);
|
||||||
params.put("password", password);
|
|
||||||
params.put("zone", Long.toString(dcId));
|
params.put("url", hostMo.getHostName());
|
||||||
params.put("pod", Long.toString(podId));
|
params.put("username", username);
|
||||||
params.put("cluster", Long.toString(clusterId));
|
params.put("password", password);
|
||||||
|
params.put("zone", Long.toString(dcId));
|
||||||
|
params.put("pod", Long.toString(podId));
|
||||||
|
params.put("cluster", Long.toString(clusterId));
|
||||||
params.put("guid", guid);
|
params.put("guid", guid);
|
||||||
|
if (privateTrafficLabel != null) {
|
||||||
VmwareResource resource = new VmwareResource();
|
params.put("private.network.vswitch.name", privateTrafficLabel);
|
||||||
try {
|
}
|
||||||
resource.configure("VMware", params);
|
|
||||||
} catch (ConfigurationException e) {
|
VmwareResource resource = new VmwareResource();
|
||||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
|
try {
|
||||||
s_logger.warn("Unable to instantiate " + url.getHost(), e);
|
resource.configure("VMware", params);
|
||||||
}
|
} catch (ConfigurationException e) {
|
||||||
resource.start();
|
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
|
||||||
|
s_logger.warn("Unable to instantiate " + url.getHost(), e);
|
||||||
resources.put(resource, details);
|
}
|
||||||
}
|
resource.start();
|
||||||
|
|
||||||
// place a place holder guid derived from cluster ID
|
resources.put(resource, details);
|
||||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
}
|
||||||
_clusterDao.update(clusterId, cluster);
|
|
||||||
|
// place a place holder guid derived from cluster ID
|
||||||
|
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||||
|
_clusterDao.update(clusterId, cluster);
|
||||||
|
|
||||||
return resources;
|
return resources;
|
||||||
} catch (DiscoveredWithErrorException e) {
|
} catch (DiscoveredWithErrorException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mortbay.jetty.servlet.Context;
|
|
||||||
|
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||||
@ -35,10 +34,8 @@ import com.cloud.utils.db.GlobalLock;
|
|||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.utils.net.NetUtils;
|
import com.cloud.utils.net.NetUtils;
|
||||||
import com.vmware.vim25.BoolPolicy;
|
import com.vmware.vim25.BoolPolicy;
|
||||||
import com.vmware.vim25.DVPortgroupConfigSpec;
|
|
||||||
import com.vmware.vim25.DVSTrafficShapingPolicy;
|
|
||||||
//import com.vmware.vim25.DistributedVirtualSwitchKeyedOpaqueBlob;
|
|
||||||
import com.vmware.vim25.DVPortgroupConfigInfo;
|
import com.vmware.vim25.DVPortgroupConfigInfo;
|
||||||
|
import com.vmware.vim25.DVSTrafficShapingPolicy;
|
||||||
import com.vmware.vim25.DynamicProperty;
|
import com.vmware.vim25.DynamicProperty;
|
||||||
import com.vmware.vim25.HostNetworkTrafficShapingPolicy;
|
import com.vmware.vim25.HostNetworkTrafficShapingPolicy;
|
||||||
import com.vmware.vim25.HostPortGroupSpec;
|
import com.vmware.vim25.HostPortGroupSpec;
|
||||||
@ -130,7 +127,7 @@ public class HypervisorHostHelper {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getValidatedVsmCredentials(VmwareContext context) throws Exception, CloudRuntimeException {
|
public static Map<String, String> getValidatedVsmCredentials(VmwareContext context) throws Exception {
|
||||||
Map<String, String> vsmCredentials = context.getStockObject("vsmcredentials");
|
Map<String, String> vsmCredentials = context.getStockObject("vsmcredentials");
|
||||||
String msg;
|
String msg;
|
||||||
if(vsmCredentials == null || vsmCredentials.size() != 3) {
|
if(vsmCredentials == null || vsmCredentials.size() != 3) {
|
||||||
@ -145,12 +142,12 @@ public class HypervisorHostHelper {
|
|||||||
if(vsmIp == null || vsmIp.isEmpty() || vsmUserName == null || vsmUserName.isEmpty() || vsmPassword == null || vsmPassword.isEmpty()) {
|
if(vsmIp == null || vsmIp.isEmpty() || vsmUserName == null || vsmUserName.isEmpty() || vsmPassword == null || vsmPassword.isEmpty()) {
|
||||||
msg = "Detected invalid credentials for Nexus VSM";
|
msg = "Detected invalid credentials for Nexus VSM";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new CloudRuntimeException(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
return vsmCredentials;
|
return vsmCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vid, Integer networkRateMbps) throws Exception, CloudRuntimeException {
|
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vid, Integer networkRateMbps) throws Exception {
|
||||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||||
String vsmIp = vsmCredentials.get("vsmip");
|
String vsmIp = vsmCredentials.get("vsmip");
|
||||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||||
@ -187,7 +184,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, Integer vid, Integer networkRateMbps) throws CloudRuntimeException, Exception {
|
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, Integer vid, Integer networkRateMbps) throws Exception {
|
||||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||||
String vsmIp = vsmCredentials.get("vsmip");
|
String vsmIp = vsmCredentials.get("vsmip");
|
||||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||||
@ -218,7 +215,7 @@ public class HypervisorHostHelper {
|
|||||||
|
|
||||||
public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPortProfileName, String namePrefix,
|
public static Pair<ManagedObjectReference, String> prepareNetwork(String ethPortProfileName, String namePrefix,
|
||||||
HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps,
|
HostMO hostMo, String vlanId, Integer networkRateMbps, Integer networkRateMulticastMbps,
|
||||||
long timeOutMs) throws Exception, CloudRuntimeException {
|
long timeOutMs) throws Exception {
|
||||||
ManagedObjectReference morNetwork = null;
|
ManagedObjectReference morNetwork = null;
|
||||||
VmwareContext context = hostMo.getContext();
|
VmwareContext context = hostMo.getContext();
|
||||||
ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
|
ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user