mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Merge pull request #1140 from GNS3/duplicate_docker
Support duplicate for Docker
This commit is contained in:
commit
bb90c0ba52
@ -141,6 +141,26 @@ class DockerHandler:
|
|||||||
yield from container.delete()
|
yield from container.delete()
|
||||||
response.set_status(204)
|
response.set_status(204)
|
||||||
|
|
||||||
|
@Route.post(
|
||||||
|
r"/projects/{project_id}/docker/nodes/{node_id}/duplicate",
|
||||||
|
parameters={
|
||||||
|
"project_id": "Project UUID",
|
||||||
|
"node_id": "Node UUID"
|
||||||
|
},
|
||||||
|
status_codes={
|
||||||
|
201: "Instance duplicated",
|
||||||
|
404: "Instance doesn't exist"
|
||||||
|
},
|
||||||
|
description="Duplicate a Docker instance")
|
||||||
|
def duplicate(request, response):
|
||||||
|
|
||||||
|
new_node = yield from Docker.instance().duplicate_node(
|
||||||
|
request.match_info["node_id"],
|
||||||
|
request.json["destination_node_id"]
|
||||||
|
)
|
||||||
|
response.set_status(201)
|
||||||
|
response.json(new_node)
|
||||||
|
|
||||||
@Route.post(
|
@Route.post(
|
||||||
r"/projects/{project_id}/docker/nodes/{node_id}/pause",
|
r"/projects/{project_id}/docker/nodes/{node_id}/pause",
|
||||||
parameters={
|
parameters={
|
||||||
|
@ -184,3 +184,17 @@ def test_docker_stop_capture(http_compute, vm, tmpdir, project):
|
|||||||
assert response.status == 204
|
assert response.status == 204
|
||||||
|
|
||||||
assert stop_capture.called
|
assert stop_capture.called
|
||||||
|
|
||||||
|
|
||||||
|
def test_docker_duplicate(http_compute, vm):
|
||||||
|
with asyncio_patch("gns3server.compute.docker.Docker.duplicate_node", return_value=True) as mock:
|
||||||
|
response = http_compute.post(
|
||||||
|
"/projects/{project_id}/docker/nodes/{node_id}/duplicate".format(
|
||||||
|
project_id=vm["project_id"],
|
||||||
|
node_id=vm["node_id"]),
|
||||||
|
body={
|
||||||
|
"destination_node_id": str(uuid.uuid4())
|
||||||
|
},
|
||||||
|
example=True)
|
||||||
|
assert mock.called
|
||||||
|
assert response.status == 201
|
||||||
|
Loading…
Reference in New Issue
Block a user