bug CS-14964: use shorter UUID for datastore names

This commit is contained in:
Kelven Yang 2012-05-24 15:02:42 -07:00
parent b6e5530a0b
commit 1e84fa4b12
3 changed files with 534 additions and 528 deletions

View File

@ -39,6 +39,7 @@ import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.hypervisor.vmware.mo.CustomFieldConstants; import com.cloud.hypervisor.vmware.mo.CustomFieldConstants;
import com.cloud.hypervisor.vmware.mo.DatacenterMO; import com.cloud.hypervisor.vmware.mo.DatacenterMO;
import com.cloud.hypervisor.vmware.mo.DatastoreMO; import com.cloud.hypervisor.vmware.mo.DatastoreMO;
import com.cloud.hypervisor.vmware.mo.HypervisorHostHelper;
import com.cloud.hypervisor.vmware.mo.VirtualMachineMO; import com.cloud.hypervisor.vmware.mo.VirtualMachineMO;
import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost; import com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost;
import com.cloud.hypervisor.vmware.util.VmwareContext; import com.cloud.hypervisor.vmware.util.VmwareContext;
@ -122,11 +123,11 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter()); DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true); VirtualMachineMO templateMo = VmwareHelper.pickOneVmOnRunningHost(dcMo.findVmByNameAndLabel(templateUuidName), true);
if (templateMo == null) { if (templateMo == null) {
if(s_logger.isInfoEnabled()) if(s_logger.isInfoEnabled())
s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName); s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getPoolUuid()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
assert (morDs != null); assert (morDs != null);
DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs); DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);
@ -170,10 +171,9 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
VmwareContext context = hostService.getServiceContext(cmd); VmwareContext context = hostService.getServiceContext(cmd);
VirtualMachineMO vmMo = null; VirtualMachineMO vmMo = null;
try {
try { VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd); morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());
morDs = hyperHost.findDatastore(cmd.getPool().getUuid());
try { try {
vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName()); vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
@ -340,79 +340,79 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath, hyperHost, cmd, vmName, volumeId, cmd.getPool().getUuid(), volumePath,
secondaryStorageURL, secondaryStorageURL,
hostService.getWorkerName(context, cmd, 0)); hostService.getWorkerName(context, cmd, 0));
} else { } else {
StorageFilerTO poolTO = cmd.getPool(); StorageFilerTO poolTO = cmd.getPool();
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
if (morDatastore == null) {
morDatastore = hyperHost.mountDatastore(
false,
poolTO.getHost(), 0, poolTO.getPath(),
poolTO.getUuid().replace("-", ""));
if (morDatastore == null) {
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
}
}
result = copyVolumeFromSecStorage(
hyperHost, volumeId,
new DatastoreMO(context, morDatastore),
secondaryStorageURL, volumePath);
}
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second());
} catch (Throwable e) {
if (e instanceof RemoteException) {
hostService.invalidateServiceContext(context);
}
ManagedObjectReference morDatastore = hyperHost.findDatastore(poolTO.getUuid()); String msg = "Unable to execute CopyVolumeCommand due to exception";
if (morDatastore == null) { s_logger.error(msg, e);
morDatastore = hyperHost.mountDatastore( return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null);
false, }
poolTO.getHost(), 0, poolTO.getPath(), }
poolTO.getUuid());
@Override
if (morDatastore == null) { public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) {
throw new Exception("Unable to mount storage pool on host. storeUrl: " + poolTO.getHost() + ":/" + poolTO.getPath());
} String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel();
} Long accountId = cmd.getAccountId();
Long volumeId = cmd.getVolumeId();
result = copyVolumeFromSecStorage( String secondaryStorageUrl = cmd.getSecondaryStorageUrl();
hyperHost, volumeId, String backedUpSnapshotUuid = cmd.getSnapshotUuid();
new DatastoreMO(context, morDatastore),
secondaryStorageURL, volumePath); String details = null;
} boolean success = false;
return new CopyVolumeAnswer(cmd, true, null, result.first(), result.second()); String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
} catch (Throwable e) {
if (e instanceof RemoteException) { VmwareContext context = hostService.getServiceContext(cmd);
hostService.invalidateServiceContext(context); try {
} VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
String msg = "Unable to execute CopyVolumeCommand due to exception"; ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, primaryStorageNameLabel);
s_logger.error(msg, e); if (morPrimaryDs == null) {
return new CopyVolumeAnswer(cmd, false, "CopyVolumeCommand failed due to exception: " + StringUtils.getExceptionStackInfo(e), null, null); String msg = "Unable to find datastore: " + primaryStorageNameLabel;
} s_logger.error(msg);
} throw new Exception(msg);
}
@Override
public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCommand cmd) { DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel(); newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
Long accountId = cmd.getAccountId(); if (details == null) {
Long volumeId = cmd.getVolumeId(); success = true;
String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); }
String backedUpSnapshotUuid = cmd.getSnapshotUuid(); } catch (Throwable e) {
if (e instanceof RemoteException) {
String details = null; hostService.invalidateServiceContext(context);
boolean success = false; }
String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");
s_logger.error("Unexpecpted exception ", e);
VmwareContext context = hostService.getServiceContext(cmd); details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
try { }
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
ManagedObjectReference morPrimaryDs = hyperHost.findDatastore(primaryStorageNameLabel); }
if (morPrimaryDs == null) {
String msg = "Unable to find datastore: " + primaryStorageNameLabel;
s_logger.error(msg);
throw new Exception(msg);
}
DatastoreMO primaryDsMo = new DatastoreMO(hyperHost.getContext(), morPrimaryDs);
details = createVolumeFromSnapshot(hyperHost, primaryDsMo,
newVolumeName, accountId, volumeId, secondaryStorageUrl, backedUpSnapshotUuid);
if (details == null) {
success = true;
}
} catch (Throwable e) {
if (e instanceof RemoteException) {
hostService.invalidateServiceContext(context);
}
s_logger.error("Unexpecpted exception ", e);
details = "CreateVolumeFromSnapshotCommand exception: " + StringUtils.getExceptionStackInfo(e);
}
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
}
// templateName: name in secondary storage // templateName: name in secondary storage
// templateUuid: will be used at hypervisor layer // templateUuid: will be used at hypervisor layer
@ -783,7 +783,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
String exportName = UUID.randomUUID().toString(); String exportName = UUID.randomUUID().toString();
try { try {
ManagedObjectReference morDs = hyperHost.findDatastore(poolId); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId);
if (morDs == null) { if (morDs == null) {
String msg = "Unable to find volumes's storage pool for copy volume operation"; String msg = "Unable to find volumes's storage pool for copy volume operation";

View File

@ -1639,7 +1639,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (vol.getType() != Volume.Type.ISO) { if (vol.getType() != Volume.Type.ISO) {
String poolUuid = vol.getPoolUuid(); String poolUuid = vol.getPoolUuid();
if(poolMors.get(poolUuid) == null) { if(poolMors.get(poolUuid) == null) {
ManagedObjectReference morDataStore = hyperHost.findDatastore(poolUuid); ManagedObjectReference morDataStore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolUuid);
if (morDataStore == null) { if (morDataStore == null) {
String msg = "Failed to get the mounted datastore for the volume's pool " + poolUuid; String msg = "Failed to get the mounted datastore for the volume's pool " + poolUuid;
s_logger.error(msg); s_logger.error(msg);
@ -2303,127 +2303,128 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if (pool.getType() != StoragePoolType.NetworkFilesystem && pool.getType() != StoragePoolType.VMFS) { if (pool.getType() != StoragePoolType.NetworkFilesystem && pool.getType() != StoragePoolType.VMFS) {
throw new Exception("Unsupported storage pool type " + pool.getType()); throw new Exception("Unsupported storage pool type " + pool.getType());
} }
ManagedObjectReference morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid()); ManagedObjectReference morDatastore = hyperHost.mountDatastore(pool.getType() == StoragePoolType.VMFS, pool.getHost(),
pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""));
assert (morDatastore != null);
DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary(); assert (morDatastore != null);
long capacity = summary.getCapacity(); DatastoreSummary summary = new DatastoreMO(getServiceContext(), morDatastore).getSummary();
long available = summary.getFreeSpace(); long capacity = summary.getCapacity();
Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>(); long available = summary.getFreeSpace();
ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, available, tInfo); Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
return answer; ModifyStoragePoolAnswer answer = new ModifyStoragePoolAnswer(cmd, capacity, available, tInfo);
} catch (Throwable e) { return answer;
if (e instanceof RemoteException) { } catch (Throwable e) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); if (e instanceof RemoteException) {
invalidateServiceContext(); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
} invalidateServiceContext();
}
String msg = "ModifyStoragePoolCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e); String msg = "ModifyStoragePoolCommand failed due to " + VmwareHelper.getExceptionMessage(e);
return new Answer(cmd, false, msg); s_logger.error(msg, e);
} return new Answer(cmd, false, msg);
} }
}
protected Answer execute(DeleteStoragePoolCommand cmd) {
if (s_logger.isInfoEnabled()) { protected Answer execute(DeleteStoragePoolCommand cmd) {
s_logger.info("Executing resource DeleteStoragePoolCommand: " + _gson.toJson(cmd)); if (s_logger.isInfoEnabled()) {
} s_logger.info("Executing resource DeleteStoragePoolCommand: " + _gson.toJson(cmd));
}
StorageFilerTO pool = cmd.getPool();
StorageFilerTO pool = cmd.getPool();
try { try {
// We will leave datastore cleanup management to vCenter. Since for cluster VMFS datastore, it will always // We will leave datastore cleanup management to vCenter. Since for cluster VMFS datastore, it will always
// be mounted by vCenter. // be mounted by vCenter.
// VmwareHypervisorHost hyperHost = this.getHyperHost(getServiceContext()); // VmwareHypervisorHost hyperHost = this.getHyperHost(getServiceContext());
// hyperHost.unmountDatastore(pool.getUuid()); // hyperHost.unmountDatastore(pool.getUuid());
Answer answer = new Answer(cmd, true, "success"); Answer answer = new Answer(cmd, true, "success");
return answer; return answer;
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String msg = "DeleteStoragePoolCommand (pool: " + pool.getHost() + ", path: " + pool.getPath() + ") failed due to " + VmwareHelper.getExceptionMessage(e); String msg = "DeleteStoragePoolCommand (pool: " + pool.getHost() + ", path: " + pool.getPath() + ") failed due to " + VmwareHelper.getExceptionMessage(e);
return new Answer(cmd, false, msg); return new Answer(cmd, false, msg);
} }
} }
protected Answer execute(AttachVolumeCommand cmd) { protected Answer execute(AttachVolumeCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource AttachVolumeCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource AttachVolumeCommand: " + _gson.toJson(cmd));
} }
/* /*
* AttachVolumeCommand { "attach":true,"vmName":"i-2-1-KY","pooltype":"NetworkFilesystem", * AttachVolumeCommand { "attach":true,"vmName":"i-2-1-KY","pooltype":"NetworkFilesystem",
* "volumeFolder":"/export/home/kelven/vmware-test/primary", "volumePath":"uuid", * "volumeFolder":"/export/home/kelven/vmware-test/primary", "volumePath":"uuid",
* "volumeName":"volume name","deviceId":1 } * "volumeName":"volume name","deviceId":1 }
*/ */
try { try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName()); VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
if (vmMo == null) { if (vmMo == null) {
String msg = "Unable to find the VM to execute AttachVolumeCommand, vmName: " + cmd.getVmName(); String msg = "Unable to find the VM to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
s_logger.error(msg); s_logger.error(msg);
throw new Exception(msg); throw new Exception(msg);
} }
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getPoolUuid()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
if (morDs == null) { if (morDs == null) {
String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName(); String msg = "Unable to find the mounted datastore to execute AttachVolumeCommand, vmName: " + cmd.getVmName();
s_logger.error(msg); s_logger.error(msg);
throw new Exception(msg); throw new Exception(msg);
} }
DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDs); DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDs);
String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), cmd.getVolumePath()); String datastoreVolumePath = String.format("[%s] %s.vmdk", dsMo.getName(), cmd.getVolumePath());
AttachVolumeAnswer answer = new AttachVolumeAnswer(cmd, cmd.getDeviceId()); AttachVolumeAnswer answer = new AttachVolumeAnswer(cmd, cmd.getDeviceId());
if (cmd.getAttach()) { if (cmd.getAttach()) {
vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs); vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
} else { } else {
vmMo.removeAllSnapshots(); vmMo.removeAllSnapshots();
vmMo.detachDisk(datastoreVolumePath, false); vmMo.detachDisk(datastoreVolumePath, false);
} }
return answer; return answer;
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String msg = "AttachVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e); String msg = "AttachVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e); s_logger.error(msg, e);
return new AttachVolumeAnswer(cmd, msg); return new AttachVolumeAnswer(cmd, msg);
} }
} }
protected Answer execute(AttachIsoCommand cmd) { protected Answer execute(AttachIsoCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource AttachIsoCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource AttachIsoCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName()); VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
if (vmMo == null) { if (vmMo == null) {
String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName(); String msg = "Unable to find VM in vSphere to execute AttachIsoCommand, vmName: " + cmd.getVmName();
s_logger.error(msg); s_logger.error(msg);
throw new Exception(msg); throw new Exception(msg);
} }
String storeUrl = cmd.getStoreUrl(); String storeUrl = cmd.getStoreUrl();
if (storeUrl == null) { if (storeUrl == null) {
if (!cmd.getIsoPath().equalsIgnoreCase("vmware-tools.iso")) { if (!cmd.getIsoPath().equalsIgnoreCase("vmware-tools.iso")) {
String msg = "ISO store root url is not found in AttachIsoCommand"; String msg = "ISO store root url is not found in AttachIsoCommand";
s_logger.error(msg); s_logger.error(msg);
throw new Exception(msg); throw new Exception(msg);
} else { } else {
if (cmd.isAttach()) { if (cmd.isAttach()) {
vmMo.mountToolsInstaller(); vmMo.mountToolsInstaller();
} else { } else {
vmMo.unmountToolsInstaller(); vmMo.unmountToolsInstaller();
} }
@ -2470,224 +2471,223 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
String msg = "AttachIsoCommand(detach) failed due to " + VmwareHelper.getExceptionMessage(e); String msg = "AttachIsoCommand(detach) failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.warn(msg, e); s_logger.warn(msg, e);
return new Answer(cmd, false, msg); return new Answer(cmd, false, msg);
} }
} }
} }
private synchronized ManagedObjectReference prepareSecondaryDatastoreOnHost(String storeUrl) throws Exception { private synchronized ManagedObjectReference prepareSecondaryDatastoreOnHost(String storeUrl) throws Exception {
String storeName = getSecondaryDatastoreUUID(storeUrl); String storeName = getSecondaryDatastoreUUID(storeUrl);
URI uri = new URI(storeUrl); URI uri = new URI(storeUrl);
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext()); VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName); ManagedObjectReference morDatastore = hyperHost.mountDatastore(false, uri.getHost(), 0, uri.getPath(), storeName.replace("-", ""));
if (morDatastore == null) { if (morDatastore == null)
throw new Exception("Unable to mount secondary storage on host. storeUrl: " + storeUrl); throw new Exception("Unable to mount secondary storage on host. storeUrl: " + storeUrl);
}
return morDatastore;
return morDatastore; }
}
private static String getSecondaryDatastoreUUID(String storeUrl) {
private static String getSecondaryDatastoreUUID(String storeUrl) { return UUID.nameUUIDFromBytes(storeUrl.getBytes()).toString();
return UUID.nameUUIDFromBytes(storeUrl.getBytes()).toString(); }
}
protected Answer execute(ValidateSnapshotCommand cmd) {
protected Answer execute(ValidateSnapshotCommand cmd) { if (s_logger.isInfoEnabled()) {
if (s_logger.isInfoEnabled()) { s_logger.info("Executing resource ValidateSnapshotCommand: " + _gson.toJson(cmd));
s_logger.info("Executing resource ValidateSnapshotCommand: " + _gson.toJson(cmd)); }
}
// the command is no longer available
// the command is no longer available String expectedSnapshotBackupUuid = null;
String expectedSnapshotBackupUuid = null; String actualSnapshotBackupUuid = null;
String actualSnapshotBackupUuid = null; String actualSnapshotUuid = null;
String actualSnapshotUuid = null; return new ValidateSnapshotAnswer(cmd, false, "ValidateSnapshotCommand is not supported for vmware yet", expectedSnapshotBackupUuid, actualSnapshotBackupUuid, actualSnapshotUuid);
return new ValidateSnapshotAnswer(cmd, false, "ValidateSnapshotCommand is not supported for vmware yet", expectedSnapshotBackupUuid, actualSnapshotBackupUuid, actualSnapshotUuid); }
}
protected Answer execute(ManageSnapshotCommand cmd) {
protected Answer execute(ManageSnapshotCommand cmd) { if (s_logger.isInfoEnabled()) {
if (s_logger.isInfoEnabled()) { s_logger.info("Executing resource ManageSnapshotCommand: " + _gson.toJson(cmd));
s_logger.info("Executing resource ManageSnapshotCommand: " + _gson.toJson(cmd)); }
}
long snapshotId = cmd.getSnapshotId();
long snapshotId = cmd.getSnapshotId();
/*
/* * "ManageSnapshotCommand",
* "ManageSnapshotCommand", * "{\"_commandSwitch\":\"-c\",\"_volumePath\":\"i-2-3-KY-ROOT\",\"_snapshotName\":\"i-2-3-KY_i-2-3-KY-ROOT_20101102203827\",\"_snapshotId\":1,\"_vmName\":\"i-2-3-KY\"}"
* "{\"_commandSwitch\":\"-c\",\"_volumePath\":\"i-2-3-KY-ROOT\",\"_snapshotName\":\"i-2-3-KY_i-2-3-KY-ROOT_20101102203827\",\"_snapshotId\":1,\"_vmName\":\"i-2-3-KY\"}" */
*/ boolean success = false;
boolean success = false; String cmdSwitch = cmd.getCommandSwitch();
String cmdSwitch = cmd.getCommandSwitch(); String snapshotOp = "Unsupported snapshot command." + cmdSwitch;
String snapshotOp = "Unsupported snapshot command." + cmdSwitch; if (cmdSwitch.equals(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
if (cmdSwitch.equals(ManageSnapshotCommand.CREATE_SNAPSHOT)) { snapshotOp = "create";
snapshotOp = "create"; } else if (cmdSwitch.equals(ManageSnapshotCommand.DESTROY_SNAPSHOT)) {
} else if (cmdSwitch.equals(ManageSnapshotCommand.DESTROY_SNAPSHOT)) { snapshotOp = "destroy";
snapshotOp = "destroy"; }
}
String details = "ManageSnapshotCommand operation: " + snapshotOp + " Failed for snapshotId: " + snapshotId;
String details = "ManageSnapshotCommand operation: " + snapshotOp + " Failed for snapshotId: " + snapshotId; String snapshotUUID = null;
String snapshotUUID = null;
// snapshot operation (create or destroy) is handled inside BackupSnapshotCommand(), we just fake // snapshot operation (create or destroy) is handled inside BackupSnapshotCommand(), we just fake
// a success return here // a success return here
snapshotUUID = UUID.randomUUID().toString(); snapshotUUID = UUID.randomUUID().toString();
success = true; success = true;
details = null; details = null;
return new ManageSnapshotAnswer(cmd, snapshotId, snapshotUUID, success, details); return new ManageSnapshotAnswer(cmd, snapshotId, snapshotUUID, success, details);
} }
protected Answer execute(BackupSnapshotCommand cmd) { protected Answer execute(BackupSnapshotCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource BackupSnapshotCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource BackupSnapshotCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd); return mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String details = "BackupSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e); String details = "BackupSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(details, e); s_logger.error(details, e);
return new BackupSnapshotAnswer(cmd, false, details, null, true); return new BackupSnapshotAnswer(cmd, false, details, null, true);
} }
} }
protected Answer execute(CreateVolumeFromSnapshotCommand cmd) { protected Answer execute(CreateVolumeFromSnapshotCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource CreateVolumeFromSnapshotCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource CreateVolumeFromSnapshotCommand: " + _gson.toJson(cmd));
} }
String details = null; String details = null;
boolean success = false; boolean success = false;
String newVolumeName = UUID.randomUUID().toString(); String newVolumeName = UUID.randomUUID().toString();
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd); return mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
details = "CreateVolumeFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e); details = "CreateVolumeFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(details, e); s_logger.error(details, e);
} }
return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName); return new CreateVolumeFromSnapshotAnswer(cmd, success, details, newVolumeName);
} }
protected Answer execute(CreatePrivateTemplateFromVolumeCommand cmd) { protected Answer execute(CreatePrivateTemplateFromVolumeCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource CreatePrivateTemplateFromVolumeCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource CreatePrivateTemplateFromVolumeCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd); return mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String details = "CreatePrivateTemplateFromVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e); String details = "CreatePrivateTemplateFromVolumeCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(details, e); s_logger.error(details, e);
return new CreatePrivateTemplateAnswer(cmd, false, details); return new CreatePrivateTemplateAnswer(cmd, false, details);
} }
} }
protected Answer execute(final UpgradeSnapshotCommand cmd) { protected Answer execute(final UpgradeSnapshotCommand cmd) {
return new Answer(cmd, true, "success"); return new Answer(cmd, true, "success");
} }
protected Answer execute(CreatePrivateTemplateFromSnapshotCommand cmd) { protected Answer execute(CreatePrivateTemplateFromSnapshotCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource CreatePrivateTemplateFromSnapshotCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource CreatePrivateTemplateFromSnapshotCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return mgr.getStorageManager().execute(this, cmd); return mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String details = "CreatePrivateTemplateFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e); String details = "CreatePrivateTemplateFromSnapshotCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(details, e); s_logger.error(details, e);
return new CreatePrivateTemplateAnswer(cmd, false, details); return new CreatePrivateTemplateAnswer(cmd, false, details);
} }
} }
protected Answer execute(GetStorageStatsCommand cmd) { protected Answer execute(GetStorageStatsCommand cmd) {
if (s_logger.isTraceEnabled()) { if (s_logger.isTraceEnabled()) {
s_logger.trace("Executing resource GetStorageStatsCommand: " + _gson.toJson(cmd)); s_logger.trace("Executing resource GetStorageStatsCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
ManagedObjectReference morDs = hyperHost.findDatastore(cmd.getStorageId()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getStorageId());
if (morDs != null) { if (morDs != null) {
DatastoreMO datastoreMo = new DatastoreMO(context, morDs); DatastoreMO datastoreMo = new DatastoreMO(context, morDs);
DatastoreSummary summary = datastoreMo.getSummary(); DatastoreSummary summary = datastoreMo.getSummary();
assert (summary != null); assert (summary != null);
long capacity = summary.getCapacity(); long capacity = summary.getCapacity();
long free = summary.getFreeSpace(); long free = summary.getFreeSpace();
long used = capacity - free; long used = capacity - free;
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Datastore summary info, storageId: " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ", capacity: " + capacity s_logger.debug("Datastore summary info, storageId: " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ", capacity: " + capacity
+ ", free: " + free + ", used: " + used); + ", free: " + free + ", used: " + used);
} }
if (summary.getCapacity() <= 0) { if (summary.getCapacity() <= 0) {
s_logger.warn("Something is wrong with vSphere NFS datastore, rebooting ESX(ESXi) host should help"); s_logger.warn("Something is wrong with vSphere NFS datastore, rebooting ESX(ESXi) host should help");
} }
return new GetStorageStatsAnswer(cmd, capacity, used); return new GetStorageStatsAnswer(cmd, capacity, used);
} else { } else {
String msg = "Could not find datastore for GetStorageStatsCommand storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype(); String msg = "Could not find datastore for GetStorageStatsCommand storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype();
s_logger.error(msg); s_logger.error(msg);
return new GetStorageStatsAnswer(cmd, msg); return new GetStorageStatsAnswer(cmd, msg);
} }
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String msg = "Unable to execute GetStorageStatsCommand(storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ") due to " String msg = "Unable to execute GetStorageStatsCommand(storageId : " + cmd.getStorageId() + ", localPath: " + cmd.getLocalPath() + ", poolType: " + cmd.getPooltype() + ") due to "
+ VmwareHelper.getExceptionMessage(e); + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e); s_logger.error(msg, e);
return new GetStorageStatsAnswer(cmd, msg); return new GetStorageStatsAnswer(cmd, msg);
} }
} }
protected Answer execute(GetVncPortCommand cmd) { protected Answer execute(GetVncPortCommand cmd) {
if (s_logger.isTraceEnabled()) { if (s_logger.isTraceEnabled()) {
s_logger.trace("Executing resource GetVncPortCommand: " + _gson.toJson(cmd)); s_logger.trace("Executing resource GetVncPortCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
assert(hyperHost instanceof HostMO); assert(hyperHost instanceof HostMO);
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
@ -2756,74 +2756,74 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
} }
protected Answer execute(ModifySshKeysCommand cmd) { protected Answer execute(ModifySshKeysCommand cmd) {
//do not log the command contents for this command. do NOT log the ssh keys //do not log the command contents for this command. do NOT log the ssh keys
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource ModifySshKeysCommand."); s_logger.info("Executing resource ModifySshKeysCommand.");
} }
return new Answer(cmd); return new Answer(cmd);
} }
protected Answer execute(PoolEjectCommand cmd) { protected Answer execute(PoolEjectCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource PoolEjectCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource PoolEjectCommand: " + _gson.toJson(cmd));
} }
return new Answer(cmd, false, "PoolEjectCommand is not available for vmware"); return new Answer(cmd, false, "PoolEjectCommand is not available for vmware");
} }
@Override @Override
public PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd) { public PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource PrimaryStorageDownloadCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource PrimaryStorageDownloadCommand: " + _gson.toJson(cmd));
} }
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
return (PrimaryStorageDownloadAnswer) mgr.getStorageManager().execute(this, cmd); return (PrimaryStorageDownloadAnswer) mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) { } catch (Throwable e) {
if (e instanceof RemoteException) { if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context"); s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
invalidateServiceContext(); invalidateServiceContext();
} }
String msg = "PrimaryStorageDownloadCommand failed due to " + VmwareHelper.getExceptionMessage(e); String msg = "PrimaryStorageDownloadCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.error(msg, e); s_logger.error(msg, e);
return new PrimaryStorageDownloadAnswer(msg); return new PrimaryStorageDownloadAnswer(msg);
} }
} }
@Override @Override
public Answer execute(DestroyCommand cmd) { public Answer execute(DestroyCommand cmd) {
if (s_logger.isInfoEnabled()) { if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource DestroyCommand: " + _gson.toJson(cmd)); s_logger.info("Executing resource DestroyCommand: " + _gson.toJson(cmd));
} }
/* /*
* DestroyCommand content example * DestroyCommand content example
* *
* {"volume": {"id":5,"name":"Volume1", "mountPoint":"/export/home/kelven/vmware-test/primary", * {"volume": {"id":5,"name":"Volume1", "mountPoint":"/export/home/kelven/vmware-test/primary",
* "path":"6bb8762f-c34c-453c-8e03-26cc246ceec4", "size":0,"type":"DATADISK","resourceType": * "path":"6bb8762f-c34c-453c-8e03-26cc246ceec4", "size":0,"type":"DATADISK","resourceType":
* "STORAGE_POOL","storagePoolType":"NetworkFilesystem", "poolId":0,"deviceId":0 } } * "STORAGE_POOL","storagePoolType":"NetworkFilesystem", "poolId":0,"deviceId":0 } }
* *
* {"volume": {"id":1, "name":"i-2-1-KY-ROOT", "mountPoint":"/export/home/kelven/vmware-test/primary", * {"volume": {"id":1, "name":"i-2-1-KY-ROOT", "mountPoint":"/export/home/kelven/vmware-test/primary",
* "path":"i-2-1-KY-ROOT","size":0,"type":"ROOT", "resourceType":"STORAGE_POOL", "storagePoolType":"NetworkFilesystem", * "path":"i-2-1-KY-ROOT","size":0,"type":"ROOT", "resourceType":"STORAGE_POOL", "storagePoolType":"NetworkFilesystem",
* "poolId":0,"deviceId":0 } } * "poolId":0,"deviceId":0 } }
*/ */
try { try {
VmwareContext context = getServiceContext(); VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
VolumeTO vol = cmd.getVolume(); VolumeTO vol = cmd.getVolume();
ManagedObjectReference morDs = hyperHost.findDatastore(vol.getPoolUuid()); ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, vol.getPoolUuid());
if (morDs == null) { if (morDs == null) {
String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint(); String msg = "Unable to find datastore based on volume mount point " + cmd.getVolume().getMountPoint();
s_logger.error(msg); s_logger.error(msg);
throw new Exception(msg); throw new Exception(msg);
} }
DatastoreMO dsMo = new DatastoreMO(context, morDs); DatastoreMO dsMo = new DatastoreMO(context, morDs);
ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter(); ManagedObjectReference morDc = hyperHost.getHyperHostDatacenter();
@ -2980,18 +2980,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
VmwareHypervisorHost hyperHost = getHyperHost(context); VmwareHypervisorHost hyperHost = getHyperHost(context);
DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter()); DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
VmwareManager vmwareMgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME); ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
if (morDatastore == null)
ManagedObjectReference morDatastore = hyperHost.findDatastore(pool.getUuid()); throw new Exception("Unable to find datastore in vSphere");
if (morDatastore == null) {
throw new Exception("Unable to find datastore in vSphere"); DatastoreMO dsMo = new DatastoreMO(context, morDatastore);
}
DatastoreMO dsMo = new DatastoreMO(context, morDatastore); if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) {
if (cmd.getTemplateUrl() == null) {
if (cmd.getDiskCharacteristics().getType() == Volume.Type.ROOT) { // create a root volume for blank VM
if (cmd.getTemplateUrl() == null) { String dummyVmName = getWorkerName(context, cmd, 0);
// create a root volume for blank VM
String dummyVmName = getWorkerName(context, cmd, 0);
VirtualMachineMO vmMo = null; VirtualMachineMO vmMo = null;
try { try {

View File

@ -43,42 +43,50 @@ import com.vmware.vim25.VirtualMachineConfigSpec;
import com.vmware.vim25.VirtualMachineFileInfo; import com.vmware.vim25.VirtualMachineFileInfo;
import com.vmware.vim25.VirtualMachineVideoCard; import com.vmware.vim25.VirtualMachineVideoCard;
import com.vmware.vim25.VirtualSCSISharing; import com.vmware.vim25.VirtualSCSISharing;
public class HypervisorHostHelper { public class HypervisorHostHelper {
private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class); private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600; private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600;
// make vmware-base loosely coupled with cloud-specific stuff, duplicate VLAN.UNTAGGED constant here // make vmware-base loosely coupled with cloud-specific stuff, duplicate VLAN.UNTAGGED constant here
private static final String UNTAGGED_VLAN_NAME = "untagged"; private static final String UNTAGGED_VLAN_NAME = "untagged";
public static VirtualMachineMO findVmFromObjectContent(VmwareContext context, public static VirtualMachineMO findVmFromObjectContent(VmwareContext context,
ObjectContent[] ocs, String name) { ObjectContent[] ocs, String name) {
if(ocs != null && ocs.length > 0) { if(ocs != null && ocs.length > 0) {
for(ObjectContent oc : ocs) { for(ObjectContent oc : ocs) {
DynamicProperty prop = oc.getPropSet(0); DynamicProperty prop = oc.getPropSet(0);
assert(prop != null); assert(prop != null);
if(prop.getVal().toString().equals(name)) if(prop.getVal().toString().equals(name))
return new VirtualMachineMO(context, oc.getObj()); return new VirtualMachineMO(context, oc.getObj());
} }
} }
return null; return null;
} }
public static DatastoreMO getHyperHostDatastoreMO(VmwareHypervisorHost hyperHost, String datastoreName) throws Exception { public static ManagedObjectReference findDatastoreWithBackwardsCompatibility(VmwareHypervisorHost hyperHost, String uuidName) throws Exception {
ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} ); ManagedObjectReference morDs = hyperHost.findDatastore(uuidName.replace("-", ""));
if(ocs != null && ocs.length > 0) { if(morDs == null)
for(ObjectContent oc : ocs) { morDs = hyperHost.findDatastore(uuidName);
DynamicProperty[] objProps = oc.getPropSet();
if(objProps != null) { return morDs;
for(DynamicProperty objProp : objProps) { }
if(objProp.getVal().toString().equals(datastoreName))
return new DatastoreMO(hyperHost.getContext(), oc.getObj()); public static DatastoreMO getHyperHostDatastoreMO(VmwareHypervisorHost hyperHost, String datastoreName) throws Exception {
} ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} );
} if(ocs != null && ocs.length > 0) {
} for(ObjectContent oc : ocs) {
} DynamicProperty[] objProps = oc.getPropSet();
return null; if(objProps != null) {
for(DynamicProperty objProp : objProps) {
if(objProp.getVal().toString().equals(datastoreName))
return new DatastoreMO(hyperHost.getContext(), oc.getObj());
}
}
}
}
return null;
} }
public static String getPublicNetworkNamePrefix(String vlanId) { public static String getPublicNetworkNamePrefix(String vlanId) {