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,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; | ||||
| @ -188,6 +188,7 @@ import com.cloud.utils.exception.ExceptionUtil; | ||||
| import com.cloud.utils.mgmt.JmxUtil; | ||||
| import com.cloud.utils.mgmt.PropertyMapDynamicBean; | ||||
| import com.cloud.utils.net.NetUtils; | ||||
| import com.cloud.utils.ssh.SshHelper; | ||||
| import com.cloud.vm.DiskProfile; | ||||
| import com.cloud.vm.VirtualMachine; | ||||
| import com.cloud.vm.VirtualMachine.State; | ||||
| @ -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