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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@Table(name = "legacy_zones")
|
||||
public class LegacyZoneVO implements LegacyZone {
|
||||
|
||||
private static final long serialVersionUID = -3979866054555152793L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
@ -60,7 +62,7 @@ public class LegacyZoneVO implements LegacyZone {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof LegacyZoneVO) {
|
||||
return ((LegacyZoneVO)obj).getId() == this.getId();
|
||||
return ((LegacyZoneVO)obj).getId() == getId();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -70,7 +72,7 @@ public class LegacyZoneVO implements LegacyZone {
|
||||
}
|
||||
|
||||
public LegacyZoneVO(long zoneId) {
|
||||
this.id = zoneId;
|
||||
id = zoneId;
|
||||
}
|
||||
|
||||
public LegacyZoneVO(long id, long zoneId) {
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.vmware;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -98,16 +97,6 @@ public class VmwareCleanupMaid {
|
||||
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) {
|
||||
List<VmwareCleanupMaid> l = s_leftoverDummyVMs.get(context.getServerAddress());
|
||||
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
@ -37,6 +37,8 @@ import com.cloud.utils.db.Encrypt;
|
||||
@Table(name = "vmware_data_center")
|
||||
public class VmwareDatacenterVO implements VmwareDatacenter {
|
||||
|
||||
private static final long serialVersionUID = -9114941929893819232L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
@ -105,11 +107,11 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
|
||||
}
|
||||
|
||||
public void setVmwareDatacenterName(String name) {
|
||||
this.vmwareDatacenterName = name;
|
||||
vmwareDatacenterName = name;
|
||||
}
|
||||
|
||||
public void setVcenterHost(String vCenterHost) {
|
||||
this.vcenterHost = vCenterHost;
|
||||
vcenterHost = vCenterHost;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
@ -134,17 +136,17 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof VmwareDatacenterVO) {
|
||||
return ((VmwareDatacenterVO)obj).getId() == this.getId();
|
||||
return ((VmwareDatacenterVO)obj).getId() == getId();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public VmwareDatacenterVO(String guid, String name, String vCenterHost, String user, String password) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.vmwareDatacenterName = name;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
vmwareDatacenterName = name;
|
||||
this.guid = guid;
|
||||
this.vcenterHost = vCenterHost;
|
||||
vcenterHost = vCenterHost;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
}
|
||||
@ -155,7 +157,7 @@ public class VmwareDatacenterVO implements VmwareDatacenter {
|
||||
}
|
||||
|
||||
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")
|
||||
public class VmwareDatacenterZoneMapVO implements VmwareDatacenterZoneMap {
|
||||
|
||||
private static final long serialVersionUID = -2155826205976479040L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
|
||||
@ -126,7 +126,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>>
|
||||
find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||
find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||
|
||||
if (s_logger.isInfoEnabled())
|
||||
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
|
||||
@ -158,7 +158,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
if (usernameNotProvided || passwordNotProvided) {
|
||||
// Retrieve credentials associated with VMware DC
|
||||
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();
|
||||
password = vmwareDc.getPassword();
|
||||
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
|
||||
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.
|
||||
//
|
||||
@ -272,7 +272,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
if (pNetworkListGuestTraffic.contains(pNetworkPublic)) {
|
||||
if (publicTrafficLabelObj.getVirtualSwitchType() != guestTrafficLabelObj.getVirtualSwitchType()) {
|
||||
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" +
|
||||
". A physical network cannot be shared by different types of virtual switches.";
|
||||
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);
|
||||
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
|
||||
// 1) The global config parameter vmware.use.nexus.vswitch
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
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)
|
||||
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()));
|
||||
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath(), "UTF-8"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
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()));
|
||||
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath(), "UTF-8"));
|
||||
|
||||
if (morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
|
||||
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())) {
|
||||
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;
|
||||
s_logger.error(msg);
|
||||
throw new DiscoveryException(msg);
|
||||
} else if (!vmwareDcNameFromDb.equalsIgnoreCase(vmwareDcNameFromApi)) {
|
||||
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;
|
||||
s_logger.error(msg);
|
||||
throw new DiscoveryException(msg);
|
||||
@ -567,8 +567,8 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
if (tmplt == null) {
|
||||
id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
VMTemplateVO template =
|
||||
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);
|
||||
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);
|
||||
_tmpltDao.persist(template);
|
||||
} else {
|
||||
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,
|
||||
String vSwitchName, Long clusterId) {
|
||||
String vSwitchName, Long clusterId) {
|
||||
VmwareTrafficLabel trafficLabelObj = null;
|
||||
Map<String, String> clusterDetails = null;
|
||||
try {
|
||||
@ -664,7 +664,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
}
|
||||
|
||||
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, Map<String, String> clusterDetails,
|
||||
VirtualSwitchType defVirtualSwitchType) {
|
||||
VirtualSwitchType defVirtualSwitchType) {
|
||||
VmwareTrafficLabel trafficLabelObj = null;
|
||||
try {
|
||||
trafficLabelObj = new VmwareTrafficLabel(zoneWideTrafficLabel, trafficType, defVirtualSwitchType);
|
||||
|
||||
@ -40,7 +40,6 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.vmware.vim25.AboutInfo;
|
||||
import com.vmware.vim25.HostConnectSpec;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
|
||||
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.HostMO;
|
||||
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.VmwareContextFactory;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareClient;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||
import com.cloud.network.CiscoNexusVSMDeviceVO;
|
||||
@ -400,7 +397,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
|
||||
@Override
|
||||
public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceContext, long dcId, Long podId, Long clusterId, String hostInventoryPath)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
ManagedObjectReference mor = null;
|
||||
if (serviceContext != null) {
|
||||
mor = serviceContext.getHostMorByPath(hostInventoryPath);
|
||||
@ -415,7 +412,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
|
||||
|
||||
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);
|
||||
|
||||
// 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));
|
||||
return returnedHostList;
|
||||
} 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);
|
||||
|
||||
if (hosts.size() > 0) {
|
||||
@ -462,45 +459,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
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
|
||||
public String getSecondaryStorageStoreUrl(long dcId) {
|
||||
|
||||
@ -579,7 +537,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
return false;
|
||||
}
|
||||
|
||||
long startTick = Long.parseLong(tokens[0]);
|
||||
Long.parseLong(tokens[0]);
|
||||
long msid = Long.parseLong(tokens[1]);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -631,7 +589,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
_configServer.updateKeyPairs();
|
||||
|
||||
s_logger.info("Copy System VM patch ISO file to secondary storage. source ISO: " + srcIso.getAbsolutePath() + ", destination: " +
|
||||
destIso.getAbsolutePath());
|
||||
destIso.getAbsolutePath());
|
||||
try {
|
||||
FileUtil.copyfile(srcIso, destIso);
|
||||
} catch (IOException e) {
|
||||
@ -1040,7 +998,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
|
||||
if (vCenterHost == null) {
|
||||
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) {
|
||||
@ -1060,11 +1018,11 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
VmwareDatacenterVO associatedVmwareDc = _vmwareDcDao.findById(associatedVmwareDcId);
|
||||
if (associatedVmwareDc.getVcenterHost().equalsIgnoreCase(vCenterHost) && associatedVmwareDc.getVmwareDatacenterName().equalsIgnoreCase(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;
|
||||
} else {
|
||||
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.
|
||||
@ -1158,8 +1116,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
||||
String userName;
|
||||
String password;
|
||||
DatacenterMO dcMo = null;
|
||||
Transaction txn;
|
||||
|
||||
final VmwareDatacenterZoneMapVO vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
|
||||
// Check if zone is associated with VMware DC
|
||||
if (vmwareDcZoneMap == null) {
|
||||
|
||||
@ -198,9 +198,6 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
String installPath = volume.getPath();
|
||||
int index = installPath.lastIndexOf(File.separator);
|
||||
String volumeUuid = installPath.substring(index + 1);
|
||||
String details = null;
|
||||
boolean success = false;
|
||||
|
||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||
//The real volume path
|
||||
String volumePath = installPath + File.separator + volumeUuid + ".ova";
|
||||
@ -351,8 +348,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
}
|
||||
|
||||
snapshotBackupUuid =
|
||||
backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
|
||||
hostService.getWorkerName(context, cmd, 1));
|
||||
backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
|
||||
hostService.getWorkerName(context, cmd, 1));
|
||||
|
||||
success = (snapshotBackupUuid != null);
|
||||
if (success) {
|
||||
@ -407,7 +404,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
if (vmMo == null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
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());
|
||||
|
||||
@ -419,8 +416,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
}
|
||||
|
||||
Ternary<String, Long, Long> result =
|
||||
createTemplateFromVolume(vmMo, accountId, templateId, cmd.getUniqueName(), secondaryStoragePoolURL, volumePath,
|
||||
hostService.getWorkerName(context, cmd, 0));
|
||||
createTemplateFromVolume(vmMo, accountId, templateId, cmd.getUniqueName(), secondaryStoragePoolURL, volumePath,
|
||||
hostService.getWorkerName(context, cmd, 0));
|
||||
|
||||
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;
|
||||
if (cmd.toSecondaryStorage()) {
|
||||
result =
|
||||
copyVolumeToSecStorage(hostService, hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath, secondaryStorageURL,
|
||||
hostService.getWorkerName(context, cmd, 0));
|
||||
copyVolumeToSecStorage(hostService, hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath, secondaryStorageURL,
|
||||
hostService.getWorkerName(context, cmd, 0));
|
||||
} else {
|
||||
StorageFilerTO poolTO = cmd.getPool();
|
||||
|
||||
@ -549,10 +546,10 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
// templateName: name in secondary storage
|
||||
// templateUuid: will be used at hypervisor layer
|
||||
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: " +
|
||||
templatePathAtSecondaryStorage + ", templateName: " + templateName);
|
||||
templatePathAtSecondaryStorage + ", templateName: " + templateName);
|
||||
|
||||
String secondaryMountPoint = _mountService.getMountPoint(secondaryStorageUrl);
|
||||
s_logger.info("Secondary storage mount point: " + secondaryMountPoint);
|
||||
@ -587,7 +584,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(vmName);
|
||||
if (vmMo == null) {
|
||||
String msg =
|
||||
"Failed to import OVA template. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage +
|
||||
"Failed to import OVA template. secondaryStorage: " + secondaryStorageUrl + ", templatePathAtSecondaryStorage: " + templatePathAtSecondaryStorage +
|
||||
", templateName: " + templateName + ", templateUuid: " + templateUuid;
|
||||
s_logger.error(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,
|
||||
String volumePath, String workerVmName) throws Exception {
|
||||
String volumePath, String workerVmName) throws Exception {
|
||||
|
||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||
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,
|
||||
String backedUpSnapshotUuid) throws Exception {
|
||||
String backedUpSnapshotUuid) throws Exception {
|
||||
|
||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||
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,
|
||||
String secStorageUrl, String snapshotBackupUuid) throws Exception {
|
||||
String secStorageUrl, String snapshotBackupUuid) throws Exception {
|
||||
|
||||
restoreVolumeFromSecStorage(hyperHost, primaryDsMo, newVolumeName, secStorageUrl, getSnapshotRelativeDirInSecStorage(accountId, volumeId), snapshotBackupUuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
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 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,
|
||||
String prevSnapshotUuid, String prevBackupUuid, String workerVmName) throws Exception {
|
||||
String prevSnapshotUuid, String prevBackupUuid, String workerVmName) throws Exception {
|
||||
|
||||
String backupUuid = UUID.randomUUID().toString();
|
||||
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,
|
||||
String workerVmName) throws Exception {
|
||||
String workerVmName) throws Exception {
|
||||
|
||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||
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,
|
||||
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) + "/";
|
||||
VirtualMachineMO workerVm = null;
|
||||
@ -1043,7 +1008,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
vmMo.createSnapshot(exportName, "Temporary snapshot for copy-volume command", false, false);
|
||||
|
||||
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);
|
||||
|
||||
} 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)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
|
||||
String volumeFolder = String.valueOf(volumeId) + "/";
|
||||
String newVolume = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
@ -1085,69 +1050,54 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
s_logger.info("getOVAfromMetaFile: " + metafileName);
|
||||
try {
|
||||
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);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
s_logger.info("loading properties from ova meta file: " + metafileName);
|
||||
if (null != ova_metafile) {
|
||||
props = new Properties();
|
||||
props.load(strm);
|
||||
if (props == null) {
|
||||
s_logger.info("getOVAfromMetaFile: props is null. ");
|
||||
}
|
||||
String[] disks = new String[diskNum];
|
||||
for (int i = 0; i < diskNum; i++) {
|
||||
// String diskNameKey = "disk" + Integer.toString(i+1) + ".name"; // Fang use this
|
||||
String diskNameKey = "disk1.name";
|
||||
disks[i] = props.getProperty(diskNameKey);
|
||||
s_logger.info("diskname " + disks[i]);
|
||||
}
|
||||
if (null != props) {
|
||||
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);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
String[] disks = new String[diskNum];
|
||||
for (int i = 0; i < diskNum; i++) {
|
||||
// String diskNameKey = "disk" + Integer.toString(i+1) + ".name"; // Fang use this
|
||||
String diskNameKey = "disk1.name";
|
||||
disks[i] = props.getProperty(diskNameKey);
|
||||
s_logger.info("diskname " + disks[i]);
|
||||
}
|
||||
String exportDir = ova_metafile.getParent();
|
||||
s_logger.info("exportDir: " + exportDir);
|
||||
// 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);
|
||||
}
|
||||
String exportDir = ova_metafile.getParent();
|
||||
s_logger.info("exportDir: " + exportDir);
|
||||
// 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 = "Error reading the ova meta file: " + metafileName;
|
||||
String msg = exportDir + File.separator + ovaFileName + ".ova is not created as expected";
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Exception in getOVAFromMetafile", e);
|
||||
return null;
|
||||
// Do something, re-throw the exception
|
||||
} finally {
|
||||
@ -1252,7 +1202,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
|
||||
// wait if there are already VM snapshot task running
|
||||
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) {
|
||||
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
|
||||
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) {
|
||||
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.
|
||||
|
||||
private static final long serialVersionUID = 3091674059522739481L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
@ -167,11 +169,11 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
||||
// Setter methods
|
||||
|
||||
public void setHostId(long hostid) {
|
||||
this.hostId = hostid;
|
||||
hostId = hostid;
|
||||
}
|
||||
|
||||
public void setVsmUserName(String username) {
|
||||
this.vsmUserName = username;
|
||||
vsmUserName = username;
|
||||
}
|
||||
|
||||
public void setVsmName(String vsmName) {
|
||||
@ -179,7 +181,7 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
||||
}
|
||||
|
||||
public void setVsmPassword(String password) {
|
||||
this.vsmPassword = password;
|
||||
vsmPassword = password;
|
||||
}
|
||||
|
||||
public void setMgmtIpAddr(String ipaddr) {
|
||||
@ -187,50 +189,50 @@ public class CiscoNexusVSMDeviceVO implements CiscoNexusVSMDevice {
|
||||
}
|
||||
|
||||
public void setManagementVlan(int vlan) {
|
||||
this.managementVlan = vlan;
|
||||
managementVlan = vlan;
|
||||
}
|
||||
|
||||
public void setControlVlan(int vlan) {
|
||||
this.controlVlan = vlan;
|
||||
controlVlan = vlan;
|
||||
}
|
||||
|
||||
public void setPacketVlan(int vlan) {
|
||||
this.packetVlan = vlan;
|
||||
packetVlan = vlan;
|
||||
}
|
||||
|
||||
public void setStorageVlan(int vlan) {
|
||||
this.storageVlan = vlan;
|
||||
storageVlan = vlan;
|
||||
}
|
||||
|
||||
public void setVsmDomainId(long id) {
|
||||
this.vsmDomainId = id;
|
||||
vsmDomainId = id;
|
||||
}
|
||||
|
||||
public void setVsmConfigMode(VSMConfigMode mode) {
|
||||
this.vsmConfigMode = mode;
|
||||
vsmConfigMode = mode;
|
||||
}
|
||||
|
||||
public void setVsmConfigState(VSMConfigState state) {
|
||||
this.vsmConfigState = state;
|
||||
vsmConfigState = state;
|
||||
}
|
||||
|
||||
public void setVsmDeviceState(VSMDeviceState devState) {
|
||||
this.vsmDeviceState = devState;
|
||||
vsmDeviceState = devState;
|
||||
}
|
||||
|
||||
// Constructors.
|
||||
|
||||
public CiscoNexusVSMDeviceVO(String vsmIpAddr, String username, String password) {
|
||||
// Set all the VSM's properties here.
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.setMgmtIpAddr(vsmIpAddr);
|
||||
this.setVsmUserName(username);
|
||||
this.setVsmPassword(password);
|
||||
this.setVsmName(vsmName);
|
||||
this.setVsmDeviceState(VSMDeviceState.Enabled);
|
||||
uuid = UUID.randomUUID().toString();
|
||||
setMgmtIpAddr(vsmIpAddr);
|
||||
setVsmUserName(username);
|
||||
setVsmPassword(password);
|
||||
setVsmName(vsmName);
|
||||
setVsmDeviceState(VSMDeviceState.Enabled);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Transaction txn;
|
||||
|
||||
// If VSM already exists and is mapped to a cluster, fail this operation.
|
||||
vsm = _vsmDao.getVSMbyIpaddress(vsmIp);
|
||||
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.VmwareHypervisorHostNetworkSummary;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||
import com.cloud.serializer.GsonHelper;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -125,7 +124,7 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
||||
}
|
||||
|
||||
protected Answer execute(CreateEntityDownloadURLCommand cmd) {
|
||||
boolean result = _storageMgr.execute(this, cmd);
|
||||
_storageMgr.execute(this, cmd);
|
||||
return _resource.defaultAction(cmd);
|
||||
}
|
||||
|
||||
@ -315,46 +314,6 @@ public class VmwareSecondaryStorageResourceHandler implements SecondaryStorageRe
|
||||
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
|
||||
public ManagedObjectReference prepareManagedStorage(VmwareHypervisorHost hyperHost, String iScsiName,
|
||||
String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret,
|
||||
|
||||
@ -86,7 +86,7 @@ public class VmwareResourceTest {
|
||||
doReturn(false).when(vmSpec).getLimitCpuUse();
|
||||
when(vmMo.configureVm(vmConfigSpec)).thenReturn(true);
|
||||
|
||||
ScaleVmAnswer answer = _resource.execute(cmd);
|
||||
_resource.execute(cmd);
|
||||
verify(_resource).execute(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ public class VmwareStorageMotionStrategyTest {
|
||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||
|
||||
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
|
||||
@ -166,7 +166,7 @@ public class VmwareStorageMotionStrategyTest {
|
||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||
|
||||
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
|
||||
@ -190,7 +190,7 @@ public class VmwareStorageMotionStrategyTest {
|
||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||
|
||||
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
|
||||
@ -214,25 +214,20 @@ public class VmwareStorageMotionStrategyTest {
|
||||
when(agentMgr.send(anyLong(), isA(MigrateWithStorageCommand.class))).thenReturn(migAnswerMock);
|
||||
|
||||
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> {
|
||||
final Map<VolumeInfo, DataStore> volumeToPool;
|
||||
final AsyncCallFuture<CommandResult> future;
|
||||
|
||||
/**
|
||||
* @param callback
|
||||
*/
|
||||
public MockContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CommandResult> future, Map<VolumeInfo, DataStore> volumeToPool) {
|
||||
super(callback);
|
||||
this.volumeToPool = volumeToPool;
|
||||
this.future = future;
|
||||
}
|
||||
}
|
||||
|
||||
protected Void mockCallBack(AsyncCallbackDispatcher<VmwareStorageMotionStrategyTest, CopyCommandResult> callback, MockContext<CommandResult> context) {
|
||||
this.result = callback.getResult();
|
||||
result = callback.getResult();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user