Skip to content

Commit

Permalink
Fix #607
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed May 15, 2018
1 parent 6238bbe commit f4ce85f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
31 changes: 29 additions & 2 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/unit/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ 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
memory.size=512m and
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'
)"""
Expand Down

0 comments on commit f4ce85f

Please sign in to comment.