diff --git a/build/build-cloud-plugins.xml b/build/build-cloud-plugins.xml
index 0ca33964895..53dc1d34d85 100755
--- a/build/build-cloud-plugins.xml
+++ b/build/build-cloud-plugins.xml
@@ -198,8 +198,8 @@
-
-
+
+
@@ -212,6 +212,11 @@
+
+
+
+
+
diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in
index 58541a59606..5add24cfd55 100755
--- a/client/tomcatconf/components.xml.in
+++ b/client/tomcatconf/components.xml.in
@@ -157,11 +157,14 @@
+
+
+
diff --git a/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java b/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
index 6f47b547182..868a81e4b82 100755
--- a/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
+++ b/core/src/com/cloud/hypervisor/hyperv/resource/HypervResource.java
@@ -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;
diff --git a/plugins/hypervisors/vmware/.classpath b/plugins/hypervisors/vmware/.classpath
new file mode 100755
index 00000000000..74eb425c5d7
--- /dev/null
+++ b/plugins/hypervisors/vmware/.classpath
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/hypervisors/vmware/.project b/plugins/hypervisors/vmware/.project
new file mode 100755
index 00000000000..f53a2a299a5
--- /dev/null
+++ b/plugins/hypervisors/vmware/.project
@@ -0,0 +1,23 @@
+
+
+ vmware
+
+
+
+
+
+ org.python.pydev.PyDevBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.python.pydev.pythonNature
+
+
diff --git a/plugins/hypervisors/vmware/build.xml b/plugins/hypervisors/vmware/build.xml
new file mode 100755
index 00000000000..f6bcd435ae4
--- /dev/null
+++ b/plugins/hypervisors/vmware/build.xml
@@ -0,0 +1,135 @@
+
+
+
+
+
+
+ Cloud Stack ant build file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java b/plugins/hypervisors/vmware/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
similarity index 100%
rename from server/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
rename to plugins/hypervisors/vmware/src/com/cloud/api/commands/DeleteCiscoNexusVSMCmd.java
diff --git a/server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java b/plugins/hypervisors/vmware/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
similarity index 100%
rename from server/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
rename to plugins/hypervisors/vmware/src/com/cloud/api/commands/DisableCiscoNexusVSMCmd.java
diff --git a/server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java b/plugins/hypervisors/vmware/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
similarity index 100%
rename from server/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
rename to plugins/hypervisors/vmware/src/com/cloud/api/commands/EnableCiscoNexusVSMCmd.java
diff --git a/server/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java b/plugins/hypervisors/vmware/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java
similarity index 100%
rename from server/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java
rename to plugins/hypervisors/vmware/src/com/cloud/api/commands/ListCiscoNexusVSMsCmd.java
diff --git a/api/src/com/cloud/api/response/CiscoNexusVSMResponse.java b/plugins/hypervisors/vmware/src/com/cloud/api/response/CiscoNexusVSMResponse.java
similarity index 100%
rename from api/src/com/cloud/api/response/CiscoNexusVSMResponse.java
rename to plugins/hypervisors/vmware/src/com/cloud/api/response/CiscoNexusVSMResponse.java
diff --git a/server/src/com/cloud/ha/VmwareFencer.java b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java
similarity index 100%
rename from server/src/com/cloud/ha/VmwareFencer.java
rename to plugins/hypervisors/vmware/src/com/cloud/ha/VmwareFencer.java
diff --git a/server/src/com/cloud/ha/VmwareInvestigator.java b/plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java
similarity index 100%
rename from server/src/com/cloud/ha/VmwareInvestigator.java
rename to plugins/hypervisors/vmware/src/com/cloud/ha/VmwareInvestigator.java
diff --git a/server/src/com/cloud/hypervisor/guru/VMwareGuru.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
similarity index 100%
rename from server/src/com/cloud/hypervisor/guru/VMwareGuru.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java
diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java
similarity index 100%
rename from server/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java
diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
similarity index 98%
rename from server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index 65a10688608..af53daded02 100755
--- a/server/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -10,8 +10,8 @@
// limitations under the License.
//
// Automatically generated by addcopyright.py at 04/03/2012
-package com.cloud.hypervisor.vmware;
-
+package com.cloud.hypervisor.vmware;
+
import java.net.URI;
import java.net.URLDecoder;
import java.util.HashMap;
@@ -64,42 +64,42 @@ import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.vmware.vim25.ClusterDasConfigInfo;
import com.vmware.vim25.ManagedObjectReference;
-
-@Local(value=Discoverer.class)
-public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
- private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
-
- @Inject ClusterDao _clusterDao;
- @Inject VmwareManager _vmwareMgr;
- @Inject AlertManager _alertMgr;
- @Inject VMTemplateDao _tmpltDao;
+
+@Local(value=Discoverer.class)
+public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
+ private static final Logger s_logger = Logger.getLogger(VmwareServerDiscoverer.class);
+
+ @Inject ClusterDao _clusterDao;
+ @Inject VmwareManager _vmwareMgr;
+ @Inject AlertManager _alertMgr;
+ @Inject VMTemplateDao _tmpltDao;
@Inject ClusterDetailsDao _clusterDetailsDao;
@Inject HostDao _hostDao;
@Inject
- DataCenterDao _dcDao;
+ DataCenterDao _dcDao;
@Inject ResourceManager _resourceMgr;
@Inject CiscoNexusVSMDeviceDao _nexusDao;
@Inject
NetworkManager _netmgr;
-
- @Override
- public Map extends ServerResource, Map> find(long dcId, Long podId, Long clusterId, URI url,
- String username, String password, List hostTags) throws DiscoveryException {
-
- if(s_logger.isInfoEnabled())
- s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
-
- if(podId == null) {
- if(s_logger.isInfoEnabled())
- s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
- return null;
- }
-
- ClusterVO cluster = _clusterDao.findById(clusterId);
- if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
- if(s_logger.isInfoEnabled())
- s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
- return null;
+
+ @Override
+ public Map extends ServerResource, Map> find(long dcId, Long podId, Long clusterId, URI url,
+ String username, String password, List hostTags) throws DiscoveryException {
+
+ if(s_logger.isInfoEnabled())
+ s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
+
+ if(podId == null) {
+ if(s_logger.isInfoEnabled())
+ s_logger.info("No pod is assigned, assuming that it is not for vmware and skip it to next discoverer");
+ return null;
+ }
+
+ ClusterVO cluster = _clusterDao.findById(clusterId);
+ if(cluster == null || cluster.getHypervisorType() != HypervisorType.VMware) {
+ if(s_logger.isInfoEnabled())
+ s_logger.info("invalid cluster id or cluster is not for VMware hypervisors");
+ return null;
}
List hosts = _resourceMgr.listAllHostsInCluster(clusterId);
@@ -135,9 +135,9 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
}
vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
}
-
- VmwareContext context = null;
- try {
+
+ VmwareContext context = null;
+ try {
context = VmwareContextFactory.create(url.getHost(), username, password);
if (privateTrafficLabel != null)
context.registerStockObject("privateTrafficLabel", privateTrafficLabel);
@@ -147,64 +147,64 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
s_logger.info("Stocking credentials of Nexus VSM");
context.registerStockObject("vsmcredentials", vsmCredentials);
}
- }
- List morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId,
+ }
+ List morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId,
URLDecoder.decode(url.getPath()));
if (morHosts == null)
s_logger.info("Found 0 hosts.");
if (privateTrafficLabel != null)
context.uregisterStockObject("privateTrafficLabel");
-
- if(morHosts == null) {
- s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
- return null;
- }
-
- ManagedObjectReference morCluster = null;
- Map clusterDetails = _clusterDetailsDao.findDetails(clusterId);
- if(clusterDetails.get("url") != null) {
- URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
- morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
-
- if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
- s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
- return null;
- } else {
- ClusterMO clusterMo = new ClusterMO(context, morCluster);
- ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
- if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
- clusterDetails.put("NativeHA", "true");
- _clusterDetailsDao.persist(clusterId, clusterDetails);
- }
- }
- }
-
- if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
- if(morCluster == null)
- s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
- else
- s_logger.warn("The discovered host does not belong to the cluster");
- return null;
- }
-
- Map> resources = new HashMap>();
- for(ManagedObjectReference morHost : morHosts) {
- Map details = new HashMap();
- Map params = new HashMap();
-
- HostMO hostMo = new HostMO(context, morHost);
- details.put("url", hostMo.getHostName());
- details.put("username", username);
- details.put("password", password);
- String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
- details.put("guid", guid);
-
- params.put("url", hostMo.getHostName());
- params.put("username", username);
- params.put("password", password);
- params.put("zone", Long.toString(dcId));
- params.put("pod", Long.toString(podId));
- params.put("cluster", Long.toString(clusterId));
+
+ if(morHosts == null) {
+ s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
+ return null;
+ }
+
+ ManagedObjectReference morCluster = null;
+ Map clusterDetails = _clusterDetailsDao.findDetails(clusterId);
+ if(clusterDetails.get("url") != null) {
+ URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
+ morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
+
+ if(morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
+ s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
+ return null;
+ } else {
+ ClusterMO clusterMo = new ClusterMO(context, morCluster);
+ ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
+ if(dasConfig != null && dasConfig.getEnabled() != null && dasConfig.getEnabled().booleanValue()) {
+ clusterDetails.put("NativeHA", "true");
+ _clusterDetailsDao.persist(clusterId, clusterDetails);
+ }
+ }
+ }
+
+ if(!validateDiscoveredHosts(context, morCluster, morHosts)) {
+ if(morCluster == null)
+ s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
+ else
+ s_logger.warn("The discovered host does not belong to the cluster");
+ return null;
+ }
+
+ Map> resources = new HashMap>();
+ for(ManagedObjectReference morHost : morHosts) {
+ Map details = new HashMap();
+ Map params = new HashMap();
+
+ HostMO hostMo = new HostMO(context, morHost);
+ details.put("url", hostMo.getHostName());
+ details.put("username", username);
+ details.put("password", password);
+ String guid = morHost.getType() + ":" + morHost.get_value() + "@"+ url.getHost();
+ details.put("guid", guid);
+
+ params.put("url", hostMo.getHostName());
+ params.put("username", username);
+ params.put("password", password);
+ params.put("zone", Long.toString(dcId));
+ params.put("pod", Long.toString(podId));
+ params.put("cluster", Long.toString(clusterId));
params.put("guid", guid);
if (privateTrafficLabel != null) {
params.put("private.network.vswitch.name", privateTrafficLabel);
@@ -214,113 +214,113 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
}
if (guestTrafficLabel != null) {
params.put("guest.network.vswitch.name", guestTrafficLabel);
- }
-
- VmwareResource resource = new VmwareResource();
- try {
- resource.configure("VMware", params);
- } catch (ConfigurationException e) {
- _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
- s_logger.warn("Unable to instantiate " + url.getHost(), e);
- }
- resource.start();
-
- resources.put(resource, details);
- }
-
- // place a place holder guid derived from cluster ID
- cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
- _clusterDao.update(clusterId, cluster);
-
- return resources;
+ }
+
+ VmwareResource resource = new VmwareResource();
+ try {
+ resource.configure("VMware", params);
+ } catch (ConfigurationException e) {
+ _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, "Unable to add " + url.getHost(), "Error is " + e.getMessage());
+ s_logger.warn("Unable to instantiate " + url.getHost(), e);
+ }
+ resource.start();
+
+ resources.put(resource, details);
+ }
+
+ // place a place holder guid derived from cluster ID
+ cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
+ _clusterDao.update(clusterId, cluster);
+
+ return resources;
} catch (DiscoveredWithErrorException e) {
throw e;
- } catch (Exception e) {
- s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
- return null;
- } finally {
- if(context != null)
- context.close();
- }
- }
-
- private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List morHosts) throws Exception {
- if(morCluster == null) {
- for(ManagedObjectReference morHost : morHosts) {
- ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
- if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
- return false;
- }
- } else {
- for(ManagedObjectReference morHost : morHosts) {
- ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
- if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
- return false;
-
- if(!morParent.get_value().equals(morCluster.get_value()))
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public void postDiscovery(List hosts, long msId) {
- // do nothing
- }
-
- @Override
- public boolean matchHypervisor(String hypervisor) {
- if(hypervisor == null)
- return true;
-
- return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
- }
-
- @Override
- public Hypervisor.HypervisorType getHypervisorType() {
- return Hypervisor.HypervisorType.VMware;
- }
-
- @Override
- public boolean configure(String name, Map params) throws ConfigurationException {
- if(s_logger.isInfoEnabled())
- s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
-
- super.configure(name, params);
-
- ComponentLocator locator = ComponentLocator.getCurrentLocator();
- ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
- if (configDao == null) {
- throw new ConfigurationException("Unable to get the configuration dao.");
- }
-
- createVmwareToolsIso();
-
- if(s_logger.isInfoEnabled()) {
+ } catch (Exception e) {
+ s_logger.warn("Unable to connect to Vmware vSphere server. service address: " + url.getHost());
+ return null;
+ } finally {
+ if(context != null)
+ context.close();
+ }
+ }
+
+ private boolean validateDiscoveredHosts(VmwareContext context, ManagedObjectReference morCluster, List morHosts) throws Exception {
+ if(morCluster == null) {
+ for(ManagedObjectReference morHost : morHosts) {
+ ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
+ if(morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
+ return false;
+ }
+ } else {
+ for(ManagedObjectReference morHost : morHosts) {
+ ManagedObjectReference morParent = (ManagedObjectReference)context.getServiceUtil().getDynamicProperty(morHost, "parent");
+ if(!morParent.getType().equalsIgnoreCase("ClusterComputeResource"))
+ return false;
+
+ if(!morParent.get_value().equals(morCluster.get_value()))
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public void postDiscovery(List hosts, long msId) {
+ // do nothing
+ }
+
+ @Override
+ public boolean matchHypervisor(String hypervisor) {
+ if(hypervisor == null)
+ return true;
+
+ return Hypervisor.HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor);
+ }
+
+ @Override
+ public Hypervisor.HypervisorType getHypervisorType() {
+ return Hypervisor.HypervisorType.VMware;
+ }
+
+ @Override
+ public boolean configure(String name, Map params) throws ConfigurationException {
+ if(s_logger.isInfoEnabled())
+ s_logger.info("Configure VmwareServerDiscoverer, discover name: " + name);
+
+ super.configure(name, params);
+
+ ComponentLocator locator = ComponentLocator.getCurrentLocator();
+ ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
+ if (configDao == null) {
+ throw new ConfigurationException("Unable to get the configuration dao.");
+ }
+
+ createVmwareToolsIso();
+
+ if(s_logger.isInfoEnabled()) {
s_logger.info("VmwareServerDiscoverer has been successfully configured");
}
- _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
- return true;
- }
-
- private void createVmwareToolsIso() {
- String isoName = "vmware-tools.iso";
- VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
- Long id;
- if (tmplt == null) {
- id = _tmpltDao.getNextInSequence(Long.class, "id");
- VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
- TemplateType.PERHOST, null, null, true, 64,
- Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
- _tmpltDao.persist(template);
- } else {
- id = tmplt.getId();
- tmplt.setTemplateType(TemplateType.PERHOST);
- tmplt.setUrl(null);
- _tmpltDao.update(id, tmplt);
- }
+ _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+ return true;
+ }
+
+ private void createVmwareToolsIso() {
+ String isoName = "vmware-tools.iso";
+ VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
+ Long id;
+ if (tmplt == null) {
+ id = _tmpltDao.getNextInSequence(Long.class, "id");
+ VMTemplateVO template = new VMTemplateVO(id, isoName, isoName, ImageFormat.ISO, true, true,
+ TemplateType.PERHOST, null, null, true, 64,
+ Account.ACCOUNT_ID_SYSTEM, null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
+ _tmpltDao.persist(template);
+ } else {
+ id = tmplt.getId();
+ tmplt.setTemplateType(TemplateType.PERHOST);
+ tmplt.setUrl(null);
+ _tmpltDao.update(id, tmplt);
+ }
}
@Override
@@ -359,6 +359,6 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
public boolean stop() {
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
return super.stop();
- }
-}
-
+ }
+}
+
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
similarity index 100%
rename from core/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareHostService.java
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
similarity index 100%
rename from core/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
diff --git a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
similarity index 99%
rename from server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 90a040b2eb1..debb6fe38b2 100755
--- a/server/src/com/cloud/hypervisor/vmware/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -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;
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
similarity index 100%
rename from core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManager.java
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
similarity index 99%
rename from core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index afd13d106b3..b525e13654a 100644
--- a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -123,11 +123,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
-
- if (templateMo == null) {
- if(s_logger.isInfoEnabled())
- s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
- ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
+
+ if (templateMo == null) {
+ if(s_logger.isInfoEnabled())
+ s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
+ ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
assert (morDs != null);
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
@@ -171,8 +171,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
VmwareContext context = hostService.getServiceContext(cmd);
VirtualMachineMO vmMo = null;
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
+ try {
+ VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
try {
@@ -202,7 +202,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
// attach volume to worker VM
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), volumePath);
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
- }
+ }
}
if (!vmMo.createSnapshot(snapshotUuid, "Snapshot taken for " + cmd.getSnapshotName(), false, false)) {
@@ -340,79 +340,79 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath,
secondaryStorageURL,
hostService.getWorkerName(context, cmd, 0));
- } else {
- StorageFilerTO poolTO = cmd.getPool();
-
- ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
- if (morDatastore == null) {
- morDatastore = hyperHost.mountDatastore(
- false,
- poolTO.getHost(), 0, poolTO.getPath(),
- poolTO.getUuid().replace("-", ""));
-
- if (morDatastore == null) {
- throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
- }
- }
-
- result = copyVolumeFromSecStorage(
- hyperHost, volumeId,
- new DatastoreMO(context, morDatastore),
- secondaryStorageURL, volumePath);
- }
- return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
+ } else {
+ StorageFilerTO poolTO = cmd.getPool();
- String msg = "Unable to execute CopyVolumeCommand due to exception";
- s_logger.error(msg, e);
- return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
- }
- }
-
- @Override
- public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
-
- String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
- Long accountId = cmd.getAccountId();
- Long volumeId = cmd.getVolumeId();
- String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
- String backedUpSnapshotUuid = cmd.getSnapshotUuid();
-
- String details = null;
- boolean success = false;
- String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
-
- VmwareContext context = hostService.getServiceContext(cmd);
- try {
- VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
-
- ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
- if (morPrimaryDs == null) {
- String msg = "Unable to find datastore: " + primaryStorageNameLabel;
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
- details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
- newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
- if (details == null) {
- success = true;
- }
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- hostService.invalidateServiceContext(context);
- }
-
- s_logger.error("Unexpecpted exception ", e);
- details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
- }
-
- return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
- }
+ ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
+ if (morDatastore == null) {
+ morDatastore = hyperHost.mountDatastore(
+ false,
+ poolTO.getHost(), 0, poolTO.getPath(),
+ poolTO.getUuid().replace("-", ""));
+
+ if (morDatastore == null) {
+ throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
+ }
+ }
+
+ result = copyVolumeFromSecStorage(
+ hyperHost, volumeId,
+ new DatastoreMO(context, morDatastore),
+ secondaryStorageURL, volumePath);
+ }
+ return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ hostService.invalidateServiceContext(context);
+ }
+
+ String msg = "Unable to execute CopyVolumeCommand due to exception";
+ s_logger.error(msg, e);
+ return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
+ }
+ }
+
+ @Override
+ public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
+
+ String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
+ Long accountId = cmd.getAccountId();
+ Long volumeId = cmd.getVolumeId();
+ String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
+ String backedUpSnapshotUuid = cmd.getSnapshotUuid();
+
+ String details = null;
+ boolean success = false;
+ String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
+
+ VmwareContext context = hostService.getServiceContext(cmd);
+ try {
+ VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
+
+ ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
+ if (morPrimaryDs == null) {
+ String msg = "Unable to find datastore: " + primaryStorageNameLabel;
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+
+ DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
+ details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
+ newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
+ if (details == null) {
+ success = true;
+ }
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ hostService.invalidateServiceContext(context);
+ }
+
+ s_logger.error("Unexpecpted exception ", e);
+ details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
+ }
+
+ return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
+ }
// templateName: name in secondary storage
// templateUuid: will be used at hypervisor layer
diff --git a/core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java
similarity index 100%
rename from core/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageMount.java
diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
similarity index 100%
rename from core/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
similarity index 99%
rename from core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
rename to plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index f4771b8fc2a..a8c61f6fad8 100755
--- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -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;
@@ -230,12 +231,12 @@ import com.vmware.vim25.VirtualMachineGuestOsIdentifier;
import com.vmware.vim25.VirtualMachinePowerState;
import com.vmware.vim25.VirtualMachineRuntimeInfo;
import com.vmware.vim25.VirtualSCSISharing;
-
-public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService {
- private static final Logger s_logger = Logger.getLogger(VmwareResource.class);
-
- protected String _name;
-
+
+public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService {
+ private static final Logger s_logger = Logger.getLogger(VmwareResource.class);
+
+ protected String _name;
+
protected final long _ops_timeout = 900000; // 15 minutes time out to time
protected final int _shutdown_waitMs = 300000; // wait up to 5 minutes for shutdown
@@ -789,23 +790,23 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
nicMasks &= ~(1 << publicNicInfo.first().intValue());
vmMo.setCustomFieldValue(CustomFieldConstants.CLOUD_NIC_MASK, String.valueOf(nicMasks));
- HostMO hostMo = vmMo.getRunningHost();
- List networks = vmMo.getNetworksWithDetails();
- for (NetworkDetails netDetails : networks) {
- if (netDetails.getGCTag() != null && netDetails.getGCTag().equalsIgnoreCase("true")) {
- if (netDetails.getVMMorsOnNetwork() == null || netDetails.getVMMorsOnNetwork().length == 1) {
- cleanupNetwork(hostMo, netDetails);
- }
- }
- }
- }
-
- if (s_logger.isInfoEnabled()) {
- s_logger.info("ipassoc command on domain router " + privateIpAddress + " completed");
- }
- }
-
- private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final String vifMacAddress) throws Exception {
+ HostMO hostMo = vmMo.getRunningHost();
+ List networks = vmMo.getNetworksWithDetails();
+ for (NetworkDetails netDetails : networks) {
+ if (netDetails.getGCTag() != null && netDetails.getGCTag().equalsIgnoreCase("true")) {
+ if (netDetails.getVMMorsOnNetwork() == null || netDetails.getVMMorsOnNetwork().length == 1) {
+ cleanupNetwork(hostMo, netDetails);
+ }
+ }
+ }
+ }
+
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("ipassoc command on domain router " + privateIpAddress + " completed");
+ }
+ }
+
+ private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final String vifMacAddress) throws Exception {
// TODO : probably need to set traffic shaping
Pair networkInfo = null;
@@ -1446,33 +1447,33 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (vol.getType() != Volume.Type.ISO) {
Pair volumeDsDetails = dataStoresDetails.get(vol.getPoolUuid());
assert (volumeDsDetails != null);
- VirtualDevice device;
- datastoreDiskPath = String.format("[%s] %s.vmdk", volumeDsDetails.second().getName(), vol.getPath());
- String chainInfo = vol.getChainInfo();
-
- if (chainInfo != null && !chainInfo.isEmpty()) {
- String[] diskChain = _gson.fromJson(chainInfo, String[].class);
- if (diskChain == null || diskChain.length < 1) {
- s_logger.warn("Empty previously-saved chain info, fall back to the original");
- device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, new String[] { datastoreDiskPath }, volumeDsDetails.first(), i, i + 1);
- } else {
- s_logger.info("Attach the disk with stored chain info: " + chainInfo);
- for (int j = 0; j < diskChain.length; j++) {
- diskChain[j] = String.format("[%s] %s", volumeDsDetails.second().getName(), diskChain[j]);
- }
-
- device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, diskChain, volumeDsDetails.first(), i, i + 1);
- }
- } else {
- device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, new String[] { datastoreDiskPath }, volumeDsDetails.first(), i, i + 1);
- }
- deviceConfigSpecArray[i].setDevice(device);
- deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
-
- if(s_logger.isDebugEnabled())
- s_logger.debug("Prepare volume at new device " + _gson.toJson(device));
-
- i++;
+ VirtualDevice device;
+ datastoreDiskPath = String.format("[%s] %s.vmdk", volumeDsDetails.second().getName(), vol.getPath());
+ String chainInfo = vol.getChainInfo();
+
+ if (chainInfo != null && !chainInfo.isEmpty()) {
+ String[] diskChain = _gson.fromJson(chainInfo, String[].class);
+ if (diskChain == null || diskChain.length < 1) {
+ s_logger.warn("Empty previously-saved chain info, fall back to the original");
+ device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, new String[] { datastoreDiskPath }, volumeDsDetails.first(), i, i + 1);
+ } else {
+ s_logger.info("Attach the disk with stored chain info: " + chainInfo);
+ for (int j = 0; j < diskChain.length; j++) {
+ diskChain[j] = String.format("[%s] %s", volumeDsDetails.second().getName(), diskChain[j]);
+ }
+
+ device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, diskChain, volumeDsDetails.first(), i, i + 1);
+ }
+ } else {
+ device = VmwareHelper.prepareDiskDevice(vmMo, controllerKey, new String[] { datastoreDiskPath }, volumeDsDetails.first(), i, i + 1);
+ }
+ deviceConfigSpecArray[i].setDevice(device);
+ deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
+
+ if(s_logger.isDebugEnabled())
+ s_logger.debug("Prepare volume at new device " + _gson.toJson(device));
+
+ i++;
}
}
@@ -1496,11 +1497,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
nic = VmwareHelper.prepareNicDevice(vmMo, networkInfo.first(), nicDeviceType, networkInfo.second(), nicTo.getMac(), i, i + 1, true, true);
}
- deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
- deviceConfigSpecArray[i].setDevice(nic);
- deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
-
- if(s_logger.isDebugEnabled())
+ deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
+ deviceConfigSpecArray[i].setDevice(nic);
+ deviceConfigSpecArray[i].setOperation(VirtualDeviceConfigSpecOperation.add);
+
+ if(s_logger.isDebugEnabled())
s_logger.debug("Prepare NIC at new device " + _gson.toJson(deviceConfigSpecArray[i]));
// this is really a hacking for DomR, upon DomR startup, we will reset all the NIC allocation after eth3
@@ -1672,29 +1673,29 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
poolMors.put(vol.getPoolUuid(), new Pair (morDataStore, new DatastoreMO(context, morDataStore)));
}
- }
- }
- return poolMors;
- }
-
- private String getVlanInfo(NicTO nicTo, String defaultVlan) {
- if (nicTo.getBroadcastType() == BroadcastDomainType.Native) {
- return defaultVlan;
- }
-
- if (nicTo.getBroadcastType() == BroadcastDomainType.Vlan) {
- if (nicTo.getBroadcastUri() != null) {
- return nicTo.getBroadcastUri().getHost();
- } else {
- s_logger.warn("BroadcastType is not claimed as VLAN, but without vlan info in broadcast URI. Use vlan info from labeling: " + defaultVlan);
- return defaultVlan;
- }
- }
-
- s_logger.warn("Unrecognized broadcast type in VmwareResource, type: " + nicTo.getBroadcastType().toString() + ". Use vlan info from labeling: " + defaultVlan);
- return defaultVlan;
- }
-
+ }
+ }
+ return poolMors;
+ }
+
+ private String getVlanInfo(NicTO nicTo, String defaultVlan) {
+ if (nicTo.getBroadcastType() == BroadcastDomainType.Native) {
+ return defaultVlan;
+ }
+
+ if (nicTo.getBroadcastType() == BroadcastDomainType.Vlan) {
+ if (nicTo.getBroadcastUri() != null) {
+ return nicTo.getBroadcastUri().getHost();
+ } else {
+ s_logger.warn("BroadcastType is not claimed as VLAN, but without vlan info in broadcast URI. Use vlan info from labeling: " + defaultVlan);
+ return defaultVlan;
+ }
+ }
+
+ s_logger.warn("Unrecognized broadcast type in VmwareResource, type: " + nicTo.getBroadcastType().toString() + ". Use vlan info from labeling: " + defaultVlan);
+ return defaultVlan;
+ }
+
private Pair prepareNetworkFromNicInfo(HostMO hostMo, NicTO nicTo) throws Exception {
Pair switchName = getTargetSwitch(nicTo);
@@ -2338,131 +2339,131 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (pool.getType() != StoragePoolType.NetworkFilesystem && pool.getType() != StoragePoolType.VMFS) {
throw new Exception("Unsupported storage pool type " + pool.getType());
- }
-
+ }
+
ManagedObjectReference morDatastore = null;
morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
if(morDatastore == null)
morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(),
- pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
-
- assert (morDatastore != null);
- DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
- long capacity = summary.getCapacity();
- long available = summary.getFreeSpace();
- Map tInfo = new HashMap();
- ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, available, tInfo);
- return answer;
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String msg = "ModifyStoragePoolCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(msg, e);
- return new Answer(cmd, false, msg);
- }
- }
-
- protected Answer execute(DeleteStoragePoolCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource DeleteStoragePoolCommand: " + _gson.toJson(cmd));
- }
-
- StorageFilerTO pool = cmd.getPool();
+ pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
+
+ assert (morDatastore != null);
+ DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
+ long capacity = summary.getCapacity();
+ long available = summary.getFreeSpace();
+ Map tInfo = new HashMap();
+ ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, available, tInfo);
+ return answer;
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String msg = "ModifyStoragePoolCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(msg, e);
+ return new Answer(cmd, false, msg);
+ }
+ }
+
+ protected Answer execute(DeleteStoragePoolCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource DeleteStoragePoolCommand: " + _gson.toJson(cmd));
+ }
+
+ StorageFilerTO pool = cmd.getPool();
try {
// We will leave datastore cleanup management to vCenter. Since for cluster VMFS datastore, it will always
// be mounted by vCenter.
-
- // VmwareHypervisorHost hyperHost = this.getHyperHost(getServiceContext());
- // hyperHost.unmountDatastore(pool.getUuid());
- Answer answer = new Answer(cmd, true, "success");
- return answer;
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String msg = "DeleteStoragePoolCommand (pool: " + pool.getHost() + ", path: " + pool.getPath() + ") failed due to " + VmwareHelper.getExceptionMessage(e);
- return new Answer(cmd, false, msg);
- }
- }
-
- protected Answer execute(AttachVolumeCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource AttachVolumeCommand: " + _gson.toJson(cmd));
- }
-
- /*
- * AttachVolumeCommand { "attach":true,"vmName":"i-2-1-KY","pooltype":"NetworkFilesystem",
- * "volumeFolder":"/export/home/kelven/vmware-test/primary", "volumePath":"uuid",
- * "volumeName":"volume name","deviceId":1 }
- */
- try {
- VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
- VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
- if (vmMo == null) {
- String msg = "Unable to find the VM to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
- if (morDs == null) {
- String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDs);
- String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), cmd.getVolumePath());
-
- AttachVolumeAnswer answer = new AttachVolumeAnswer(cmd, cmd.getDeviceId());
- if (cmd.getAttach()) {
- vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
- } else {
- vmMo.removeAllSnapshots();
- vmMo.detachDisk(datastoreVolumePath, false);
- }
-
- return answer;
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String msg = "AttachVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(msg, e);
- return new AttachVolumeAnswer(cmd, msg);
- }
- }
-
- protected Answer execute(AttachIsoCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource AttachIsoCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
- VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
- if (vmMo == null) {
- String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName();
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
- String storeUrl = cmd.getStoreUrl();
- if (storeUrl == null) {
- if (!cmd.getIsoPath().equalsIgnoreCase("vmware-tools.iso")) {
- String msg = "ISO store root url is not found in AttachIsoCommand";
- s_logger.error(msg);
- throw new Exception(msg);
- } else {
- if (cmd.isAttach()) {
- vmMo.mountToolsInstaller();
+
+ // VmwareHypervisorHost hyperHost = this.getHyperHost(getServiceContext());
+ // hyperHost.unmountDatastore(pool.getUuid());
+ Answer answer = new Answer(cmd, true, "success");
+ return answer;
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String msg = "DeleteStoragePoolCommand (pool: " + pool.getHost() + ", path: " + pool.getPath() + ") failed due to " + VmwareHelper.getExceptionMessage(e);
+ return new Answer(cmd, false, msg);
+ }
+ }
+
+ protected Answer execute(AttachVolumeCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource AttachVolumeCommand: " + _gson.toJson(cmd));
+ }
+
+ /*
+ * AttachVolumeCommand { "attach":true,"vmName":"i-2-1-KY","pooltype":"NetworkFilesystem",
+ * "volumeFolder":"/export/home/kelven/vmware-test/primary", "volumePath":"uuid",
+ * "volumeName":"volume name","deviceId":1 }
+ */
+ try {
+ VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+ VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
+ if (vmMo == null) {
+ String msg = "Unable to find the VM to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+
+ ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
+ if (morDs == null) {
+ String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+
+ DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDs);
+ String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), cmd.getVolumePath());
+
+ AttachVolumeAnswer answer = new AttachVolumeAnswer(cmd, cmd.getDeviceId());
+ if (cmd.getAttach()) {
+ vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
+ } else {
+ vmMo.removeAllSnapshots();
+ vmMo.detachDisk(datastoreVolumePath, false);
+ }
+
+ return answer;
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String msg = "AttachVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(msg, e);
+ return new AttachVolumeAnswer(cmd, msg);
+ }
+ }
+
+ protected Answer execute(AttachIsoCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource AttachIsoCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+ VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
+ if (vmMo == null) {
+ String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName();
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+
+ String storeUrl = cmd.getStoreUrl();
+ if (storeUrl == null) {
+ if (!cmd.getIsoPath().equalsIgnoreCase("vmware-tools.iso")) {
+ String msg = "ISO store root url is not found in AttachIsoCommand";
+ s_logger.error(msg);
+ throw new Exception(msg);
+ } else {
+ if (cmd.isAttach()) {
+ vmMo.mountToolsInstaller();
} else {
vmMo.unmountToolsInstaller();
}
@@ -2509,223 +2510,223 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
String msg = "AttachIsoCommand(detach) failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.warn(msg, e);
return new Answer(cmd, false, msg);
- }
- }
- }
-
- private synchronized ManagedObjectReference prepareSecondaryDatastoreOnHost(String storeUrl) throws Exception {
- String storeName = getSecondaryDatastoreUUID(storeUrl);
- URI uri = new URI(storeUrl);
-
- VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
- ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName.replace("-", ""));
-
+ }
+ }
+ }
+
+ private synchronized ManagedObjectReference prepareSecondaryDatastoreOnHost(String storeUrl) throws Exception {
+ String storeName = getSecondaryDatastoreUUID(storeUrl);
+ URI uri = new URI(storeUrl);
+
+ VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
+ ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName.replace("-", ""));
+
if (morDatastore == null)
- throw new Exception("Unable to mount secondary storage on host. storeUrl: " + storeUrl);
-
- return morDatastore;
- }
-
- private static String getSecondaryDatastoreUUID(String storeUrl) {
- return UUID.nameUUIDFromBytes(storeUrl.getBytes()).toString();
- }
-
- protected Answer execute(ValidateSnapshotCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource ValidateSnapshotCommand: " + _gson.toJson(cmd));
- }
-
- // the command is no longer available
- String expectedSnapshotBackupUuid = null;
- String actualSnapshotBackupUuid = null;
- String actualSnapshotUuid = null;
- return new ValidateSnapshotAnswer(cmd, false, "ValidateSnapshotCommand is not supported for vmware yet", expectedSnapshotBackupUuid, actualSnapshotBackupUuid, actualSnapshotUuid);
- }
-
- protected Answer execute(ManageSnapshotCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource ManageSnapshotCommand: " + _gson.toJson(cmd));
- }
-
- long snapshotId = cmd.getSnapshotId();
-
- /*
- * "ManageSnapshotCommand",
- * "{\"_commandSwitch\":\"-c\",\"_volumePath\":\"i-2-3-KY-ROOT\",\"_snapshotName\":\"i-2-3-KY_i-2-3-KY-ROOT_20101102203827\",\"_snapshotId\":1,\"_vmName\":\"i-2-3-KY\"}"
- */
- boolean success = false;
- String cmdSwitch = cmd.getCommandSwitch();
- String snapshotOp = "Unsupported snapshot command." + cmdSwitch;
- if (cmdSwitch.equals(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
- snapshotOp = "create";
- } else if (cmdSwitch.equals(ManageSnapshotCommand.DESTROY_SNAPSHOT)) {
- snapshotOp = "destroy";
- }
-
- String details = "ManageSnapshotCommand operation: " + snapshotOp + " Failed for snapshotId: " + snapshotId;
- String snapshotUUID = null;
+ throw new Exception("Unable to mount secondary storage on host. storeUrl: " + storeUrl);
+
+ return morDatastore;
+ }
+
+ private static String getSecondaryDatastoreUUID(String storeUrl) {
+ return UUID.nameUUIDFromBytes(storeUrl.getBytes()).toString();
+ }
+
+ protected Answer execute(ValidateSnapshotCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource ValidateSnapshotCommand: " + _gson.toJson(cmd));
+ }
+
+ // the command is no longer available
+ String expectedSnapshotBackupUuid = null;
+ String actualSnapshotBackupUuid = null;
+ String actualSnapshotUuid = null;
+ return new ValidateSnapshotAnswer(cmd, false, "ValidateSnapshotCommand is not supported for vmware yet", expectedSnapshotBackupUuid, actualSnapshotBackupUuid, actualSnapshotUuid);
+ }
+
+ protected Answer execute(ManageSnapshotCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource ManageSnapshotCommand: " + _gson.toJson(cmd));
+ }
+
+ long snapshotId = cmd.getSnapshotId();
+
+ /*
+ * "ManageSnapshotCommand",
+ * "{\"_commandSwitch\":\"-c\",\"_volumePath\":\"i-2-3-KY-ROOT\",\"_snapshotName\":\"i-2-3-KY_i-2-3-KY-ROOT_20101102203827\",\"_snapshotId\":1,\"_vmName\":\"i-2-3-KY\"}"
+ */
+ boolean success = false;
+ String cmdSwitch = cmd.getCommandSwitch();
+ String snapshotOp = "Unsupported snapshot command." + cmdSwitch;
+ if (cmdSwitch.equals(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
+ snapshotOp = "create";
+ } else if (cmdSwitch.equals(ManageSnapshotCommand.DESTROY_SNAPSHOT)) {
+ snapshotOp = "destroy";
+ }
+
+ String details = "ManageSnapshotCommand operation: " + snapshotOp + " Failed for snapshotId: " + snapshotId;
+ String snapshotUUID = null;
// snapshot operation (create or destroy) is handled inside BackupSnapshotCommand(), we just fake
// a success return here
snapshotUUID = UUID.randomUUID().toString();
success = true;
details = null;
-
- return new ManageSnapshotAnswer(cmd, snapshotId, snapshotUUID, success, details);
- }
-
- protected Answer execute(BackupSnapshotCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource BackupSnapshotCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareContext context = getServiceContext();
- VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
-
- return mgr.getStorageManager().execute(this, cmd);
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String details = "BackupSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(details, e);
- return new BackupSnapshotAnswer(cmd, false, details, null, true);
- }
- }
-
-
- protected Answer execute(CreateVolumeFromSnapshotCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource CreateVolumeFromSnapshotCommand: " + _gson.toJson(cmd));
- }
-
- String details = null;
- boolean success = false;
- String newVolumeName = UUID.randomUUID().toString();
-
- try {
- VmwareContext context = getServiceContext();
- VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- return mgr.getStorageManager().execute(this, cmd);
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- details = "CreateVolumeFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(details, e);
- }
-
- return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
- }
-
- protected Answer execute(CreatePrivateTemplateFromVolumeCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource CreatePrivateTemplateFromVolumeCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareContext context = getServiceContext();
- VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
-
- return mgr.getStorageManager().execute(this, cmd);
-
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String details = "CreatePrivateTemplateFromVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(details, e);
- return new CreatePrivateTemplateAnswer(cmd, false, details);
- }
- }
-
- protected Answer execute(final UpgradeSnapshotCommand cmd) {
- return new Answer(cmd, true, "success");
- }
-
- protected Answer execute(CreatePrivateTemplateFromSnapshotCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource CreatePrivateTemplateFromSnapshotCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- return mgr.getStorageManager().execute(this, cmd);
-
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String details = "CreatePrivateTemplateFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(details, e);
- return new CreatePrivateTemplateAnswer(cmd, false, details);
- }
- }
-
- protected Answer execute(GetStorageStatsCommand cmd) {
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Executing resource GetStorageStatsCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareContext context = getServiceContext();
- VmwareHypervisorHost hyperHost = getHyperHost(context);
- ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getStorageId());
-
- if (morDs != null) {
- DatastoreMO datastoreMo = new DatastoreMO(context, morDs);
- DatastoreSummary summary = datastoreMo.getSummary();
- assert (summary != null);
-
- long capacity = summary.getCapacity();
- long free = summary.getFreeSpace();
- long used = capacity - free;
-
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Datastore summary info, storageId: " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ", capacity: " + capacity
- + ", free: " + free + ", used: " + used);
- }
-
- if (summary.getCapacity() <= 0) {
- s_logger.warn("Something is wrong with vSphere NFS datastore, rebooting ESX(ESXi) host should help");
- }
-
- return new GetStorageStatsAnswer(cmd, capacity, used);
- } else {
- String msg = "Could not find datastore for GetStorageStatsCommand storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype();
-
- s_logger.error(msg);
- return new GetStorageStatsAnswer(cmd, msg);
- }
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String msg = "Unable to execute GetStorageStatsCommand(storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ") due to "
- + VmwareHelper.getExceptionMessage(e);
- s_logger.error(msg, e);
- return new GetStorageStatsAnswer(cmd, msg);
- }
- }
-
- protected Answer execute(GetVncPortCommand cmd) {
- if (s_logger.isTraceEnabled()) {
- s_logger.trace("Executing resource GetVncPortCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareContext context = getServiceContext();
+
+ return new ManageSnapshotAnswer(cmd, snapshotId, snapshotUUID, success, details);
+ }
+
+ protected Answer execute(BackupSnapshotCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource BackupSnapshotCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareContext context = getServiceContext();
+ VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+
+ return mgr.getStorageManager().execute(this, cmd);
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String details = "BackupSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(details, e);
+ return new BackupSnapshotAnswer(cmd, false, details, null, true);
+ }
+ }
+
+
+ protected Answer execute(CreateVolumeFromSnapshotCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource CreateVolumeFromSnapshotCommand: " + _gson.toJson(cmd));
+ }
+
+ String details = null;
+ boolean success = false;
+ String newVolumeName = UUID.randomUUID().toString();
+
+ try {
+ VmwareContext context = getServiceContext();
+ VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+ return mgr.getStorageManager().execute(this, cmd);
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ details = "CreateVolumeFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(details, e);
+ }
+
+ return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
+ }
+
+ protected Answer execute(CreatePrivateTemplateFromVolumeCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource CreatePrivateTemplateFromVolumeCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareContext context = getServiceContext();
+ VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+
+ return mgr.getStorageManager().execute(this, cmd);
+
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String details = "CreatePrivateTemplateFromVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(details, e);
+ return new CreatePrivateTemplateAnswer(cmd, false, details);
+ }
+ }
+
+ protected Answer execute(final UpgradeSnapshotCommand cmd) {
+ return new Answer(cmd, true, "success");
+ }
+
+ protected Answer execute(CreatePrivateTemplateFromSnapshotCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource CreatePrivateTemplateFromSnapshotCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+ return mgr.getStorageManager().execute(this, cmd);
+
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String details = "CreatePrivateTemplateFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(details, e);
+ return new CreatePrivateTemplateAnswer(cmd, false, details);
+ }
+ }
+
+ protected Answer execute(GetStorageStatsCommand cmd) {
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("Executing resource GetStorageStatsCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareContext context = getServiceContext();
+ VmwareHypervisorHost hyperHost = getHyperHost(context);
+ ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getStorageId());
+
+ if (morDs != null) {
+ DatastoreMO datastoreMo = new DatastoreMO(context, morDs);
+ DatastoreSummary summary = datastoreMo.getSummary();
+ assert (summary != null);
+
+ long capacity = summary.getCapacity();
+ long free = summary.getFreeSpace();
+ long used = capacity - free;
+
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Datastore summary info, storageId: " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ", capacity: " + capacity
+ + ", free: " + free + ", used: " + used);
+ }
+
+ if (summary.getCapacity() <= 0) {
+ s_logger.warn("Something is wrong with vSphere NFS datastore, rebooting ESX(ESXi) host should help");
+ }
+
+ return new GetStorageStatsAnswer(cmd, capacity, used);
+ } else {
+ String msg = "Could not find datastore for GetStorageStatsCommand storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype();
+
+ s_logger.error(msg);
+ return new GetStorageStatsAnswer(cmd, msg);
+ }
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String msg = "Unable to execute GetStorageStatsCommand(storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ") due to "
+ + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(msg, e);
+ return new GetStorageStatsAnswer(cmd, msg);
+ }
+ }
+
+ protected Answer execute(GetVncPortCommand cmd) {
+ if (s_logger.isTraceEnabled()) {
+ s_logger.trace("Executing resource GetVncPortCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context);
assert(hyperHost instanceof HostMO);
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
@@ -2794,74 +2795,74 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
}
protected Answer execute(ModifySshKeysCommand cmd) {
- //do not log the command contents for this command. do NOT log the ssh keys
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource ModifySshKeysCommand.");
- }
-
- return new Answer(cmd);
- }
-
- protected Answer execute(PoolEjectCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource PoolEjectCommand: " + _gson.toJson(cmd));
- }
-
- return new Answer(cmd, false, "PoolEjectCommand is not available for vmware");
- }
-
- @Override
- public PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource PrimaryStorageDownloadCommand: " + _gson.toJson(cmd));
- }
-
- try {
- VmwareContext context = getServiceContext();
- VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- return (PrimaryStorageDownloadAnswer) mgr.getStorageManager().execute(this, cmd);
- } catch (Throwable e) {
- if (e instanceof RemoteException) {
- s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
- invalidateServiceContext();
- }
-
- String msg = "PrimaryStorageDownloadCommand failed due to " + VmwareHelper.getExceptionMessage(e);
- s_logger.error(msg, e);
- return new PrimaryStorageDownloadAnswer(msg);
- }
- }
-
- @Override
- public Answer execute(DestroyCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource DestroyCommand: " + _gson.toJson(cmd));
- }
-
- /*
- * DestroyCommand content example
- *
- * {"volume": {"id":5,"name":"Volume1", "mountPoint":"/export/home/kelven/vmware-test/primary",
- * "path":"6bb8762f-c34c-453c-8e03-26cc246ceec4", "size":0,"type":"DATADISK","resourceType":
- * "STORAGE_POOL","storagePoolType":"NetworkFilesystem", "poolId":0,"deviceId":0 } }
- *
- * {"volume": {"id":1, "name":"i-2-1-KY-ROOT", "mountPoint":"/export/home/kelven/vmware-test/primary",
- * "path":"i-2-1-KY-ROOT","size":0,"type":"ROOT", "resourceType":"STORAGE_POOL", "storagePoolType":"NetworkFilesystem",
- * "poolId":0,"deviceId":0 } }
- */
-
- try {
- VmwareContext context = getServiceContext();
- VmwareHypervisorHost hyperHost = getHyperHost(context);
- VolumeTO vol = cmd.getVolume();
-
- ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, vol.getPoolUuid());
- if (morDs == null) {
- String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint();
- s_logger.error(msg);
- throw new Exception(msg);
- }
-
+ //do not log the command contents for this command. do NOT log the ssh keys
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource ModifySshKeysCommand.");
+ }
+
+ return new Answer(cmd);
+ }
+
+ protected Answer execute(PoolEjectCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource PoolEjectCommand: " + _gson.toJson(cmd));
+ }
+
+ return new Answer(cmd, false, "PoolEjectCommand is not available for vmware");
+ }
+
+ @Override
+ public PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource PrimaryStorageDownloadCommand: " + _gson.toJson(cmd));
+ }
+
+ try {
+ VmwareContext context = getServiceContext();
+ VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+ return (PrimaryStorageDownloadAnswer) mgr.getStorageManager().execute(this, cmd);
+ } catch (Throwable e) {
+ if (e instanceof RemoteException) {
+ s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
+ invalidateServiceContext();
+ }
+
+ String msg = "PrimaryStorageDownloadCommand failed due to " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(msg, e);
+ return new PrimaryStorageDownloadAnswer(msg);
+ }
+ }
+
+ @Override
+ public Answer execute(DestroyCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource DestroyCommand: " + _gson.toJson(cmd));
+ }
+
+ /*
+ * DestroyCommand content example
+ *
+ * {"volume": {"id":5,"name":"Volume1", "mountPoint":"/export/home/kelven/vmware-test/primary",
+ * "path":"6bb8762f-c34c-453c-8e03-26cc246ceec4", "size":0,"type":"DATADISK","resourceType":
+ * "STORAGE_POOL","storagePoolType":"NetworkFilesystem", "poolId":0,"deviceId":0 } }
+ *
+ * {"volume": {"id":1, "name":"i-2-1-KY-ROOT", "mountPoint":"/export/home/kelven/vmware-test/primary",
+ * "path":"i-2-1-KY-ROOT","size":0,"type":"ROOT", "resourceType":"STORAGE_POOL", "storagePoolType":"NetworkFilesystem",
+ * "poolId":0,"deviceId":0 } }
+ */
+
+ try {
+ VmwareContext context = getServiceContext();
+ VmwareHypervisorHost hyperHost = getHyperHost(context);
+ VolumeTO vol = cmd.getVolume();
+
+ ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, vol.getPoolUuid());
+ if (morDs == null) {
+ String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint();
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+
DatastoreMO dsMo = new DatastoreMO(context, morDs);
ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter();
@@ -3018,16 +3019,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VmwareHypervisorHost hyperHost = getHyperHost(context);
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
- ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
+ ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
if (morDatastore == null)
- throw new Exception("Unable to find datastore in vSphere");
-
- DatastoreMO dsMo = new DatastoreMO(context, morDatastore);
-
- if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) {
- if (cmd.getTemplateUrl() == null) {
- // create a root volume for blank VM
- String dummyVmName = getWorkerName(context, cmd, 0);
+ throw new Exception("Unable to find datastore in vSphere");
+
+ DatastoreMO dsMo = new DatastoreMO(context, morDatastore);
+
+ if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) {
+ if (cmd.getTemplateUrl() == null) {
+ // create a root volume for blank VM
+ String dummyVmName = getWorkerName(context, cmd, 0);
VirtualMachineMO vmMo = null;
try {
@@ -4027,23 +4028,23 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
_morHyperHost.setType(hostTokens[0]);
_morHyperHost.set_value(hostTokens[1]);
- VmwareContext context = getServiceContext();
- try {
- VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- mgr.setupResourceStartupParams(params);
-
- CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager());
+ VmwareContext context = getServiceContext();
+ try {
+ VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
+ mgr.setupResourceStartupParams(params);
+
+ CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager());
cfmMo.ensureCustomFieldDef("Datastore", CustomFieldConstants.CLOUD_UUID);
if (mgr.getNexusVSwitchGlobalParameter()) {
cfmMo.ensureCustomFieldDef("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP);
- } else {
+ } else {
cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC);
- }
+ }
cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_UUID);
cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_NIC_MASK);
-
- VmwareHypervisorHost hostMo = this.getHyperHost(context);
+
+ VmwareHypervisorHost hostMo = this.getHyperHost(context);
_hostName = hostMo.getHyperHostName();
Map vsmCredentials;
@@ -4057,17 +4058,17 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
_publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
_guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
}
-
- } catch (Exception e) {
- s_logger.error("Unexpected Exception ", e);
- }
-
+
+ } catch (Exception e) {
+ s_logger.error("Unexpected Exception ", e);
+ }
+
if(_privateNetworkVSwitchName == null) {
_privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name");
}
- if(_publicNetworkVSwitchName == null) {
+ if(_publicNetworkVSwitchName == null) {
_publicNetworkVSwitchName = (String) params.get("public.network.vswitch.name");
- }
+ }
if(_guestNetworkVSwitchName == null) {
_guestNetworkVSwitchName = (String) params.get("guest.network.vswitch.name");
}
@@ -4102,42 +4103,42 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if(value != null && value.equalsIgnoreCase("true"))
_nexusVSwitch = true;
- s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: "
- + _guestNetworkVSwitchName);
-
- return true;
- }
-
- @Override
- public String getName() {
- return _name;
- }
-
- @Override
- public boolean start() {
- return true;
- }
-
- @Override
- public boolean stop() {
- return true;
- }
-
- private VmwareContext getServiceContext() {
- return getServiceContext(null);
- }
-
- private void invalidateServiceContext() {
- invalidateServiceContext(null);
- }
-
- private VmwareHypervisorHost getHyperHost(VmwareContext context) {
- return getHyperHost(context, null);
- }
-
- @Override
- public synchronized VmwareContext getServiceContext(Command cmd) {
- if (_serviceContext == null) {
+ s_logger.info("VmwareResource network configuration info. private vSwitch: " + _privateNetworkVSwitchName + ", public vSwitch: " + _publicNetworkVSwitchName + ", guest network: "
+ + _guestNetworkVSwitchName);
+
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return _name;
+ }
+
+ @Override
+ public boolean start() {
+ return true;
+ }
+
+ @Override
+ public boolean stop() {
+ return true;
+ }
+
+ private VmwareContext getServiceContext() {
+ return getServiceContext(null);
+ }
+
+ private void invalidateServiceContext() {
+ invalidateServiceContext(null);
+ }
+
+ private VmwareHypervisorHost getHyperHost(VmwareContext context) {
+ return getHyperHost(context, null);
+ }
+
+ @Override
+ public synchronized VmwareContext getServiceContext(Command cmd) {
+ if (_serviceContext == null) {
try {
_serviceContext = VmwareContextFactory.create(_vCenterAddress, _username, _password);
VmwareHypervisorHost hyperHost = getHyperHost(_serviceContext, cmd);
@@ -4162,23 +4163,23 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if(bRefresh)
firewallMo.refreshFirewall();
}
- } catch (Exception e) {
- s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
- throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
- }
- }
- return _serviceContext;
- }
-
- @Override
- public synchronized void invalidateServiceContext(VmwareContext context) {
- if (_serviceContext != null) {
- _serviceContext.close();
- }
- _serviceContext = null;
- }
-
- @Override
+ } catch (Exception e) {
+ s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
+ throw new CloudRuntimeException("Unable to connect to vSphere server: " + _vCenterAddress);
+ }
+ }
+ return _serviceContext;
+ }
+
+ @Override
+ public synchronized void invalidateServiceContext(VmwareContext context) {
+ if (_serviceContext != null) {
+ _serviceContext.close();
+ }
+ _serviceContext = null;
+ }
+
+ @Override
public VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd) {
if (_morHyperHost.getType().equalsIgnoreCase("HostSystem")) {
return new HostMO(context, _morHyperHost);
diff --git a/api/src/com/cloud/network/CiscoNexusVSMDevice.java b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDevice.java
similarity index 97%
rename from api/src/com/cloud/network/CiscoNexusVSMDevice.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDevice.java
index db0db55fa7d..c58a6a77a77 100644
--- a/api/src/com/cloud/network/CiscoNexusVSMDevice.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDevice.java
@@ -14,59 +14,59 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
-package com.cloud.network;
-
-public interface CiscoNexusVSMDevice {
-
- // This tells us whether the VSM is currently enabled or disabled. We may
- // need this if we would like to carry out any sort of maintenance on the
- // VSM or CS.
- public enum VSMDeviceState {
- Enabled,
- Disabled
- }
-
- // This tells us whether the VSM is currently configured with a standby (HA)
- // or does not have any standby (Standalone).
- public enum VSMConfigMode {
- Standalone,
- HA
- }
-
- // This tells us whether the VSM is currently a primary or a standby VSM.
- public enum VSMConfigState {
- Primary,
- Standby
- }
-
- long getId();
-
- public String getvsmName();
-
- public long getHostId();
-
- public String getUserName();
-
- public String getPassword();
-
- public String getipaddr();
-
- public int getManagementVlan();
-
- public int getControlVlan();
-
- public int getPacketVlan();
-
- public int getStorageVlan();
-
- public long getvsmDomainId();
-
- public VSMConfigMode getvsmConfigMode();
-
- public VSMConfigState getvsmConfigState();
-
- public VSMDeviceState getvsmDeviceState();
-
- public String getUuid();
-
-}
+package com.cloud.network;
+
+public interface CiscoNexusVSMDevice {
+
+ // This tells us whether the VSM is currently enabled or disabled. We may
+ // need this if we would like to carry out any sort of maintenance on the
+ // VSM or CS.
+ public enum VSMDeviceState {
+ Enabled,
+ Disabled
+ }
+
+ // This tells us whether the VSM is currently configured with a standby (HA)
+ // or does not have any standby (Standalone).
+ public enum VSMConfigMode {
+ Standalone,
+ HA
+ }
+
+ // This tells us whether the VSM is currently a primary or a standby VSM.
+ public enum VSMConfigState {
+ Primary,
+ Standby
+ }
+
+ long getId();
+
+ public String getvsmName();
+
+ public long getHostId();
+
+ public String getUserName();
+
+ public String getPassword();
+
+ public String getipaddr();
+
+ public int getManagementVlan();
+
+ public int getControlVlan();
+
+ public int getPacketVlan();
+
+ public int getStorageVlan();
+
+ public long getvsmDomainId();
+
+ public VSMConfigMode getvsmConfigMode();
+
+ public VSMConfigState getvsmConfigState();
+
+ public VSMDeviceState getvsmDeviceState();
+
+ public String getUuid();
+
+}
diff --git a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
similarity index 72%
rename from server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
index e00564f1f10..69638587f7a 100644
--- a/server/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceManagerImpl.java
@@ -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 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;
+ }
}
diff --git a/server/src/com/cloud/network/CiscoNexusVSMDeviceVO.java b/plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceVO.java
similarity index 100%
rename from server/src/com/cloud/network/CiscoNexusVSMDeviceVO.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/CiscoNexusVSMDeviceVO.java
diff --git a/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java b/plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
similarity index 100%
rename from server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDao.java
diff --git a/server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java b/plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
similarity index 100%
rename from server/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/dao/CiscoNexusVSMDeviceDaoImpl.java
diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElement.java b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
similarity index 100%
rename from server/src/com/cloud/network/element/CiscoNexusVSMElement.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
diff --git a/server/src/com/cloud/network/element/CiscoNexusVSMElementService.java b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
similarity index 100%
rename from server/src/com/cloud/network/element/CiscoNexusVSMElementService.java
rename to plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElementService.java
diff --git a/core/src/com/cloud/storage/resource/PremiumSecondaryStorageResource.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/PremiumSecondaryStorageResource.java
similarity index 100%
rename from core/src/com/cloud/storage/resource/PremiumSecondaryStorageResource.java
rename to plugins/hypervisors/vmware/src/com/cloud/storage/resource/PremiumSecondaryStorageResource.java
diff --git a/core/src/com/cloud/storage/resource/VmwareSecondaryStorageContextFactory.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageContextFactory.java
similarity index 100%
rename from core/src/com/cloud/storage/resource/VmwareSecondaryStorageContextFactory.java
rename to plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageContextFactory.java
diff --git a/core/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java b/plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
similarity index 100%
rename from core/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
rename to plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareSecondaryStorageResourceHandler.java
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 3bfe84df25d..61b6861df89 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -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
diff --git a/server/src/com/cloud/configuration/PremiumComponentLibrary.java b/server/src/com/cloud/configuration/PremiumComponentLibrary.java
index fd240f6e92a..1a656eb05db 100755
--- a/server/src/com/cloud/configuration/PremiumComponentLibrary.java
+++ b/server/src/com/cloud/configuration/PremiumComponentLibrary.java
@@ -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);
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 423e6dfa707..73935f12a3b 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -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 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;
}
diff --git a/core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java b/utils/src/com/cloud/utils/ssh/SshHelper.java
similarity index 99%
rename from core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java
rename to utils/src/com/cloud/utils/ssh/SshHelper.java
index e85e9ca7a3a..f29b368cbe5 100755
--- a/core/src/com/cloud/hypervisor/vmware/resource/SshHelper.java
+++ b/utils/src/com/cloud/utils/ssh/SshHelper.java
@@ -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;