mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
moving out VMWAre and Nexus VSM support code into plugins/hypervisors/vmware
This commit is contained in:
parent
550b22576f
commit
8197f1f07c
@ -198,8 +198,8 @@
|
||||
|
||||
<!-- ===================== Hypervisors ========================= -->
|
||||
|
||||
<target name="compile-hypervisors" depends="compile-ovm, compile-xen" description="Compile all hypervisors"/>
|
||||
<target name="build-hypervisors" depends="build-ovm, build-xen" description="Builds all hypervisors"/>
|
||||
<target name="compile-hypervisors" depends="compile-ovm, compile-xen, compile-vmware" description="Compile all hypervisors"/>
|
||||
<target name="build-hypervisors" depends="build-ovm, build-xen, build-vmware" description="Builds all hypervisors"/>
|
||||
|
||||
<target name="compile-ovm" depends="-init, compile-server" description="Compile OVM">
|
||||
<ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="build"/>
|
||||
@ -212,6 +212,11 @@
|
||||
</target>
|
||||
<target name="build-xen" depends="compile-xen" />
|
||||
|
||||
<target name="compile-vmware" depends="-init, compile-server" description="Compiles Vmware">
|
||||
<ant antfile="${base.dir}/plugins/hypervisors/vmware/build.xml" target="build"/>
|
||||
</target>
|
||||
<target name="build-vmware" depends="compile-vmware" />
|
||||
|
||||
|
||||
<!-- ===================== Deployment Planners ================= -->
|
||||
|
||||
|
||||
@ -157,11 +157,14 @@
|
||||
<adapters key="com.cloud.agent.StartupCommandProcessor">
|
||||
<adapter name="BasicAgentAuthorizer" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager"/>
|
||||
</adapters>
|
||||
<manager name="VmwareManager" key="com.cloud.hypervisor.vmware.manager.VmwareManager" class="com.cloud.hypervisor.vmware.manager.VmwareManagerImpl"/>
|
||||
<pluggableservice name="VirtualRouterElementService" key="com.cloud.network.element.VirtualRouterElementService" class="com.cloud.network.element.VirtualRouterElement"/>
|
||||
<pluggableservice name="NetscalerExternalLoadBalancerElementService" key="com.cloud.network.element.NetscalerLoadBalancerElementService" class="com.cloud.network.element.NetscalerElement"/>
|
||||
<pluggableservice name="F5ExternalLoadBalancerElementService" key="com.cloud.network.element.F5ExternalLoadBalancerElementService" class="com.cloud.network.element.F5ExternalLoadBalancerElement"/>
|
||||
<pluggableservice name="JuniperSRXFirewallElementService" key="com.cloud.network.element.JuniperSRXFirewallElementService" class="com.cloud.network.element.JuniperSRXExternalFirewallElement"/>
|
||||
<pluggableservice name="CiscoNexusVSMElementService" key="com.coud.network.element.CiscoNexusVSMElementService" class="com.cloud.network.element.CiscoNexusVSMElement"/>
|
||||
<dao name="NetScalerPodDao" class="com.cloud.network.dao.NetScalerPodDaoImpl" singleton="false"/>
|
||||
<dao name="CiscoNexusVSMDeviceDao" class="com.cloud.network.dao.CiscoNexusVSMDeviceDaoImpl" singleton="false"/>
|
||||
</management-server>
|
||||
|
||||
<configuration-server class="com.cloud.server.ConfigurationServerImpl">
|
||||
|
||||
@ -96,7 +96,7 @@ import com.cloud.agent.api.to.VirtualMachineTO;
|
||||
import com.cloud.agent.api.to.VolumeTO;
|
||||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.vmware.resource.SshHelper;
|
||||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.resource.ServerResourceBase;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
|
||||
12
plugins/hypervisors/vmware/.classpath
Executable file
12
plugins/hypervisors/vmware/.classpath
Executable file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/deps"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/vmware-base"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
23
plugins/hypervisors/vmware/.project
Executable file
23
plugins/hypervisors/vmware/.project
Executable file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vmware</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
135
plugins/hypervisors/vmware/build.xml
Executable file
135
plugins/hypervisors/vmware/build.xml
Executable file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<project name="Cloud Stack Vmware" default="help" basedir=".">
|
||||
<description>
|
||||
Cloud Stack ant build file
|
||||
</description>
|
||||
|
||||
<dirname property="vmware.base.dir" file="${ant.file.Cloud Stack Vmware}/"/>
|
||||
<!-- This directory must be set -->
|
||||
<property name="top.dir" location="${vmware.base.dir}/../../.."/>
|
||||
<property name="build.dir" location="${top.dir}/build"/>
|
||||
|
||||
<echo message="build.dir=${build.dir}; top.dir=${top.dir}; vmware.base.dir=${vmware.base.dir}"/>
|
||||
|
||||
<!-- Import anything that the user wants to set-->
|
||||
<!-- Import properties files and environment variables here -->
|
||||
|
||||
<property environment="env" />
|
||||
|
||||
<condition property="build-cloud.properties.file" value="${build.dir}/override/build-cloud.properties" else="${build.dir}/build-cloud.properties">
|
||||
<available file="${build.dir}/override/build-cloud.properties" />
|
||||
</condition>
|
||||
|
||||
<condition property="cloud.properties.file" value="${build.dir}/override/cloud.properties" else="${build.dir}/cloud.properties">
|
||||
<available file="${build.dir}/override/cloud.properties" />
|
||||
</condition>
|
||||
|
||||
<condition property="override.file" value="${build.dir}/override/replace.properties" else="${build.dir}/replace.properties">
|
||||
<available file="${build.dir}/override/replace.properties" />
|
||||
</condition>
|
||||
|
||||
<echo message="Using build parameters from ${build-cloud.properties.file}" />
|
||||
<property file="${build-cloud.properties.file}" />
|
||||
|
||||
<echo message="Using company info from ${cloud.properties.file}" />
|
||||
<property file="${cloud.properties.file}" />
|
||||
|
||||
<echo message="Using override file from ${override.file}" />
|
||||
<property file="${override.file}" />
|
||||
|
||||
<property file="${build.dir}/build.number" />
|
||||
|
||||
<!-- In case these didn't get defined in the build-cloud.properties -->
|
||||
<property name="branding.name" value="default" />
|
||||
<property name="deprecation" value="off" />
|
||||
<property name="target.compat.version" value="1.6" />
|
||||
<property name="source.compat.version" value="1.6" />
|
||||
<property name="debug" value="true" />
|
||||
<property name="debuglevel" value="lines,source"/>
|
||||
|
||||
<echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
|
||||
<!-- directories for build and distribution -->
|
||||
<property name="target.dir" location="${top.dir}/target" />
|
||||
<property name="classes.dir" location="${target.dir}/classes" />
|
||||
<property name="jar.dir" location="${target.dir}/jar" />
|
||||
<property name="dep.cache.dir" location="${target.dir}/dep-cache" />
|
||||
<property name="build.log" location="${target.dir}/ant_verbose.txt" />
|
||||
|
||||
<property name="deps.dir" location="${top.dir}/deps" />
|
||||
|
||||
<property name="vmware.jar" value="cloud-vmware.jar" />
|
||||
<property name="vmware-scripts.dir" location="${base.dir}/plugins/hypervisors/vmware/scripts" />
|
||||
|
||||
<import file="${build.dir}/build-common.xml"/>
|
||||
|
||||
<echo message="target.dir=${target.dir}; top.dir=${top.dir}"/>
|
||||
|
||||
<!-- This section needs to be replaced by some kind of dependency library-->
|
||||
<path id="deps.classpath">
|
||||
<!--filelist files="${deps.classpath}" /-->
|
||||
<fileset dir="${deps.dir}" erroronmissingdir="false">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<path id="cloudstack.classpath">
|
||||
<fileset dir="${jar.dir}">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<path id="vmware.classpath">
|
||||
<path refid="deps.classpath"/>
|
||||
<path refid="cloudstack.classpath"/>
|
||||
</path>
|
||||
|
||||
<!-- This section needs to be replaced by some kind of dependency library-->
|
||||
|
||||
<target name="deploy-vmware" >
|
||||
<copy todir="${server.deploy.to.dir}/webapps/client/WEB-INF/lib/scripts">
|
||||
<fileset dir="${vmware-scripts.dir}">
|
||||
<include name="**/*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="init" description="Initialize binaries directory">
|
||||
<mkdir dir="${classes.dir}/${vmware.jar}"/>
|
||||
<mkdir dir="${jar.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile-vmware" depends="init" description="Compiles Vmware">
|
||||
<compile-java jar.name="${vmware.jar}" top.dir="${vmware.base.dir}" classpath="vmware.classpath" />
|
||||
</target>
|
||||
|
||||
<target name="help" description="help">
|
||||
<echo level="info" message="This is the build file for vmware"/>
|
||||
<echo level="info" message="You can do a build by doing ant build or clean by ant clean" />
|
||||
</target>
|
||||
|
||||
<target name="clean-vmware">
|
||||
<delete dir="${classes.dir}/${vmware.jar}"/>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="compile-vmware"/>
|
||||
<target name="clean" depends="clean-vmware"/>
|
||||
|
||||
</project>
|
||||
@ -10,8 +10,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// 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.URLDecoder;
|
||||
import java.util.HashMap;
|
||||
@ -64,42 +64,42 @@ import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.vmware.vim25.ClusterDasConfigInfo;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
|
||||
@Local(value=Discoverer.class)
|
||||
public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
|
||||
|
||||
@Inject ClusterDao _clusterDao;
|
||||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject AlertManager _alertMgr;
|
||||
@Inject VMTemplateDao _tmpltDao;
|
||||
|
||||
@Local(value=Discoverer.class)
|
||||
public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
|
||||
|
||||
@Inject ClusterDao _clusterDao;
|
||||
@Inject VmwareManager _vmwareMgr;
|
||||
@Inject AlertManager _alertMgr;
|
||||
@Inject VMTemplateDao _tmpltDao;
|
||||
@Inject ClusterDetailsDao _clusterDetailsDao;
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject
|
||||
DataCenterDao _dcDao;
|
||||
DataCenterDao _dcDao;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||
@Inject
|
||||
NetworkManager _netmgr;
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
|
||||
String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
||||
|
||||
if(podId == null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
|
||||
return null;
|
||||
}
|
||||
|
||||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||
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;
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url,
|
||||
String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
||||
|
||||
if(podId == null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
|
||||
return null;
|
||||
}
|
||||
|
||||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||
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;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||
@ -135,9 +135,9 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
}
|
||||
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
|
||||
}
|
||||
|
||||
VmwareContext context = null;
|
||||
try {
|
||||
|
||||
VmwareContext context = null;
|
||||
try {
|
||||
context = VmwareContextFactory.create(url.getHost(), username, password);
|
||||
if (privateTrafficLabel != null)
|
||||
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
|
||||
@ -147,64 +147,64 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
s_logger.info("Stocking credentials of Nexus VSM");
|
||||
context.registerStockObject("vsmcredentials", vsmCredentials);
|
||||
}
|
||||
}
|
||||
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId,
|
||||
}
|
||||
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");
|
||||
|
||||
if(morHosts == null) {
|
||||
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
||||
return null;
|
||||
}
|
||||
|
||||
ManagedObjectReference morCluster = null;
|
||||
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
||||
if(clusterDetails.get("url") != null) {
|
||||
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
||||
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
||||
|
||||
if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
||||
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
||||
return null;
|
||||
} else {
|
||||
ClusterMO clusterMo = new ClusterMO(context, morCluster);
|
||||
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
|
||||
s_logger.warn("The discovered host does not belong to the cluster");
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
|
||||
for(ManagedObjectReference morHost : morHosts) {
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
|
||||
HostMO hostMo = new HostMO(context, morHost);
|
||||
details.put("url", hostMo.getHostName());
|
||||
details.put("username", username);
|
||||
details.put("password", password);
|
||||
String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
|
||||
details.put("guid", guid);
|
||||
|
||||
params.put("url", hostMo.getHostName());
|
||||
params.put("username", username);
|
||||
params.put("password", password);
|
||||
params.put("zone", Long.toString(dcId));
|
||||
params.put("pod", Long.toString(podId));
|
||||
params.put("cluster", Long.toString(clusterId));
|
||||
|
||||
if(morHosts == null) {
|
||||
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
||||
return null;
|
||||
}
|
||||
|
||||
ManagedObjectReference morCluster = null;
|
||||
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
||||
if(clusterDetails.get("url") != null) {
|
||||
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
||||
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
||||
|
||||
if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
||||
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
||||
return null;
|
||||
} else {
|
||||
ClusterMO clusterMo = new ClusterMO(context, morCluster);
|
||||
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
|
||||
s_logger.warn("The discovered host does not belong to the cluster");
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
|
||||
for(ManagedObjectReference morHost : morHosts) {
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
|
||||
HostMO hostMo = new HostMO(context, morHost);
|
||||
details.put("url", hostMo.getHostName());
|
||||
details.put("username", username);
|
||||
details.put("password", password);
|
||||
String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
|
||||
details.put("guid", guid);
|
||||
|
||||
params.put("url", hostMo.getHostName());
|
||||
params.put("username", username);
|
||||
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);
|
||||
if (privateTrafficLabel != null) {
|
||||
params.put("private.network.vswitch.name", privateTrafficLabel);
|
||||
@ -214,113 +214,113 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
}
|
||||
if (guestTrafficLabel != null) {
|
||||
params.put("guest.network.vswitch.name", guestTrafficLabel);
|
||||
}
|
||||
|
||||
VmwareResource resource = new VmwareResource();
|
||||
try {
|
||||
resource.configure("VMware", params);
|
||||
} catch (ConfigurationException e) {
|
||||
_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);
|
||||
}
|
||||
resource.start();
|
||||
|
||||
resources.put(resource, details);
|
||||
}
|
||||
|
||||
// place a place holder guid derived from cluster ID
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||
_clusterDao.update(clusterId, cluster);
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
VmwareResource resource = new VmwareResource();
|
||||
try {
|
||||
resource.configure("VMware", params);
|
||||
} catch (ConfigurationException e) {
|
||||
_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);
|
||||
}
|
||||
resource.start();
|
||||
|
||||
resources.put(resource, details);
|
||||
}
|
||||
|
||||
// place a place holder guid derived from cluster ID
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||
_clusterDao.update(clusterId, cluster);
|
||||
|
||||
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
|
||||
@ -359,6 +359,6 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
public boolean stop() {
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
return super.stop();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.hypervisor.vmware;
|
||||
package com.cloud.hypervisor.vmware.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -54,6 +54,7 @@ import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.vmware.VmwareCleanupMaid;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareManager;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
||||
import com.cloud.hypervisor.vmware.manager.VmwareStorageManagerImpl;
|
||||
@ -65,7 +66,7 @@ import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
||||
import com.cloud.hypervisor.vmware.mo.TaskMO;
|
||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
||||
import com.cloud.hypervisor.vmware.resource.SshHelper;
|
||||
import com.cloud.utils.ssh.SshHelper;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||
import com.cloud.network.NetworkManager;
|
||||
@ -123,11 +123,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
|
||||
VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
|
||||
|
||||
if (templateMo == null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
|
||||
|
||||
if (templateMo == null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
|
||||
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
|
||||
assert (morDs != null);
|
||||
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
|
||||
|
||||
@ -171,8 +171,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
VmwareContext context = hostService.getServiceContext(cmd);
|
||||
VirtualMachineMO vmMo = null;
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
|
||||
|
||||
try {
|
||||
@ -202,7 +202,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
// attach volume to worker VM
|
||||
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
|
||||
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vmMo.createSnapshot(snapshotUuid, "Snapshot taken for " + cmd.getSnapshotName(), false, false)) {
|
||||
@ -340,79 +340,79 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath,
|
||||
secondaryStorageURL,
|
||||
hostService.getWorkerName(context, cmd, 0));
|
||||
} else {
|
||||
StorageFilerTO poolTO = cmd.getPool();
|
||||
|
||||
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
|
||||
if (morDatastore == null) {
|
||||
morDatastore = hyperHost.mountDatastore(
|
||||
false,
|
||||
poolTO.getHost(), 0, poolTO.getPath(),
|
||||
poolTO.getUuid().replace("-", ""));
|
||||
|
||||
if (morDatastore == null) {
|
||||
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
result = copyVolumeFromSecStorage(
|
||||
hyperHost, volumeId,
|
||||
new DatastoreMO(context, morDatastore),
|
||||
secondaryStorageURL, volumePath);
|
||||
}
|
||||
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
} else {
|
||||
StorageFilerTO poolTO = cmd.getPool();
|
||||
|
||||
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
||||
s_logger.error(msg, e);
|
||||
return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
|
||||
|
||||
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
|
||||
Long accountId = cmd.getAccountId();
|
||||
Long volumeId = cmd.getVolumeId();
|
||||
String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
|
||||
String backedUpSnapshotUuid = cmd.getSnapshotUuid();
|
||||
|
||||
String details = null;
|
||||
boolean success = false;
|
||||
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
|
||||
VmwareContext context = hostService.getServiceContext(cmd);
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
|
||||
ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
|
||||
if (morPrimaryDs == null) {
|
||||
String msg = "Unable to find datastore: " + primaryStorageNameLabel;
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
|
||||
details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
|
||||
newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
|
||||
if (details == null) {
|
||||
success = true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
||||
}
|
||||
|
||||
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
|
||||
}
|
||||
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
|
||||
if (morDatastore == null) {
|
||||
morDatastore = hyperHost.mountDatastore(
|
||||
false,
|
||||
poolTO.getHost(), 0, poolTO.getPath(),
|
||||
poolTO.getUuid().replace("-", ""));
|
||||
|
||||
if (morDatastore == null) {
|
||||
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
result = copyVolumeFromSecStorage(
|
||||
hyperHost, volumeId,
|
||||
new DatastoreMO(context, morDatastore),
|
||||
secondaryStorageURL, volumePath);
|
||||
}
|
||||
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
||||
s_logger.error(msg, e);
|
||||
return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
|
||||
|
||||
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
|
||||
Long accountId = cmd.getAccountId();
|
||||
Long volumeId = cmd.getVolumeId();
|
||||
String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
|
||||
String backedUpSnapshotUuid = cmd.getSnapshotUuid();
|
||||
|
||||
String details = null;
|
||||
boolean success = false;
|
||||
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
|
||||
VmwareContext context = hostService.getServiceContext(cmd);
|
||||
try {
|
||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||
|
||||
ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
|
||||
if (morPrimaryDs == null) {
|
||||
String msg = "Unable to find datastore: " + primaryStorageNameLabel;
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
|
||||
details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
|
||||
newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
|
||||
if (details == null) {
|
||||
success = true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof RemoteException) {
|
||||
hostService.invalidateServiceContext(context);
|
||||
}
|
||||
|
||||
s_logger.error("Unexpecpted exception ", e);
|
||||
details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
||||
}
|
||||
|
||||
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
|
||||
}
|
||||
|
||||
// templateName: name in secondary storage
|
||||
// templateUuid: will be used at hypervisor layer
|
||||
File diff suppressed because it is too large
Load Diff
@ -14,59 +14,59 @@
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
public interface CiscoNexusVSMDevice {
|
||||
|
||||
// This tells us whether the VSM is currently enabled or disabled. We may
|
||||
// need this if we would like to carry out any sort of maintenance on the
|
||||
// VSM or CS.
|
||||
public enum VSMDeviceState {
|
||||
Enabled,
|
||||
Disabled
|
||||
}
|
||||
|
||||
// This tells us whether the VSM is currently configured with a standby (HA)
|
||||
// or does not have any standby (Standalone).
|
||||
public enum VSMConfigMode {
|
||||
Standalone,
|
||||
HA
|
||||
}
|
||||
|
||||
// This tells us whether the VSM is currently a primary or a standby VSM.
|
||||
public enum VSMConfigState {
|
||||
Primary,
|
||||
Standby
|
||||
}
|
||||
|
||||
long getId();
|
||||
|
||||
public String getvsmName();
|
||||
|
||||
public long getHostId();
|
||||
|
||||
public String getUserName();
|
||||
|
||||
public String getPassword();
|
||||
|
||||
public String getipaddr();
|
||||
|
||||
public int getManagementVlan();
|
||||
|
||||
public int getControlVlan();
|
||||
|
||||
public int getPacketVlan();
|
||||
|
||||
public int getStorageVlan();
|
||||
|
||||
public long getvsmDomainId();
|
||||
|
||||
public VSMConfigMode getvsmConfigMode();
|
||||
|
||||
public VSMConfigState getvsmConfigState();
|
||||
|
||||
public VSMDeviceState getvsmDeviceState();
|
||||
|
||||
public String getUuid();
|
||||
|
||||
}
|
||||
package com.cloud.network;
|
||||
|
||||
public interface CiscoNexusVSMDevice {
|
||||
|
||||
// This tells us whether the VSM is currently enabled or disabled. We may
|
||||
// need this if we would like to carry out any sort of maintenance on the
|
||||
// VSM or CS.
|
||||
public enum VSMDeviceState {
|
||||
Enabled,
|
||||
Disabled
|
||||
}
|
||||
|
||||
// This tells us whether the VSM is currently configured with a standby (HA)
|
||||
// or does not have any standby (Standalone).
|
||||
public enum VSMConfigMode {
|
||||
Standalone,
|
||||
HA
|
||||
}
|
||||
|
||||
// This tells us whether the VSM is currently a primary or a standby VSM.
|
||||
public enum VSMConfigState {
|
||||
Primary,
|
||||
Standby
|
||||
}
|
||||
|
||||
long getId();
|
||||
|
||||
public String getvsmName();
|
||||
|
||||
public long getHostId();
|
||||
|
||||
public String getUserName();
|
||||
|
||||
public String getPassword();
|
||||
|
||||
public String getipaddr();
|
||||
|
||||
public int getManagementVlan();
|
||||
|
||||
public int getControlVlan();
|
||||
|
||||
public int getPacketVlan();
|
||||
|
||||
public int getStorageVlan();
|
||||
|
||||
public long getvsmDomainId();
|
||||
|
||||
public VSMConfigMode getvsmConfigMode();
|
||||
|
||||
public VSMConfigState getvsmConfigState();
|
||||
|
||||
public VSMDeviceState getvsmDeviceState();
|
||||
|
||||
public String getUuid();
|
||||
|
||||
}
|
||||
@ -21,6 +21,8 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterDetailsDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.ClusterVSMMapVO;
|
||||
@ -62,7 +64,8 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
||||
HostDetailsDao _hostDetailDao;
|
||||
@Inject
|
||||
PortProfileDao _ppDao;
|
||||
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerDeviceManagerImpl.class);
|
||||
|
||||
@ -312,4 +315,94 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@DB
|
||||
public boolean vliadateVsmCluster(String vsmIp, String vsmUser, String vsmPassword, long clusterId, String clusterName) throws ResourceInUseException {
|
||||
// Check if we're associating a Cisco Nexus VSM with a vmware cluster.
|
||||
if (Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) {
|
||||
|
||||
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);
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
Transaction txn;
|
||||
|
||||
// If VSM already exists and is mapped to a cluster, fail this operation.
|
||||
CiscoNexusVSMDeviceVO vsm = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(vsmIp);
|
||||
if(vsm != null) {
|
||||
List<ClusterVSMMapVO> clusterList = _clusterVSMDao.listByVSMId(vsm.getId());
|
||||
if (clusterList != null && !clusterList.isEmpty()) {
|
||||
s_logger.error("Failed to add cluster: specified Nexus VSM is already associated with another cluster");
|
||||
_clusterDao.remove(clusterId);
|
||||
ResourceInUseException ex = new ResourceInUseException("Failed to add cluster: specified Nexus VSM is already associated with another cluster with specified Id");
|
||||
ex.addProxyObject("cluster", clusterList.get(0).getClusterId(), "clusterId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
// persist credentials to database if the VSM entry is not already in the db.
|
||||
if (_ciscoNexusVSMDeviceDao.getVSMbyIpaddress(vsmIp) == null) {
|
||||
vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword);
|
||||
txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
vsm = _ciscoNexusVSMDeviceDao.persist(vsm);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
s_logger.error("Failed to persist Cisco Nexus 1000v VSM details to database. Exception: " + e.getMessage());
|
||||
// Removing the cluster record which was added already because the persistence of Nexus VSM credentials has failed.
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
// Create a mapping between the cluster and the vsm.
|
||||
vsm = _ciscoNexusVSMDeviceDao.getVSMbyIpaddress(vsmIp);
|
||||
if (vsm != null) {
|
||||
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 Cisco Nexus 1000v VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String msg;
|
||||
msg = "The global parameter " + Config.VmwareUseNexusVSwitch.toString() +
|
||||
" is set to \"true\". Following mandatory parameters are not specified. ";
|
||||
if(vsmIp == null) {
|
||||
msg += "vsmipaddress: Management IP address of Cisco Nexus 1000v dvSwitch. ";
|
||||
}
|
||||
if(vsmUser == null) {
|
||||
msg += "vsmusername: Name of a user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
|
||||
}
|
||||
if(vsmPassword == null) {
|
||||
if(vsmUser != null) {
|
||||
msg += "vsmpassword: Password of user account " + vsmUser + ". ";
|
||||
} else {
|
||||
msg += "vsmpassword: Password of user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
|
||||
}
|
||||
}
|
||||
s_logger.error(msg);
|
||||
// Cleaning up the cluster record as addCluster operation failed because Nexus dvSwitch credentials are supplied.
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,6 @@ import com.cloud.maint.dao.AgentUpgradeDaoImpl;
|
||||
import com.cloud.network.ExternalLoadBalancerUsageManagerImpl;
|
||||
import com.cloud.network.NetworkManagerImpl;
|
||||
import com.cloud.network.StorageNetworkManagerImpl;
|
||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDaoImpl;
|
||||
import com.cloud.network.dao.ExternalFirewallDeviceDaoImpl;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceDaoImpl;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
|
||||
@ -94,8 +93,6 @@ import com.cloud.network.dao.PortProfileDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.element.CiscoNexusVSMElement;
|
||||
import com.cloud.network.element.CiscoNexusVSMElementService;
|
||||
import com.cloud.network.element.VirtualRouterElement;
|
||||
import com.cloud.network.element.VirtualRouterElementService;
|
||||
import com.cloud.network.firewall.FirewallManagerImpl;
|
||||
@ -316,7 +313,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
||||
addDao("ExternalFirewallDeviceDao", ExternalFirewallDeviceDaoImpl.class);
|
||||
addDao("NetworkExternalLoadBalancerDao", NetworkExternalLoadBalancerDaoImpl.class);
|
||||
addDao("NetworkExternalFirewallDao", NetworkExternalFirewallDaoImpl.class);
|
||||
addDao("CiscoNexusVSMDeviceDao", CiscoNexusVSMDeviceDaoImpl.class);
|
||||
addDao("ClusterVSMMapDao", ClusterVSMMapDaoImpl.class);
|
||||
addDao("PortProfileDao", PortProfileDaoImpl.class);
|
||||
addDao("PhysicalNetworkTrafficTypeDao", PhysicalNetworkTrafficTypeDaoImpl.class);
|
||||
@ -412,7 +408,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
||||
|
||||
protected void populateServices() {
|
||||
addService("VirtualRouterElementService", VirtualRouterElementService.class, VirtualRouterElement.class);
|
||||
addService("CiscoNexusVSMElementService", CiscoNexusVSMElementService.class, CiscoNexusVSMElement.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -23,7 +23,6 @@ import com.cloud.baremetal.PxeServerManager.PxeServerType;
|
||||
import com.cloud.baremetal.PxeServerManagerImpl;
|
||||
import com.cloud.baremetal.PxeServerService;
|
||||
import com.cloud.ha.HighAvailabilityManagerExtImpl;
|
||||
import com.cloud.hypervisor.vmware.VmwareManagerImpl;
|
||||
import com.cloud.netapp.NetappManagerImpl;
|
||||
import com.cloud.netapp.dao.LunDaoImpl;
|
||||
import com.cloud.netapp.dao.PoolDaoImpl;
|
||||
@ -60,7 +59,6 @@ public class PremiumComponentLibrary extends DefaultComponentLibrary {
|
||||
addManager("secondary storage vm manager", PremiumSecondaryStorageManagerImpl.class);
|
||||
|
||||
addManager("HA Manager", HighAvailabilityManagerExtImpl.class);
|
||||
addManager("VMWareManager", VmwareManagerImpl.class);
|
||||
addManager("ExternalNetworkManager", ExternalNetworkDeviceManagerImpl.class);
|
||||
addManager("BareMetalVmManager", BareMetalVmManagerImpl.class);
|
||||
addManager("ExternalDhcpManager", ExternalDhcpManagerImpl.class);
|
||||
|
||||
@ -95,9 +95,7 @@ import com.cloud.host.dao.HostTagsDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.kvm.resource.KvmDummyResourceBase;
|
||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.org.Grouping;
|
||||
@ -173,10 +171,6 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
@Inject
|
||||
protected ClusterDao _clusterDao;
|
||||
@Inject
|
||||
protected ClusterVSMMapDao _clusterVSMDao;
|
||||
@Inject
|
||||
protected CiscoNexusVSMDeviceDao _vsmDao;
|
||||
@Inject
|
||||
protected CapacityDao _capacityDao;
|
||||
@Inject
|
||||
protected HostDao _hostDao;
|
||||
@ -434,95 +428,6 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
clusterId = cluster.getId();
|
||||
result.add(cluster);
|
||||
|
||||
// Check if we're associating a Cisco Nexus VSM with a vmware cluster.
|
||||
if (hypervisorType == HypervisorType.VMware &&
|
||||
Boolean.parseBoolean(_configDao.getValue(Config.VmwareUseNexusVSwitch.toString()))) {
|
||||
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);
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
|
||||
Transaction txn;
|
||||
|
||||
// If VSM already exists and is mapped to a cluster, fail this operation.
|
||||
CiscoNexusVSMDeviceVO vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
|
||||
if(vsm != null) {
|
||||
List<ClusterVSMMapVO> clusterList = _clusterVSMDao.listByVSMId(vsm.getId());
|
||||
if (clusterList != null && !clusterList.isEmpty()) {
|
||||
s_logger.error("Failed to add cluster: specified Nexus VSM is already associated with another cluster");
|
||||
_clusterDao.remove(clusterId);
|
||||
ResourceInUseException ex = new ResourceInUseException("Failed to add cluster: specified Nexus VSM is already associated with another cluster with specified Id");
|
||||
ex.addProxyObject("cluster", clusterList.get(0).getClusterId(), "clusterId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
// persist credentials to database if the VSM entry is not already in the db.
|
||||
if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) {
|
||||
vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword);
|
||||
txn = Transaction.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
vsm = _vsmDao.persist(vsm);
|
||||
txn.commit();
|
||||
} catch (Exception e) {
|
||||
txn.rollback();
|
||||
s_logger.error("Failed to persist Cisco Nexus 1000v VSM details to database. Exception: " + e.getMessage());
|
||||
// Removing the cluster record which was added already because the persistence of Nexus VSM credentials has failed.
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
// Create a mapping between the cluster and the vsm.
|
||||
vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
|
||||
if (vsm != null) {
|
||||
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 Cisco Nexus 1000v VSM with cluster: " + clusterName + ". Exception: " + e.getMessage());
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String msg;
|
||||
msg = "The global parameter " + Config.VmwareUseNexusVSwitch.toString() +
|
||||
" is set to \"true\". Following mandatory parameters are not specified. ";
|
||||
if(vsmIp == null) {
|
||||
msg += "vsmipaddress: Management IP address of Cisco Nexus 1000v dvSwitch. ";
|
||||
}
|
||||
if(vsmUser == null) {
|
||||
msg += "vsmusername: Name of a user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
|
||||
}
|
||||
if(vsmPassword == null) {
|
||||
if(vsmUser != null) {
|
||||
msg += "vsmpassword: Password of user account " + vsmUser + ". ";
|
||||
} else {
|
||||
msg += "vsmpassword: Password of user account with admin privileges over Cisco Nexus 1000v dvSwitch. ";
|
||||
}
|
||||
}
|
||||
s_logger.error(msg);
|
||||
// Cleaning up the cluster record as addCluster operation failed because Nexus dvSwitch credentials are supplied.
|
||||
_clusterDao.remove(clusterId);
|
||||
throw new CloudRuntimeException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (clusterType == Cluster.ClusterType.CloudManaged) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.hypervisor.vmware.resource;
|
||||
package com.cloud.utils.ssh;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
Loading…
x
Reference in New Issue
Block a user