From f386cadf21c0966a25479529c55ff7d965e7473c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantino=20V=C3=A1zquez=20Blanco?= Date: Mon, 27 Apr 2009 18:52:05 +0000 Subject: [PATCH] Polishing VMWare VMM git-svn-id: http://svn.opennebula.org/one/trunk@493 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- src/vmm_mad/vmware/DeployVM.java | 2 +- src/vmm_mad/vmware/OneVmmVmware.java | 21 +++++++++++---------- src/vmm_mad/vmware/ParseXML.java | 22 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/vmm_mad/vmware/DeployVM.java b/src/vmm_mad/vmware/DeployVM.java index db33fc8851..f851b96e5e 100644 --- a/src/vmm_mad/vmware/DeployVM.java +++ b/src/vmm_mad/vmware/DeployVM.java @@ -169,7 +169,7 @@ public class DeployVM return datastoreName; } - private boolean shapeVM() throws Exception + public boolean shapeVM() throws Exception { virtualMachine diff --git a/src/vmm_mad/vmware/OneVmmVmware.java b/src/vmm_mad/vmware/OneVmmVmware.java index 9d75d7dbb9..9ccfbdf4c9 100644 --- a/src/vmm_mad/vmware/OneVmmVmware.java +++ b/src/vmm_mad/vmware/OneVmmVmware.java @@ -124,25 +124,26 @@ class OneVmmVmware extends Thread // TODO this is just for testing // argsWithHost[arguments.length + 1 ] = "https://" + hostName + ":443/sdk"; argsWithHost[arguments.length + 1 ] = "https://localhost:8008/sdk"; - RegisterVM rVM = new RegisterVM(argsWithHost, hostName, "one-" + vid_str); - if(!rVM.registerVirtualMachine()) - { - throw new Exception("Error registering VM.") - } - - // Now, let's read the XML file and extract needed info + // let's read the XML file and extract needed info ParseXML pXML = new ParseXML(fileName); - // Now, proceed with the reconfiguration + DeployVM dVM = new DeployVM(argsWithHost, hostName, "one-" + vid_str,pXML); - if(!rVM.shapeVM()) + if(!dVM.registerVirtualMachine()) { - throw new Exception("Error reconfiguring VM.") + throw new Exception("Error registering VM."); } + // Now, proceed with the reconfiguration + if(!dVM.shapeVM()) + { + throw new Exception("Error reconfiguring VM."); + } + + continue; } catch(Exception e) diff --git a/src/vmm_mad/vmware/ParseXML.java b/src/vmm_mad/vmware/ParseXML.java index 902fe7e1d4..d2275a8e23 100644 --- a/src/vmm_mad/vmware/ParseXML.java +++ b/src/vmm_mad/vmware/ParseXML.java @@ -13,7 +13,7 @@ import org.xml.sax.SAXParseException; public class ParseXML { - + private String name; private String cpu; private String[] disk; private String memory; @@ -41,6 +41,17 @@ public class ParseXML throw new Exception("Number of VM tags different of 1: [" + vm.getLength() + "]"); } + // Name + + NodeList nameNL = doc.getElementsByTagName("NAME"); + + if(nameNL.getLength()!=1) + { + throw new Exception("Number of NAME tags different of 1: [" + nameNL.getLength() + "]"); + } + + name = ((Node)nameNL.item(0)).getNodeValue().trim(); + // CPU NodeList cpuNL = doc.getElementsByTagName("CPU"); @@ -137,4 +148,13 @@ public class ParseXML { return macs; } + + /** + * Returns VM name + * @return anme of the VM + **/ + String getName() + { + return name; + } } \ No newline at end of file