incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [15/40] git commit: refs/heads/master - Fix a bug in converting Enum type to String.
Date Tue, 05 Mar 2013 02:09:46 GMT
Fix a bug in converting Enum type to String.

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/640fa6be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/640fa6be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/640fa6be

Branch: refs/heads/master
Commit: 640fa6be760177d11bca2d03805462a9bdf41e8e
Parents: 105bf71
Author: Min Chen <min.chen@citrix.com>
Authored: Thu Feb 7 12:23:57 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Thu Feb 7 12:23:57 2013 -0800

----------------------------------------------------------------------
 .../vmware/manager/VmwareStorageManagerImpl.java   |    4 +-
 .../hypervisor/vmware/resource/VmwareResource.java |    6 ++--
 .../cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java |   22 ++++++++++++++-
 .../hypervisor/vmware/mo/VirtualMachineMO.java     |   14 +++++-----
 .../cloud/hypervisor/vmware/util/VmwareHelper.java |   10 +++---
 5 files changed, 38 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/640fa6be/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
index 435db74..fd3afe8 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareStorageManagerImpl.java
@@ -192,7 +192,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
 						workerVMName = hostService.getWorkerName(context, cmd, 0);
 
 						// 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";
 							s_logger.error(msg);
 							throw new Exception(msg);
@@ -804,7 +804,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager
{
                 vmConfig.setName(workerVmName);
                 vmConfig.setMemoryMB((long) 4);
                 vmConfig.setNumCPUs(1);
-                vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString());
+                vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
                 VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
                 fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
                 vmConfig.setFiles(fileInfo);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/640fa6be/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 51b463e..21f1732 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -2094,7 +2094,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 
                     if (!hyperHost.createBlankVm(vmName, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
                             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);
                     }
                 }
@@ -2126,7 +2126,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
             int ramMb = (int) (vmSpec.getMinRam() / (1024 * 1024));
             VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getSpeed().intValue(),
                     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];
             int i = 0;
@@ -3935,7 +3935,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         vmConfig.setName(vmName);
         vmConfig.setMemoryMB((long) 4); // vmware request minimum of 4 MB
         vmConfig.setNumCPUs(1);
-        vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.toString());
+        vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
         VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
         fileInfo.setVmPathName(String.format("[%s]", dsMo.getName()));
         vmConfig.setFiles(fileInfo);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/640fa6be/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
index 1198b33..ca36280 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
@@ -20,17 +20,23 @@ import java.io.BufferedReader;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.rmi.RemoteException;
+import java.util.Arrays;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+import org.w3c.dom.Element;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.vmware.vim25.HttpNfcLeaseInfo;
 import com.vmware.vim25.HttpNfcLeaseManifestEntry;
 import com.vmware.vim25.HttpNfcLeaseState;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.ObjectSpec;
 import com.vmware.vim25.OvfCreateImportSpecResult;
 import com.vmware.vim25.OvfFileItem;
+import com.vmware.vim25.PropertyFilterSpec;
+import com.vmware.vim25.PropertySpec;
 
 public class HttpNfcLeaseMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(HttpNfcLeaseMO.class);
@@ -44,7 +50,19 @@ public class HttpNfcLeaseMO extends BaseMO {
 	}
 
 	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 {
@@ -59,6 +77,8 @@ public class HttpNfcLeaseMO extends BaseMO {
 		}
 	}
 
+
+
 	public HttpNfcLeaseInfo getLeaseInfo() throws Exception {
 		return (HttpNfcLeaseInfo)_context.getVimClient().getDynamicProperty(_mor, "info");
 	}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/640fa6be/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 6f836c4..2b07f9a 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -571,14 +571,14 @@ public class VirtualMachineMO extends BaseMO {
                 VirtualMachineRelocateSpecDiskLocator loc = new VirtualMachineRelocateSpecDiskLocator();
             	loc.setDatastore(morDs);
             	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);
             }
 
