Fix: HTTP 204 response must not contain any payload. 12/5812/2
authorpeusterm <manuel.peuster@uni-paderborn.de>
Wed, 10 Jan 2018 10:06:05 +0000 (11:06 +0100)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Wed, 10 Jan 2018 11:38:38 +0000 (12:38 +0100)
Change-Id: Ib2fed74478233851e50f438c241b97bd949325d0
Signed-off-by: peusterm <manuel.peuster@uni-paderborn.de>
src/emuvim/api/openstack/openstack_dummies/heat_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/neutron_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/neutron_sfc_dummy_api.py
src/emuvim/api/openstack/openstack_dummies/nova_dummy_api.py

index 96af19a..9822f22 100755 (executable)
@@ -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")
index 385163c..3b1ceda 100755 (executable)
@@ -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.")
index e353e81..1494bce 100644 (file)
@@ -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')
index 550f8e7..3409436 100755 (executable)
@@ -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