hey guys,
Sorry to come back to this again.
I was pointed to xmlreader last week to parse an XML file, but i'm struggling to wrap my head around this.
I can get the 'jobid' out of XML which was where i needed to start...
So that works fine, but once I have the jobid, I need to use that to check that the job succeeded, which returns yet more xml.
This time i need to pull a few bits of info, but i cant work out how to mod the existing code to work for me.
the XML looks like this...
<queryasyncjobresultresponse cloud-stack-version="4.2.1"><accountid>c8e78722-610a-11e3-8340-ae0e38d3ea92</accountid><userid>c8e854cc-610a-11e3-8340-ae0e38d3ea92</userid><cmd>org.apache.cloudstack.api.command.user.vm.DeployVMCmd</cmd><jobstatus>1</jobstatus><jobprocstatus>0</jobprocstatus><jobresultcode>0</jobresultcode><jobresulttype>object</jobresulttype><jobresult><virtualmachine><id>3829f994-c53a-42db-b92b-53e0c6505e8a</id><name>DBX-Test-13</name><displayname>DBXTest13</displayname><account>system</account><domainid>281a6774-610a-11e3-8340-ae0e38d3ea92</domainid><domain>ROOT</domain><created>2013-12-16T08:27:07+0000</created><state>Running</state><haenable>false</haenable><zoneid>f149c335-07a6-4d1c-9dc7-df9243d86f3d</zoneid><zonename>dbx Zone 1</zonename><hostid>7049cca4-da80-436a-a037-05f498705dc6</hostid><hostname>localhost.localdomain</hostname><templateid>7788f0d0-605c-4036-846f-808885a6bac1</templateid><templatename>Windows 2008 R2 Enterprise</templatename><templatedisplaytext>Windows 2008 R2 Enterprise Instance</templatedisplaytext><passwordenabled>false</passwordenabled><serviceofferingid>50a7fa4a-f4d3-4bad-a46b-2dde3eea32d1</serviceofferingid><serviceofferingname>DBX2008 Basic</serviceofferingname><cpunumber>1</cpunumber><cpuspeed>1500</cpuspeed><memory>512</memory><guestosid>28703910-610a-11e3-8340-ae0e38d3ea92</guestosid><rootdeviceid>0</rootdeviceid><rootdevicetype>ROOT</rootdevicetype><securitygroup><id>df6e57be-8096-4ca3-8781-9af3b8430516</id><name>default</name><description>Default Security Group</description><account>system</account></securitygroup><nic><id>841afe48-326d-426d-ab15-b46854723002</id><networkid>3c2b214f-455d-49c5-b109-4182a22413e8</networkid><networkname>defaultGuestNetwork</networkname><netmask>255.255.255.0</netmask><gateway>192.168.16.254</gateway><ipaddress>192.168.16.122</ipaddress><isolationuri>ec2://untagged</isolationuri><broadcasturi>vlan://untagged</broadcasturi><traffictype>Guest</traffictype><type>Shared</type><isdefault>true</isdefault><macaddress>06:67:e2:00:00:1e</macaddress></nic><hypervisor>XenServer</hypervisor><instancename>i-1-61-VM</instancename><displayvm>true</displayvm><isdynamicallyscalable>false</isdynamicallyscalable><details>{hypervisortoolsversion=xenserver61}</details><jobid>03079df0-06f3-4dd8-9537-034eebd5169e</jobid><jobstatus>0</jobstatus></virtualmachine></jobresult><created>2013-12-16T08:27:08+0000</created><jobid>03079df0-06f3-4dd8-9537-034eebd5169e</jobid></queryasyncjobresultresponse>
The info i need to retrieve here is under the <virtualmachine> tag is is :
state
hostname
cpunumber
cpuspeed
memory
netmask
gateway
ipaddress
instancename
templatename
Any help is appriciated guys.
Thanks
Jonny
Sorry to come back to this again.
I was pointed to xmlreader last week to parse an XML file, but i'm struggling to wrap my head around this.
I can get the 'jobid' out of XML which was where i needed to start...
Code:
Dim doc As New System.Xml.XmlDocument
doc.LoadXml(api_result) ''api_result contains xml returned from a http request.
Dim new_vm_jobidxml = doc.GetElementsByTagName("jobid")
For Each item As System.Xml.XmlElement In new_vm_jobidxml
new_vm_jobid = item.ChildNodes(0).InnerText()
This time i need to pull a few bits of info, but i cant work out how to mod the existing code to work for me.
the XML looks like this...
Quote:
<queryasyncjobresultresponse cloud-stack-version="4.2.1"><accountid>c8e78722-610a-11e3-8340-ae0e38d3ea92</accountid><userid>c8e854cc-610a-11e3-8340-ae0e38d3ea92</userid><cmd>org.apache.cloudstack.api.command.user.vm.DeployVMCmd</cmd><jobstatus>1</jobstatus><jobprocstatus>0</jobprocstatus><jobresultcode>0</jobresultcode><jobresulttype>object</jobresulttype><jobresult><virtualmachine><id>3829f994-c53a-42db-b92b-53e0c6505e8a</id><name>DBX-Test-13</name><displayname>DBXTest13</displayname><account>system</account><domainid>281a6774-610a-11e3-8340-ae0e38d3ea92</domainid><domain>ROOT</domain><created>2013-12-16T08:27:07+0000</created><state>Running</state><haenable>false</haenable><zoneid>f149c335-07a6-4d1c-9dc7-df9243d86f3d</zoneid><zonename>dbx Zone 1</zonename><hostid>7049cca4-da80-436a-a037-05f498705dc6</hostid><hostname>localhost.localdomain</hostname><templateid>7788f0d0-605c-4036-846f-808885a6bac1</templateid><templatename>Windows 2008 R2 Enterprise</templatename><templatedisplaytext>Windows 2008 R2 Enterprise Instance</templatedisplaytext><passwordenabled>false</passwordenabled><serviceofferingid>50a7fa4a-f4d3-4bad-a46b-2dde3eea32d1</serviceofferingid><serviceofferingname>DBX2008 Basic</serviceofferingname><cpunumber>1</cpunumber><cpuspeed>1500</cpuspeed><memory>512</memory><guestosid>28703910-610a-11e3-8340-ae0e38d3ea92</guestosid><rootdeviceid>0</rootdeviceid><rootdevicetype>ROOT</rootdevicetype><securitygroup><id>df6e57be-8096-4ca3-8781-9af3b8430516</id><name>default</name><description>Default Security Group</description><account>system</account></securitygroup><nic><id>841afe48-326d-426d-ab15-b46854723002</id><networkid>3c2b214f-455d-49c5-b109-4182a22413e8</networkid><networkname>defaultGuestNetwork</networkname><netmask>255.255.255.0</netmask><gateway>192.168.16.254</gateway><ipaddress>192.168.16.122</ipaddress><isolationuri>ec2://untagged</isolationuri><broadcasturi>vlan://untagged</broadcasturi><traffictype>Guest</traffictype><type>Shared</type><isdefault>true</isdefault><macaddress>06:67:e2:00:00:1e</macaddress></nic><hypervisor>XenServer</hypervisor><instancename>i-1-61-VM</instancename><displayvm>true</displayvm><isdynamicallyscalable>false</isdynamicallyscalable><details>{hypervisortoolsversion=xenserver61}</details><jobid>03079df0-06f3-4dd8-9537-034eebd5169e</jobid><jobstatus>0</jobstatus></virtualmachine></jobresult><created>2013-12-16T08:27:08+0000</created><jobid>03079df0-06f3-4dd8-9537-034eebd5169e</jobid></queryasyncjobresultresponse>
state
hostname
cpunumber
cpuspeed
memory
netmask
gateway
ipaddress
instancename
templatename
Any help is appriciated guys.
Thanks
Jonny