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

Get informations about a VPCS instance

This commit is contained in:
Julien Duponchelle 2015-01-21 17:21:17 +01:00
parent ce9fd3cb25
commit 7abb426d04
6 changed files with 78 additions and 1 deletions

View File

@ -0,0 +1,22 @@
curl -i -X GET 'http://localhost:8000/vpcs/{uuid}'
GET /vpcs/{uuid} HTTP/1.1
HTTP/1.1 200
CONNECTION: close
CONTENT-LENGTH: 213
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /vpcs/{uuid}
{
"console": 2001,
"name": "PC TEST 1",
"project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
"script_file": null,
"startup_script": null,
"uuid": "40f76457-de2b-4399-8853-a35393a72a2d"
}

View File

@ -0,0 +1,15 @@
curl -i -X POST 'http://localhost:8000/virtualbox/{uuid}/start' -d '{}'
POST /virtualbox/{uuid}/start HTTP/1.1
{}
HTTP/1.1 200
CONNECTION: close
CONTENT-LENGTH: 2
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /virtualbox/{uuid}/start
{}

View File

@ -0,0 +1,15 @@
curl -i -X POST 'http://localhost:8000/virtualbox/{uuid}/stop' -d '{}'
POST /virtualbox/{uuid}/stop HTTP/1.1
{}
HTTP/1.1 200
CONNECTION: close
CONTENT-LENGTH: 2
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /virtualbox/{uuid}/stop
{}

View File

@ -21,5 +21,5 @@ X-ROUTE: /vpcs
"project_uuid": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
"script_file": null,
"startup_script": null,
"uuid": "6370f75e-0a48-4e2b-95a8-0140da6ef1fb"
"uuid": "a022aa0d-acab-4554-b2a6-6e6f51c9d65e"
}

View File

@ -50,6 +50,23 @@ class VPCSHandler:
startup_script=request.json.get("startup_script"))
response.json(vm)
@classmethod
@Route.get(
r"/vpcs/{uuid}",
parameters={
"uuid": "VPCS instance UUID"
},
status_codes={
200: "VPCS instance started",
404: "VPCS instance doesn't exist"
},
description="Get a VPCS instance")
def show(request, response):
vpcs_manager = VPCS.instance()
vm = vpcs_manager.get_vm(request.match_info["uuid"])
response.json(vm)
@classmethod
@Route.post(
r"/vpcs/{uuid}/start",

View File

@ -39,6 +39,14 @@ def test_vpcs_create(server, project):
assert response.json["script_file"] is None
def test_vpcs_get(server, project, vm):
response = server.get("/vpcs/{}".format(vm["uuid"]), example=True)
assert response.status == 200
assert response.route == "/vpcs/{uuid}"
assert response.json["name"] == "PC TEST 1"
assert response.json["project_uuid"] == project.uuid
def test_vpcs_create_script_file(server, project, tmpdir):
path = os.path.join(str(tmpdir), "test")
with open(path, 'w+') as f: