Skip to content

Commit

Permalink
implements apache#2027
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jul 2, 2024
1 parent 44e9945 commit f61e19c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions libcloud/compute/drivers/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4325,8 +4325,9 @@ def ex_attach_floating_ip_to_node(self, node, ip, port_id=None):
return False
if not port_id:
ports = self.ex_get_node_ports(node)
port_id = ports[0].id
if ports:
if ports:
port_id = ports[0].id
if port_id:
# Set to the first node port
resp = self.network_connection.request(
"/v2.0/floatingips/%s" % ip_id,
Expand Down
12 changes: 10 additions & 2 deletions libcloud/test/compute/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1677,10 +1677,8 @@ def test_ex_attach_floating_ip_to_node(self):
node = self.driver.create_node(name="racktest", image=image, size=size)
node.id = 4242
ip = "42.42.42.42"
port_id = 'ce531f90-199f-48c0-816c-13e38010b442'

self.assertTrue(self.driver.ex_attach_floating_ip_to_node(node, ip))
self.assertTrue(self.driver.ex_attach_floating_ip_to_node(node, ip, port_id))

def test_detach_floating_ip_from_node(self):
image = NodeImage(id=11, name="Ubuntu 8.10 (intrepid)", driver=self.driver)
Expand Down Expand Up @@ -2549,6 +2547,16 @@ def test_ex_delete_floating_ip(self):
ip = OpenStack_1_1_FloatingIpAddress("foo-bar-id", "42.42.42.42", None)
self.assertTrue(self.driver.ex_delete_floating_ip(ip))

def test_ex_attach_floating_ip_to_node(self):
image = NodeImage(id=11, name="Ubuntu 8.10 (intrepid)", driver=self.driver)
size = NodeSize(1, "256 slice", None, None, None, None, driver=self.driver)
node = self.driver.create_node(name="racktest", image=image, size=size)
node.id = 4242
ip = "42.42.42.42"
port_id = 'ce531f90-199f-48c0-816c-13e38010b442'

self.assertTrue(self.driver.ex_attach_floating_ip_to_node(node, ip, port_id))


class OpenStack_1_1_FactoryMethodTests(OpenStack_1_1_Tests):
should_list_locations = False
Expand Down

0 comments on commit f61e19c

Please sign in to comment.