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)
media_upload_href = match.group(1)
else:
raise Exception('Could not parse the upload URL for the media file from the last response')
-
+ upload_iso_task = self.get_task_from_response(response.content)
headers['Content-Type'] = 'application/octet-stream'
response = self.perform_request(req_type='PUT',
url=media_upload_href,
if response.status_code != 200:
raise Exception('PUT request to "{}" failed'.format(media_upload_href))
+ result = self.client.get_task_monitor().wait_for_success(task=upload_iso_task)
+ if result.get('status') != 'success':
+ raise Exception('The upload iso task failed with status {}'.format(result.get('status')))
def get_vcd_availibility_zones(self,respool_href, headers):
""" Method to find presence of av zone is VIM resource pool
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/{}"/>
self.org_name))
host = self.url
client = Client(host, verify_ssl_certs=False)
+ client.set_highest_supported_version()
client.set_credentials(BasicLoginCredentials(self.user, self.org_name, self.passwd))
# connection object
self.client = client