Bug 692 vmware vcd vimconnnector: Fix parsing vAppTemplate response 58/7458/1 v5.0
authorAnanda Baitharu <ananda.baitharu@riftio.com>
Fri, 10 May 2019 15:43:18 +0000 (15:43 +0000)
committerAnanda Baitharu <ananda.baitharu@riftio.com>
Mon, 13 May 2019 10:46:18 +0000 (10:46 +0000)
Change-Id: I1d69e984dc1c8ef05d8cff29059c6b2893edeb0e
Signed-off-by: Ananda Baitharu <ananda.baitharu@riftio.com>
osm_ro/vimconn_vmware.py

index 4a5ab97..4327be5 100644 (file)
@@ -1643,13 +1643,12 @@ class vimconnector(vimconn.vimconnector):
                 else:
                     result = (response.content).replace("\n"," ")
 
-                src = re.search('<Vm goldMaster="false"\sstatus="\d+"\sname="(.*?)"\s'
-                                               'id="(\w+:\w+:vm:.*?)"\shref="(.*?)"\s'
-                              'type="application/vnd\.vmware\.vcloud\.vm\+xml',result)
-                if src:
-                    vm_name = src.group(1)
-                    vm_id = src.group(2)
-                    vm_href = src.group(3)
+                vapp_template_tree = XmlElementTree.fromstring(response.content)
+                children_element = [child for child in vapp_template_tree if 'Children' in child.tag][0]
+                vm_element = [child for child in children_element if 'Vm' in child.tag][0]
+                vm_name = vm_element.get('name')
+                vm_id = vm_element.get('id')
+                vm_href = vm_element.get('href')
 
                 cpus = re.search('<rasd:Description>Number of Virtual CPUs</.*?>(\d+)</rasd:VirtualQuantity>',result).group(1)
                 memory_mb = re.search('<rasd:Description>Memory Size</.*?>(\d+)</rasd:VirtualQuantity>',result).group(1)