diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 1480fb21f..5517d3781 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -289,26 +289,41 @@ def map_radl_ost_networks(self, radl_nets, ost_nets): if net_name: for radl_net in radl_nets: net_provider_id = radl_net.getValue('provider_id') + if net_provider_id: + parts = net_provider_id.split(".") + if len(parts) > 1: + net_provider_id = parts[0] if net_name == net_provider_id: - res[radl_net.id] = ip - break + if radl_net.isPublic() == is_public: + res[radl_net.id] = ip + break + else: + # the ip not matches the is_public value + res["#UNMAPPED#"].append(ip) else: if radl_net.id not in res: if radl_net.isPublic() == is_public: res[radl_net.id] = ip radl_net.setValue('provider_id', net_name) + if ip in res["#UNMAPPED#"]: + res["#UNMAPPED#"].remove(ip) break else: # the ip not matches the is_public value res["#UNMAPPED#"].append(ip) else: # It seems to be a floating IP + added = False for radl_net in radl_nets: if radl_net.id not in res and radl_net.isPublic() == is_public: res[radl_net.id] = ip + added = True break + if not added: + res["#UNMAPPED#"].append(ip) + return res def get_node_floating_ips(self, node): @@ -451,6 +466,10 @@ def get_networks(self, driver, radl): else: # First check if the user has specified a provider ID if net_provider_id: + parts = net_provider_id.split(".") + if len(parts) > 1: + net_provider_id = parts[0] + for net in ost_nets: if net.name == net_provider_id: if net.name not in used_nets: @@ -630,6 +649,14 @@ def manage_elastic_ips(self, vm, node, public_ips): if net.isPublic(): fixed_ip = vm.getRequestedSystem().getValue("net_interface." + str(n) + ".ip") pool_name = net.getValue("pool_name") + + if not pool_name: + net_provider_id = net.getValue("provider_id") + if net_provider_id: + parts = net_provider_id.split(".") + if len(parts) > 1: + pool_name = parts[1] + requested_ips.append((fixed_ip, pool_name)) n += 1 diff --git a/scripts/db_1_5_0_to_1_7_0.py b/scripts/db_1_5_0_to_1_7_0.py index b6176fa5c..57188bacf 100644 --- a/scripts/db_1_5_0_to_1_7_0.py +++ b/scripts/db_1_5_0_to_1_7_0.py @@ -43,4 +43,4 @@ sys.stderr.write("Error connecting with DB: %s\n" % Config.DATA_DB) sys.exit(-1) - sys.exit(0) \ No newline at end of file + sys.exit(0) diff --git a/test/unit/connectors/OpenStack.py b/test/unit/connectors/OpenStack.py index 277b529b4..21c92c77e 100755 --- a/test/unit/connectors/OpenStack.py +++ b/test/unit/connectors/OpenStack.py @@ -206,7 +206,7 @@ def test_20_launch(self, save_data, get_driver): @patch('libcloud.compute.drivers.openstack.OpenStackNodeDriver') def test_30_updateVMInfo(self, get_driver): radl_data = """ - network net (outbound = 'yes') + network net (outbound = 'yes' and provider_id = 'os-lan.pool1') system test ( cpu.arch='x86_64' and cpu.count=1 and @@ -214,7 +214,7 @@ def test_30_updateVMInfo(self, get_driver): net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and - disk.0.image.url = 'one://server.com/1' and + disk.0.image.url = 'ost://server.com/ami-id' and disk.0.os.credentials.username = 'user' and disk.0.os.credentials.password = 'pass' )"""