-            rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.toString());
+            rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value());
             rSpec.getDisk().addAll(diskLocator);
         } else {
-        	rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.toString());
+        	rSpec.setDiskMoveType(VirtualMachineRelocateDiskMoveOptions.CREATE_NEW_CHILD_DISK_BACKING.value());
         }
         rSpec.setPool(morResourcePool);
 
@@ -868,7 +868,7 @@ public class VirtualMachineMO extends BaseMO {
 			|| diskType == VirtualDiskType.EAGER_ZEROED_THICK) {
 
 			VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
-	        backingInfo.setDiskMode(diskMode.PERSISTENT.toString());
+	        backingInfo.setDiskMode(diskMode.PERSISTENT.value());
 	        if(diskType == VirtualDiskType.THIN) {
                 backingInfo.setThinProvisioned(true);
             } else {
@@ -894,7 +894,7 @@ public class VirtualMachineMO extends BaseMO {
 	        }
 	        backingInfo.setDeviceName(rdmDeviceName);
 	        if(diskType == VirtualDiskType.RDM) {
-	        	backingInfo.setDiskMode(diskMode.PERSISTENT.toString());
+	        	backingInfo.setDiskMode(diskMode.PERSISTENT.value());
 	        }
 
 	        backingInfo.setDatastore(morDs);
@@ -1894,10 +1894,10 @@ public class VirtualMachineMO extends BaseMO {
 	}
 
 	public int tryGetIDEDeviceControllerKey() throws Exception {
-	    VirtualDevice[] devices = (VirtualDevice [])_context.getVimClient().
+	    List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().
     		getDynamicProperty(_mor, "config.hardware.device");
 
-	    if(devices != null && devices.length > 0) {
+	    if(devices != null && devices.size() > 0) {
 	    	for(VirtualDevice device : devices) {
 	    		if(device instanceof VirtualIDEController) {
 	    			return ((VirtualIDEController)device).getKey();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/640fa6be/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
index 8e6947f..32e36a6 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java
@@ -169,7 +169,7 @@ public class VmwareHelper {
 		VirtualDisk disk = new VirtualDisk();
 
 		VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
-        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
+        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
     	backingInfo.setThinProvisioned(true);
     	backingInfo.setEagerlyScrub(false);
         backingInfo.setDatastore(morDs);
@@ -273,7 +273,7 @@ public class VmwareHelper {
 		VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
         backingInfo.setDatastore(morDs);
         backingInfo.setFileName(vmdkDatastorePathChain[0]);
-        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
+        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
         if(vmdkDatastorePathChain.length > 1) {
         	String[] parentDisks = new String[vmdkDatastorePathChain.length - 1];
         	for(int i = 0; i < vmdkDatastorePathChain.length - 1; i++)
@@ -313,7 +313,7 @@ public class VmwareHelper {
 		VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo();
         backingInfo.setDatastore(vmdkDatastorePathChain[0].second());
         backingInfo.setFileName(vmdkDatastorePathChain[0].first());
-        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
+        backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value());
         if(vmdkDatastorePathChain.length > 1) {
         	Pair<String, ManagedObjectReference>[] parentDisks = new Pair[vmdkDatastorePathChain.length
- 1];
         	for(int i = 0; i < vmdkDatastorePathChain.length - 1; i++)
@@ -346,7 +346,7 @@ public class VmwareHelper {
 
 		VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
 		parentBacking.setDatastore(morDs);
-		parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
+		parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.value());
 
 		if(parentDatastorePathList.length > 1) {
 			String[] nextDatastorePathList = new String[parentDatastorePathList.length -1];
@@ -364,7 +364,7 @@ public class VmwareHelper {
 
 		VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
 		parentBacking.setDatastore(parentDatastorePathList[0].second());
-		parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.toString());
+		parentBacking.setDiskMode(VirtualDiskMode.PERSISTENT.value());
 
 		if(parentDatastorePathList.length > 1) {
 			Pair<String, ManagedObjectReference>[] nextDatastorePathList = new Pair[parentDatastorePathList.length
-1];


Mime
View raw message