if service_uuid in GK.services:
# ok, we have a service uuid, lets start the service
service_instance_uuid = GK.services.get(service_uuid).start_service()
- return {"service_instance_uuid": service_instance_uuid}
+ return {"service_instance_uuid": service_instance_uuid}, 201
return "Service not found", 404
def get(self):
# try to extract the service and instance UUID from the request
json_data = request.get_json(force=True)
service_uuid = json_data.get("service_uuid")
- instance_uuid = json_data.get("instance_uuid")
+ instance_uuid = json_data.get("service_instance_uuid")
# try to be fuzzy
if service_uuid is None and len(GK.services) > 0:
if service_uuid in GK.services and instance_uuid in GK.services[service_uuid].instances:
# valid service and instance UUID, stop service
GK.services.get(service_uuid).stop_service(instance_uuid)
- return "", 0
+ del GK.services.get(service_uuid).instances[instance_uuid]
+ return
return "Service not found", 404
class Exit(fr.Resource):
"""
Stop the running Containernet instance regardless of data transmitted
"""
- # exit the mininet CLI
+ GK.net.stop()
+
+
+def initialize_GK():
+ global GK
+ GK = Gatekeeper()
+
# create a single, global GK object
-GK = Gatekeeper()
+GK = None
+initialize_GK()
# setup Flask
app = Flask(__name__)
app.config['MAX_CONTENT_LENGTH'] = 512 * 1024 * 1024 # 512 MB max upload
api.add_resource(Exit, '/emulator/exit')
+#def initialize_GK():
+# global GK
+# GK = Gatekeeper()
+
+
def start_rest_api(host, port, datacenters=dict()):
GK.dcs = datacenters
# start the Flask server (not the best performance but ok for our use case)