cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raf...@apache.org
Subject [2/5] git commit: updated refs/heads/master to 4480d05
Date Tue, 23 Feb 2016 23:39:23 GMT
CLOUDSTACK-9211: Add javadoc and refactor method


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

Branch: refs/heads/master
Commit: 448b43faeae58c923fe52c5540d604db03d70b15
Parents: 656ae10
Author: nvazquez <nicolas.m.vazquez@gmail.com>
Authored: Thu Jan 14 17:26:36 2016 -0200
Committer: nvazquez <nicolas.m.vazquez@gmail.com>
Committed: Thu Jan 14 17:26:36 2016 -0200

----------------------------------------------------------------------
 .../vmware/resource/VmwareResource.java         | 88 ++++++++++++--------
 1 file changed, 51 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/448b43fa/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 7248b08..6796c47 100644
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -1896,9 +1896,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
 
             postDiskConfigBeforeStart(vmMo, vmSpec, sortedDisks, ideControllerKey, scsiControllerKey,
iqnToPath, hyperHost, context);
 
-            //Sets video card memory to the one provided in detail svga.vramSize (if provided),
64MB was always set before
             postVideoCardMemoryConfigBeforeStart(vmMo, vmSpec);
-            
+
             //
             // Power-on VM
             //
@@ -1947,42 +1946,57 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         }
     }
 
+    /**
+     * Sets video card memory to the one provided in detail svga.vramSize (if provided).
+     * 64MB was always set before.
+     * Size must be in KB.
+     * @param vmMo virtual machine mo
+     * @param vmSpec virtual machine specs
+     */
     private void postVideoCardMemoryConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachineTO
vmSpec) {
-    	String paramVRamSize = "svga.vramSize";
-    	if (vmSpec.getDetails().containsKey(paramVRamSize)){
-    		String value = vmSpec.getDetails().get(paramVRamSize);
-    		try {
-    			long svgaVmramSize = Long.parseLong(value);
-    			for (VirtualDevice device : vmMo.getAllDeviceList()){
-    				if (device instanceof VirtualMachineVideoCard){
-    					VirtualMachineVideoCard videoCard = (VirtualMachineVideoCard) device;
-    					if (videoCard.getVideoRamSizeInKB().longValue() != svgaVmramSize){
-    						s_logger.info("Video card memory was set " + videoCard.getVideoRamSizeInKB().longValue()
+ "kb instead of " + svgaVmramSize + "kb");
-    						videoCard.setVideoRamSizeInKB(svgaVmramSize);
-    						videoCard.setUseAutoDetect(false);
-
-    						VirtualDeviceConfigSpec arrayVideoCardConfigSpecs = new VirtualDeviceConfigSpec();
-    						arrayVideoCardConfigSpecs.setDevice(videoCard);
-    						arrayVideoCardConfigSpecs.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
-
-    						VirtualMachineConfigSpec changeVideoCardSpecs = new VirtualMachineConfigSpec();
-    						changeVideoCardSpecs.getDeviceChange().add(arrayVideoCardConfigSpecs);
-
-    						boolean res = vmMo.configureVm(changeVideoCardSpecs);
-    						if (res) {
-    							s_logger.info("Video card memory successfully updated to " + svgaVmramSize + "kb");
-    						}
-    					}
-    				}
-    			}
-    		}
-    		catch (NumberFormatException e){
-    			s_logger.error("Unexpected value, cannot parse " + value + " to long due to: " + e.getMessage());
-    		}
-    		catch (Exception e){
-    			s_logger.error("Error while reconfiguring vm due to: " + e.getMessage());
-    		}
-    	}
+        String paramVRamSize = "svga.vramSize";
+        if (vmSpec.getDetails().containsKey(paramVRamSize)){
+            String value = vmSpec.getDetails().get(paramVRamSize);
+            try {
+                long svgaVmramSize = Long.parseLong(value);
+                for (VirtualDevice device : vmMo.getAllDeviceList()){
+                    if (device instanceof VirtualMachineVideoCard){
+                        VirtualMachineVideoCard videoCard = (VirtualMachineVideoCard) device;
+                        if (videoCard.getVideoRamSizeInKB().longValue() != svgaVmramSize){
+                            s_logger.info("Video card memory was set " + videoCard.getVideoRamSizeInKB().longValue()
+ "kb instead of " + svgaVmramSize + "kb");
+                            boolean res = vmMo.configureVm(configSpecVideoCardNewVRamSize(videoCard,
svgaVmramSize));
+                            if (res) {
+                                s_logger.info("Video card memory successfully updated to
" + svgaVmramSize + "kb");
+                            }
+                        }
+                    }
+                }
+            }
+            catch (NumberFormatException e){
+                s_logger.error("Unexpected value, cannot parse " + value + " to long due
to: " + e.getMessage());
+            }
+            catch (Exception e){
+                s_logger.error("Error while reconfiguring vm due to: " + e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Returns a VirtualMachineConfigSpec to edit its svga vram size
+     * @param videoCard video card device to edit providing the svga vram size
+     * @param svgaVmramSize new svga vram size
+     */
+    private VirtualMachineConfigSpec configSpecVideoCardNewVRamSize(VirtualMachineVideoCard
videoCard, long svgaVmramSize){
+        videoCard.setVideoRamSizeInKB(svgaVmramSize);
+        videoCard.setUseAutoDetect(false);
+
+        VirtualDeviceConfigSpec arrayVideoCardConfigSpecs = new VirtualDeviceConfigSpec();
+        arrayVideoCardConfigSpecs.setDevice(videoCard);
+        arrayVideoCardConfigSpecs.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
+
+        VirtualMachineConfigSpec changeVideoCardSpecs = new VirtualMachineConfigSpec();
+        changeVideoCardSpecs.getDeviceChange().add(arrayVideoCardConfigSpecs);
+        return changeVideoCardSpecs;
     }
 
     private void tearDownVm(VirtualMachineMO vmMo) throws Exception{


Mime
View raw message