mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 16:28:11 +00:00
Unload should not delete VMs, just close them.
This commit is contained in:
parent
6e7a5ca8bd
commit
bc3d63081b
@ -42,7 +42,7 @@ class ProjectHandler:
|
|||||||
@classmethod
|
@classmethod
|
||||||
@Route.get(
|
@Route.get(
|
||||||
r"/project/{uuid}",
|
r"/project/{uuid}",
|
||||||
description="Get project informations",
|
description="Get project information",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "Project instance UUID",
|
"uuid": "Project instance UUID",
|
||||||
},
|
},
|
||||||
|
@ -33,7 +33,7 @@ class VPCSHandler:
|
|||||||
@Route.post(
|
@Route.post(
|
||||||
r"/vpcs",
|
r"/vpcs",
|
||||||
status_codes={
|
status_codes={
|
||||||
201: "VPCS instance created",
|
201: "Instance created",
|
||||||
400: "Invalid project UUID",
|
400: "Invalid project UUID",
|
||||||
409: "Conflict"
|
409: "Conflict"
|
||||||
},
|
},
|
||||||
@ -56,13 +56,14 @@ class VPCSHandler:
|
|||||||
@Route.get(
|
@Route.get(
|
||||||
r"/vpcs/{uuid}",
|
r"/vpcs/{uuid}",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID"
|
"uuid": "Instance UUID"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
200: "Success",
|
200: "Success",
|
||||||
404: "VPCS instance doesn't exist"
|
404: "Instance doesn't exist"
|
||||||
},
|
},
|
||||||
description="Get a VPCS instance")
|
description="Get a VPCS instance",
|
||||||
|
output=VPCS_OBJECT_SCHEMA)
|
||||||
def show(request, response):
|
def show(request, response):
|
||||||
|
|
||||||
vpcs_manager = VPCS.instance()
|
vpcs_manager = VPCS.instance()
|
||||||
@ -73,11 +74,11 @@ class VPCSHandler:
|
|||||||
@Route.put(
|
@Route.put(
|
||||||
r"/vpcs/{uuid}",
|
r"/vpcs/{uuid}",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID"
|
"uuid": "Instance UUID"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
200: "VPCS instance updated",
|
200: "Instance updated",
|
||||||
404: "VPCS instance doesn't exist",
|
404: "Instance doesn't exist",
|
||||||
409: "Conflict"
|
409: "Conflict"
|
||||||
},
|
},
|
||||||
description="Update a VPCS instance",
|
description="Update a VPCS instance",
|
||||||
@ -97,11 +98,11 @@ class VPCSHandler:
|
|||||||
@Route.delete(
|
@Route.delete(
|
||||||
r"/vpcs/{uuid}",
|
r"/vpcs/{uuid}",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID"
|
"uuid": "Instance UUID"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
204: "VPCS instance deleted",
|
204: "Instance deleted",
|
||||||
404: "VPCS instance doesn't exist"
|
404: "Instance doesn't exist"
|
||||||
},
|
},
|
||||||
description="Delete a VPCS instance")
|
description="Delete a VPCS instance")
|
||||||
def delete(request, response):
|
def delete(request, response):
|
||||||
@ -113,12 +114,12 @@ class VPCSHandler:
|
|||||||
@Route.post(
|
@Route.post(
|
||||||
r"/vpcs/{uuid}/start",
|
r"/vpcs/{uuid}/start",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID"
|
"uuid": "Instance UUID"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
204: "VPCS instance started",
|
204: "Instance started",
|
||||||
400: "Invalid VPCS instance UUID",
|
400: "Invalid VPCS instance UUID",
|
||||||
404: "VPCS instance doesn't exist"
|
404: "Instance doesn't exist"
|
||||||
},
|
},
|
||||||
description="Start a VPCS instance")
|
description="Start a VPCS instance")
|
||||||
def start(request, response):
|
def start(request, response):
|
||||||
@ -132,12 +133,12 @@ class VPCSHandler:
|
|||||||
@Route.post(
|
@Route.post(
|
||||||
r"/vpcs/{uuid}/stop",
|
r"/vpcs/{uuid}/stop",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID"
|
"uuid": "Instance UUID"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
204: "VPCS instance stopped",
|
204: "Instance stopped",
|
||||||
400: "Invalid VPCS instance UUID",
|
400: "Invalid VPCS instance UUID",
|
||||||
404: "VPCS instance doesn't exist"
|
404: "Instance doesn't exist"
|
||||||
},
|
},
|
||||||
description="Stop a VPCS instance")
|
description="Stop a VPCS instance")
|
||||||
def stop(request, response):
|
def stop(request, response):
|
||||||
@ -147,18 +148,37 @@ class VPCSHandler:
|
|||||||
yield from vm.stop()
|
yield from vm.stop()
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
@Route.post(
|
@Route.post(
|
||||||
r"/vpcs/{uuid}/ports/{port_id}/nio",
|
r"/vpcs/{uuid}/reload",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID",
|
"uuid": "Instance UUID",
|
||||||
"port_id": "Id of the port where the nio should be add"
|
},
|
||||||
|
status_codes={
|
||||||
|
204: "Instance reloaded",
|
||||||
|
400: "Invalid instance UUID",
|
||||||
|
404: "Instance doesn't exist"
|
||||||
|
},
|
||||||
|
description="Reload a VPCS instance")
|
||||||
|
def reload(request, response):
|
||||||
|
|
||||||
|
vpcs_manager = VPCS.instance()
|
||||||
|
vm = vpcs_manager.get_vm(request.match_info["uuid"])
|
||||||
|
yield from vm.reload()
|
||||||
|
response.set_status(204)
|
||||||
|
|
||||||
|
@Route.post(
|
||||||
|
r"/vpcs/{uuid}/ports/{port_id:\d+}/nio",
|
||||||
|
parameters={
|
||||||
|
"uuid": "Instance UUID",
|
||||||
|
"port_id": "ID of the port where the nio should be added"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
201: "NIO created",
|
201: "NIO created",
|
||||||
400: "Invalid VPCS instance UUID",
|
400: "Invalid instance UUID",
|
||||||
404: "VPCS instance doesn't exist"
|
404: "Instance doesn't exist"
|
||||||
},
|
},
|
||||||
description="Add a NIO to a VPCS",
|
description="Add a NIO to a VPCS instance",
|
||||||
input=VPCS_NIO_SCHEMA,
|
input=VPCS_NIO_SCHEMA,
|
||||||
output=VPCS_NIO_SCHEMA)
|
output=VPCS_NIO_SCHEMA)
|
||||||
def create_nio(request, response):
|
def create_nio(request, response):
|
||||||
@ -172,39 +192,20 @@ class VPCSHandler:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@Route.delete(
|
@Route.delete(
|
||||||
r"/vpcs/{uuid}/ports/{port_id}/nio",
|
r"/vpcs/{uuid}/ports/{port_id:\d+}/nio",
|
||||||
parameters={
|
parameters={
|
||||||
"uuid": "VPCS instance UUID",
|
"uuid": "Instance UUID",
|
||||||
"port_id": "ID of the port where the nio should be removed"
|
"port_id": "ID of the port from where the nio should be removed"
|
||||||
},
|
},
|
||||||
status_codes={
|
status_codes={
|
||||||
204: "NIO deleted",
|
204: "NIO deleted",
|
||||||
400: "Invalid VPCS instance UUID",
|
400: "Invalid instance UUID",
|
||||||
404: "VPCS instance doesn't exist"
|
404: "Instance doesn't exist"
|
||||||
},
|
},
|
||||||
description="Remove a NIO from a VPCS")
|
description="Remove a NIO from a VPCS instance")
|
||||||
def delete_nio(request, response):
|
def delete_nio(request, response):
|
||||||
|
|
||||||
vpcs_manager = VPCS.instance()
|
vpcs_manager = VPCS.instance()
|
||||||
vm = vpcs_manager.get_vm(request.match_info["uuid"])
|
vm = vpcs_manager.get_vm(request.match_info["uuid"])
|
||||||
nio = vm.port_remove_nio_binding(int(request.match_info["port_id"]))
|
vm.port_remove_nio_binding(int(request.match_info["port_id"]))
|
||||||
response.set_status(204)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
@Route.post(
|
|
||||||
r"/vpcs/{uuid}/reload",
|
|
||||||
parameters={
|
|
||||||
"uuid": "VPCS instance UUID",
|
|
||||||
},
|
|
||||||
status_codes={
|
|
||||||
204: "VPCS reloaded",
|
|
||||||
400: "Invalid VPCS instance UUID",
|
|
||||||
404: "VPCS instance doesn't exist"
|
|
||||||
},
|
|
||||||
description="Remove a NIO from a VPCS")
|
|
||||||
def reload(request, response):
|
|
||||||
|
|
||||||
vpcs_manager = VPCS.instance()
|
|
||||||
vm = vpcs_manager.get_vm(request.match_info["uuid"])
|
|
||||||
yield from vm.reload()
|
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
@ -102,6 +102,7 @@ def parse_arguments():
|
|||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
Entry point for GNS3 server
|
Entry point for GNS3 server
|
||||||
|
@ -97,9 +97,9 @@ class BaseManager:
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def unload(self):
|
def unload(self):
|
||||||
|
|
||||||
for uuid in list(self._vms.keys()):
|
for uuid in self._vms.keys():
|
||||||
try:
|
try:
|
||||||
yield from self.delete_vm(uuid)
|
yield from self.close_vm(uuid)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.warn("Could not delete VM {}: {}".format(uuid, e))
|
log.warn("Could not delete VM {}: {}".format(uuid, e))
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user