1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Suspend for Docker nodes.

This commit is contained in:
grossmj 2018-01-18 11:43:04 +08:00
parent 7ded71142f
commit bd8816d14c
10 changed files with 48 additions and 13 deletions

View File

@ -188,7 +188,7 @@ class ATMSwitchHandler:
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend an ATM Relay switch") description="Suspend an ATM Relay switch (does nothing)")
def suspend(request, response): def suspend(request, response):
Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

View File

@ -168,7 +168,7 @@ class CloudHandler:
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend a cloud") description="Suspend a cloud (does nothing)")
def suspend(request, response): def suspend(request, response):
Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

View File

@ -105,6 +105,24 @@ class DockerHandler:
yield from container.stop() yield from container.stop()
response.set_status(204) response.set_status(204)
@Route.post(
r"/projects/{project_id}/docker/nodes/{node_id}/suspend",
parameters={
"project_id": "Project UUID",
"node_id": "Node UUID"
},
status_codes={
204: "Instance suspended",
400: "Invalid request",
404: "Instance doesn't exist"
},
description="Suspend a Docker container")
def suspend(request, response):
docker_manager = Docker.instance()
container = docker_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
yield from container.pause()
response.set_status(204)
@Route.post( @Route.post(
r"/projects/{project_id}/docker/nodes/{node_id}/reload", r"/projects/{project_id}/docker/nodes/{node_id}/reload",
parameters={ parameters={

View File

@ -191,7 +191,7 @@ class EthernetHubHandler:
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend an Ethernet hub") description="Suspend an Ethernet hub (does nothing)")
def suspend(request, response): def suspend(request, response):
Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

View File

@ -204,7 +204,7 @@ class EthernetSwitchHandler:
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend an Ethernet switch") description="Suspend an Ethernet switch (does nothing)")
def suspend(request, response): def suspend(request, response):
Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

View File

@ -188,7 +188,7 @@ class FrameRelaySwitchHandler:
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend a Frame Relay switch") description="Suspend a Frame Relay switch (does nothing)")
def suspend(request, response): def suspend(request, response):
Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) Dynamips.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

View File

@ -207,6 +207,24 @@ class IOUHandler:
yield from vm.stop() yield from vm.stop()
response.set_status(204) response.set_status(204)
@Route.post(
r"/projects/{project_id}/iou/nodes/{node_id}/suspend",
parameters={
"project_id": "Project UUID",
"node_id": "Node UUID"
},
status_codes={
204: "Instance suspended",
400: "Invalid request",
404: "Instance doesn't exist"
},
description="Suspend an IOU instance (does nothing)")
def suspend(request, response):
iou_manager = IOU.instance()
iou_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
response.set_status(204)
@Route.post( @Route.post(
r"/projects/{project_id}/iou/nodes/{node_id}/reload", r"/projects/{project_id}/iou/nodes/{node_id}/reload",
parameters={ parameters={

View File

@ -166,7 +166,7 @@ class NatHandler:
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend a nat") description="Suspend a nat (does nothing)")
def suspend(request, response): def suspend(request, response):
Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])

View File

@ -184,16 +184,15 @@ class VPCSHandler:
"node_id": "Node UUID" "node_id": "Node UUID"
}, },
status_codes={ status_codes={
204: "Instance stopped", 204: "Instance suspended",
400: "Invalid request", 400: "Invalid request",
404: "Instance doesn't exist" 404: "Instance doesn't exist"
}, },
description="Suspend a VPCS instance (stop it)") description="Suspend a VPCS instance (does nothing)")
def stop(request, response): def suspend(request, response):
vpcs_manager = VPCS.instance() vpcs_manager = VPCS.instance()
vm = vpcs_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) vpcs_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
yield from vm.stop()
response.set_status(204) response.set_status(204)
@Route.post( @Route.post(

View File

@ -25,7 +25,7 @@ function help {
echo "Usage:" >&2 echo "Usage:" >&2
echo "--with-openvpn: Install Open VPN" >&2 echo "--with-openvpn: Install Open VPN" >&2
echo "--with-iou: Install IOU" >&2 echo "--with-iou: Install IOU" >&2
echo "--with-i386-repository: Add i386 repositories require by IOU if they are not available on the system. Warning this will replace your source.list in order to use official ubuntu mirror" >&2 echo "--with-i386-repository: Add the i386 repositories required by IOU if they are not already available on the system. Warning: this will replace your source.list in order to use the official Ubuntu mirror" >&2
echo "--unstable: Use the GNS3 unstable repository" echo "--unstable: Use the GNS3 unstable repository"
echo "--help: This help" >&2 echo "--help: This help" >&2
} }
@ -37,7 +37,7 @@ function log {
lsb_release -d | grep "LTS" > /dev/null lsb_release -d | grep "LTS" > /dev/null
if [ $? != 0 ] if [ $? != 0 ]
then then
echo "You can use this script on Ubuntu LTS only" echo "This script can only be run on a Linux Ubuntu LTS release"
exit 1 exit 1
fi fi