Update disassociate fip API

1. Remove DELETE request body
2. Add API doc

Change-Id: I2b86826427bd6d464f4da4c003ef6624a6a354a8
This commit is contained in:
Zhenguo Niu 2017-02-15 19:13:04 +08:00
parent 974540e456
commit d0683bb32a
4 changed files with 33 additions and 15 deletions

View File

@ -66,3 +66,24 @@ Request
**Example request to Add (Associate) Floating IP to an instance:**
.. literalinclude:: samples/instances/instance-associate-fip-req.json
Remove (Disassociate) Floating IP
=================================
.. rest_method:: DELETE /v1/instances/{instance_uuid}/networks/floatingips/{fip_address}
Removes, or disassociates, a floating IP address from an instance.
Normal response codes: 204
Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), conflict(409)
Request
-------
.. rest_parameters:: parameters.yaml
- instance_uuid: instance_ident
- fip_address: address_path

View File

@ -9,6 +9,12 @@ openstack-request-id:
type: string
# variables in path
address_path:
description: |
The floating IP address.
in: path
required: true
type: string
api_version:
in: path
required: true

View File

@ -207,17 +207,18 @@ class FloatingIPController(InstanceControllerBase):
msg, status_code=http_client.BAD_REQUEST)
@policy.authorize_wsgi("mogan:instance", "disassociate_floatingip")
@expose.expose(None, types.uuid, types.jsontype,
@expose.expose(None, types.uuid, wtypes.text,
status_code=http_client.NO_CONTENT)
def delete(self, instance_uuid, floatingip):
def delete(self, instance_uuid, address):
"""Dissociate floating_ip from an instance.
:param instance_uuid: UUID of a instance.
:param floatingip: The floating IP within the request body.
"""
validation.check_schema(floatingip, fip_schemas.remove_floating_ip)
address = floatingip['address']
if not netutils.is_valid_ipv4(address):
msg = "Invalid IP address %s" % address
raise wsme.exc.ClientSideError(
msg, status_code=http_client.BAD_REQUEST)
# get the floating ip object
try:
floating_ip = self.network_api.get_floating_ip_by_address(

View File

@ -26,13 +26,3 @@ add_floating_ip = {
'required': ['address'],
'additionalProperties': False
}
remove_floating_ip = {
'type': 'object',
'properties': {
'address': parameter_types.ip_address,
},
'required': ['address'],
'additionalProperties': False
}