Merge pull request #41552 from Enquier/neutron-floatingip-remove

Adding logic so that update_floatingip can dissassociate floatingip's
This commit is contained in:
Mike Place 2017-06-06 13:25:55 -05:00 committed by GitHub
commit 846ca54688
2 changed files with 11 additions and 6 deletions

View File

@ -816,7 +816,7 @@ def create_floatingip(floating_network, port=None, profile=None):
return conn.create_floatingip(floating_network, port)
def update_floatingip(floatingip_id, port, profile=None):
def update_floatingip(floatingip_id, port=None, profile=None):
'''
Updates a floatingIP
@ -827,7 +827,8 @@ def update_floatingip(floatingip_id, port, profile=None):
salt '*' neutron.update_floatingip network-name port-name
:param floatingip_id: ID of floatingIP
:param port: ID or name of port
:param port: ID or name of port, to associate floatingip to
`None` or do not specify to disassociate the floatingip (Optional)
:param profile: Profile to build on (Optional)
:return: Value of updated floating IP information
'''

View File

@ -537,12 +537,16 @@ class SaltNeutron(NeutronShell):
return self.network_conn.create_floatingip(body={'floatingip': body})
def update_floatingip(self, floatingip_id, port):
def update_floatingip(self, floatingip_id, port=None):
'''
Updates a floatingip
Updates a floatingip, disassociates the floating ip if
port is set to `None`
'''
port_id = self._find_port_id(port)
body = {'floatingip': {'port_id': port_id}}
if port is None:
body = {'floatingip': {}}
else:
port_id = self._find_port_id(port)
body = {'floatingip': {'port_id': port_id}}
return self.network_conn.update_floatingip(
floatingip=floatingip_id, body=body)