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
@ -34,6 +34,8 @@ import com.cloud.utils.NumbersUtil;
|
||||
@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")
|
||||
|
||||
@ -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"));
|
||||
|
||||
@ -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;
|
||||
@ -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]);
|
||||
|
||||
@ -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";
|
||||
@ -973,38 +970,6 @@ 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 {
|
||||
|
||||
@ -1085,21 +1050,10 @@ 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.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. ");
|
||||
}
|
||||
}
|
||||
if (null != props) {
|
||||
ovaFileName = props.getProperty("ova.filename");
|
||||
s_logger.info("ovafilename: " + ovaFileName);
|
||||
String ovfFileName = props.getProperty("ovf");
|
||||
@ -1142,12 +1096,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
}
|
||||
} else {
|
||||
String msg = "Error reading the ova meta file: " + metafileName;
|
||||
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"));
|
||||
|
||||
@ -16,6 +16,98 @@
|
||||
// under the License.
|
||||
package com.cloud.hypervisor.vmware.resource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.NDC;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.vmware.vim25.AboutInfo;
|
||||
import com.vmware.vim25.BoolPolicy;
|
||||
import com.vmware.vim25.ClusterDasConfigInfo;
|
||||
import com.vmware.vim25.ComputeResourceSummary;
|
||||
import com.vmware.vim25.CustomFieldStringValue;
|
||||
import com.vmware.vim25.DVPortConfigInfo;
|
||||
import com.vmware.vim25.DVPortConfigSpec;
|
||||
import com.vmware.vim25.DatastoreSummary;
|
||||
import com.vmware.vim25.DistributedVirtualPort;
|
||||
import com.vmware.vim25.DistributedVirtualSwitchPortConnection;
|
||||
import com.vmware.vim25.DistributedVirtualSwitchPortCriteria;
|
||||
import com.vmware.vim25.DynamicProperty;
|
||||
import com.vmware.vim25.HostCapability;
|
||||
import com.vmware.vim25.HostHostBusAdapter;
|
||||
import com.vmware.vim25.HostInternetScsiHba;
|
||||
import com.vmware.vim25.HostInternetScsiHbaAuthenticationProperties;
|
||||
import com.vmware.vim25.HostInternetScsiHbaStaticTarget;
|
||||
import com.vmware.vim25.HostInternetScsiTargetTransport;
|
||||
import com.vmware.vim25.HostScsiDisk;
|
||||
import com.vmware.vim25.HostScsiTopology;
|
||||
import com.vmware.vim25.HostScsiTopologyInterface;
|
||||
import com.vmware.vim25.HostScsiTopologyLun;
|
||||
import com.vmware.vim25.HostScsiTopologyTarget;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
import com.vmware.vim25.ObjectContent;
|
||||
import com.vmware.vim25.OptionValue;
|
||||
import com.vmware.vim25.PerfCounterInfo;
|
||||
import com.vmware.vim25.PerfEntityMetric;
|
||||
import com.vmware.vim25.PerfEntityMetricBase;
|
||||
import com.vmware.vim25.PerfMetricId;
|
||||
import com.vmware.vim25.PerfMetricIntSeries;
|
||||
import com.vmware.vim25.PerfMetricSeries;
|
||||
import com.vmware.vim25.PerfQuerySpec;
|
||||
import com.vmware.vim25.PerfSampleInfo;
|
||||
import com.vmware.vim25.RuntimeFaultFaultMsg;
|
||||
import com.vmware.vim25.ToolsUnavailableFaultMsg;
|
||||
import com.vmware.vim25.VMwareDVSPortSetting;
|
||||
import com.vmware.vim25.VimPortType;
|
||||
import com.vmware.vim25.VirtualDevice;
|
||||
import com.vmware.vim25.VirtualDeviceBackingInfo;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpec;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpecOperation;
|
||||
import com.vmware.vim25.VirtualDisk;
|
||||
import com.vmware.vim25.VirtualEthernetCard;
|
||||
import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
|
||||
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
|
||||
import com.vmware.vim25.VirtualMachineConfigSpec;
|
||||
import com.vmware.vim25.VirtualMachineGuestOsIdentifier;
|
||||
import com.vmware.vim25.VirtualMachinePowerState;
|
||||
import com.vmware.vim25.VirtualMachineRelocateSpec;
|
||||
import com.vmware.vim25.VirtualMachineRelocateSpecDiskLocator;
|
||||
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
||||
|
||||
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
|
||||
import com.cloud.agent.IAgentControl;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.AttachIsoCommand;
|
||||
@ -237,95 +329,6 @@ import com.cloud.vm.VirtualMachine.PowerState;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineName;
|
||||
import com.cloud.vm.VmDetailConstants;
|
||||
import com.google.gson.Gson;
|
||||
import com.vmware.vim25.AboutInfo;
|
||||
import com.vmware.vim25.BoolPolicy;
|
||||
import com.vmware.vim25.ClusterDasConfigInfo;
|
||||
import com.vmware.vim25.ComputeResourceSummary;
|
||||
import com.vmware.vim25.CustomFieldStringValue;
|
||||
import com.vmware.vim25.DVPortConfigInfo;
|
||||
import com.vmware.vim25.DVPortConfigSpec;
|
||||
import com.vmware.vim25.DatastoreSummary;
|
||||
import com.vmware.vim25.DistributedVirtualPort;
|
||||
import com.vmware.vim25.DistributedVirtualSwitchPortConnection;
|
||||
import com.vmware.vim25.DistributedVirtualSwitchPortCriteria;
|
||||
import com.vmware.vim25.DynamicProperty;
|
||||
import com.vmware.vim25.GuestInfo;
|
||||
import com.vmware.vim25.HostCapability;
|
||||
import com.vmware.vim25.HostHostBusAdapter;
|
||||
import com.vmware.vim25.HostInternetScsiHba;
|
||||
import com.vmware.vim25.HostInternetScsiHbaAuthenticationProperties;
|
||||
import com.vmware.vim25.HostInternetScsiHbaStaticTarget;
|
||||
import com.vmware.vim25.HostInternetScsiTargetTransport;
|
||||
import com.vmware.vim25.HostScsiDisk;
|
||||
import com.vmware.vim25.HostScsiTopology;
|
||||
import com.vmware.vim25.HostScsiTopologyInterface;
|
||||
import com.vmware.vim25.HostScsiTopologyLun;
|
||||
import com.vmware.vim25.HostScsiTopologyTarget;
|
||||
import com.vmware.vim25.ManagedObjectReference;
|
||||
import com.vmware.vim25.ObjectContent;
|
||||
import com.vmware.vim25.OptionValue;
|
||||
import com.vmware.vim25.PerfCounterInfo;
|
||||
import com.vmware.vim25.PerfEntityMetric;
|
||||
import com.vmware.vim25.PerfEntityMetricBase;
|
||||
import com.vmware.vim25.PerfMetricId;
|
||||
import com.vmware.vim25.PerfMetricIntSeries;
|
||||
import com.vmware.vim25.PerfMetricSeries;
|
||||
import com.vmware.vim25.PerfQuerySpec;
|
||||
import com.vmware.vim25.PerfSampleInfo;
|
||||
import com.vmware.vim25.RuntimeFaultFaultMsg;
|
||||
import com.vmware.vim25.ToolsUnavailableFaultMsg;
|
||||
import com.vmware.vim25.VMwareDVSPortSetting;
|
||||
import com.vmware.vim25.VimPortType;
|
||||
import com.vmware.vim25.VirtualDevice;
|
||||
import com.vmware.vim25.VirtualDeviceBackingInfo;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpec;
|
||||
import com.vmware.vim25.VirtualDeviceConfigSpecOperation;
|
||||
import com.vmware.vim25.VirtualDisk;
|
||||
import com.vmware.vim25.VirtualEthernetCard;
|
||||
import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
|
||||
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
|
||||
import com.vmware.vim25.VirtualMachineConfigSpec;
|
||||
import com.vmware.vim25.VirtualMachineGuestOsIdentifier;
|
||||
import com.vmware.vim25.VirtualMachinePowerState;
|
||||
import com.vmware.vim25.VirtualMachineRelocateSpec;
|
||||
import com.vmware.vim25.VirtualMachineRelocateSpecDiskLocator;
|
||||
import com.vmware.vim25.VirtualMachineRuntimeInfo;
|
||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
||||
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.NDC;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService {
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareResource.class);
|
||||
@ -1069,7 +1072,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
tmpCfgFileContents += "\n";
|
||||
}
|
||||
|
||||
if (!createFileInVR(controlIp, "/etc/haproxy/", "haproxy.cfg.new", tmpCfgFileContents)) {
|
||||
if (!createFileInVR(controlIp, tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents)) {
|
||||
return new Answer(cmd, false, "Fail to create LB config file in VR");
|
||||
}
|
||||
|
||||
@ -1136,39 +1139,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// list available ethx devices
|
||||
// ls /proc/sys/net/ipv4/conf
|
||||
//
|
||||
private int allocRouterEthDeviceIndex(String domrName, String routerIp) throws Exception {
|
||||
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "ls /proc/sys/net/ipv4/conf");
|
||||
|
||||
if (result.first()) {
|
||||
String[] tokens = result.second().split("\\s+");
|
||||
HashMap<String, String> deviceNames = new HashMap<String, String>();
|
||||
for (String token : tokens) {
|
||||
if (!("all".equalsIgnoreCase(token) || "default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
|
||||
deviceNames.put(token, token);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1;; i++) {
|
||||
if (!deviceNames.containsKey("eth" + i))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// find mac address of a specified ethx device
|
||||
// ip address show ethx | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2
|
||||
// returns
|
||||
// eth0:xx.xx.xx.xx
|
||||
|
||||
//
|
||||
// list IP with eth devices
|
||||
// ifconfig ethx |grep -B1 "inet addr" | awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }'
|
||||
@ -2188,7 +2158,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
args = args + dhcpTo.getRouterIp() + ":" + dhcpTo.getGateway() + ":" + dhcpTo.getNetmask() + ":" + dhcpTo.getStartIpOfSubnet() + "-";
|
||||
}
|
||||
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
|
||||
File keyFile = mgr.getSystemVMKeyFile();
|
||||
mgr.getSystemVMKeyFile();
|
||||
|
||||
try {
|
||||
Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/dnsmasq.sh " + args);
|
||||
@ -3312,32 +3282,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private Map<String, String> validateVmDetails(Map<String, String> vmDetails) {
|
||||
|
||||
Map<String, String> validatedDetails = new HashMap<String, String>();
|
||||
|
||||
if (vmDetails != null && vmDetails.size() > 0) {
|
||||
for (Map.Entry<String, String> entry : vmDetails.entrySet()) {
|
||||
if ("machine.id".equalsIgnoreCase(entry.getKey()))
|
||||
continue;
|
||||
else if ("devices.hotplug".equalsIgnoreCase(entry.getKey()))
|
||||
continue;
|
||||
else if ("RemoteDisplay.vnc.enabled".equalsIgnoreCase(entry.getKey()))
|
||||
continue;
|
||||
else if ("RemoteDisplay.vnc.password".equalsIgnoreCase(entry.getKey()))
|
||||
continue;
|
||||
else if ("RemoteDisplay.vnc.port".equalsIgnoreCase(entry.getKey()))
|
||||
continue;
|
||||
else if ("RemoteDisplay.vnc.keymap".equalsIgnoreCase(entry.getKey()))
|
||||
continue;
|
||||
else
|
||||
validatedDetails.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return validatedDetails;
|
||||
}
|
||||
|
||||
private static NicTO[] sortNicsByDeviceId(NicTO[] nics) {
|
||||
|
||||
List<NicTO> listForSort = new ArrayList<NicTO>();
|
||||
@ -4200,8 +4144,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
VirtualMachineRelocateSpecDiskLocator diskLocator = null;
|
||||
|
||||
boolean isFirstDs = true;
|
||||
String srcDiskName = "";
|
||||
String srcDsName = "";
|
||||
String tgtDsName = "";
|
||||
String tgtDsNfsHost;
|
||||
String tgtDsNfsPath;
|
||||
@ -4240,7 +4182,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
volume = entry.getKey();
|
||||
filerTo = entry.getValue();
|
||||
|
||||
srcDsName = volume.getPoolUuid().replace("-", "");
|
||||
volume.getPoolUuid().replace("-", "");
|
||||
tgtDsName = filerTo.getUuid().replace("-", "");
|
||||
tgtDsNfsHost = filerTo.getHost();
|
||||
tgtDsNfsPath = filerTo.getPath();
|
||||
@ -4267,7 +4209,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
relocateSpec.setDatastore(morDsAtSource);
|
||||
isFirstDs = false;
|
||||
}
|
||||
srcDiskName =
|
||||
VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(new DatastoreMO(srcHyperHost.getContext(), morDsAtSource), vmName, volume.getPath() +
|
||||
".vmdk");
|
||||
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
|
||||
@ -4363,7 +4304,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
List<VirtualMachineRelocateSpecDiskLocator> diskLocators = new ArrayList<VirtualMachineRelocateSpecDiskLocator>();
|
||||
VirtualMachineRelocateSpecDiskLocator diskLocator = null;
|
||||
|
||||
String srcDiskName = "";
|
||||
String tgtDsName = "";
|
||||
|
||||
try {
|
||||
@ -4387,7 +4327,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
throw new Exception(msg);
|
||||
}
|
||||
|
||||
srcDiskName =
|
||||
VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(new DatastoreMO(srcHyperHost.getContext(), morDs), vmName, volumePath + ".vmdk");
|
||||
diskLocator = new VirtualMachineRelocateSpecDiskLocator();
|
||||
diskLocator.setDatastore(morDs);
|
||||
@ -6456,7 +6395,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
PerfCounterInfo rxPerfCounterInfo = null;
|
||||
PerfCounterInfo txPerfCounterInfo = null;
|
||||
|
||||
List<PerfCounterInfo> cInfo = (List<PerfCounterInfo>)getServiceContext().getVimClient().getDynamicProperty(perfMgr, "perfCounter");
|
||||
List<PerfCounterInfo> cInfo = getServiceContext().getVimClient().getDynamicProperty(perfMgr, "perfCounter");
|
||||
for (PerfCounterInfo info : cInfo) {
|
||||
if ("net".equalsIgnoreCase(info.getGroupInfo().getKey())) {
|
||||
if ("transmitted".equalsIgnoreCase(info.getNameInfo().getKey())) {
|
||||
@ -6497,7 +6436,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
maxCpuUsage = objProp.getVal().toString();
|
||||
}
|
||||
}
|
||||
VirtualMachineMO vmMo = new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
|
||||
new VirtualMachineMO(hyperHost.getContext(), oc.getObj());
|
||||
if (vmInternalCSName != null) {
|
||||
name = vmInternalCSName;
|
||||
} else {
|
||||
@ -6511,7 +6450,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
ManagedObjectReference vmMor = hyperHost.findVmOnHyperHost(name).getMor();
|
||||
assert (vmMor != null);
|
||||
|
||||
ArrayList vmNetworkMetrics = new ArrayList();
|
||||
ArrayList<PerfMetricId> vmNetworkMetrics = new ArrayList<PerfMetricId>();
|
||||
// get all the metrics from the available sample period
|
||||
List<PerfMetricId> perfMetrics = service.queryAvailablePerfMetric(perfMgr, vmMor, null, null, null);
|
||||
if (perfMetrics != null) {
|
||||
@ -6530,7 +6469,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
if (vmNetworkMetrics.size() != 0) {
|
||||
PerfQuerySpec qSpec = new PerfQuerySpec();
|
||||
qSpec.setEntity(vmMor);
|
||||
PerfMetricId[] availableMetricIds = (PerfMetricId[])vmNetworkMetrics.toArray(new PerfMetricId[0]);
|
||||
PerfMetricId[] availableMetricIds = vmNetworkMetrics.toArray(new PerfMetricId[0]);
|
||||
qSpec.getMetricId().addAll(Arrays.asList(availableMetricIds));
|
||||
List<PerfQuerySpec> qSpecs = new ArrayList<PerfQuerySpec>();
|
||||
qSpecs.add(qSpec);
|
||||
@ -7017,9 +6956,4 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
||||
return new Answer(cmd, false, msg);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isVMWareToolsInstalled(VirtualMachineMO vmMo) throws Exception {
|
||||
GuestInfo guestInfo = vmMo.getVmGuestInfo();
|
||||
return (guestInfo != null && guestInfo.getGuestState() != null && guestInfo.getGuestState().equalsIgnoreCase("running"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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