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 ========================= -->
|
<!-- ===================== Hypervisors ========================= -->
|
||||||
|
|
||||||
<target name="compile-hypervisors" depends="compile-ovm, compile-xen" description="Compile 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" description="Builds 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">
|
<target name="compile-ovm" depends="-init, compile-server" description="Compile OVM">
|
||||||
<ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="build"/>
|
<ant antfile="${base.dir}/plugins/hypervisors/ovm/build.xml" target="build"/>
|
||||||
@ -212,6 +212,11 @@
|
|||||||
</target>
|
</target>
|
||||||
<target name="build-xen" depends="compile-xen" />
|
<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 ================= -->
|
<!-- ===================== Deployment Planners ================= -->
|
||||||
|
|
||||||
|
|||||||
@ -157,11 +157,14 @@
|
|||||||
<adapters key="com.cloud.agent.StartupCommandProcessor">
|
<adapters key="com.cloud.agent.StartupCommandProcessor">
|
||||||
<adapter name="BasicAgentAuthorizer" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager"/>
|
<adapter name="BasicAgentAuthorizer" class="com.cloud.agent.manager.authn.impl.BasicAgentAuthManager"/>
|
||||||
</adapters>
|
</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="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="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="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="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="NetScalerPodDao" class="com.cloud.network.dao.NetScalerPodDaoImpl" singleton="false"/>
|
||||||
|
<dao name="CiscoNexusVSMDeviceDao" class="com.cloud.network.dao.CiscoNexusVSMDeviceDaoImpl" singleton="false"/>
|
||||||
</management-server>
|
</management-server>
|
||||||
|
|
||||||
<configuration-server class="com.cloud.server.ConfigurationServerImpl">
|
<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.agent.api.to.VolumeTO;
|
||||||
import com.cloud.host.Host.Type;
|
import com.cloud.host.Host.Type;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
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.ServerResource;
|
||||||
import com.cloud.resource.ServerResourceBase;
|
import com.cloud.resource.ServerResourceBase;
|
||||||
import com.cloud.serializer.GsonHelper;
|
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.
|
// 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;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -64,42 +64,42 @@ 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
|
@Inject
|
||||||
DataCenterDao _dcDao;
|
DataCenterDao _dcDao;
|
||||||
@Inject ResourceManager _resourceMgr;
|
@Inject ResourceManager _resourceMgr;
|
||||||
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
@Inject CiscoNexusVSMDeviceDao _nexusDao;
|
||||||
@Inject
|
@Inject
|
||||||
NetworkManager _netmgr;
|
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,
|
||||||
String username, String password, List<String> hostTags) throws DiscoveryException {
|
String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||||
|
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled())
|
||||||
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
||||||
|
|
||||||
if(podId == null) {
|
if(podId == null) {
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled())
|
||||||
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
|
s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||||
if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
|
if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled())
|
||||||
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
|
s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
|
||||||
@ -135,9 +135,9 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
}
|
}
|
||||||
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
|
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
VmwareContext context = null;
|
VmwareContext context = null;
|
||||||
try {
|
try {
|
||||||
context = VmwareContextFactory.create(url.getHost(), username, password);
|
context = VmwareContextFactory.create(url.getHost(), username, password);
|
||||||
if (privateTrafficLabel != null)
|
if (privateTrafficLabel != null)
|
||||||
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
|
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
|
||||||
@ -147,64 +147,64 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
s_logger.info("Stocking credentials of Nexus VSM");
|
s_logger.info("Stocking credentials of Nexus VSM");
|
||||||
context.registerStockObject("vsmcredentials", vsmCredentials);
|
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()));
|
URLDecoder.decode(url.getPath()));
|
||||||
if (morHosts == null)
|
if (morHosts == null)
|
||||||
s_logger.info("Found 0 hosts.");
|
s_logger.info("Found 0 hosts.");
|
||||||
if (privateTrafficLabel != null)
|
if (privateTrafficLabel != null)
|
||||||
context.uregisterStockObject("privateTrafficLabel");
|
context.uregisterStockObject("privateTrafficLabel");
|
||||||
|
|
||||||
if(morHosts == null) {
|
if(morHosts == null) {
|
||||||
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ManagedObjectReference morCluster = null;
|
ManagedObjectReference morCluster = null;
|
||||||
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
||||||
if(clusterDetails.get("url") != null) {
|
if(clusterDetails.get("url") != null) {
|
||||||
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
||||||
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
||||||
|
|
||||||
if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
||||||
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
ClusterMO clusterMo = new ClusterMO(context, morCluster);
|
ClusterMO clusterMo = new ClusterMO(context, morCluster);
|
||||||
ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
|
ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
|
||||||
if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
|
if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
|
||||||
clusterDetails.put("NativeHA", "true");
|
clusterDetails.put("NativeHA", "true");
|
||||||
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
_clusterDetailsDao.persist(clusterId, clusterDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
|
if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
|
||||||
if(morCluster == null)
|
if(morCluster == null)
|
||||||
s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
|
s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
|
||||||
else
|
else
|
||||||
s_logger.warn("The discovered host does not belong to the cluster");
|
s_logger.warn("The discovered host does not belong to the cluster");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
|
Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
|
||||||
for(ManagedObjectReference morHost : morHosts) {
|
for(ManagedObjectReference morHost : morHosts) {
|
||||||
Map<String, String> details = new HashMap<String, String>();
|
Map<String, String> details = new HashMap<String, String>();
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
|
|
||||||
HostMO hostMo = new HostMO(context, morHost);
|
HostMO hostMo = new HostMO(context, morHost);
|
||||||
details.put("url", hostMo.getHostName());
|
details.put("url", hostMo.getHostName());
|
||||||
details.put("username", username);
|
details.put("username", username);
|
||||||
details.put("password", password);
|
details.put("password", password);
|
||||||
String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
|
String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
|
||||||
details.put("guid", guid);
|
details.put("guid", guid);
|
||||||
|
|
||||||
params.put("url", hostMo.getHostName());
|
params.put("url", hostMo.getHostName());
|
||||||
params.put("username", username);
|
params.put("username", username);
|
||||||
params.put("password", password);
|
params.put("password", password);
|
||||||
params.put("zone", Long.toString(dcId));
|
params.put("zone", Long.toString(dcId));
|
||||||
params.put("pod", Long.toString(podId));
|
params.put("pod", Long.toString(podId));
|
||||||
params.put("cluster", Long.toString(clusterId));
|
params.put("cluster", Long.toString(clusterId));
|
||||||
params.put("guid", guid);
|
params.put("guid", guid);
|
||||||
if (privateTrafficLabel != null) {
|
if (privateTrafficLabel != null) {
|
||||||
params.put("private.network.vswitch.name", privateTrafficLabel);
|
params.put("private.network.vswitch.name", privateTrafficLabel);
|
||||||
@ -214,113 +214,113 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
}
|
}
|
||||||
if (guestTrafficLabel != null) {
|
if (guestTrafficLabel != null) {
|
||||||
params.put("guest.network.vswitch.name", guestTrafficLabel);
|
params.put("guest.network.vswitch.name", guestTrafficLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
VmwareResource resource = new VmwareResource();
|
VmwareResource resource = new VmwareResource();
|
||||||
try {
|
try {
|
||||||
resource.configure("VMware", params);
|
resource.configure("VMware", params);
|
||||||
} catch (ConfigurationException e) {
|
} catch (ConfigurationException e) {
|
||||||
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
|
_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);
|
s_logger.warn("Unable to instantiate " + url.getHost(), e);
|
||||||
}
|
}
|
||||||
resource.start();
|
resource.start();
|
||||||
|
|
||||||
resources.put(resource, details);
|
resources.put(resource, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
// place a place holder guid derived from cluster ID
|
// place a place holder guid derived from cluster ID
|
||||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||||
_clusterDao.update(clusterId, cluster);
|
_clusterDao.update(clusterId, cluster);
|
||||||
|
|
||||||
return resources;
|
return resources;
|
||||||
} catch (DiscoveredWithErrorException e) {
|
} catch (DiscoveredWithErrorException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
|
s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
if(context != null)
|
if(context != null)
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List<ManagedObjectReference> morHosts) throws Exception {
|
private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List<ManagedObjectReference> morHosts) throws Exception {
|
||||||
if(morCluster == null) {
|
if(morCluster == null) {
|
||||||
for(ManagedObjectReference morHost : morHosts) {
|
for(ManagedObjectReference morHost : morHosts) {
|
||||||
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
||||||
if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(ManagedObjectReference morHost : morHosts) {
|
for(ManagedObjectReference morHost : morHosts) {
|
||||||
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
|
||||||
if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!morParent.get_value().equals(morCluster.get_value()))
|
if(!morParent.get_value().equals(morCluster.get_value()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postDiscovery(List<HostVO> hosts, long msId) {
|
public void postDiscovery(List<HostVO> hosts, long msId) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchHypervisor(String hypervisor) {
|
public boolean matchHypervisor(String hypervisor) {
|
||||||
if(hypervisor == null)
|
if(hypervisor == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
|
return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hypervisor.HypervisorType getHypervisorType() {
|
public Hypervisor.HypervisorType getHypervisorType() {
|
||||||
return Hypervisor.HypervisorType.VMware;
|
return Hypervisor.HypervisorType.VMware;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled())
|
||||||
s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
|
s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
|
||||||
|
|
||||||
super.configure(name, params);
|
super.configure(name, params);
|
||||||
|
|
||||||
ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||||
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
|
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
|
||||||
if (configDao == null) {
|
if (configDao == null) {
|
||||||
throw new ConfigurationException("Unable to get the configuration dao.");
|
throw new ConfigurationException("Unable to get the configuration dao.");
|
||||||
}
|
}
|
||||||
|
|
||||||
createVmwareToolsIso();
|
createVmwareToolsIso();
|
||||||
|
|
||||||
if(s_logger.isInfoEnabled()) {
|
if(s_logger.isInfoEnabled()) {
|
||||||
s_logger.info("VmwareServerDiscoverer has been successfully configured");
|
s_logger.info("VmwareServerDiscoverer has been successfully configured");
|
||||||
}
|
}
|
||||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createVmwareToolsIso() {
|
private void createVmwareToolsIso() {
|
||||||
String isoName = "vmware-tools.iso";
|
String isoName = "vmware-tools.iso";
|
||||||
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
|
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
|
||||||
Long id;
|
Long id;
|
||||||
if (tmplt == null) {
|
if (tmplt == null) {
|
||||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||||
VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
|
VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
|
||||||
TemplateType.PERHOST, null, null, true, 64,
|
TemplateType.PERHOST, null, null, true, 64,
|
||||||
Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
|
Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
|
||||||
_tmpltDao.persist(template);
|
_tmpltDao.persist(template);
|
||||||
} else {
|
} else {
|
||||||
id = tmplt.getId();
|
id = tmplt.getId();
|
||||||
tmplt.setTemplateType(TemplateType.PERHOST);
|
tmplt.setTemplateType(TemplateType.PERHOST);
|
||||||
tmplt.setUrl(null);
|
tmplt.setUrl(null);
|
||||||
_tmpltDao.update(id, tmplt);
|
_tmpltDao.update(id, tmplt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -359,6 +359,6 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||||
return super.stop();
|
return super.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10,7 +10,7 @@
|
|||||||
// 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.manager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -54,6 +54,7 @@ import com.cloud.host.HostVO;
|
|||||||
import com.cloud.host.Status;
|
import com.cloud.host.Status;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
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.VmwareManager;
|
||||||
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
||||||
import com.cloud.hypervisor.vmware.manager.VmwareStorageManagerImpl;
|
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.TaskMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
|
||||||
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
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.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||||
import com.cloud.network.NetworkManager;
|
import com.cloud.network.NetworkManager;
|
||||||
@ -123,11 +123,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
|
|
||||||
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
|
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
|
||||||
VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
|
VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
|
||||||
|
|
||||||
if (templateMo == null) {
|
if (templateMo == null) {
|
||||||
if(s_logger.isInfoEnabled())
|
if(s_logger.isInfoEnabled())
|
||||||
s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
|
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());
|
ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
|
||||||
assert (morDs != null);
|
assert (morDs != null);
|
||||||
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
|
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
|
||||||
|
|
||||||
@ -171,8 +171,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
|
|
||||||
VmwareContext context = hostService.getServiceContext(cmd);
|
VmwareContext context = hostService.getServiceContext(cmd);
|
||||||
VirtualMachineMO vmMo = null;
|
VirtualMachineMO vmMo = null;
|
||||||
try {
|
try {
|
||||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||||
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
|
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -202,7 +202,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
// attach volume to worker VM
|
// attach volume to worker VM
|
||||||
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
|
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
|
||||||
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
|
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vmMo.createSnapshot(snapshotUuid, "Snapshot taken for " + cmd.getSnapshotName(), false, false)) {
|
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,
|
hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath,
|
||||||
secondaryStorageURL,
|
secondaryStorageURL,
|
||||||
hostService.getWorkerName(context, cmd, 0));
|
hostService.getWorkerName(context, cmd, 0));
|
||||||
} else {
|
} else {
|
||||||
StorageFilerTO poolTO = cmd.getPool();
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
|
||||||
s_logger.error(msg, e);
|
if (morDatastore == null) {
|
||||||
return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
|
morDatastore = hyperHost.mountDatastore(
|
||||||
}
|
false,
|
||||||
}
|
poolTO.getHost(), 0, poolTO.getPath(),
|
||||||
|
poolTO.getUuid().replace("-", ""));
|
||||||
@Override
|
|
||||||
public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
|
if (morDatastore == null) {
|
||||||
|
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
|
||||||
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
|
}
|
||||||
Long accountId = cmd.getAccountId();
|
}
|
||||||
Long volumeId = cmd.getVolumeId();
|
|
||||||
String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
|
result = copyVolumeFromSecStorage(
|
||||||
String backedUpSnapshotUuid = cmd.getSnapshotUuid();
|
hyperHost, volumeId,
|
||||||
|
new DatastoreMO(context, morDatastore),
|
||||||
String details = null;
|
secondaryStorageURL, volumePath);
|
||||||
boolean success = false;
|
}
|
||||||
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
|
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
|
||||||
|
} catch (Throwable e) {
|
||||||
VmwareContext context = hostService.getServiceContext(cmd);
|
if (e instanceof RemoteException) {
|
||||||
try {
|
hostService.invalidateServiceContext(context);
|
||||||
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
}
|
||||||
|
|
||||||
ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
|
String msg = "Unable to execute CopyVolumeCommand due to exception";
|
||||||
if (morPrimaryDs == null) {
|
s_logger.error(msg, e);
|
||||||
String msg = "Unable to find datastore: " + primaryStorageNameLabel;
|
return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
|
||||||
s_logger.error(msg);
|
}
|
||||||
throw new Exception(msg);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
|
public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
|
||||||
details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
|
|
||||||
newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
|
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
|
||||||
if (details == null) {
|
Long accountId = cmd.getAccountId();
|
||||||
success = true;
|
Long volumeId = cmd.getVolumeId();
|
||||||
}
|
String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
|
||||||
} catch (Throwable e) {
|
String backedUpSnapshotUuid = cmd.getSnapshotUuid();
|
||||||
if (e instanceof RemoteException) {
|
|
||||||
hostService.invalidateServiceContext(context);
|
String details = null;
|
||||||
}
|
boolean success = false;
|
||||||
|
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
s_logger.error("Unexpecpted exception ", e);
|
|
||||||
details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
|
VmwareContext context = hostService.getServiceContext(cmd);
|
||||||
}
|
try {
|
||||||
|
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
|
||||||
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
|
|
||||||
}
|
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
|
// templateName: name in secondary storage
|
||||||
// templateUuid: will be used at hypervisor layer
|
// 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
|
// KIND, either express or implied. See the License for the
|
||||||
// specific language governing permissions and limitations
|
// specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.network;
|
package com.cloud.network;
|
||||||
|
|
||||||
public interface CiscoNexusVSMDevice {
|
public interface CiscoNexusVSMDevice {
|
||||||
|
|
||||||
// This tells us whether the VSM is currently enabled or disabled. We may
|
// 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
|
// need this if we would like to carry out any sort of maintenance on the
|
||||||
// VSM or CS.
|
// VSM or CS.
|
||||||
public enum VSMDeviceState {
|
public enum VSMDeviceState {
|
||||||
Enabled,
|
Enabled,
|
||||||
Disabled
|
Disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// This tells us whether the VSM is currently configured with a standby (HA)
|
// This tells us whether the VSM is currently configured with a standby (HA)
|
||||||
// or does not have any standby (Standalone).
|
// or does not have any standby (Standalone).
|
||||||
public enum VSMConfigMode {
|
public enum VSMConfigMode {
|
||||||
Standalone,
|
Standalone,
|
||||||
HA
|
HA
|
||||||
}
|
}
|
||||||
|
|
||||||
// This tells us whether the VSM is currently a primary or a standby VSM.
|
// This tells us whether the VSM is currently a primary or a standby VSM.
|
||||||
public enum VSMConfigState {
|
public enum VSMConfigState {
|
||||||
Primary,
|
Primary,
|
||||||
Standby
|
Standby
|
||||||
}
|
}
|
||||||
|
|
||||||
long getId();
|
long getId();
|
||||||
|
|
||||||
public String getvsmName();
|
public String getvsmName();
|
||||||
|
|
||||||
public long getHostId();
|
public long getHostId();
|
||||||
|
|
||||||
public String getUserName();
|
public String getUserName();
|
||||||
|
|
||||||
public String getPassword();
|
public String getPassword();
|
||||||
|
|
||||||
public String getipaddr();
|
public String getipaddr();
|
||||||
|
|
||||||
public int getManagementVlan();
|
public int getManagementVlan();
|
||||||
|
|
||||||
public int getControlVlan();
|
public int getControlVlan();
|
||||||
|
|
||||||
public int getPacketVlan();
|
public int getPacketVlan();
|
||||||
|
|
||||||
public int getStorageVlan();
|
public int getStorageVlan();
|
||||||
|
|
||||||
public long getvsmDomainId();
|
public long getvsmDomainId();
|
||||||
|
|
||||||
public VSMConfigMode getvsmConfigMode();
|
public VSMConfigMode getvsmConfigMode();
|
||||||
|
|
||||||
public VSMConfigState getvsmConfigState();
|
public VSMConfigState getvsmConfigState();
|
||||||
|
|
||||||
public VSMDeviceState getvsmDeviceState();
|
public VSMDeviceState getvsmDeviceState();
|
||||||
|
|
||||||
public String getUuid();
|
public String getUuid();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -21,6 +21,8 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.agent.api.StartupCommand;
|
import com.cloud.agent.api.StartupCommand;
|
||||||
import com.cloud.api.ApiConstants;
|
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.ClusterDetailsDao;
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
import com.cloud.dc.ClusterVSMMapVO;
|
import com.cloud.dc.ClusterVSMMapVO;
|
||||||
@ -62,7 +64,8 @@ public abstract class CiscoNexusVSMDeviceManagerImpl extends AdapterBase {
|
|||||||
HostDetailsDao _hostDetailDao;
|
HostDetailsDao _hostDetailDao;
|
||||||
@Inject
|
@Inject
|
||||||
PortProfileDao _ppDao;
|
PortProfileDao _ppDao;
|
||||||
|
@Inject
|
||||||
|
ConfigurationDao _configDao;
|
||||||
|
|
||||||
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalLoadBalancerDeviceManagerImpl.class);
|
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
|
// TODO Auto-generated method stub
|
||||||
return null;
|
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.ExternalLoadBalancerUsageManagerImpl;
|
||||||
import com.cloud.network.NetworkManagerImpl;
|
import com.cloud.network.NetworkManagerImpl;
|
||||||
import com.cloud.network.StorageNetworkManagerImpl;
|
import com.cloud.network.StorageNetworkManagerImpl;
|
||||||
import com.cloud.network.dao.CiscoNexusVSMDeviceDaoImpl;
|
|
||||||
import com.cloud.network.dao.ExternalFirewallDeviceDaoImpl;
|
import com.cloud.network.dao.ExternalFirewallDeviceDaoImpl;
|
||||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceDaoImpl;
|
import com.cloud.network.dao.ExternalLoadBalancerDeviceDaoImpl;
|
||||||
import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
|
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.RemoteAccessVpnDaoImpl;
|
||||||
import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
|
import com.cloud.network.dao.VirtualRouterProviderDaoImpl;
|
||||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
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.VirtualRouterElement;
|
||||||
import com.cloud.network.element.VirtualRouterElementService;
|
import com.cloud.network.element.VirtualRouterElementService;
|
||||||
import com.cloud.network.firewall.FirewallManagerImpl;
|
import com.cloud.network.firewall.FirewallManagerImpl;
|
||||||
@ -316,7 +313,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||||||
addDao("ExternalFirewallDeviceDao", ExternalFirewallDeviceDaoImpl.class);
|
addDao("ExternalFirewallDeviceDao", ExternalFirewallDeviceDaoImpl.class);
|
||||||
addDao("NetworkExternalLoadBalancerDao", NetworkExternalLoadBalancerDaoImpl.class);
|
addDao("NetworkExternalLoadBalancerDao", NetworkExternalLoadBalancerDaoImpl.class);
|
||||||
addDao("NetworkExternalFirewallDao", NetworkExternalFirewallDaoImpl.class);
|
addDao("NetworkExternalFirewallDao", NetworkExternalFirewallDaoImpl.class);
|
||||||
addDao("CiscoNexusVSMDeviceDao", CiscoNexusVSMDeviceDaoImpl.class);
|
|
||||||
addDao("ClusterVSMMapDao", ClusterVSMMapDaoImpl.class);
|
addDao("ClusterVSMMapDao", ClusterVSMMapDaoImpl.class);
|
||||||
addDao("PortProfileDao", PortProfileDaoImpl.class);
|
addDao("PortProfileDao", PortProfileDaoImpl.class);
|
||||||
addDao("PhysicalNetworkTrafficTypeDao", PhysicalNetworkTrafficTypeDaoImpl.class);
|
addDao("PhysicalNetworkTrafficTypeDao", PhysicalNetworkTrafficTypeDaoImpl.class);
|
||||||
@ -412,7 +408,6 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com
|
|||||||
|
|
||||||
protected void populateServices() {
|
protected void populateServices() {
|
||||||
addService("VirtualRouterElementService", VirtualRouterElementService.class, VirtualRouterElement.class);
|
addService("VirtualRouterElementService", VirtualRouterElementService.class, VirtualRouterElement.class);
|
||||||
addService("CiscoNexusVSMElementService", CiscoNexusVSMElementService.class, CiscoNexusVSMElement.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import com.cloud.baremetal.PxeServerManager.PxeServerType;
|
|||||||
import com.cloud.baremetal.PxeServerManagerImpl;
|
import com.cloud.baremetal.PxeServerManagerImpl;
|
||||||
import com.cloud.baremetal.PxeServerService;
|
import com.cloud.baremetal.PxeServerService;
|
||||||
import com.cloud.ha.HighAvailabilityManagerExtImpl;
|
import com.cloud.ha.HighAvailabilityManagerExtImpl;
|
||||||
import com.cloud.hypervisor.vmware.VmwareManagerImpl;
|
|
||||||
import com.cloud.netapp.NetappManagerImpl;
|
import com.cloud.netapp.NetappManagerImpl;
|
||||||
import com.cloud.netapp.dao.LunDaoImpl;
|
import com.cloud.netapp.dao.LunDaoImpl;
|
||||||
import com.cloud.netapp.dao.PoolDaoImpl;
|
import com.cloud.netapp.dao.PoolDaoImpl;
|
||||||
@ -60,7 +59,6 @@ public class PremiumComponentLibrary extends DefaultComponentLibrary {
|
|||||||
addManager("secondary storage vm manager", PremiumSecondaryStorageManagerImpl.class);
|
addManager("secondary storage vm manager", PremiumSecondaryStorageManagerImpl.class);
|
||||||
|
|
||||||
addManager("HA Manager", HighAvailabilityManagerExtImpl.class);
|
addManager("HA Manager", HighAvailabilityManagerExtImpl.class);
|
||||||
addManager("VMWareManager", VmwareManagerImpl.class);
|
|
||||||
addManager("ExternalNetworkManager", ExternalNetworkDeviceManagerImpl.class);
|
addManager("ExternalNetworkManager", ExternalNetworkDeviceManagerImpl.class);
|
||||||
addManager("BareMetalVmManager", BareMetalVmManagerImpl.class);
|
addManager("BareMetalVmManager", BareMetalVmManagerImpl.class);
|
||||||
addManager("ExternalDhcpManager", ExternalDhcpManagerImpl.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;
|
||||||
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;
|
||||||
@ -173,10 +171,6 @@ 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;
|
||||||
@ -434,95 +428,6 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
clusterId = cluster.getId();
|
clusterId = cluster.getId();
|
||||||
result.add(cluster);
|
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) {
|
if (clusterType == Cluster.ClusterType.CloudManaged) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
// 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.resource;
|
package com.cloud.utils.ssh;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
Loading…
x
Reference in New Issue
Block a user