diff --git libcloud/drivers/vcloud.py libcloud/drivers/vcloud.py index 1913d5b..8289aab 100644 --- libcloud/drivers/vcloud.py +++ libcloud/drivers/vcloud.py @@ -78,7 +78,7 @@ class InstantiateVAppXML(object): "InstantiateVAppTemplateParams", {'name': self.name, 'xml:lang': 'en', - 'xmlns': "http://www.vmware.com/vcloud/v1", + 'xmlns': "http://www.vmware.com/vcloud/v0.8", 'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance"} ) @@ -93,7 +93,7 @@ class InstantiateVAppXML(object): prod_section = ET.SubElement( parent, "ProductSection", - {'xmlns:q1': "http://www.vmware.com/vcloud/v1", + {'xmlns:q1': "http://www.vmware.com/vcloud/v0.8", 'xmlns:ovf': "http://schemas.dmtf.org/ovf/envelope/1"} ) @@ -121,7 +121,7 @@ class InstantiateVAppXML(object): vh = ET.SubElement( parent, "VirtualHardwareSection", - {'xmlns:q1': "http://www.vmware.com/vcloud/v1"} + {'xmlns:q1': "http://www.vmware.com/vcloud/v0.8"} ) self._add_cpu(vh) @@ -286,20 +286,17 @@ class VCloudNodeDriver(NodeDriver): def _to_node(self, name, elm): state = self.NODE_STATE_MAP[elm.get('status')] - public_ips = [ip.text for ip in elm.findall(fixxpath(elm, 'NetworkConnectionSection/NetworkConnection/IPAddress'))] + public_ips = [] + private_ips = [] # Following code to find private IPs works for Terremark - sections = elm.findall('{http://schemas.dmtf.org/ovf/envelope/1}Section') - network_connection_section = None - for section in sections: - section_type = section.get('{http://www.w3.org/2001/XMLSchema-instance}type') - if section_type == 'q1:NetworkConnectionSectionType': - network_connection_section = section - - if network_connection_section: - private_ips = [ip.text for ip in network_connection_section.findall(fixxpath(elm, 'NetworkConnection/IpAddress'))] - else: - private_ips = [] + connections = elm.findall('{http://schemas.dmtf.org/ovf/envelope/1}NetworkConnectionSection/{http://www.vmware.com/vcloud/v0.8}NetworkConnection') + for connection in connections: + ips = [ip.text for ip in connection.findall(fixxpath(elm, "IpAddress"))] + if connection.get('Network') == 'Internal': + private_ips.extend(ips) + else: + public_ips.extend(ips) node = Node(id=elm.get('href'), name=name, diff --git test/test_vcloud.py test/test_vcloud.py index 3920082..5ee2fea 100644 --- test/test_vcloud.py +++ test/test_vcloud.py @@ -81,14 +81,14 @@ class TerremarkMockHttp(MockHttp): def _api_v0_8_login(self, method, url, body, headers): headers['set-cookie'] = 'vcloud-token=testtoken' - body = """ + body = """ """ return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _api_v0_8_org_240(self, method, url, body, headers): - body = """ + body = """ @@ -97,7 +97,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _api_v0_8_vdc_224(self, method, url, body, headers): - body = """ + body = """ @@ -113,7 +113,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _api_v0_8_vdc_224_catalog(self, method, url, body, headers): - body = """ + body = """ @@ -122,7 +122,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _api_v0_8_catalogItem_5(self, method, url, body, headers): - body = """ + body = """ @@ -132,14 +132,14 @@ class TerremarkMockHttp(MockHttp): return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _api_v0_8_vdc_224_action_instantiateVAppTemplate(self, method, url, body, headers): - body = """ + body = """ """ return (httplib.OK, body, headers, httplib.responses[httplib.OK]) def _api_v0_8_vapp_14031_action_deploy(self, method, url, body, headers): - body = """ + body = """ @@ -147,7 +147,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]) def _api_v0_8_task_10496(self, method, url, body, headers): - body = """ + body = """ @@ -155,7 +155,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]) def _api_v0_8_vapp_14031_power_action_powerOn(self, method, url, body, headers): - body = """ + body = """ @@ -165,11 +165,11 @@ class TerremarkMockHttp(MockHttp): def _api_v0_8_vapp_14031(self, method, url, body, headers): if method == 'GET': - body = """ + body = """ -
+
10.112.78.69 @@ -178,7 +178,7 @@ class TerremarkMockHttp(MockHttp): The kind of installed guest operating system Red Hat Enterprise Linux 5 (32-bit) -
+
Virtual Hardware @@ -303,7 +303,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]) def _api_v0_8_vapp_14031_power_action_reset(self, method, url, body, headers): - body = """ + body = """ @@ -311,7 +311,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]) def _api_v0_8_vapp_14031_power_action_poweroff(self, method, url, body, headers): - body = """ + body = """ @@ -319,7 +319,7 @@ class TerremarkMockHttp(MockHttp): return (httplib.ACCEPTED, body, headers, httplib.responses[httplib.ACCEPTED]) def _api_v0_8_task_11001(self, method, url, body, headers): - body = """ + body = """