INTERVAL_TIME = 5
MAX_WAIT_TIME = 1800
-API_VERSION = '31.0'
+API_VERSION = '27.0'
__author__ = "Mustafa Bayramov, Arpita Kate, Sachin Bhangare, Prakash Kasar"
__date__ = "$09-Mar-2018 11:09:29$"
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)
namespaces["xmlns"] = "http://www.vmware.com/vcloud/v1.5"
nwcfglist = newelem.findall(".//xmlns:NetworkConfig", namespaces)
+ # VCD 9.7 returns an incorrect parentnetwork element. Fix it before PUT operation
+ parentnetworklist = newelem.findall(".//xmlns:ParentNetwork", namespaces)
+ if parentnetworklist:
+ for pn in parentnetworklist:
+ if "href" not in pn.keys():
+ id_val = pn.get("id")
+ href_val = "{}/api/network/{}".format(self.url, id_val)
+ pn.set("href", href_val)
+
newstr = """<NetworkConfig networkName="{}">
<Configuration>
<ParentNetwork href="{}/api/network/{}"/>