mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Get rid of compiler warnings and dead code in plugin-hypervisor-vmware
This commit is contained in:
parent
b20add810e
commit
532bf4b190
@ -27,13 +27,15 @@ import javax.persistence.Table;
|
|||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LegacyZoneVO contains id of CloudStack zone containing clusters from multiple VMware vCetners and/or VMware Datacenters.
|
* LegacyZoneVO contains id of CloudStack zone containing clusters from multiple VMware vCetners and/or VMware Datacenters.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "legacy_zones")
|
@Table(name = "legacy_zones")
|
||||||
public class LegacyZoneVO implements LegacyZone {
|
public class LegacyZoneVO implements LegacyZone {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3979866054555152793L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
@ -60,7 +62,7 @@ public class LegacyZoneVO implements LegacyZone {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof LegacyZoneVO) {
|
if (obj instanceof LegacyZoneVO) {
|
||||||
return ((LegacyZoneVO)obj).getId() == this.getId();
|
return ((LegacyZoneVO)obj).getId() == getId();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -70,7 +72,7 @@ public class LegacyZoneVO implements LegacyZone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LegacyZoneVO(long zoneId) {
|
public LegacyZoneVO(long zoneId) {
|
||||||
this.id = zoneId;
|
id = zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyZoneVO(long id, long zoneId) {
|
public LegacyZoneVO(long id, long zoneId) {
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package com.cloud.hypervisor.vmware;
|
package com.cloud.hypervisor.vmware;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -98,16 +97,6 @@ public class VmwareCleanupMaid {
|
|||||||
return _checkPoint;
|
return _checkPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized static void addLeftOverVM(VmwareCleanupMaid cleanupMaid) {
|
|
||||||
List<VmwareCleanupMaid> l = s_leftoverDummyVMs.get(cleanupMaid.getVCenterServer());
|
|
||||||
if (l == null) {
|
|
||||||
l = new ArrayList<VmwareCleanupMaid>();
|
|
||||||
s_leftoverDummyVMs.put(cleanupMaid.getVCenterServer(), l);
|
|
||||||
}
|
|
||||||
|
|
||||||
l.add(cleanupMaid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized static void gcLeftOverVMs(VmwareContext context) {
|
public synchronized static void gcLeftOverVMs(VmwareContext context) {
|
||||||
List<VmwareCleanupMaid> l = s_leftoverDummyVMs.get(context.getServerAddress());
|
List<VmwareCleanupMaid> l = s_leftoverDummyVMs.get(context.getServerAddress());
|
||||||
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||||
|
|||||||
@ -37,6 +37,8 @@ import com.cloud.utils.db.Encrypt;
|
|||||||
@Table(name = "vmware_data_center")
|
@Table(name = "vmware_data_center")
|
||||||
public class VmwareDatacenterVO implements VmwareDatacenter {
|
public class VmwareDatacenterVO implements VmwareDatacenter {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -9114941929893819232L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
@ -105,11 +107,11 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVmwareDatacenterName(String name) {
|
public void setVmwareDatacenterName(String name) {
|
||||||
this.vmwareDatacenterName = name;
|
vmwareDatacenterName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVcenterHost(String vCenterHost) {
|
public void setVcenterHost(String vCenterHost) {
|
||||||
this.vcenterHost = vCenterHost;
|
vcenterHost = vCenterHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUser(String user) {
|
public void setUser(String user) {
|
||||||
@ -134,17 +136,17 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof VmwareDatacenterVO) {
|
if (obj instanceof VmwareDatacenterVO) {
|
||||||
return ((VmwareDatacenterVO)obj).getId() == this.getId();
|
return ((VmwareDatacenterVO)obj).getId() == getId();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public VmwareDatacenterVO(String guid, String name, String vCenterHost, String user, String password) {
|
public VmwareDatacenterVO(String guid, String name, String vCenterHost, String user, String password) {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
this.vmwareDatacenterName = name;
|
vmwareDatacenterName = name;
|
||||||
this.guid = guid;
|
this.guid = guid;
|
||||||
this.vcenterHost = vCenterHost;
|
vcenterHost = vCenterHost;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
@ -155,7 +157,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VmwareDatacenterVO() {
|
public VmwareDatacenterVO() {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,8 @@ import javax.persistence.Table;
|
|||||||
@Table(name = "vmware_data_center_zone_map")
|
@Table(name = "vmware_data_center_zone_map")
|
||||||
public class VmwareDatacenterZoneMapVO implements VmwareDatacenterZoneMap {
|
public class VmwareDatacenterZoneMapVO implements VmwareDatacenterZoneMap {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -2155826205976479040L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
|
|||||||
@ -126,7 +126,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<? extends ServerResource, Map<String, String>>
|
public Map<? extends ServerResource, Map<String, String>>
|
||||||
find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
|
find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled())
|
if (s_logger.isInfoEnabled())
|
||||||
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
||||||
@ -158,7 +158,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
if (usernameNotProvided || passwordNotProvided) {
|
if (usernameNotProvided || passwordNotProvided) {
|
||||||
// Retrieve credentials associated with VMware DC
|
// Retrieve credentials associated with VMware DC
|
||||||
s_logger.info("Username and/or Password not provided while adding cluster to cloudstack zone. "
|
s_logger.info("Username and/or Password not provided while adding cluster to cloudstack zone. "
|
||||||
+ "Hence using both username & password provided while adding VMware DC to CloudStack zone.");
|
+ "Hence using both username & password provided while adding VMware DC to CloudStack zone.");
|
||||||
username = vmwareDc.getUser();
|
username = vmwareDc.getUser();
|
||||||
password = vmwareDc.getPassword();
|
password = vmwareDc.getPassword();
|
||||||
clusterDetails.put("username", username);
|
clusterDetails.put("username", username);
|
||||||
@ -252,7 +252,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
|
|
||||||
// Process traffic label information provided at zone level and cluster level
|
// Process traffic label information provided at zone level and cluster level
|
||||||
publicTrafficLabelObj =
|
publicTrafficLabelObj =
|
||||||
getTrafficInfo(TrafficType.Public, publicTrafficLabel, defaultVirtualSwitchType, paramPublicVswitchType, paramPublicVswitchName, clusterId);
|
getTrafficInfo(TrafficType.Public, publicTrafficLabel, defaultVirtualSwitchType, paramPublicVswitchType, paramPublicVswitchName, clusterId);
|
||||||
|
|
||||||
// Configuration Check: A physical network cannot be shared by different types of virtual switches.
|
// Configuration Check: A physical network cannot be shared by different types of virtual switches.
|
||||||
//
|
//
|
||||||
@ -272,7 +272,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
if (pNetworkListGuestTraffic.contains(pNetworkPublic)) {
|
if (pNetworkListGuestTraffic.contains(pNetworkPublic)) {
|
||||||
if (publicTrafficLabelObj.getVirtualSwitchType() != guestTrafficLabelObj.getVirtualSwitchType()) {
|
if (publicTrafficLabelObj.getVirtualSwitchType() != guestTrafficLabelObj.getVirtualSwitchType()) {
|
||||||
String msg =
|
String msg =
|
||||||
"Both public traffic and guest traffic is over same physical network " + pNetworkPublic +
|
"Both public traffic and guest traffic is over same physical network " + pNetworkPublic +
|
||||||
". And virtual switch type chosen for each traffic is different" +
|
". And virtual switch type chosen for each traffic is different" +
|
||||||
". A physical network cannot be shared by different types of virtual switches.";
|
". A physical network cannot be shared by different types of virtual switches.";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
@ -295,7 +295,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
}
|
}
|
||||||
Pair<Boolean, Long> vsmInfo = new Pair<Boolean, Long>(false, 0L);
|
Pair<Boolean, Long> vsmInfo = new Pair<Boolean, Long>(false, 0L);
|
||||||
if (nexusDVS && (guestTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch) ||
|
if (nexusDVS && (guestTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch) ||
|
||||||
((zoneType == NetworkType.Advanced) && (publicTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch))) {
|
((zoneType == NetworkType.Advanced) && (publicTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch))) {
|
||||||
// Expect Cisco Nexus VSM details only if following 2 condition met
|
// Expect Cisco Nexus VSM details only if following 2 condition met
|
||||||
// 1) The global config parameter vmware.use.nexus.vswitch
|
// 1) The global config parameter vmware.use.nexus.vswitch
|
||||||
// 2) Atleast 1 traffic type uses Nexus distributed virtual switch as backend.
|
// 2) Atleast 1 traffic type uses Nexus distributed virtual switch as backend.
|
||||||
@ -335,14 +335,14 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
context.registerStockObject("vsmcredentials", vsmCredentials);
|
context.registerStockObject("vsmcredentials", vsmCredentials);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId, URLDecoder.decode(url.getPath()));
|
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId, URLDecoder.decode(url.getPath(), "UTF-8"));
|
||||||
if (morHosts == null)
|
if (morHosts == null)
|
||||||
s_logger.info("Found 0 hosts.");
|
s_logger.info("Found 0 hosts.");
|
||||||
if (privateTrafficLabel != null)
|
if (privateTrafficLabel != null)
|
||||||
context.uregisterStockObject("privateTrafficLabel");
|
context.uregisterStockObject("privateTrafficLabel");
|
||||||
|
|
||||||
if (morHosts == null) {
|
if (morHosts == null) {
|
||||||
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
|
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath(), "UTF-8"));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
clusterDetails = _clusterDetailsDao.findDetails(clusterId);
|
||||||
if (clusterDetails.get("url") != null) {
|
if (clusterDetails.get("url") != null) {
|
||||||
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
|
||||||
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
|
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath(), "UTF-8"));
|
||||||
|
|
||||||
if (morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
if (morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
||||||
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
|
||||||
@ -491,13 +491,13 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
|
|
||||||
if (!vCenterHost.equalsIgnoreCase(url.getHost())) {
|
if (!vCenterHost.equalsIgnoreCase(url.getHost())) {
|
||||||
msg =
|
msg =
|
||||||
"This cluster " + clusterName + " belongs to vCenter " + url.getHost() + ". But this zone is associated with VMware DC from vCenter " + vCenterHost +
|
"This cluster " + clusterName + " belongs to vCenter " + url.getHost() + ". But this zone is associated with VMware DC from vCenter " + vCenterHost +
|
||||||
". Make sure the cluster being added belongs to vCenter " + vCenterHost + " and VMware DC " + vmwareDcNameFromDb;
|
". Make sure the cluster being added belongs to vCenter " + vCenterHost + " and VMware DC " + vmwareDcNameFromDb;
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new DiscoveryException(msg);
|
throw new DiscoveryException(msg);
|
||||||
} else if (!vmwareDcNameFromDb.equalsIgnoreCase(vmwareDcNameFromApi)) {
|
} else if (!vmwareDcNameFromDb.equalsIgnoreCase(vmwareDcNameFromApi)) {
|
||||||
msg =
|
msg =
|
||||||
"This cluster " + clusterName + " belongs to VMware DC " + vmwareDcNameFromApi + " .But this zone is associated with VMware DC " + vmwareDcNameFromDb +
|
"This cluster " + clusterName + " belongs to VMware DC " + vmwareDcNameFromApi + " .But this zone is associated with VMware DC " + vmwareDcNameFromDb +
|
||||||
". Make sure the cluster being added belongs to VMware DC " + vmwareDcNameFromDb + " in vCenter " + vCenterHost;
|
". Make sure the cluster being added belongs to VMware DC " + vmwareDcNameFromDb + " in vCenter " + vCenterHost;
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new DiscoveryException(msg);
|
throw new DiscoveryException(msg);
|
||||||
@ -567,8 +567,8 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
if (tmplt == null) {
|
if (tmplt == null) {
|
||||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||||
VMTemplateVO template =
|
VMTemplateVO template =
|
||||||
VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
|
VMTemplateVO.createPreHostIso(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);
|
null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
|
||||||
_tmpltDao.persist(template);
|
_tmpltDao.persist(template);
|
||||||
} else {
|
} else {
|
||||||
id = tmplt.getId();
|
id = tmplt.getId();
|
||||||
@ -627,7 +627,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, VirtualSwitchType defaultVirtualSwitchType, String vSwitchType,
|
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, VirtualSwitchType defaultVirtualSwitchType, String vSwitchType,
|
||||||
String vSwitchName, Long clusterId) {
|
String vSwitchName, Long clusterId) {
|
||||||
VmwareTrafficLabel trafficLabelObj = null;
|
VmwareTrafficLabel trafficLabelObj = null;
|
||||||
Map<String, String> clusterDetails = null;
|
Map<String, String> clusterDetails = null;
|
||||||
try {
|
try {
|
||||||
@ -664,7 +664,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, Map<String, String> clusterDetails,
|
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, Map<String, String> clusterDetails,
|
||||||
VirtualSwitchType defVirtualSwitchType) {
|
VirtualSwitchType defVirtualSwitchType) {
|
||||||
VmwareTrafficLabel trafficLabelObj = null;
|
VmwareTrafficLabel trafficLabelObj = null;
|
||||||
try {
|
try {
|
||||||
trafficLabelObj = new VmwareTrafficLabel(zoneWideTrafficLabel, trafficType, defVirtualSwitchType);
|
trafficLabelObj = new VmwareTrafficLabel(zoneWideTrafficLabel, trafficType, defVirtualSwitchType);
|
||||||
|
|||||||
@ -40,7 +40,6 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.vmware.vim25.AboutInfo;
|
import com.vmware.vim25.AboutInfo;
|
||||||
import com.vmware.vim25.HostConnectSpec;
|
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
|
import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
|
||||||
@ -94,11 +93,9 @@ import com.cloud.hypervisor.vmware.mo.DiskControllerType;
|
|||||||
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
|
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HostMO;
|
import com.cloud.hypervisor.vmware.mo.HostMO;
|
||||||
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
|
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.VirtualEthernetCardType;
|
||||||
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
||||||
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareClient;
|
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||||
@ -400,7 +397,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId, String hostInventoryPath)
|
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId, String hostInventoryPath)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
ManagedObjectReference mor = null;
|
ManagedObjectReference mor = null;
|
||||||
if (serviceContext != null) {
|
if (serviceContext != null) {
|
||||||
mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
||||||
@ -415,7 +412,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
|
List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
|
||||||
|
|
||||||
if (mor.getType().equals("ComputeResource")) {
|
if (mor.getType().equals("ComputeResource")) {
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)serviceContext.getVimClient().getDynamicProperty(mor, "host");
|
List<ManagedObjectReference> hosts = serviceContext.getVimClient().getDynamicProperty(mor, "host");
|
||||||
assert (hosts != null && hosts.size() > 0);
|
assert (hosts != null && hosts.size() > 0);
|
||||||
|
|
||||||
// For ESX host, we need to enable host firewall to allow VNC access
|
// For ESX host, we need to enable host firewall to allow VNC access
|
||||||
@ -425,7 +422,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
returnedHostList.add(hosts.get(0));
|
returnedHostList.add(hosts.get(0));
|
||||||
return returnedHostList;
|
return returnedHostList;
|
||||||
} else if (mor.getType().equals("ClusterComputeResource")) {
|
} else if (mor.getType().equals("ClusterComputeResource")) {
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)serviceContext.getVimClient().getDynamicProperty(mor, "host");
|
List<ManagedObjectReference> hosts = serviceContext.getVimClient().getDynamicProperty(mor, "host");
|
||||||
assert (hosts != null);
|
assert (hosts != null);
|
||||||
|
|
||||||
if (hosts.size() > 0) {
|
if (hosts.size() > 0) {
|
||||||
@ -462,45 +459,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private ManagedObjectReference
|
|
||||||
addHostToVCenterCluster(VmwareContext serviceContext, ManagedObjectReference morCluster, String host, String userName, String password) throws Exception {
|
|
||||||
|
|
||||||
VmwareClient vclient = serviceContext.getVimClient();
|
|
||||||
ManagedObjectReference morHost = vclient.getDecendentMoRef(morCluster, "HostSystem", host);
|
|
||||||
if (morHost == null) {
|
|
||||||
HostConnectSpec hostSpec = new HostConnectSpec();
|
|
||||||
hostSpec.setUserName(userName);
|
|
||||||
hostSpec.setPassword(password);
|
|
||||||
hostSpec.setHostName(host);
|
|
||||||
hostSpec.setForce(true); // forcely take over the host
|
|
||||||
|
|
||||||
ManagedObjectReference morTask = serviceContext.getService().addHostTask(morCluster, hostSpec, true, null, null);
|
|
||||||
boolean taskResult = vclient.waitForTask(morTask);
|
|
||||||
if (!taskResult) {
|
|
||||||
s_logger.error("Unable to add host " + host + " to vSphere cluster due to " + TaskMO.getTaskFailureInfo(serviceContext, morTask));
|
|
||||||
throw new CloudRuntimeException("Unable to add host " + host + " to vSphere cluster due to " + taskResult);
|
|
||||||
}
|
|
||||||
serviceContext.waitForTaskProgressDone(morTask);
|
|
||||||
|
|
||||||
// init morHost after it has been created
|
|
||||||
morHost = vclient.getDecendentMoRef(morCluster, "HostSystem", host);
|
|
||||||
if (morHost == null) {
|
|
||||||
throw new CloudRuntimeException(
|
|
||||||
"Successfully added host into vSphere but unable to find it later on?!. Please make sure you are either using IP address or full qualified domain name for host");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// For ESX host, we need to enable host firewall to allow VNC access
|
|
||||||
HostMO hostMo = new HostMO(serviceContext, morHost);
|
|
||||||
HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
|
|
||||||
if (firewallMo != null) {
|
|
||||||
firewallMo.enableRuleset("vncServer");
|
|
||||||
firewallMo.refreshFirewall();
|
|
||||||
}
|
|
||||||
return morHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSecondaryStorageStoreUrl(long dcId) {
|
public String getSecondaryStorageStoreUrl(long dcId) {
|
||||||
|
|
||||||
@ -579,7 +537,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
long startTick = Long.parseLong(tokens[0]);
|
Long.parseLong(tokens[0]);
|
||||||
long msid = Long.parseLong(tokens[1]);
|
long msid = Long.parseLong(tokens[1]);
|
||||||
long runid = Long.parseLong(tokens[2]);
|
long runid = Long.parseLong(tokens[2]);
|
||||||
|
|
||||||
@ -603,7 +561,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000);
|
s_logger.info("Worker VM expired, seconds elapsed: " + (System.currentTimeMillis() - startTick) / 1000);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +589,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
_configServer.updateKeyPairs();
|
_configServer.updateKeyPairs();
|
||||||
|
|
||||||
s_logger.info("Copy System VM patch ISO file to secondary storage. source ISO: " + srcIso.getAbsolutePath() + ", destination: " +
|
s_logger.info("Copy System VM patch ISO file to secondary storage. source ISO: " + srcIso.getAbsolutePath() + ", destination: " +
|
||||||
destIso.getAbsolutePath());
|
destIso.getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
FileUtil.copyfile(srcIso, destIso);
|
FileUtil.copyfile(srcIso, destIso);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -1040,7 +998,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
|
|
||||||
if (vCenterHost == null) {
|
if (vCenterHost == null) {
|
||||||
throw new InvalidParameterValueException("Missing or invalid parameter name. "
|
throw new InvalidParameterValueException("Missing or invalid parameter name. "
|
||||||
+ "Please provide valid VMware vCenter server's IP address or fully qualified domain name.");
|
+ "Please provide valid VMware vCenter server's IP address or fully qualified domain name.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zoneId == null) {
|
if (zoneId == null) {
|
||||||
@ -1060,11 +1018,11 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
VmwareDatacenterVO associatedVmwareDc = _vmwareDcDao.findById(associatedVmwareDcId);
|
VmwareDatacenterVO associatedVmwareDc = _vmwareDcDao.findById(associatedVmwareDcId);
|
||||||
if (associatedVmwareDc.getVcenterHost().equalsIgnoreCase(vCenterHost) && associatedVmwareDc.getVmwareDatacenterName().equalsIgnoreCase(vmwareDcName)) {
|
if (associatedVmwareDc.getVcenterHost().equalsIgnoreCase(vCenterHost) && associatedVmwareDc.getVmwareDatacenterName().equalsIgnoreCase(vmwareDcName)) {
|
||||||
s_logger.info("Ignoring API call addVmwareDc, because VMware DC " + vCenterHost + "/" + vmwareDcName +
|
s_logger.info("Ignoring API call addVmwareDc, because VMware DC " + vCenterHost + "/" + vmwareDcName +
|
||||||
" is already associated with specified zone with id " + zoneId);
|
" is already associated with specified zone with id " + zoneId);
|
||||||
return associatedVmwareDc;
|
return associatedVmwareDc;
|
||||||
} else {
|
} else {
|
||||||
throw new CloudRuntimeException("Zone " + zoneId + " is already associated with a VMware datacenter. " +
|
throw new CloudRuntimeException("Zone " + zoneId + " is already associated with a VMware datacenter. " +
|
||||||
"Only 1 VMware DC can be associated with a zone.");
|
"Only 1 VMware DC can be associated with a zone.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Zone validation to check if the zone already has resources.
|
// Zone validation to check if the zone already has resources.
|
||||||
@ -1158,8 +1116,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||||||
String userName;
|
String userName;
|
||||||
String password;
|
String password;
|
||||||
DatacenterMO dcMo = null;
|
DatacenterMO dcMo = null;
|
||||||
Transaction txn;
|
|
||||||
|
|
||||||
final VmwareDatacenterZoneMapVO vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
|
final VmwareDatacenterZoneMapVO vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
|
||||||
// Check if zone is associated with VMware DC
|
// Check if zone is associated with VMware DC
|
||||||
if (vmwareDcZoneMap == null) {
|
if (vmwareDcZoneMap == null) {
|
||||||
|
|||||||
@ -198,9 +198,6 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
String installPath = volume.getPath();
|
String installPath = volume.getPath();
|
||||||
int index = installPath.lastIndexOf(File.separator);
|
int index = installPath.lastIndexOf(File.separator);
|
||||||
String volumeUuid = installPath.substring(index + 1);
|
String volumeUuid = installPath.substring(index + 1);
|
||||||
String details = null;
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||||
//The real volume path
|
//The real volume path
|
||||||
String volumePath = installPath + File.separator + volumeUuid + ".ova";
|
String volumePath = installPath + File.separator + volumeUuid + ".ova";
|
||||||
@ -351,8 +348,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
snapshotBackupUuid =
|
snapshotBackupUuid =
|
||||||
backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
|
backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
|
||||||
hostService.getWorkerName(context, cmd, 1));
|
hostService.getWorkerName(context, cmd, 1));
|
||||||
|
|
||||||
success = (snapshotBackupUuid != null);
|
success = (snapshotBackupUuid != null);
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -407,7 +404,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
if (vmMo == null) {
|
if (vmMo == null) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Unable to find the owner VM for CreatePrivateTemplateFromVolumeCommand on host " + hyperHost.getHyperHostName() +
|
s_logger.debug("Unable to find the owner VM for CreatePrivateTemplateFromVolumeCommand on host " + hyperHost.getHyperHostName() +
|
||||||
", try within datacenter");
|
", try within datacenter");
|
||||||
}
|
}
|
||||||
vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getVmName());
|
vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getVmName());
|
||||||
|
|
||||||
@ -419,8 +416,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ternary<String, Long, Long> result =
|
Ternary<String, Long, Long> result =
|
||||||
createTemplateFromVolume(vmMo, accountId, templateId, cmd.getUniqueName(), secondaryStoragePoolURL, volumePath,
|
createTemplateFromVolume(vmMo, accountId, templateId, cmd.getUniqueName(), secondaryStoragePoolURL, volumePath,
|
||||||
hostService.getWorkerName(context, cmd, 0));
|
hostService.getWorkerName(context, cmd, 0));
|
||||||
|
|
||||||
return new CreatePrivateTemplateAnswer(cmd, true, null, result.first(), result.third(), result.second(), cmd.getUniqueName(), ImageFormat.OVA);
|
return new CreatePrivateTemplateAnswer(cmd, true, null, result.first(), result.third(), result.second(), cmd.getUniqueName(), ImageFormat.OVA);
|
||||||
|
|
||||||
@ -477,8 +474,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
Pair<String, String> result;
|
Pair<String, String> result;
|
||||||
if (cmd.toSecondaryStorage()) {
|
if (cmd.toSecondaryStorage()) {
|
||||||
result =
|
result =
|
||||||
copyVolumeToSecStorage(hostService, hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath, secondaryStorageURL,
|
copyVolumeToSecStorage(hostService, hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath, secondaryStorageURL,
|
||||||
hostService.getWorkerName(context, cmd, 0));
|
hostService.getWorkerName(context, cmd, 0));
|
||||||
} else {
|
} else {
|
||||||
StorageFilerTO poolTO = cmd.getPool();
|
StorageFilerTO poolTO = cmd.getPool();
|
||||||
|
|
||||||
@ -549,10 +546,10 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
// templateName: name in secondary storage
|
// templateName: name in secondary storage
|
||||||
// templateUuid: will be used at hypervisor layer
|
// templateUuid: will be used at hypervisor layer
|
||||||
private void copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
|
private void copyTemplateFromSecondaryToPrimary(VmwareHypervisorHost hyperHost, DatastoreMO datastoreMo, String secondaryStorageUrl,
|
||||||
String templatePathAtSecondaryStorage, String templateName, String templateUuid) throws Exception {
|
String templatePathAtSecondaryStorage, String templateName, String templateUuid) throws Exception {
|
||||||
|
|
||||||
s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " +
|
s_logger.info("Executing copyTemplateFromSecondaryToPrimary. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " +
|
||||||
templatePathAtSecondaryStorage + ", templateName: " + templateName);
|
templatePathAtSecondaryStorage + ", templateName: " + templateName);
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secondaryStorageUrl);
|
String secondaryMountPoint = _mountService.getMountPoint(secondaryStorageUrl);
|
||||||
s_logger.info("Secondary storage mount point: " + secondaryMountPoint);
|
s_logger.info("Secondary storage mount point: " + secondaryMountPoint);
|
||||||
@ -587,7 +584,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
||||||
if (vmMo == null) {
|
if (vmMo == null) {
|
||||||
String msg =
|
String msg =
|
||||||
"Failed to import OVA template. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage +
|
"Failed to import OVA template. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage +
|
||||||
", templateName: " + templateName + ", templateUuid: " + templateUuid;
|
", templateName: " + templateName + ", templateUuid: " + templateUuid;
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
@ -605,7 +602,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vmMo, long accountId, long templateId, String templateUniqueName, String secStorageUrl,
|
private Ternary<String, Long, Long> createTemplateFromVolume(VirtualMachineMO vmMo, long accountId, long templateId, String templateUniqueName, String secStorageUrl,
|
||||||
String volumePath, String workerVmName) throws Exception {
|
String volumePath, String workerVmName) throws Exception {
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||||
String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
|
String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
|
||||||
@ -670,7 +667,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Ternary<String, Long, Long> createTemplateFromSnapshot(long accountId, long templateId, String templateUniqueName, String secStorageUrl, long volumeId,
|
private Ternary<String, Long, Long> createTemplateFromSnapshot(long accountId, long templateId, String templateUniqueName, String secStorageUrl, long volumeId,
|
||||||
String backedUpSnapshotUuid) throws Exception {
|
String backedUpSnapshotUuid) throws Exception {
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||||
String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
|
String installPath = getTemplateRelativeDirInSecStorage(accountId, templateId);
|
||||||
@ -854,14 +851,14 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String createVolumeFromSnapshot(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName, long accountId, long volumeId,
|
private String createVolumeFromSnapshot(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName, long accountId, long volumeId,
|
||||||
String secStorageUrl, String snapshotBackupUuid) throws Exception {
|
String secStorageUrl, String snapshotBackupUuid) throws Exception {
|
||||||
|
|
||||||
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), snapshotBackupUuid);
|
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), snapshotBackupUuid);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName, String secStorageUrl, String secStorageDir,
|
private void restoreVolumeFromSecStorage(VmwareHypervisorHost hyperHost, DatastoreMO primaryDsMo, String newVolumeName, String secStorageUrl, String secStorageDir,
|
||||||
String backupName) throws Exception {
|
String backupName) throws Exception {
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||||
String srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/" + backupName + "." + ImageFormat.OVA.getFileExtension();
|
String srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/" + backupName + "." + ImageFormat.OVA.getFileExtension();
|
||||||
@ -921,7 +918,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String backupSnapshotToSecondaryStorage(VirtualMachineMO vmMo, long accountId, long volumeId, String volumePath, String snapshotUuid, String secStorageUrl,
|
private String backupSnapshotToSecondaryStorage(VirtualMachineMO vmMo, long accountId, long volumeId, String volumePath, String snapshotUuid, String secStorageUrl,
|
||||||
String prevSnapshotUuid, String prevBackupUuid, String workerVmName) throws Exception {
|
String prevSnapshotUuid, String prevBackupUuid, String workerVmName) throws Exception {
|
||||||
|
|
||||||
String backupUuid = UUID.randomUUID().toString();
|
String backupUuid = UUID.randomUUID().toString();
|
||||||
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), backupUuid, workerVmName);
|
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), backupUuid, workerVmName);
|
||||||
@ -929,7 +926,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath, String secStorageUrl, String secStorageDir, String exportName,
|
private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath, String secStorageUrl, String secStorageDir, String exportName,
|
||||||
String workerVmName) throws Exception {
|
String workerVmName) throws Exception {
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||||
String exportPath = secondaryMountPoint + "/" + secStorageDir + "/" + exportName;
|
String exportPath = secondaryMountPoint + "/" + secStorageDir + "/" + exportName;
|
||||||
@ -973,40 +970,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String deleteSnapshotOnSecondaryStorge(long accountId, long volumeId, String secStorageUrl, String backupUuid) throws Exception {
|
|
||||||
|
|
||||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
|
||||||
String snapshotMountRoot = secondaryMountPoint + "/" + getSnapshotRelativeDirInSecStorage(accountId, volumeId);
|
|
||||||
File file = new File(snapshotMountRoot + "/" + backupUuid + ".ovf");
|
|
||||||
if (file.exists()) {
|
|
||||||
File snapshotdir = new File(snapshotMountRoot);
|
|
||||||
File[] ssfiles = snapshotdir.listFiles();
|
|
||||||
// List<String> filenames = new ArrayList<String>();
|
|
||||||
for (int i = 0; i < ssfiles.length; i++) {
|
|
||||||
String vmdkfile = ssfiles[i].getName();
|
|
||||||
if (vmdkfile.toLowerCase().startsWith(backupUuid) && vmdkfile.toLowerCase().endsWith(".vmdk")) {
|
|
||||||
// filenames.add(vmdkfile);
|
|
||||||
new File(vmdkfile).delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (file.delete()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
File file1 = new File(snapshotMountRoot + "/" + backupUuid + ".ova");
|
|
||||||
if (file1.exists()) {
|
|
||||||
if (file1.delete()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return "Backup file does not exist. backupUuid: " + backupUuid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "Failed to delete snapshot backup file, backupUuid: " + backupUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostService, VmwareHypervisorHost hyperHost, CopyVolumeCommand cmd, String vmName,
|
private Pair<String, String> copyVolumeToSecStorage(VmwareHostService hostService, VmwareHypervisorHost hyperHost, CopyVolumeCommand cmd, String vmName,
|
||||||
long volumeId, String poolId, String volumePath, String secStorageUrl, String workerVmName) throws Exception {
|
long volumeId, String poolId, String volumePath, String secStorageUrl, String workerVmName) throws Exception {
|
||||||
|
|
||||||
String volumeFolder = String.valueOf(volumeId) + "/";
|
String volumeFolder = String.valueOf(volumeId) + "/";
|
||||||
VirtualMachineMO workerVm = null;
|
VirtualMachineMO workerVm = null;
|
||||||
@ -1043,7 +1008,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
|
vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
|
||||||
|
|
||||||
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName,
|
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl, "volumes/" + volumeFolder, exportName,
|
||||||
hostService.getWorkerName(hyperHost.getContext(), cmd, 1));
|
hostService.getWorkerName(hyperHost.getContext(), cmd, 1));
|
||||||
return new Pair<String, String>(volumeFolder, exportName);
|
return new Pair<String, String>(volumeFolder, exportName);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
@ -1066,7 +1031,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost, long volumeId, DatastoreMO dsMo, String secStorageUrl, String exportName)
|
private Pair<String, String> copyVolumeFromSecStorage(VmwareHypervisorHost hyperHost, long volumeId, DatastoreMO dsMo, String secStorageUrl, String exportName)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
String volumeFolder = String.valueOf(volumeId) + "/";
|
String volumeFolder = String.valueOf(volumeId) + "/";
|
||||||
String newVolume = UUID.randomUUID().toString().replaceAll("-", "");
|
String newVolume = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
@ -1085,69 +1050,54 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
s_logger.info("getOVAfromMetaFile: " + metafileName);
|
s_logger.info("getOVAfromMetaFile: " + metafileName);
|
||||||
try {
|
try {
|
||||||
strm = new FileInputStream(ova_metafile);
|
strm = new FileInputStream(ova_metafile);
|
||||||
if (null == strm) {
|
|
||||||
String msg = "Cannot read ova meta file.";
|
s_logger.info("loading properties from ova meta file: " + metafileName);
|
||||||
|
props = new Properties();
|
||||||
|
props.load(strm);
|
||||||
|
ovaFileName = props.getProperty("ova.filename");
|
||||||
|
s_logger.info("ovafilename: " + ovaFileName);
|
||||||
|
String ovfFileName = props.getProperty("ovf");
|
||||||
|
s_logger.info("ovffilename: " + ovfFileName);
|
||||||
|
int diskNum = Integer.parseInt(props.getProperty("numDisks"));
|
||||||
|
if (diskNum <= 0) {
|
||||||
|
String msg = "VMDK disk file number is 0. Error";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
|
String[] disks = new String[diskNum];
|
||||||
s_logger.info("loading properties from ova meta file: " + metafileName);
|
for (int i = 0; i < diskNum; i++) {
|
||||||
if (null != ova_metafile) {
|
// String diskNameKey = "disk" + Integer.toString(i+1) + ".name"; // Fang use this
|
||||||
props = new Properties();
|
String diskNameKey = "disk1.name";
|
||||||
props.load(strm);
|
disks[i] = props.getProperty(diskNameKey);
|
||||||
if (props == null) {
|
s_logger.info("diskname " + disks[i]);
|
||||||
s_logger.info("getOVAfromMetaFile: props is null. ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (null != props) {
|
String exportDir = ova_metafile.getParent();
|
||||||
ovaFileName = props.getProperty("ova.filename");
|
s_logger.info("exportDir: " + exportDir);
|
||||||
s_logger.info("ovafilename: " + ovaFileName);
|
// Important! we need to sync file system before we can safely use tar to work around a linux kernal bug(or feature)
|
||||||
String ovfFileName = props.getProperty("ovf");
|
s_logger.info("Sync file system before we package OVA..., before tar ");
|
||||||
s_logger.info("ovffilename: " + ovfFileName);
|
s_logger.info("ova: " + ovaFileName + ", ovf:" + ovfFileName + ", vmdk:" + disks[0] + ".");
|
||||||
int diskNum = Integer.parseInt(props.getProperty("numDisks"));
|
Script commandSync = new Script(true, "sync", 0, s_logger);
|
||||||
if (diskNum <= 0) {
|
commandSync.execute();
|
||||||
String msg = "VMDK disk file number is 0. Error";
|
Script command = new Script(false, "tar", 0, s_logger);
|
||||||
s_logger.error(msg);
|
command.setWorkDir(exportDir); // Fang: pass this in to the method?
|
||||||
throw new Exception(msg);
|
command.add("-cf", ovaFileName);
|
||||||
}
|
command.add(ovfFileName); // OVF file should be the first file in OVA archive
|
||||||
String[] disks = new String[diskNum];
|
for (String diskName : disks) {
|
||||||
for (int i = 0; i < diskNum; i++) {
|
command.add(diskName);
|
||||||
// String diskNameKey = "disk" + Integer.toString(i+1) + ".name"; // Fang use this
|
}
|
||||||
String diskNameKey = "disk1.name";
|
command.execute();
|
||||||
disks[i] = props.getProperty(diskNameKey);
|
s_logger.info("Package OVA for template in dir: " + exportDir + "cmd: " + command.toString());
|
||||||
s_logger.info("diskname " + disks[i]);
|
// to be safe, physically test existence of the target OVA file
|
||||||
}
|
if ((new File(exportDir + ovaFileName)).exists()) {
|
||||||
String exportDir = ova_metafile.getParent();
|
s_logger.info("ova file is created and ready to extract ");
|
||||||
s_logger.info("exportDir: " + exportDir);
|
return (ovaFileName);
|
||||||
// Important! we need to sync file system before we can safely use tar to work around a linux kernal bug(or feature)
|
|
||||||
s_logger.info("Sync file system before we package OVA..., before tar ");
|
|
||||||
s_logger.info("ova: " + ovaFileName + ", ovf:" + ovfFileName + ", vmdk:" + disks[0] + ".");
|
|
||||||
Script commandSync = new Script(true, "sync", 0, s_logger);
|
|
||||||
commandSync.execute();
|
|
||||||
Script command = new Script(false, "tar", 0, s_logger);
|
|
||||||
command.setWorkDir(exportDir); // Fang: pass this in to the method?
|
|
||||||
command.add("-cf", ovaFileName);
|
|
||||||
command.add(ovfFileName); // OVF file should be the first file in OVA archive
|
|
||||||
for (String diskName : disks) {
|
|
||||||
command.add(diskName);
|
|
||||||
}
|
|
||||||
command.execute();
|
|
||||||
s_logger.info("Package OVA for template in dir: " + exportDir + "cmd: " + command.toString());
|
|
||||||
// to be safe, physically test existence of the target OVA file
|
|
||||||
if ((new File(exportDir + ovaFileName)).exists()) {
|
|
||||||
s_logger.info("ova file is created and ready to extract ");
|
|
||||||
return (ovaFileName);
|
|
||||||
} else {
|
|
||||||
String msg = exportDir + File.separator + ovaFileName + ".ova is not created as expected";
|
|
||||||
s_logger.error(msg);
|
|
||||||
throw new Exception(msg);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
String msg = "Error reading the ova meta file: " + metafileName;
|
String msg = exportDir + File.separator + ovaFileName + ".ova is not created as expected";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
s_logger.error("Exception in getOVAFromMetafile", e);
|
||||||
return null;
|
return null;
|
||||||
// Do something, re-throw the exception
|
// Do something, re-throw the exception
|
||||||
} finally {
|
} finally {
|
||||||
@ -1252,7 +1202,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
|
|
||||||
// wait if there are already VM snapshot task running
|
// wait if there are already VM snapshot task running
|
||||||
ManagedObjectReference taskmgr = context.getServiceContent().getTaskManager();
|
ManagedObjectReference taskmgr = context.getServiceContent().getTaskManager();
|
||||||
List<ManagedObjectReference> tasks = (ArrayList<ManagedObjectReference>)context.getVimClient().getDynamicProperty(taskmgr, "recentTask");
|
List<ManagedObjectReference> tasks = context.getVimClient().getDynamicProperty(taskmgr, "recentTask");
|
||||||
|
|
||||||
for (ManagedObjectReference taskMor : tasks) {
|
for (ManagedObjectReference taskMor : tasks) {
|
||||||
TaskInfo info = (TaskInfo)(context.getVimClient().getDynamicProperty(taskMor, "info"));
|
TaskInfo info = (TaskInfo)(context.getVimClient().getDynamicProperty(taskMor, "info"));
|
||||||
@ -1465,7 +1415,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
|
|
||||||
// wait if there are already VM revert task running
|
// wait if there are already VM revert task running
|
||||||
ManagedObjectReference taskmgr = context.getServiceContent().getTaskManager();
|
ManagedObjectReference taskmgr = context.getServiceContent().getTaskManager();
|
||||||
List<ManagedObjectReference> tasks = (ArrayList<ManagedObjectReference>)context.getVimClient().getDynamicProperty(taskmgr, "recentTask");
|
List<ManagedObjectReference> tasks = context.getVimClient().getDynamicProperty(taskmgr, "recentTask");
|
||||||
|
|
||||||
for (ManagedObjectReference taskMor : tasks) {
|
for (ManagedObjectReference taskMor : tasks) {
|
||||||
TaskInfo info = (TaskInfo)(context.getVimClient().getDynamicProperty(taskMor, "info"));
|
TaskInfo info = (TaskInfo)(context.getVimClient().getDynamicProperty(taskMor, "info"));
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,8 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
|||||||
|
|
||||||
// We need to know what properties a VSM has. Put them here.
|
// We need to know what properties a VSM has. Put them here.
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 3091674059522739481L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
@Column(name = "id")
|
@Column(name = "id")
|
||||||
@ -167,11 +169,11 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
|||||||
// Setter methods
|
// Setter methods
|
||||||
|
|
||||||
public void setHostId(long hostid) {
|
public void setHostId(long hostid) {
|
||||||
this.hostId = hostid;
|
hostId = hostid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmUserName(String username) {
|
public void setVsmUserName(String username) {
|
||||||
this.vsmUserName = username;
|
vsmUserName = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmName(String vsmName) {
|
public void setVsmName(String vsmName) {
|
||||||
@ -179,7 +181,7 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmPassword(String password) {
|
public void setVsmPassword(String password) {
|
||||||
this.vsmPassword = password;
|
vsmPassword = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMgmtIpAddr(String ipaddr) {
|
public void setMgmtIpAddr(String ipaddr) {
|
||||||
@ -187,50 +189,50 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setManagementVlan(int vlan) {
|
public void setManagementVlan(int vlan) {
|
||||||
this.managementVlan = vlan;
|
managementVlan = vlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setControlVlan(int vlan) {
|
public void setControlVlan(int vlan) {
|
||||||
this.controlVlan = vlan;
|
controlVlan = vlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPacketVlan(int vlan) {
|
public void setPacketVlan(int vlan) {
|
||||||
this.packetVlan = vlan;
|
packetVlan = vlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStorageVlan(int vlan) {
|
public void setStorageVlan(int vlan) {
|
||||||
this.storageVlan = vlan;
|
storageVlan = vlan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmDomainId(long id) {
|
public void setVsmDomainId(long id) {
|
||||||
this.vsmDomainId = id;
|
vsmDomainId = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmConfigMode(VSMConfigMode mode) {
|
public void setVsmConfigMode(VSMConfigMode mode) {
|
||||||
this.vsmConfigMode = mode;
|
vsmConfigMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmConfigState(VSMConfigState state) {
|
public void setVsmConfigState(VSMConfigState state) {
|
||||||
this.vsmConfigState = state;
|
vsmConfigState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVsmDeviceState(VSMDeviceState devState) {
|
public void setVsmDeviceState(VSMDeviceState devState) {
|
||||||
this.vsmDeviceState = devState;
|
vsmDeviceState = devState;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructors.
|
// Constructors.
|
||||||
|
|
||||||
public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password) {
|
public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password) {
|
||||||
// Set all the VSM's properties here.
|
// Set all the VSM's properties here.
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
this.setMgmtIpAddr(vsmIpAddr);
|
setMgmtIpAddr(vsmIpAddr);
|
||||||
this.setVsmUserName(username);
|
setVsmUserName(username);
|
||||||
this.setVsmPassword(password);
|
setVsmPassword(password);
|
||||||
this.setVsmName(vsmName);
|
setVsmName(vsmName);
|
||||||
this.setVsmDeviceState(VSMDeviceState.Enabled);
|
setVsmDeviceState(VSMDeviceState.Enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CiscoNexusVSMDeviceVO() {
|
public CiscoNexusVSMDeviceVO() {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
uuid = UUID.randomUUID().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -269,8 +269,6 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme
|
|||||||
throw new CloudRuntimeException(msg);
|
throw new CloudRuntimeException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txn;
|
|
||||||
|
|
||||||
// If VSM already exists and is mapped to a cluster, fail this operation.
|
// If VSM already exists and is mapped to a cluster, fail this operation.
|
||||||
vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
|
vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
|
||||||
if (vsm != null) {
|
if (vsm != null) {
|
||||||
|
|||||||
@ -47,7 +47,6 @@ import com.cloud.hypervisor.vmware.mo.VmwareHostType;
|
|||||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
|
||||||
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
|
||||||
import com.cloud.serializer.GsonHelper;
|
import com.cloud.serializer.GsonHelper;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
@ -125,7 +124,7 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Answer execute(CreateEntityDownloadURLCommand cmd) {
|
protected Answer execute(CreateEntityDownloadURLCommand cmd) {
|
||||||
boolean result = _storageMgr.execute(this, cmd);
|
_storageMgr.execute(this, cmd);
|
||||||
return _resource.defaultAction(cmd);
|
return _resource.defaultAction(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,46 +314,6 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
|||||||
return _resource.getRootDir(storageUrl);
|
return _resource.getRootDir(storageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateContext(VmwareContext context, Command cmd) {
|
|
||||||
String guid = cmd.getContextParam("guid");
|
|
||||||
assert (guid != null);
|
|
||||||
|
|
||||||
String[] tokens = guid.split("@");
|
|
||||||
assert (tokens != null && tokens.length == 2);
|
|
||||||
|
|
||||||
ManagedObjectReference morHyperHost = new ManagedObjectReference();
|
|
||||||
String[] hostTokens = tokens[0].split(":");
|
|
||||||
assert (hostTokens.length == 2);
|
|
||||||
|
|
||||||
morHyperHost.setType(hostTokens[0]);
|
|
||||||
morHyperHost.setValue(hostTokens[1]);
|
|
||||||
|
|
||||||
if (morHyperHost.getType().equalsIgnoreCase("HostSystem")) {
|
|
||||||
HostMO hostMo = new HostMO(context, morHyperHost);
|
|
||||||
try {
|
|
||||||
VmwareHypervisorHostNetworkSummary netSummary =
|
|
||||||
hostMo.getHyperHostNetworkSummary(hostMo.getHostType() == VmwareHostType.ESXi ? cmd.getContextParam("manageportgroup")
|
|
||||||
: cmd.getContextParam("serviceconsole"));
|
|
||||||
assert (netSummary != null);
|
|
||||||
if (netSummary.getHostIp() != null && !netSummary.getHostIp().isEmpty()) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Context validation succeeded. Validated via host: " + netSummary.getHostIp() + ", guid: " + guid);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_logger.warn("Context validation failed due to invalid host network summary");
|
|
||||||
return false;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
s_logger.warn("Context validation failed due to " + VmwareHelper.getExceptionMessage(e));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String iScsiName,
|
public ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String iScsiName,
|
||||||
String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
|
String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public class VmwareResourceTest {
|
|||||||
doReturn(false).when(vmSpec).getLimitCpuUse();
|
doReturn(false).when(vmSpec).getLimitCpuUse();
|
||||||
when(vmMo.configureVm(vmConfigSpec)).thenReturn(true);
|
when(vmMo.configureVm(vmConfigSpec)).thenReturn(true);
|
||||||
|
|
||||||
ScaleVmAnswer answer = _resource.execute(cmd);
|
_resource.execute(cmd);
|
||||||
verify(_resource).execute(cmd);
|
verify(_resource).execute(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,7 @@ public class VmwareStorageMotionStrategyTest {
|
|||||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||||
|
|
||||||
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
||||||
assertTrue("Migration within cluster isn't successful.", this.result.isSuccess());
|
assertTrue("Migration within cluster isn't successful.", result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -166,7 +166,7 @@ public class VmwareStorageMotionStrategyTest {
|
|||||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||||
|
|
||||||
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
||||||
assertFalse("Migration within cluster didn't fail.", this.result.isSuccess());
|
assertFalse("Migration within cluster didn't fail.", result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -190,7 +190,7 @@ public class VmwareStorageMotionStrategyTest {
|
|||||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||||
|
|
||||||
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
||||||
assertTrue("Migration across cluster isn't successful.", this.result.isSuccess());
|
assertTrue("Migration across cluster isn't successful.", result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -214,25 +214,20 @@ public class VmwareStorageMotionStrategyTest {
|
|||||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||||
|
|
||||||
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
strategy.copyAsync(volumeMap, to, srcHost, destHost, caller);
|
||||||
assertFalse("Migration across cluster didn't fail.", this.result.isSuccess());
|
assertFalse("Migration across cluster didn't fail.", result.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MockContext<T> extends AsyncRpcContext<T> {
|
private class MockContext<T> extends AsyncRpcContext<T> {
|
||||||
final Map<VolumeInfo, DataStore> volumeToPool;
|
|
||||||
final AsyncCallFuture<CommandResult> future;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
public MockContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CommandResult> future, Map<VolumeInfo, DataStore> volumeToPool) {
|
public MockContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CommandResult> future, Map<VolumeInfo, DataStore> volumeToPool) {
|
||||||
super(callback);
|
super(callback);
|
||||||
this.volumeToPool = volumeToPool;
|
|
||||||
this.future = future;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Void mockCallBack(AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> callback, MockContext<CommandResult> context) {
|
protected Void mockCallBack(AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> callback, MockContext<CommandResult> context) {
|
||||||
this.result = callback.getResult();
|
result = callback.getResult();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user