From ec3a23ed1a1dc21d511c49adbe1fe3d3ab8ff8c3 Mon Sep 17 00:00:00 2001 From: peusterm Date: Wed, 10 Jan 2018 11:06:05 +0100 Subject: [PATCH] Fix: HTTP 204 response must not contain any payload. Change-Id: Ib2fed74478233851e50f438c241b97bd949325d0 Signed-off-by: peusterm --- .../api/openstack/openstack_dummies/heat_dummy_api.py | 6 ++++-- .../openstack/openstack_dummies/neutron_dummy_api.py | 7 +++---- .../openstack_dummies/neutron_sfc_dummy_api.py | 11 +++++++---- .../api/openstack/openstack_dummies/nova_dummy_api.py | 10 +++++----- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py index 96af19a..9822f22 100755 --- a/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py +++ b/src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py @@ -388,12 +388,14 @@ class HeatDeleteStack(Resource): try: if stack_name_or_id in self.api.compute.stacks: self.api.compute.delete_stack(stack_name_or_id) - return Response('Deleted Stack: ' + stack_name_or_id, 204) + return Response("", 204, + mimetype='application/json') for stack in self.api.compute.stacks.values(): if stack.stack_name == stack_name_or_id: self.api.compute.delete_stack(stack.id) - return Response('Deleted Stack: ' + stack_name_or_id, 204) + return Response("", 204, + mimetype='application/json') except Exception as ex: LOG.exception("Heat: Delete Stack exception") diff --git a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py index 385163c..3b1ceda 100755 --- a/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py +++ b/src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py @@ -406,7 +406,7 @@ class NeutronDeleteNetwork(Resource): self.api.compute.delete_network(network_id) - return Response('Network ' + str(network_id) + ' deleted.\n', status=204, mimetype='application/json') + return Response('', status=204, mimetype='application/json') except Exception as ex: LOG.exception("Neutron: Delete network exception.") return Response(ex.message, status=500, mimetype='application/json') @@ -637,8 +637,7 @@ class NeutronDeleteSubnet(Resource): net.delete_subnet() - return Response('Subnet ' + str(subnet_id) + ' deleted.\n', - status=204, mimetype='application/json') + return Response('', status=204, mimetype='application/json') return Response('Could not find subnet.', status=404, mimetype='application/json') except Exception as ex: @@ -895,7 +894,7 @@ class NeutronDeletePort(Resource): # delete the port self.api.compute.delete_port(port.id) - return Response('Port ' + port_id + ' deleted.\n', status=204, mimetype='application/json') + return Response('', status=204, mimetype='application/json') except Exception as ex: LOG.exception("Neutron: Delete port exception.") diff --git a/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py index e353e81..1494bce 100644 --- a/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py +++ b/src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py @@ -99,7 +99,8 @@ class PortPairsDelete(SFC): try: self.api.compute.delete_port_pair(pair_id) - return Response("Port pair %s deleted.\n" % pair_id, status=204, mimetype='application/json') + return Response("", status=204, + mimetype='application/json') except Exception as ex: logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__)) return Response(ex.message, status=500, mimetype='application/json') @@ -191,7 +192,8 @@ class PortPairGroupDelete(SFC): try: self.api.compute.delete_port_pair_group(group_id) - return Response("Port pair group %s deleted.\n" % group_id, status=204, mimetype='application/json') + return Response("", status=204, + mimetype='application/json') except Exception as ex: logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__)) return Response(ex.message, status=500, mimetype='application/json') @@ -300,7 +302,7 @@ class FlowClassifierDelete(SFC): try: self.api.compute.delete_flow_classifier(flow_classifier_id) - return Response("Port pair group %s deleted.\n" % flow_classifier_id, status=204, + return Response("", status=204, mimetype='application/json') except Exception as ex: logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__)) @@ -404,7 +406,8 @@ class PortChainDelete(SFC): self.api.compute.delete_port_chain(chain_id) try: - return Response("Port chain %s deleted.\n" % chain_id, status=204, mimetype='application/json') + return Response("", status=204, + mimetype='application/json') except Exception as ex: logging.exception("Neutron SFC: %s Exception." % str(self.__class__.__name__)) return Response(ex.message, status=500, mimetype='application/json') diff --git a/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py b/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py index 550f8e7..3409436 100755 --- a/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py +++ b/src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py @@ -535,7 +535,7 @@ class NovaListFlavorById(Resource): Does not really remove anything from the machine, just fakes an OK. """ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) - return Response("{}", status=204, mimetype="application/json") + return Response("", status=204, mimetype="application/json") class NovaListImages(Resource): @@ -657,7 +657,7 @@ class NovaListImageById(Resource): Does not really remove anything from the machine, just fakes an OK. """ LOG.debug("API CALL: %s GET" % str(self.__class__.__name__)) - return Response("{}", status=204, mimetype="application/json") + return Response("", status=204, mimetype="application/json") class NovaShowServerDetails(Resource): @@ -729,10 +729,10 @@ class NovaShowServerDetails(Resource): :type id: ``str`` :param serverid: The UUID of the server :type serverid: ``str`` - :return: Returns 200 if everything is fine. + :return: Returns 204 if everything is fine. :rtype: :class:`flask.response` """ - LOG.debug("API CALL: %s POST" % str(self.__class__.__name__)) + LOG.debug("API CALL: %s DELETE" % str(self.__class__.__name__)) try: server = self.api.compute.find_server_by_name_or_id(serverid) if server is None: @@ -740,7 +740,7 @@ class NovaShowServerDetails(Resource): self.api.compute.stop_compute(server) - response = Response('Server deleted.', status=204, mimetype="application/json") + response = Response('', status=204, mimetype="application/json") response.headers['Access-Control-Allow-Origin'] = '*' return response -- 2.25.1