@@ -4298,7 +4298,7 @@ def ex_delete_floating_ip(self, ip):
42984298 resp = self .network_connection .request ("/v2.0/floatingips/%s" % ip .id , method = "DELETE" )
42994299 return resp .status in (httplib .NO_CONTENT , httplib .ACCEPTED )
43004300
4301- def ex_attach_floating_ip_to_node (self , node , ip ):
4301+ def ex_attach_floating_ip_to_node (self , node , ip , port_id = None ):
43024302 """
43034303 Attach the floating IP to the node
43044304
@@ -4308,6 +4308,9 @@ def ex_attach_floating_ip_to_node(self, node, ip):
43084308 :param ip: floating IP to attach
43094309 :type ip: ``str`` or :class:`OpenStack_1_1_FloatingIpAddress`
43104310
4311+ :param port_id: Optional node port ID to attach the floating IP
4312+ :type ip: ``str``
4313+
43114314 :rtype: ``bool``
43124315 """
43134316 ip_id = None
@@ -4320,13 +4323,15 @@ def ex_attach_floating_ip_to_node(self, node, ip):
43204323 ip_id = fip .id
43214324 if not ip_id :
43224325 return False
4323- ports = self .ex_get_node_ports (node )
4326+ if not port_id :
4327+ ports = self .ex_get_node_ports (node )
4328+ port_id = ports [0 ].id
43244329 if ports :
43254330 # Set to the first node port
43264331 resp = self .network_connection .request (
43274332 "/v2.0/floatingips/%s" % ip_id ,
43284333 method = "PUT" ,
4329- data = {"floatingip" : {"port_id" : ports [ 0 ]. id }},
4334+ data = {"floatingip" : {"port_id" : port_id }},
43304335 )
43314336 return resp .status == httplib .OK
43324337 else :
0 commit comments