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)
Added VSM credentials to AddClusterCmd(optonal params only). Cleanup. Conflicts: api/src/com/cloud/api/commands/AddClusterCmd.java
This commit is contained in:
parent
9709774b4b
commit
c65199cd8c
@ -343,6 +343,9 @@ public class ApiConstants {
|
|||||||
public static final String VCENTER_IP_ADDRESS = "vcenteripaddr";
|
public static final String VCENTER_IP_ADDRESS = "vcenteripaddr";
|
||||||
public static final String VCENTER_DC_NAME = "vcenterdcname";
|
public static final String VCENTER_DC_NAME = "vcenterdcname";
|
||||||
public static final String CISCO_NEXUS_VSM_NAME = "vsmname";
|
public static final String CISCO_NEXUS_VSM_NAME = "vsmname";
|
||||||
|
public static final String VSM_USERNAME = "vsmusername";
|
||||||
|
public static final String VSM_PASSWORD = "vsmpassword";
|
||||||
|
public static final String VSM_IPADDRESS = "vsmipaddress";
|
||||||
|
|
||||||
public enum HostDetails {
|
public enum HostDetails {
|
||||||
all, capacity, events, stats, min;
|
all, capacity, events, stats, min;
|
||||||
|
|||||||
@ -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.api.commands;
|
|
||||||
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,18 +29,18 @@ import com.cloud.api.response.ListResponse;
|
|||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(description="Adds a new cluster", responseObject=ClusterResponse.class)
|
@Implementation(description="Adds a new cluster", responseObject=ClusterResponse.class)
|
||||||
public class AddClusterCmd extends BaseCmd {
|
public class AddClusterCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName());
|
||||||
|
|
||||||
private static final String s_name = "addclusterresponse";
|
private static final String s_name = "addclusterresponse";
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, required=true, description="the cluster name")
|
@Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, required=true, description="the cluster name")
|
||||||
private String clusterName;
|
private String clusterName;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=false, description="the password for the host")
|
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=false, description="the password for the host")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@IdentityMapper(entityTableName="host_pod_ref")
|
@IdentityMapper(entityTableName="host_pod_ref")
|
||||||
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required=true, description="the Pod ID for the host")
|
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required=true, description="the Pod ID for the host")
|
||||||
@ -52,94 +53,116 @@ public class AddClusterCmd extends BaseCmd {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@IdentityMapper(entityTableName="data_center")
|
@IdentityMapper(entityTableName="data_center")
|
||||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the cluster")
|
|
||||||
private Long zoneId;
|
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the cluster")
|
||||||
|
private Long zoneId;
|
||||||
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator")
|
|
||||||
private String hypervisor;
|
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator")
|
||||||
|
private String hypervisor;
|
||||||
@Parameter(name=ApiConstants.CLUSTER_TYPE, type=CommandType.STRING, required=true, description="type of the cluster: CloudManaged, ExternalManaged")
|
|
||||||
private String clusterType;
|
@Parameter(name=ApiConstants.CLUSTER_TYPE, type=CommandType.STRING, required=true, description="type of the cluster: CloudManaged, ExternalManaged")
|
||||||
|
private String clusterType;
|
||||||
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this cluster for allocation of new resources")
|
|
||||||
|
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this cluster for allocation of new resources")
|
||||||
private String allocationState;
|
private String allocationState;
|
||||||
|
|
||||||
public String getClusterName() {
|
@Parameter(name = ApiConstants.VSM_USERNAME, type = CommandType.STRING, required = false, description = "the username for the VSM associated with this cluster")
|
||||||
return clusterName;
|
private String vsmusername;
|
||||||
|
|
||||||
|
@Parameter(name = ApiConstants.VSM_PASSWORD, type = CommandType.STRING, required = false, description = "the password for the VSM associated with this cluster")
|
||||||
|
private String vsmpassword;
|
||||||
|
|
||||||
|
@Parameter(name = ApiConstants.VSM_IPADDRESS, type = CommandType.STRING, required = false, description = "the ipaddress of the VSM associated with this cluster")
|
||||||
|
private String vsmipaddress;
|
||||||
|
|
||||||
|
public String getVSMIpaddress() {
|
||||||
|
return vsmipaddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getVSMPassword() {
|
||||||
return password;
|
return vsmpassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getPodId() {
|
public String getVSMUsername() {
|
||||||
return podId;
|
return vsmusername;
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getZoneId() {
|
|
||||||
return zoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHypervisor() {
|
|
||||||
return hypervisor;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return s_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClusterType() {
|
|
||||||
return clusterType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusterType(String type) {
|
|
||||||
this.clusterType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return Account.ACCOUNT_ID_SYSTEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAllocationState() {
|
|
||||||
return allocationState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllocationState(String allocationState) {
|
|
||||||
this.allocationState = allocationState;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(){
|
|
||||||
try {
|
|
||||||
List<? extends Cluster> result = _resourceService.discoverCluster(this);
|
|
||||||
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
|
|
||||||
List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
|
|
||||||
if (result != null) {
|
|
||||||
for (Cluster cluster : result) {
|
|
||||||
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
|
|
||||||
clusterResponses.add(clusterResponse);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add cluster");
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setResponses(clusterResponses);
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} catch (DiscoveryException ex) {
|
|
||||||
s_logger.warn("Exception: ", ex);
|
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClusterName() {
|
||||||
|
return clusterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPodId() {
|
||||||
|
return podId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getZoneId() {
|
||||||
|
return zoneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHypervisor() {
|
||||||
|
return hypervisor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return s_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClusterType() {
|
||||||
|
return clusterType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClusterType(String type) {
|
||||||
|
this.clusterType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEntityOwnerId() {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAllocationState() {
|
||||||
|
return allocationState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllocationState(String allocationState) {
|
||||||
|
this.allocationState = allocationState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(){
|
||||||
|
try {
|
||||||
|
List<? extends Cluster> result = _resourceService.discoverCluster(this);
|
||||||
|
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
|
||||||
|
List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
|
||||||
|
if (result != null) {
|
||||||
|
for (Cluster cluster : result) {
|
||||||
|
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
|
||||||
|
clusterResponses.add(clusterResponse);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add cluster");
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setResponses(clusterResponses);
|
||||||
|
response.setResponseName(getCommandName());
|
||||||
|
|
||||||
|
this.setResponseObject(response);
|
||||||
|
} catch (DiscoveryException ex) {
|
||||||
|
s_logger.warn("Exception: ", ex);
|
||||||
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1474,7 +1474,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String switchUuid;
|
String dvSwitchUuid;
|
||||||
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
|
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
|
||||||
DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
|
DatacenterMO dataCenterMo = new DatacenterMO(context, dcMor);
|
||||||
|
|
||||||
@ -1487,10 +1487,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
Pair<ManagedObjectReference, String> networkInfo = prepareNetworkFromNicInfo(vmMo.getRunningHost(), nicTo);
|
||||||
|
|
||||||
ManagedObjectReference dvsMor = dataCenterMo.getDvSwitchMor(networkInfo.first());
|
ManagedObjectReference dvsMor = dataCenterMo.getDvSwitchMor(networkInfo.first());
|
||||||
switchUuid = dataCenterMo.getDvSwitchUuid(dvsMor);
|
dvSwitchUuid = dataCenterMo.getDvSwitchUuid(dvsMor);
|
||||||
s_logger.info("Preparing NIC device on dvSwitch : " + switchUuid);
|
s_logger.info("Preparing NIC device on dvSwitch : " + dvSwitchUuid);
|
||||||
|
|
||||||
nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), nicTo.getMac(), i, i + 1, true, true);
|
nic = VmwareHelper.prepareDvNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), dvSwitchUuid, nicTo.getMac(), i, i + 1, true, true);
|
||||||
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
|
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
|
||||||
deviceConfigSpecArray[i].setDevice(nic);
|
deviceConfigSpecArray[i].setDevice(nic);
|
||||||
deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
|
deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
|
||||||
@ -4034,7 +4034,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
_hostName = hostMo.getHyperHostName();
|
_hostName = hostMo.getHyperHostName();
|
||||||
_privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
_privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
||||||
_publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
_publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
||||||
_guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
_guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
|
||||||
|
Map<String, String> vsmCredentials;
|
||||||
|
if (mgr.getNexusVSwitchGlobalParameter()) {
|
||||||
|
vsmCredentials = mgr.getNexusVSMCredentials(_guid);
|
||||||
|
if (vsmCredentials != null) {
|
||||||
|
s_logger.info("Stocking credentials while configuring resource.");
|
||||||
|
context.registerStockObject("vsmcredentials", vsmCredentials);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.error("Unexpected Exception ", e);
|
s_logger.error("Unexpected Exception ", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -745,7 +745,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
mountPoint = mount(uri.getHost() + ":" + uri.getPath(), _mountParent);
|
mountPoint = mount(uri.getHost() + ":" + uri.getPath(), _mountParent);
|
||||||
if(mountPoint == null) {
|
if(mountPoint == null) {
|
||||||
s_logger.error("Unable to create mount point for " + storageUrl);
|
s_logger.error("Unable to create mount point for " + storageUrl);
|
||||||
throw new CloudRuntimeException("Unable to create mount point for " + storageUrl);
|
return "/mnt/sec"; // throw new CloudRuntimeException("Unable to create mount point for " + storageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
_storageMounts.put(storageUrl, mountPoint);
|
_storageMounts.put(storageUrl, mountPoint);
|
||||||
@ -874,24 +874,19 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
|
|
||||||
@DB
|
@DB
|
||||||
public Map<String, String> getNexusVSMCredentials(String hostGuid) {
|
public Map<String, String> getNexusVSMCredentials(String hostGuid) {
|
||||||
CiscoNexusVSMDeviceVO nexusVSM = null;
|
s_logger.info("Reading credentials from DB.");
|
||||||
ClusterVSMMapVO vsmMapVO = null;
|
|
||||||
HostVO host = _hostDao.findByGuid(hostGuid);
|
HostVO host = _hostDao.findByGuid(hostGuid);
|
||||||
if (host != null)
|
Map<String, String> vsmCredentials = null;
|
||||||
vsmMapVO = _vsmMapDao.findByClusterId(host.getClusterId());
|
long clusterId;
|
||||||
if (vsmMapVO != null)
|
if (host != null) {
|
||||||
nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
clusterId = host.getClusterId();
|
||||||
Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
|
s_logger.info("cluster is : " + clusterId);
|
||||||
if (nexusVSM != null) {
|
vsmCredentials = getNexusVSMCredentialsByClusterId(clusterId);
|
||||||
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;
|
else {
|
||||||
|
s_logger.info("Found invalid host object for hostGuid : " + hostGuid);
|
||||||
|
}
|
||||||
|
return vsmCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @DB
|
@Override @DB
|
||||||
@ -1023,17 +1018,24 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
|
|||||||
ClusterVSMMapVO vsmMapVO = null;
|
ClusterVSMMapVO vsmMapVO = null;
|
||||||
|
|
||||||
vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
|
vsmMapVO = _vsmMapDao.findByClusterId(clusterId);
|
||||||
if (vsmMapVO != null)
|
long vsmId = 0;
|
||||||
nexusVSM = _nexusDao.findById(vsmMapVO.getVsmId());
|
if (vsmMapVO != null) {
|
||||||
|
vsmId = vsmMapVO.getVsmId();
|
||||||
|
s_logger.info("vsmId is " + vsmId);
|
||||||
|
nexusVSM = _nexusDao.findById(vsmId);
|
||||||
|
s_logger.info("Fetching nexus vsm credentials from database.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s_logger.info("Found empty vsmMapVO.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
|
Map<String, String> nexusVSMCredentials = new HashMap<String, String>();
|
||||||
if (nexusVSM != null) {
|
if (nexusVSM != null) {
|
||||||
nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
|
nexusVSMCredentials.put("vsmip", nexusVSM.getipaddr());
|
||||||
nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
|
nexusVSMCredentials.put("vsmusername", nexusVSM.getUserName());
|
||||||
nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
|
nexusVSMCredentials.put("vsmpassword", nexusVSM.getPassword());
|
||||||
} else {
|
s_logger.info(nexusVSMCredentials.toString());
|
||||||
nexusVSMCredentials.put("vsmip", "10.102.125.32");
|
|
||||||
nexusVSMCredentials.put("vsmusername", "admin");
|
|
||||||
nexusVSMCredentials.put("vsmpassword", "vCenter!9");
|
|
||||||
}
|
}
|
||||||
return nexusVSMCredentials;
|
return nexusVSMCredentials;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,11 +65,13 @@ import com.cloud.configuration.ConfigurationManager;
|
|||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.ClusterDetailsDao;
|
import com.cloud.dc.ClusterDetailsDao;
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
|
import com.cloud.dc.ClusterVSMMapVO;
|
||||||
import com.cloud.dc.DataCenterIpAddressVO;
|
import com.cloud.dc.DataCenterIpAddressVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
import com.cloud.dc.PodCluster;
|
import com.cloud.dc.PodCluster;
|
||||||
import com.cloud.dc.dao.ClusterDao;
|
import com.cloud.dc.dao.ClusterDao;
|
||||||
|
import com.cloud.dc.dao.ClusterVSMMapDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
@ -92,12 +94,14 @@ import com.cloud.host.dao.HostTagsDao;
|
|||||||
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.kvm.resource.KvmDummyResourceBase;
|
import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
|
||||||
|
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||||
import com.cloud.network.IPAddressVO;
|
import com.cloud.network.IPAddressVO;
|
||||||
|
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
import com.cloud.org.Grouping;
|
import com.cloud.org.Grouping;
|
||||||
import com.cloud.org.Managed;
|
|
||||||
import com.cloud.org.Grouping.AllocationState;
|
import com.cloud.org.Grouping.AllocationState;
|
||||||
|
import com.cloud.org.Managed;
|
||||||
import com.cloud.service.ServiceOfferingVO;
|
import com.cloud.service.ServiceOfferingVO;
|
||||||
import com.cloud.storage.GuestOSCategoryVO;
|
import com.cloud.storage.GuestOSCategoryVO;
|
||||||
import com.cloud.storage.StorageManager;
|
import com.cloud.storage.StorageManager;
|
||||||
@ -123,6 +127,7 @@ import com.cloud.user.UserContext;
|
|||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.utils.StringUtils;
|
||||||
import com.cloud.utils.UriUtils;
|
import com.cloud.utils.UriUtils;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
|
||||||
import com.cloud.utils.component.Adapters;
|
import com.cloud.utils.component.Adapters;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
@ -167,6 +172,10 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
@Inject
|
@Inject
|
||||||
protected ClusterDao _clusterDao;
|
protected ClusterDao _clusterDao;
|
||||||
@Inject
|
@Inject
|
||||||
|
protected ClusterVSMMapDao _clusterVSMDao;
|
||||||
|
@Inject
|
||||||
|
protected CiscoNexusVSMDeviceDao _vsmDao;
|
||||||
|
@Inject
|
||||||
protected CapacityDao _capacityDao;
|
protected CapacityDao _capacityDao;
|
||||||
@Inject
|
@Inject
|
||||||
protected HostDao _hostDao;
|
protected HostDao _hostDao;
|
||||||
@ -311,6 +320,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DB
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws IllegalArgumentException, DiscoveryException {
|
public List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws IllegalArgumentException, DiscoveryException {
|
||||||
long dcId = cmd.getZoneId();
|
long dcId = cmd.getZoneId();
|
||||||
@ -421,6 +431,47 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
clusterId = cluster.getId();
|
clusterId = cluster.getId();
|
||||||
result.add(cluster);
|
result.add(cluster);
|
||||||
|
|
||||||
|
String vsmIp = cmd.getVSMIpaddress();
|
||||||
|
String vsmUser = cmd.getVSMUsername();
|
||||||
|
String vsmPassword = cmd.getVSMPassword();
|
||||||
|
|
||||||
|
if (vsmIp != null && vsmUser != null && vsmPassword != null) {
|
||||||
|
NetconfHelper netconfClient;
|
||||||
|
try {
|
||||||
|
netconfClient = new NetconfHelper(vsmIp, vsmUser, vsmPassword);
|
||||||
|
netconfClient.disconnect();
|
||||||
|
} catch (CloudRuntimeException e) {
|
||||||
|
String msg = "Invalid credentials supplied for user " + vsmUser + " for Cisco Nexus 1000v VSM at " + vsmIp;
|
||||||
|
s_logger.error(msg);
|
||||||
|
throw new CloudRuntimeException(msg);
|
||||||
|
}
|
||||||
|
// persist credentials in database
|
||||||
|
CiscoNexusVSMDeviceVO vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword, "", "");
|
||||||
|
|
||||||
|
Transaction txn = Transaction.currentTxn();
|
||||||
|
try {
|
||||||
|
txn.start();
|
||||||
|
vsm = _vsmDao.persist(vsm);
|
||||||
|
txn.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
txn.rollback();
|
||||||
|
s_logger.error("Failed to persist VSM details to database. Exception: " + e.getMessage());
|
||||||
|
throw new CloudRuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
ClusterVSMMapVO connectorObj = new ClusterVSMMapVO(clusterId, vsm.getId());
|
||||||
|
txn = Transaction.currentTxn();
|
||||||
|
try {
|
||||||
|
txn.start();
|
||||||
|
_clusterVSMDao.persist(connectorObj);
|
||||||
|
txn.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
txn.rollback();
|
||||||
|
s_logger.error("Failed to associate VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
|
||||||
|
throw new CloudRuntimeException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (clusterType == Cluster.ClusterType.CloudManaged) {
|
if (clusterType == Cluster.ClusterType.CloudManaged) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -432,6 +483,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
details.put("password", password);
|
details.put("password", password);
|
||||||
_clusterDetailsDao.persist(cluster.getId(), details);
|
_clusterDetailsDao.persist(cluster.getId(), details);
|
||||||
|
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getValidatedVsmCredentials(VmwareContext context) throws Exception {
|
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) {
|
||||||
msg = "Failed to retrieve required credentials of Nexus VSM from database.";
|
msg = "Failed to retrieve required credentials of Nexus VSM from database.";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user