mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix a bug in converting Enum type to String.
This commit is contained in:
parent
105bf7134a
commit
640fa6be76
@ -192,7 +192,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
workerVMName = hostService.getWorkerName(context, cmd, 0);
|
workerVMName = hostService.getWorkerName(context, cmd, 0);
|
||||||
|
|
||||||
// attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
|
// attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
|
||||||
if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString(), morDs, false)) {
|
if (!hyperHost.createBlankVm(workerVMName, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier.OTHER_GUEST.value(), morDs, false)) {
|
||||||
String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
|
String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
@ -804,7 +804,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||||||
vmConfig.setName(workerVmName);
|
vmConfig.setName(workerVmName);
|
||||||
vmConfig.setMemoryMB((long) 4);
|
vmConfig.setMemoryMB((long) 4);
|
||||||
vmConfig.setNumCPUs(1);
|
vmConfig.setNumCPUs(1);
|
||||||
vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString());
|
vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
|
||||||
VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
|
VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
|
||||||
fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
|
fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
|
||||||
vmConfig.setFiles(fileInfo);
|
vmConfig.setFiles(fileInfo);
|
||||||
|
|||||||
@ -2094,7 +2094,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
|
|
||||||
if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
||||||
getReserveCpuMHz(vmSpec.getSpeed().intValue()), vmSpec.getLimitCpuUse(), ramMb, getReserveMemMB(ramMb),
|
getReserveCpuMHz(vmSpec.getSpeed().intValue()), vmSpec.getLimitCpuUse(), ramMb, getReserveMemMB(ramMb),
|
||||||
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), rootDiskDataStoreDetails.first(), false)) {
|
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), rootDiskDataStoreDetails.first(), false)) {
|
||||||
throw new Exception("Failed to create VM. vmName: " + vmName);
|
throw new Exception("Failed to create VM. vmName: " + vmName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2126,7 +2126,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
int ramMb = (int) (vmSpec.getMinRam() / (1024 * 1024));
|
int ramMb = (int) (vmSpec.getMinRam() / (1024 * 1024));
|
||||||
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
|
||||||
getReserveCpuMHz(vmSpec.getSpeed().intValue()), ramMb, getReserveMemMB(ramMb),
|
getReserveCpuMHz(vmSpec.getSpeed().intValue()), ramMb, getReserveMemMB(ramMb),
|
||||||
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).toString(), vmSpec.getLimitCpuUse());
|
translateGuestOsIdentifier(vmSpec.getArch(), vmSpec.getOs()).value(), vmSpec.getLimitCpuUse());
|
||||||
|
|
||||||
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
|
VirtualDeviceConfigSpec[] deviceConfigSpecArray = new VirtualDeviceConfigSpec[totalChangeDevices];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -3935,7 +3935,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
vmConfig.setName(vmName);
|
vmConfig.setName(vmName);
|
||||||
vmConfig.setMemoryMB((long) 4); // vmware request minimum of 4 MB
|
vmConfig.setMemoryMB((long) 4); // vmware request minimum of 4 MB
|
||||||
vmConfig.setNumCPUs(1);
|
vmConfig.setNumCPUs(1);
|
||||||
vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString());
|
vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
|
||||||
VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
|
VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
|
||||||
fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
|
fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
|
||||||
vmConfig.setFiles(fileInfo);
|
vmConfig.setFiles(fileInfo);
|
||||||
|
|||||||
@ -20,17 +20,23 @@ import java.io.BufferedReader;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
import com.vmware.vim25.HttpNfcLeaseInfo;
|
import com.vmware.vim25.HttpNfcLeaseInfo;
|
||||||
import com.vmware.vim25.HttpNfcLeaseManifestEntry;
|
import com.vmware.vim25.HttpNfcLeaseManifestEntry;
|
||||||
import com.vmware.vim25.HttpNfcLeaseState;
|
import com.vmware.vim25.HttpNfcLeaseState;
|
||||||
import com.vmware.vim25.ManagedObjectReference;
|
import com.vmware.vim25.ManagedObjectReference;
|
||||||
|
import com.vmware.vim25.ObjectSpec;
|
||||||
import com.vmware.vim25.OvfCreateImportSpecResult;
|
import com.vmware.vim25.OvfCreateImportSpecResult;
|
||||||
import com.vmware.vim25.OvfFileItem;
|
import com.vmware.vim25.OvfFileItem;
|
||||||
|
import com.vmware.vim25.PropertyFilterSpec;
|
||||||
|
import com.vmware.vim25.PropertySpec;
|
||||||
|
|
||||||
public class HttpNfcLeaseMO extends BaseMO {
|
public class HttpNfcLeaseMO extends BaseMO {
|
||||||
private static final Logger s_logger = Logger.getLogger(HttpNfcLeaseMO.class);
|
private static final Logger s_logger = Logger.getLogger(HttpNfcLeaseMO.class);
|
||||||
@ -44,7 +50,19 @@ public class HttpNfcLeaseMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HttpNfcLeaseState getState() throws Exception {
|
public HttpNfcLeaseState getState() throws Exception {
|
||||||
return (HttpNfcLeaseState)_context.getVimClient().getDynamicProperty(_mor, "state");
|
Object stateProp = _context.getVimClient().getDynamicProperty(_mor, "state");
|
||||||
|
// Due to some issue in JAX-WS De-serialization getting the information
|
||||||
|
// from the nodes
|
||||||
|
assert (stateProp.toString().contains("val: null"));
|
||||||
|
String stateVal = null;
|
||||||
|
Element stateElement = (Element) stateProp;
|
||||||
|
if (stateElement != null && stateElement.getFirstChild() != null) {
|
||||||
|
stateVal = stateElement.getFirstChild().getTextContent();
|
||||||
|
}
|
||||||
|
if (stateVal != null) {
|
||||||
|
return HttpNfcLeaseState.fromValue(stateVal);
|
||||||
|
}
|
||||||
|
return HttpNfcLeaseState.ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpNfcLeaseState waitState(HttpNfcLeaseState[] states) throws Exception {
|
public HttpNfcLeaseState waitState(HttpNfcLeaseState[] states) throws Exception {
|
||||||
@ -59,6 +77,8 @@ public class HttpNfcLeaseMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public HttpNfcLeaseInfo getLeaseInfo() throws Exception {
|
public HttpNfcLeaseInfo getLeaseInfo() throws Exception {
|
||||||
return (HttpNfcLeaseInfo)_context.getVimClient().getDynamicProperty(_mor, "info");
|
return (HttpNfcLeaseInfo)_context.getVimClient().getDynamicProperty(_mor, "info");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -571,14 +571,14 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
VirtualMachineRelocateSpecDiskLocator loc = new VirtualMachineRelocateSpecDiskLocator();
|
VirtualMachineRelocateSpecDiskLocator loc = new VirtualMachineRelocateSpecDiskLocator();
|
||||||
loc.setDatastore(morDs);
|
loc.setDatastore(morDs);
|
||||||
loc.setDiskId(independentDisks[i].getKey());
|
loc.setDiskId(independentDisks[i].getKey());
|
||||||
loc.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.MOVE_ALL_DISK_BACKINGS_AND_DISALLOW_SHARING.toString());
|
loc.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.MOVE_ALL_DISK_BACKINGS_AND_DISALLOW_SHARING.value());
|
||||||
diskLocator.add(loc);
|
diskLocator.add(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.toString());
|
rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value());
|
||||||
rSpec.getDisk().addAll(diskLocator);
|
rSpec.getDisk().addAll(diskLocator);
|
||||||
} else {
|
} else {
|
||||||
rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.toString());
|
rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value());
|
||||||
}
|
}
|
||||||
rSpec.setPool(morResourcePool);
|
rSpec.setPool(morResourcePool);
|
||||||
|
|
||||||
@ -868,7 +868,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|| diskType == VirtualDiskType.EAGER_ZEROED_THICK) {
|
|| diskType == VirtualDiskType.EAGER_ZEROED_THICK) {
|
||||||
|
|
||||||
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
||||||
backingInfo.setDiskMode(diskMode.PERSISTENT.toString());
|
backingInfo.setDiskMode(diskMode.PERSISTENT.value());
|
||||||
if(diskType == VirtualDiskType.THIN) {
|
if(diskType == VirtualDiskType.THIN) {
|
||||||
backingInfo.setThinProvisioned(true);
|
backingInfo.setThinProvisioned(true);
|
||||||
} else {
|
} else {
|
||||||
@ -894,7 +894,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
backingInfo.setDeviceName(rdmDeviceName);
|
backingInfo.setDeviceName(rdmDeviceName);
|
||||||
if(diskType == VirtualDiskType.RDM) {
|
if(diskType == VirtualDiskType.RDM) {
|
||||||
backingInfo.setDiskMode(diskMode.PERSISTENT.toString());
|
backingInfo.setDiskMode(diskMode.PERSISTENT.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
backingInfo.setDatastore(morDs);
|
backingInfo.setDatastore(morDs);
|
||||||
@ -1894,10 +1894,10 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int tryGetIDEDeviceControllerKey() throws Exception {
|
public int tryGetIDEDeviceControllerKey() throws Exception {
|
||||||
VirtualDevice[] devices = (VirtualDevice [])_context.getVimClient().
|
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
|
||||||
getDynamicProperty(_mor, "config.hardware.device");
|
getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if(devices != null && devices.length > 0) {
|
if(devices != null && devices.size() > 0) {
|
||||||
for(VirtualDevice device : devices) {
|
for(VirtualDevice device : devices) {
|
||||||
if(device instanceof VirtualIDEController) {
|
if(device instanceof VirtualIDEController) {
|
||||||
return ((VirtualIDEController)device).getKey();
|
return ((VirtualIDEController)device).getKey();
|
||||||
|
|||||||
@ -169,7 +169,7 @@ public class VmwareHelper {
|
|||||||
VirtualDisk disk = new VirtualDisk();
|
VirtualDisk disk = new VirtualDisk();
|
||||||
|
|
||||||
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
||||||
backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
|
backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
|
||||||
backingInfo.setThinProvisioned(true);
|
backingInfo.setThinProvisioned(true);
|
||||||
backingInfo.setEagerlyScrub(false);
|
backingInfo.setEagerlyScrub(false);
|
||||||
backingInfo.setDatastore(morDs);
|
backingInfo.setDatastore(morDs);
|
||||||
@ -273,7 +273,7 @@ public class VmwareHelper {
|
|||||||
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
||||||
backingInfo.setDatastore(morDs);
|
backingInfo.setDatastore(morDs);
|
||||||
backingInfo.setFileName(vmdkDatastorePathChain[0]);
|
backingInfo.setFileName(vmdkDatastorePathChain[0]);
|
||||||
backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
|
backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
|
||||||
if(vmdkDatastorePathChain.length > 1) {
|
if(vmdkDatastorePathChain.length > 1) {
|
||||||
String[] parentDisks = new String[vmdkDatastorePathChain.length - 1];
|
String[] parentDisks = new String[vmdkDatastorePathChain.length - 1];
|
||||||
for(int i = 0; i < vmdkDatastorePathChain.length - 1; i++)
|
for(int i = 0; i < vmdkDatastorePathChain.length - 1; i++)
|
||||||
@ -313,7 +313,7 @@ public class VmwareHelper {
|
|||||||
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
|
||||||
backingInfo.setDatastore(vmdkDatastorePathChain[0].second());
|
backingInfo.setDatastore(vmdkDatastorePathChain[0].second());
|
||||||
backingInfo.setFileName(vmdkDatastorePathChain[0].first());
|
backingInfo.setFileName(vmdkDatastorePathChain[0].first());
|
||||||
backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
|
backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
|
||||||
if(vmdkDatastorePathChain.length > 1) {
|
if(vmdkDatastorePathChain.length > 1) {
|
||||||
Pair<String, ManagedObjectReference>[] parentDisks = new Pair[vmdkDatastorePathChain.length - 1];
|
Pair<String, ManagedObjectReference>[] parentDisks = new Pair[vmdkDatastorePathChain.length - 1];
|
||||||
for(int i = 0; i < vmdkDatastorePathChain.length - 1; i++)
|
for(int i = 0; i < vmdkDatastorePathChain.length - 1; i++)
|
||||||
@ -346,7 +346,7 @@ public class VmwareHelper {
|
|||||||
|
|
||||||
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
|
||||||
parentBacking.setDatastore(morDs);
|
parentBacking.setDatastore(morDs);
|
||||||
parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
|
parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.value());
|
||||||
|
|
||||||
if(parentDatastorePathList.length > 1) {
|
if(parentDatastorePathList.length > 1) {
|
||||||
String[] nextDatastorePathList = new String[parentDatastorePathList.length -1];
|
String[] nextDatastorePathList = new String[parentDatastorePathList.length -1];
|
||||||
@ -364,7 +364,7 @@ public class VmwareHelper {
|
|||||||
|
|
||||||
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
|
||||||
parentBacking.setDatastore(parentDatastorePathList[0].second());
|
parentBacking.setDatastore(parentDatastorePathList[0].second());
|
||||||
parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
|
parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.value());
|
||||||
|
|
||||||
if(parentDatastorePathList.length > 1) {
|
if(parentDatastorePathList.length > 1) {
|
||||||
Pair<String, ManagedObjectReference>[] nextDatastorePathList = new Pair[parentDatastorePathList.length -1];
|
Pair<String, ManagedObjectReference>[] nextDatastorePathList = new Pair[parentDatastorePathList.length -1];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user