diff --git a/docs/api/examples/delete_projectsprojectid.txt b/docs/api/examples/delete_projectsprojectid.txt
index 45efff6c..d48bdd35 100644
--- a/docs/api/examples/delete_projectsprojectid.txt
+++ b/docs/api/examples/delete_projectsprojectid.txt
@@ -5,9 +5,9 @@ DELETE /projects/{project_id} HTTP/1.1
HTTP/1.1 204
-CONNECTION: keep-alive
+CONNECTION: close
CONTENT-LENGTH: 0
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/projects/{project_id}
diff --git a/docs/api/examples/delete_virtualboxuuidadaptersadapteriddnio.txt b/docs/api/examples/delete_virtualboxuuidadaptersadapteriddnio.txt
deleted file mode 100644
index cb1c3b9e..00000000
--- a/docs/api/examples/delete_virtualboxuuidadaptersadapteriddnio.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-curl -i -X DELETE 'http://localhost:8000/virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio'
-
-DELETE /virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio HTTP/1.1
-
-
-
-HTTP/1.1 204
-CONNECTION: keep-alive
-CONTENT-LENGTH: 0
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio
-
diff --git a/docs/api/examples/delete_vpcsuuidportsportnumberdnio.txt b/docs/api/examples/delete_vpcsuuidportsportnumberdnio.txt
deleted file mode 100644
index 26ac313d..00000000
--- a/docs/api/examples/delete_vpcsuuidportsportnumberdnio.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-curl -i -X DELETE 'http://localhost:8000/vpcs/{uuid}/ports/{port_number:\d+}/nio'
-
-DELETE /vpcs/{uuid}/ports/{port_number:\d+}/nio HTTP/1.1
-
-
-
-HTTP/1.1 204
-CONNECTION: keep-alive
-CONTENT-LENGTH: 0
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/vpcs/{uuid}/ports/{port_number:\d+}/nio
-
diff --git a/docs/api/examples/get_interfaces.txt b/docs/api/examples/get_interfaces.txt
index 7ac8c74d..f0566cea 100644
--- a/docs/api/examples/get_interfaces.txt
+++ b/docs/api/examples/get_interfaces.txt
@@ -5,56 +5,32 @@ GET /interfaces HTTP/1.1
HTTP/1.1 200
-CONNECTION: keep-alive
-CONTENT-LENGTH: 652
+CONNECTION: close
+CONTENT-LENGTH: 298
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/interfaces
[
{
- "id": "lo0",
- "name": "lo0"
+ "id": "lo",
+ "name": "lo"
},
{
- "id": "gif0",
- "name": "gif0"
+ "id": "eth0",
+ "name": "eth0"
},
{
- "id": "stf0",
- "name": "stf0"
+ "id": "wlan0",
+ "name": "wlan0"
},
{
- "id": "en0",
- "name": "en0"
+ "id": "vmnet1",
+ "name": "vmnet1"
},
{
- "id": "en1",
- "name": "en1"
- },
- {
- "id": "fw0",
- "name": "fw0"
- },
- {
- "id": "en2",
- "name": "en2"
- },
- {
- "id": "p2p0",
- "name": "p2p0"
- },
- {
- "id": "bridge0",
- "name": "bridge0"
- },
- {
- "id": "vboxnet0",
- "name": "vboxnet0"
- },
- {
- "id": "vboxnet1",
- "name": "vboxnet1"
+ "id": "vmnet8",
+ "name": "vmnet8"
}
]
diff --git a/docs/api/examples/get_projectsprojectid.txt b/docs/api/examples/get_projectsprojectid.txt
index 152a815a..035e8487 100644
--- a/docs/api/examples/get_projectsprojectid.txt
+++ b/docs/api/examples/get_projectsprojectid.txt
@@ -5,15 +5,16 @@ GET /projects/{project_id} HTTP/1.1
HTTP/1.1 200
-CONNECTION: keep-alive
-CONTENT-LENGTH: 108
+CONNECTION: close
+CONTENT-LENGTH: 165
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/projects/{project_id}
{
"location": "/tmp",
+ "path": "/tmp/00010203-0405-0607-0809-0a0b0c0d0e0f",
"project_id": "00010203-0405-0607-0809-0a0b0c0d0e0f",
"temporary": false
}
diff --git a/docs/api/examples/get_version.txt b/docs/api/examples/get_version.txt
index 88017034..ddf810d1 100644
--- a/docs/api/examples/get_version.txt
+++ b/docs/api/examples/get_version.txt
@@ -5,11 +5,11 @@ GET /version HTTP/1.1
HTTP/1.1 200
-CONNECTION: keep-alive
+CONNECTION: close
CONTENT-LENGTH: 29
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/version
{
diff --git a/docs/api/examples/get_virtualboxuuid.txt b/docs/api/examples/get_virtualboxuuid.txt
deleted file mode 100644
index 11853488..00000000
--- a/docs/api/examples/get_virtualboxuuid.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-curl -i -X GET 'http://localhost:8000/virtualbox/{uuid}'
-
-GET /virtualbox/{uuid} HTTP/1.1
-
-
-
-HTTP/1.1 200
-CONNECTION: keep-alive
-CONTENT-LENGTH: 346
-CONTENT-TYPE: application/json
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/virtualbox/{uuid}
-
-{
- "adapter_start_index": 0,
- "adapter_type": "Intel PRO/1000 MT Desktop (82540EM)",
- "adapters": 0,
- "console": 2001,
- "enable_remote_console": false,
- "headless": false,
- "name": "VMTEST",
- "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
- "uuid": "aa7a7c1e-6fc2-43b8-b53b-60e605565625",
- "vmname": "VMTEST"
-}
diff --git a/docs/api/examples/get_vpcsuuid.txt b/docs/api/examples/get_vpcsuuid.txt
deleted file mode 100644
index 19f913bc..00000000
--- a/docs/api/examples/get_vpcsuuid.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-curl -i -X GET 'http://localhost:8000/vpcs/{uuid}'
-
-GET /vpcs/{uuid} HTTP/1.1
-
-
-
-HTTP/1.1 200
-CONNECTION: keep-alive
-CONTENT-LENGTH: 211
-CONTENT-TYPE: application/json
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/vpcs/{uuid}
-
-{
- "console": 2003,
- "name": "PC TEST 1",
- "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
- "script_file": null,
- "startup_script": null,
- "uuid": "c505f88b-7fe1-4985-9aca-a3798f6659ab"
-}
diff --git a/docs/api/examples/post_portsudp.txt b/docs/api/examples/post_portsudp.txt
index 3be4b74c..828df022 100644
--- a/docs/api/examples/post_portsudp.txt
+++ b/docs/api/examples/post_portsudp.txt
@@ -5,11 +5,11 @@ POST /ports/udp HTTP/1.1
HTTP/1.1 201
-CONNECTION: keep-alive
+CONNECTION: close
CONTENT-LENGTH: 25
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/ports/udp
{
diff --git a/docs/api/examples/post_projectsprojectidclose.txt b/docs/api/examples/post_projectsprojectidclose.txt
index bcc429c9..66366b9c 100644
--- a/docs/api/examples/post_projectsprojectidclose.txt
+++ b/docs/api/examples/post_projectsprojectidclose.txt
@@ -5,9 +5,9 @@ POST /projects/{project_id}/close HTTP/1.1
HTTP/1.1 204
-CONNECTION: keep-alive
+CONNECTION: close
CONTENT-LENGTH: 0
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/projects/{project_id}/close
diff --git a/docs/api/examples/post_projectsprojectidcommit.txt b/docs/api/examples/post_projectsprojectidcommit.txt
index 0b36f05d..b17f5a85 100644
--- a/docs/api/examples/post_projectsprojectidcommit.txt
+++ b/docs/api/examples/post_projectsprojectidcommit.txt
@@ -5,9 +5,9 @@ POST /projects/{project_id}/commit HTTP/1.1
HTTP/1.1 204
-CONNECTION: keep-alive
+CONNECTION: close
CONTENT-LENGTH: 0
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/projects/{project_id}/commit
diff --git a/docs/api/examples/post_version.txt b/docs/api/examples/post_version.txt
index 2f6c1452..b6f654df 100644
--- a/docs/api/examples/post_version.txt
+++ b/docs/api/examples/post_version.txt
@@ -7,11 +7,11 @@ POST /version HTTP/1.1
HTTP/1.1 200
-CONNECTION: keep-alive
+CONNECTION: close
CONTENT-LENGTH: 29
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/version
{
diff --git a/docs/api/examples/post_virtualbox.txt b/docs/api/examples/post_virtualbox.txt
deleted file mode 100644
index 06dec3c8..00000000
--- a/docs/api/examples/post_virtualbox.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-curl -i -X POST 'http://localhost:8000/virtualbox' -d '{"linked_clone": false, "name": "VM1", "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80", "vmname": "VM1"}'
-
-POST /virtualbox HTTP/1.1
-{
- "linked_clone": false,
- "name": "VM1",
- "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
- "vmname": "VM1"
-}
-
-
-HTTP/1.1 201
-CONNECTION: keep-alive
-CONTENT-LENGTH: 340
-CONTENT-TYPE: application/json
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/virtualbox
-
-{
- "adapter_start_index": 0,
- "adapter_type": "Intel PRO/1000 MT Desktop (82540EM)",
- "adapters": 0,
- "console": 2000,
- "enable_remote_console": false,
- "headless": false,
- "name": "VM1",
- "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
- "uuid": "267f3908-f3dd-4cac-bca3-2e31a1018493",
- "vmname": "VM1"
-}
diff --git a/docs/api/examples/post_virtualboxuuidadaptersadapteriddnio.txt b/docs/api/examples/post_virtualboxuuidadaptersadapteriddnio.txt
deleted file mode 100644
index 527a758e..00000000
--- a/docs/api/examples/post_virtualboxuuidadaptersadapteriddnio.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-curl -i -X POST 'http://localhost:8000/virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio' -d '{"lport": 4242, "rhost": "127.0.0.1", "rport": 4343, "type": "nio_udp"}'
-
-POST /virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio HTTP/1.1
-{
- "lport": 4242,
- "rhost": "127.0.0.1",
- "rport": 4343,
- "type": "nio_udp"
-}
-
-
-HTTP/1.1 201
-CONNECTION: keep-alive
-CONTENT-LENGTH: 89
-CONTENT-TYPE: application/json
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio
-
-{
- "lport": 4242,
- "rhost": "127.0.0.1",
- "rport": 4343,
- "type": "nio_udp"
-}
diff --git a/docs/api/examples/post_vpcs.txt b/docs/api/examples/post_vpcs.txt
deleted file mode 100644
index c9ff1f35..00000000
--- a/docs/api/examples/post_vpcs.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-curl -i -X POST 'http://localhost:8000/vpcs' -d '{"name": "PC TEST 1", "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80"}'
-
-POST /vpcs HTTP/1.1
-{
- "name": "PC TEST 1",
- "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80"
-}
-
-
-HTTP/1.1 201
-CONNECTION: keep-alive
-CONTENT-LENGTH: 211
-CONTENT-TYPE: application/json
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/vpcs
-
-{
- "console": 2001,
- "name": "PC TEST 1",
- "project_id": "a1e920ca-338a-4e9f-b363-aa607b09dd80",
- "script_file": null,
- "startup_script": null,
- "uuid": "d7a9ef38-2863-4cf2-97ce-dcf8416a93ae"
-}
diff --git a/docs/api/examples/post_vpcsuuidportsportnumberdnio.txt b/docs/api/examples/post_vpcsuuidportsportnumberdnio.txt
deleted file mode 100644
index 83bf344c..00000000
--- a/docs/api/examples/post_vpcsuuidportsportnumberdnio.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-curl -i -X POST 'http://localhost:8000/vpcs/{uuid}/ports/{port_number:\d+}/nio' -d '{"lport": 4242, "rhost": "127.0.0.1", "rport": 4343, "type": "nio_udp"}'
-
-POST /vpcs/{uuid}/ports/{port_number:\d+}/nio HTTP/1.1
-{
- "lport": 4242,
- "rhost": "127.0.0.1",
- "rport": 4343,
- "type": "nio_udp"
-}
-
-
-HTTP/1.1 201
-CONNECTION: keep-alive
-CONTENT-LENGTH: 89
-CONTENT-TYPE: application/json
-DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
-X-ROUTE: /v1/vpcs/{uuid}/ports/{port_number:\d+}/nio
-
-{
- "lport": 4242,
- "rhost": "127.0.0.1",
- "rport": 4343,
- "type": "nio_udp"
-}
diff --git a/docs/api/examples/put_projectsprojectid.txt b/docs/api/examples/put_projectsprojectid.txt
index e0366b62..b4043f7e 100644
--- a/docs/api/examples/put_projectsprojectid.txt
+++ b/docs/api/examples/put_projectsprojectid.txt
@@ -1,21 +1,20 @@
-curl -i -X PUT 'http://localhost:8000/projects/{project_id}' -d '{"temporary": false}'
+curl -i -X PUT 'http://localhost:8000/projects/{project_id}' -d '{"path": "/tmp/pytest-42/test_update_path_project_non_l0"}'
PUT /projects/{project_id} HTTP/1.1
{
- "temporary": false
+ "path": "/tmp/pytest-42/test_update_path_project_non_l0"
}
-HTTP/1.1 200
-CONNECTION: keep-alive
-CONTENT-LENGTH: 164
+HTTP/1.1 403
+CONNECTION: close
+CONTENT-LENGTH: 101
CONTENT-TYPE: application/json
DATE: Thu, 08 Jan 2015 16:09:15 GMT
-SERVER: Python/3.4 GNS3/1.3.dev1
+SERVER: Python/3.4 aiohttp/0.13.1
X-ROUTE: /v1/projects/{project_id}
{
- "location": "/var/folders/3s/r2wbv07n7wg4vrsn874lmxxh0000gn/T/tmptf8_s67s",
- "project_id": "12d03846-c355-4da9-b708-cd45e5d30a50",
- "temporary": false
+ "message": "You are not allowed to modifiy the project directory location",
+ "status": 403
}
diff --git a/docs/api/v1projects.rst b/docs/api/v1projects.rst
index 303c52a9..c1fa393c 100644
--- a/docs/api/v1projects.rst
+++ b/docs/api/v1projects.rst
@@ -29,6 +29,7 @@ Output
Name | Mandatory | Type | Description |
location | ✔ | string | Base directory where the project should be created on remote server |
+ path | | string | Directory of the project on the server |
project_id | ✔ | string | Project UUID |
temporary | ✔ | boolean | If project is a temporary project |
diff --git a/docs/api/v1projectsprojectid.rst b/docs/api/v1projectsprojectid.rst
index 0b872074..0ad7f43e 100644
--- a/docs/api/v1projectsprojectid.rst
+++ b/docs/api/v1projectsprojectid.rst
@@ -23,6 +23,7 @@ Output
Name | Mandatory | Type | Description |
location | ✔ | string | Base directory where the project should be created on remote server |
+ path | | string | Directory of the project on the server |
project_id | ✔ | string | Project UUID |
temporary | ✔ | boolean | If project is a temporary project |
@@ -39,6 +40,7 @@ Parameters
Response status codes
**********************
- **200**: The project has been updated
+- **403**: You are not allowed to modify this property
- **404**: The project doesn't exist
Input
@@ -47,6 +49,7 @@ Input
Name | Mandatory | Type | Description |
+ path | | ['string', 'null'] | Path of the project on the server (work only with --local) |
temporary | | boolean | If project is a temporary project |
@@ -57,6 +60,7 @@ Output
Name | Mandatory | Type | Description |
location | ✔ | string | Base directory where the project should be created on remote server |
+ path | | string | Directory of the project on the server |
project_id | ✔ | string | Project UUID |
temporary | ✔ | boolean | If project is a temporary project |
diff --git a/docs/api/v1virtualbox.rst b/docs/api/v1virtualbox.rst
deleted file mode 100644
index 754badb1..00000000
--- a/docs/api/v1virtualbox.rst
+++ /dev/null
@@ -1,53 +0,0 @@
-/v1/virtualbox
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Create a new VirtualBox VM instance
-
-Response status codes
-**********************
-- **400**: Invalid project UUID
-- **201**: Instance created
-- **409**: Conflict
-
-Input
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- adapter_start_index | | integer | adapter index from which to start using adapters |
- adapter_type | | string | VirtualBox adapter type |
- adapters | | integer | number of adapters |
- console | | integer | console TCP port |
- enable_remote_console | | boolean | enable the remote console |
- headless | | boolean | headless mode |
- linked_clone | ✔ | boolean | either the VM is a linked clone or not |
- name | ✔ | string | VirtualBox VM instance name |
- project_id | ✔ | string | Project UUID |
- uuid | | string | VirtualBox VM instance UUID |
- vbox_id | | integer | VirtualBox VM instance ID (for project created before GNS3 1.3) |
- vmname | ✔ | string | VirtualBox VM name (in VirtualBox itself) |
-
-
-Output
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- adapter_start_index | | integer | adapter index from which to start using adapters |
- adapter_type | | string | VirtualBox adapter type |
- adapters | | integer | number of adapters |
- console | | integer | console TCP port |
- enable_remote_console | | boolean | enable the remote console |
- headless | | boolean | headless mode |
- name | ✔ | string | VirtualBox VM instance name |
- project_id | ✔ | string | Project UUID |
- uuid | ✔ | string | VirtualBox VM instance UUID |
- vmname | | string | VirtualBox VM name (in VirtualBox itself) |
-
-
diff --git a/docs/api/v1virtualboxuuid.rst b/docs/api/v1virtualboxuuid.rst
deleted file mode 100644
index 90b30f7c..00000000
--- a/docs/api/v1virtualboxuuid.rst
+++ /dev/null
@@ -1,99 +0,0 @@
-/v1/virtualbox/{uuid}
------------------------------------------------------------
-
-.. contents::
-
-GET /v1/virtualbox/**{uuid}**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Get a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **200**: Success
-- **404**: Instance doesn't exist
-
-Output
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- adapter_start_index | | integer | adapter index from which to start using adapters |
- adapter_type | | string | VirtualBox adapter type |
- adapters | | integer | number of adapters |
- console | | integer | console TCP port |
- enable_remote_console | | boolean | enable the remote console |
- headless | | boolean | headless mode |
- name | ✔ | string | VirtualBox VM instance name |
- project_id | ✔ | string | Project UUID |
- uuid | ✔ | string | VirtualBox VM instance UUID |
- vmname | | string | VirtualBox VM name (in VirtualBox itself) |
-
-
-
-PUT /v1/virtualbox/**{uuid}**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Update a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **200**: Instance updated
-- **409**: Conflict
-- **404**: Instance doesn't exist
-
-Input
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- adapter_start_index | | integer | adapter index from which to start using adapters |
- adapter_type | | string | VirtualBox adapter type |
- adapters | | integer | number of adapters |
- console | | integer | console TCP port |
- enable_remote_console | | boolean | enable the remote console |
- headless | | boolean | headless mode |
- name | | string | VirtualBox VM instance name |
- vmname | | string | VirtualBox VM name (in VirtualBox itself) |
-
-
-Output
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- adapter_start_index | | integer | adapter index from which to start using adapters |
- adapter_type | | string | VirtualBox adapter type |
- adapters | | integer | number of adapters |
- console | | integer | console TCP port |
- enable_remote_console | | boolean | enable the remote console |
- headless | | boolean | headless mode |
- name | ✔ | string | VirtualBox VM instance name |
- project_id | ✔ | string | Project UUID |
- uuid | ✔ | string | VirtualBox VM instance UUID |
- vmname | | string | VirtualBox VM name (in VirtualBox itself) |
-
-
-
-DELETE /v1/virtualbox/**{uuid}**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Delete a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **404**: Instance doesn't exist
-- **204**: Instance deleted
-
diff --git a/docs/api/v1virtualboxuuidadaptersadapteriddnio.rst b/docs/api/v1virtualboxuuidadaptersadapteriddnio.rst
deleted file mode 100644
index dc6649f7..00000000
--- a/docs/api/v1virtualboxuuidadaptersadapteriddnio.rst
+++ /dev/null
@@ -1,36 +0,0 @@
-/v1/virtualbox/{uuid}/adapters/{adapter_id:\d+}/nio
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/adapters/**{adapter_id:\d+}**/nio
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Add a NIO to a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-- **adapter_id**: Adapter where the nio should be added
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **201**: NIO created
-- **404**: Instance doesn't exist
-
-
-DELETE /v1/virtualbox/**{uuid}**/adapters/**{adapter_id:\d+}**/nio
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Remove a NIO from a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-- **adapter_id**: Adapter from where the nio should be removed
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: NIO deleted
-
diff --git a/docs/api/v1virtualboxuuidcaptureadapteriddstart.rst b/docs/api/v1virtualboxuuidcaptureadapteriddstart.rst
deleted file mode 100644
index db6f0f61..00000000
--- a/docs/api/v1virtualboxuuidcaptureadapteriddstart.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-/v1/virtualbox/{uuid}/capture/{adapter_id:\d+}/start
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/capture/**{adapter_id:\d+}**/start
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Start a packet capture on a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-- **adapter_id**: Adapter to start a packet capture
-
-Response status codes
-**********************
-- **200**: Capture started
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-
-Input
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- capture_filename | ✔ | string | Capture file name |
-
-
diff --git a/docs/api/v1virtualboxuuidcaptureadapteriddstop.rst b/docs/api/v1virtualboxuuidcaptureadapteriddstop.rst
deleted file mode 100644
index eacc8212..00000000
--- a/docs/api/v1virtualboxuuidcaptureadapteriddstop.rst
+++ /dev/null
@@ -1,20 +0,0 @@
-/v1/virtualbox/{uuid}/capture/{adapter_id:\d+}/stop
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/capture/**{adapter_id:\d+}**/stop
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Stop a packet capture on a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-- **adapter_id**: Adapter to stop a packet capture
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Capture stopped
-
diff --git a/docs/api/v1virtualboxuuidreload.rst b/docs/api/v1virtualboxuuidreload.rst
deleted file mode 100644
index 3ad6c3b7..00000000
--- a/docs/api/v1virtualboxuuidreload.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/virtualbox/{uuid}/reload
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/reload
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Reload a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance reloaded
-
diff --git a/docs/api/v1virtualboxuuidresume.rst b/docs/api/v1virtualboxuuidresume.rst
deleted file mode 100644
index 97bfdbf8..00000000
--- a/docs/api/v1virtualboxuuidresume.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/virtualbox/{uuid}/resume
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/resume
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Resume a suspended VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance resumed
-
diff --git a/docs/api/v1virtualboxuuidstart.rst b/docs/api/v1virtualboxuuidstart.rst
deleted file mode 100644
index 178ed7d4..00000000
--- a/docs/api/v1virtualboxuuidstart.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/virtualbox/{uuid}/start
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/start
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Start a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance started
-
diff --git a/docs/api/v1virtualboxuuidstop.rst b/docs/api/v1virtualboxuuidstop.rst
deleted file mode 100644
index 8cbe9441..00000000
--- a/docs/api/v1virtualboxuuidstop.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/virtualbox/{uuid}/stop
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/stop
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Stop a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance stopped
-
diff --git a/docs/api/v1virtualboxuuidsuspend.rst b/docs/api/v1virtualboxuuidsuspend.rst
deleted file mode 100644
index 3c14bc16..00000000
--- a/docs/api/v1virtualboxuuidsuspend.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/virtualbox/{uuid}/suspend
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/virtualbox/**{uuid}**/suspend
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Suspend a VirtualBox VM instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance suspended
-
diff --git a/docs/api/v1vpcs.rst b/docs/api/v1vpcs.rst
deleted file mode 100644
index 3e26b9ce..00000000
--- a/docs/api/v1vpcs.rst
+++ /dev/null
@@ -1,43 +0,0 @@
-/v1/vpcs
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/vpcs
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Create a new VPCS instance
-
-Response status codes
-**********************
-- **400**: Invalid project UUID
-- **201**: Instance created
-- **409**: Conflict
-
-Input
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- console | | ['integer', 'null'] | console TCP port |
- name | ✔ | string | VPCS device name |
- project_id | ✔ | string | Project UUID |
- startup_script | | ['string', 'null'] | Content of the VPCS startup script |
- uuid | | string | VPCS device UUID |
- vpcs_id | | integer | VPCS device instance ID (for project created before GNS3 1.3) |
-
-
-Output
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- console | ✔ | integer | console TCP port |
- name | ✔ | string | VPCS device name |
- project_id | ✔ | string | Project UUID |
- script_file | | ['string', 'null'] | VPCS startup script |
- startup_script | | ['string', 'null'] | Content of the VPCS startup script |
- uuid | ✔ | string | VPCS device UUID |
-
-
diff --git a/docs/api/v1vpcsuuid.rst b/docs/api/v1vpcsuuid.rst
deleted file mode 100644
index 0bc9e4e5..00000000
--- a/docs/api/v1vpcsuuid.rst
+++ /dev/null
@@ -1,86 +0,0 @@
-/v1/vpcs/{uuid}
------------------------------------------------------------
-
-.. contents::
-
-GET /v1/vpcs/**{uuid}**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Get a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **200**: Success
-- **404**: Instance doesn't exist
-
-Output
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- console | ✔ | integer | console TCP port |
- name | ✔ | string | VPCS device name |
- project_id | ✔ | string | Project UUID |
- script_file | | ['string', 'null'] | VPCS startup script |
- startup_script | | ['string', 'null'] | Content of the VPCS startup script |
- uuid | ✔ | string | VPCS device UUID |
-
-
-
-PUT /v1/vpcs/**{uuid}**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Update a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **200**: Instance updated
-- **409**: Conflict
-- **404**: Instance doesn't exist
-
-Input
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- console | | ['integer', 'null'] | console TCP port |
- name | | ['string', 'null'] | VPCS device name |
- startup_script | | ['string', 'null'] | Content of the VPCS startup script |
-
-
-Output
-*******
-.. raw:: html
-
-
- Name | Mandatory | Type | Description |
- console | ✔ | integer | console TCP port |
- name | ✔ | string | VPCS device name |
- project_id | ✔ | string | Project UUID |
- script_file | | ['string', 'null'] | VPCS startup script |
- startup_script | | ['string', 'null'] | Content of the VPCS startup script |
- uuid | ✔ | string | VPCS device UUID |
-
-
-
-DELETE /v1/vpcs/**{uuid}**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Delete a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **404**: Instance doesn't exist
-- **204**: Instance deleted
-
diff --git a/docs/api/v1vpcsuuidportsportnumberdnio.rst b/docs/api/v1vpcsuuidportsportnumberdnio.rst
deleted file mode 100644
index 72a5b999..00000000
--- a/docs/api/v1vpcsuuidportsportnumberdnio.rst
+++ /dev/null
@@ -1,36 +0,0 @@
-/v1/vpcs/{uuid}/ports/{port_number:\d+}/nio
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/vpcs/**{uuid}**/ports/**{port_number:\d+}**/nio
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Add a NIO to a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-- **port_number**: Port where the nio should be added
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **201**: NIO created
-- **404**: Instance doesn't exist
-
-
-DELETE /v1/vpcs/**{uuid}**/ports/**{port_number:\d+}**/nio
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Remove a NIO from a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-- **port_number**: Port from where the nio should be removed
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: NIO deleted
-
diff --git a/docs/api/v1vpcsuuidreload.rst b/docs/api/v1vpcsuuidreload.rst
deleted file mode 100644
index 5495cc6e..00000000
--- a/docs/api/v1vpcsuuidreload.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/vpcs/{uuid}/reload
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/vpcs/**{uuid}**/reload
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Reload a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance reloaded
-
diff --git a/docs/api/v1vpcsuuidstart.rst b/docs/api/v1vpcsuuidstart.rst
deleted file mode 100644
index 60b9af17..00000000
--- a/docs/api/v1vpcsuuidstart.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/vpcs/{uuid}/start
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/vpcs/**{uuid}**/start
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Start a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid VPCS instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance started
-
diff --git a/docs/api/v1vpcsuuidstop.rst b/docs/api/v1vpcsuuidstop.rst
deleted file mode 100644
index 90f96f06..00000000
--- a/docs/api/v1vpcsuuidstop.rst
+++ /dev/null
@@ -1,19 +0,0 @@
-/v1/vpcs/{uuid}/stop
------------------------------------------------------------
-
-.. contents::
-
-POST /v1/vpcs/**{uuid}**/stop
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Stop a VPCS instance
-
-Parameters
-**********
-- **uuid**: Instance UUID
-
-Response status codes
-**********************
-- **400**: Invalid VPCS instance UUID
-- **404**: Instance doesn't exist
-- **204**: Instance stopped
-
diff --git a/gns3server/handlers/virtualbox_handler.py b/gns3server/handlers/virtualbox_handler.py
index 00518700..61ad2556 100644
--- a/gns3server/handlers/virtualbox_handler.py
+++ b/gns3server/handlers/virtualbox_handler.py
@@ -23,6 +23,7 @@ from ..schemas.virtualbox import VBOX_NIO_SCHEMA
from ..schemas.virtualbox import VBOX_CAPTURE_SCHEMA
from ..schemas.virtualbox import VBOX_OBJECT_SCHEMA
from ..modules.virtualbox import VirtualBox
+from ..modules.project_manager import ProjectManager
class VirtualBoxHandler:
@@ -33,7 +34,7 @@ class VirtualBoxHandler:
@classmethod
@Route.get(
- r"/virtualbox/vms_tmp",
+ r"/virtualbox/vms",
status_codes={
200: "Success",
},
@@ -46,10 +47,13 @@ class VirtualBoxHandler:
@classmethod
@Route.post(
- r"/virtualbox/vms",
+ r"/{project_id}/virtualbox/vms",
+ parameters={
+ "project_id": "UUID for the project"
+ },
status_codes={
201: "Instance created",
- 400: "Invalid project ID",
+ 400: "Invalid request",
409: "Conflict"
},
description="Create a new VirtualBox VM instance",
@@ -59,7 +63,7 @@ class VirtualBoxHandler:
vbox_manager = VirtualBox.instance()
vm = yield from vbox_manager.create_vm(request.json.pop("name"),
- request.json.pop("project_id"),
+ request.match_info["project_id"],
request.json.get("vm_id"),
request.json.pop("vmname"),
request.json.pop("linked_clone"),
@@ -74,12 +78,14 @@ class VirtualBoxHandler:
@classmethod
@Route.get(
- r"/virtualbox/vms/{vm_id}",
+ r"/{project_id}/virtualbox/vms/{vm_id}",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
200: "Success",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Get a VirtualBox VM instance",
@@ -87,17 +93,19 @@ class VirtualBoxHandler:
def show(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
response.json(vm)
@classmethod
@Route.put(
- r"/virtualbox/vms/{vm_id}",
+ r"/{project_id}/virtualbox/vms/{vm_id}",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
200: "Instance updated",
+ 400: "Invalid request",
404: "Instance doesn't exist",
409: "Conflict"
},
@@ -107,7 +115,7 @@ class VirtualBoxHandler:
def update(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
for name, value in request.json.items():
if hasattr(vm, name) and getattr(vm, name) != value:
@@ -118,124 +126,135 @@ class VirtualBoxHandler:
@classmethod
@Route.delete(
- r"/virtualbox/vms/{vm_id}",
+ r"/{project_id}/virtualbox/vms/{vm_id}",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance deleted",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Delete a VirtualBox VM instance")
def delete(request, response):
+ # check the project_id exists
+ ProjectManager.instance().get_project(request.match_info["project_id"])
+
yield from VirtualBox.instance().delete_vm(request.match_info["vm_id"])
response.set_status(204)
@classmethod
@Route.post(
- r"/virtualbox/vms/{vm_id}/start",
+ r"/{project_id}/virtualbox/vms/{vm_id}/start",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance started",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Start a VirtualBox VM instance")
def start(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.start()
response.set_status(204)
@classmethod
@Route.post(
- r"/virtualbox/vms/{vm_id}/stop",
+ r"/{project_id}/virtualbox/vms/{vm_id}/stop",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance stopped",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Stop a VirtualBox VM instance")
def stop(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.stop()
response.set_status(204)
@classmethod
@Route.post(
- r"/virtualbox/vms/{vm_id}/suspend",
+ r"/{project_id}/virtualbox/vms/{vm_id}/suspend",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance suspended",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Suspend a VirtualBox VM instance")
def suspend(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.suspend()
response.set_status(204)
@classmethod
@Route.post(
- r"/virtualbox/vms/{vm_id}/resume",
+ r"/{project_id}/virtualbox/vms/{vm_id}/resume",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance resumed",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Resume a suspended VirtualBox VM instance")
def suspend(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.resume()
response.set_status(204)
@classmethod
@Route.post(
- r"/virtualbox/vms/{vm_id}/reload",
+ r"/{project_id}/virtualbox/vms/{vm_id}/reload",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance reloaded",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Reload a VirtualBox VM instance")
- def suspend(request, response):
+ def reload(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.reload()
response.set_status(204)
@Route.post(
- r"/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio",
+ r"/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
"adapter_id": "Adapter where the nio should be added"
},
status_codes={
201: "NIO created",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Add a NIO to a VirtualBox VM instance",
@@ -244,7 +263,7 @@ class VirtualBoxHandler:
def create_nio(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
nio = vbox_manager.create_nio(vbox_manager.vboxmanage_path, request.json)
vm.port_add_nio_binding(int(request.match_info["adapter_id"]), nio)
response.set_status(201)
@@ -252,33 +271,35 @@ class VirtualBoxHandler:
@classmethod
@Route.delete(
- r"/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio",
+ r"/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
"adapter_id": "Adapter from where the nio should be removed"
},
status_codes={
204: "NIO deleted",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Remove a NIO from a VirtualBox VM instance")
def delete_nio(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
vm.port_remove_nio_binding(int(request.match_info["adapter_id"]))
response.set_status(204)
@Route.post(
- r"/virtualbox/{vm_id}/capture/{adapter_id:\d+}/start",
+ r"/{project_id}/virtualbox/{vm_id}/capture/{adapter_id:\d+}/start",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
"adapter_id": "Adapter to start a packet capture"
},
status_codes={
200: "Capture started",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Start a packet capture on a VirtualBox VM instance",
@@ -286,27 +307,28 @@ class VirtualBoxHandler:
def start_capture(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
adapter_id = int(request.match_info["adapter_id"])
pcap_file_path = os.path.join(vm.project.capture_working_directory(), request.json["filename"])
vm.start_capture(adapter_id, pcap_file_path)
response.json({"pcap_file_path": pcap_file_path})
@Route.post(
- r"/virtualbox/{vm_id}/capture/{adapter_id:\d+}/stop",
+ r"/{project_id}/virtualbox/{vm_id}/capture/{adapter_id:\d+}/stop",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
"adapter_id": "Adapter to stop a packet capture"
},
status_codes={
204: "Capture stopped",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Stop a packet capture on a VirtualBox VM instance")
def start_capture(request, response):
vbox_manager = VirtualBox.instance()
- vm = vbox_manager.get_vm(request.match_info["vm_id"])
+ vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
vm.stop_capture(int(request.match_info["adapter_id"]))
response.set_status(204)
diff --git a/gns3server/handlers/vpcs_handler.py b/gns3server/handlers/vpcs_handler.py
index 539ebb68..871f2713 100644
--- a/gns3server/handlers/vpcs_handler.py
+++ b/gns3server/handlers/vpcs_handler.py
@@ -31,10 +31,13 @@ class VPCSHandler:
@classmethod
@Route.post(
- r"/vpcs/vms",
+ r"/{project_id}/vpcs/vms",
+ parameters={
+ "project_id": "UUID for the project"
+ },
status_codes={
201: "Instance created",
- 400: "Invalid project UUID",
+ 400: "Invalid request",
409: "Conflict"
},
description="Create a new VPCS instance",
@@ -44,7 +47,7 @@ class VPCSHandler:
vpcs = VPCS.instance()
vm = yield from vpcs.create_vm(request.json["name"],
- request.json["project_id"],
+ request.match_info["project_id"],
request.json.get("vm_id"),
console=request.json.get("console"),
startup_script=request.json.get("startup_script"))
@@ -53,12 +56,14 @@ class VPCSHandler:
@classmethod
@Route.get(
- r"/vpcs/vms/{vm_id}",
+ r"/{project_id}/vpcs/vms/{vm_id}",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
200: "Success",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Get a VPCS instance",
@@ -66,17 +71,19 @@ class VPCSHandler:
def show(request, response):
vpcs_manager = VPCS.instance()
- vm = vpcs_manager.get_vm(request.match_info["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
response.json(vm)
@classmethod
@Route.put(
- r"/vpcs/vms/{vm_id}",
+ r"/{project_id}/vpcs/vms/{vm_id}",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
200: "Instance updated",
+ 400: "Invalid request",
404: "Instance doesn't exist",
409: "Conflict"
},
@@ -86,7 +93,7 @@ class VPCSHandler:
def update(request, response):
vpcs_manager = VPCS.instance()
- vm = vpcs_manager.get_vm(request.match_info["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
vm.name = request.json.get("name", vm.name)
vm.console = request.json.get("console", vm.console)
vm.startup_script = request.json.get("startup_script", vm.startup_script)
@@ -94,12 +101,14 @@ class VPCSHandler:
@classmethod
@Route.delete(
- r"/vpcs/vms/{vm_id}",
+ r"/{project_id}/vpcs/vms/{vm_id}",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance deleted",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Delete a VPCS instance")
@@ -110,70 +119,74 @@ class VPCSHandler:
@classmethod
@Route.post(
- r"/vpcs/vms/{vm_id}/start",
+ r"/{project_id}/vpcs/vms/{vm_id}/start",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance started",
- 400: "Invalid VPCS instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Start a VPCS instance")
def start(request, response):
vpcs_manager = VPCS.instance()
- vm = vpcs_manager.get_vm(request.match_info["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.start()
response.set_status(204)
@classmethod
@Route.post(
- r"/vpcs/vms/{vm_id}/stop",
+ r"/{project_id}/vpcs/vms/{vm_id}/stop",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance"
},
status_codes={
204: "Instance stopped",
- 400: "Invalid VPCS instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Stop a VPCS instance")
def stop(request, response):
vpcs_manager = VPCS.instance()
- vm = vpcs_manager.get_vm(request.match_info["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.stop()
response.set_status(204)
@classmethod
@Route.post(
- r"/vpcs/vms/{vm_id}/reload",
+ r"/{project_id}/vpcs/vms/{vm_id}/reload",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
},
status_codes={
204: "Instance reloaded",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
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["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
yield from vm.reload()
response.set_status(204)
@Route.post(
- r"/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio",
+ r"/{project_id}/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
"port_number": "Port where the nio should be added"
},
status_codes={
201: "NIO created",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Add a NIO to a VPCS instance",
@@ -182,7 +195,7 @@ class VPCSHandler:
def create_nio(request, response):
vpcs_manager = VPCS.instance()
- vm = vpcs_manager.get_vm(request.match_info["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
nio = vpcs_manager.create_nio(vm.vpcs_path, request.json)
vm.port_add_nio_binding(int(request.match_info["port_number"]), nio)
response.set_status(201)
@@ -190,20 +203,21 @@ class VPCSHandler:
@classmethod
@Route.delete(
- r"/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio",
+ r"/{project_id}/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio",
parameters={
+ "project_id": "UUID for the project",
"vm_id": "UUID for the instance",
"port_number": "Port from where the nio should be removed"
},
status_codes={
204: "NIO deleted",
- 400: "Invalid instance UUID",
+ 400: "Invalid request",
404: "Instance doesn't exist"
},
description="Remove a NIO from a VPCS instance")
def delete_nio(request, response):
vpcs_manager = VPCS.instance()
- vm = vpcs_manager.get_vm(request.match_info["vm_id"])
+ vm = vpcs_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
vm.port_remove_nio_binding(int(request.match_info["port_number"]))
response.set_status(204)
diff --git a/gns3server/modules/base_manager.py b/gns3server/modules/base_manager.py
index e1cecf22..52a224c9 100644
--- a/gns3server/modules/base_manager.py
+++ b/gns3server/modules/base_manager.py
@@ -108,22 +108,34 @@ class BaseManager:
BaseManager._instance = None
log.debug("Module {} unloaded".format(self.module_name))
- def get_vm(self, vm_id):
+ def get_vm(self, vm_id, project_id=None):
"""
Returns a VM instance.
:param vm_id: VM identifier
+ :param project_id: Project identifier
:returns: VM instance
"""
+ if project_id:
+ # check the project_id exists
+ project = ProjectManager.instance().get_project(project_id)
+
try:
UUID(vm_id, version=4)
except ValueError:
- raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(vm_id))
+ raise aiohttp.web.HTTPBadRequest(text="VM ID {} is not a valid UUID".format(vm_id))
if vm_id not in self._vms:
- raise aiohttp.web.HTTPNotFound(text="ID {} doesn't exist".format(vm_id))
+ raise aiohttp.web.HTTPNotFound(text="VM ID {} doesn't exist".format(vm_id))
+
+ vm = self._vms[vm_id]
+
+ if project_id:
+ if vm.project.id != project.id:
+ raise aiohttp.web.HTTPNotFound(text="Project ID {} doesn't belong to VM {}".format(project_id, vm.name))
+
return self._vms[vm_id]
@asyncio.coroutine
diff --git a/gns3server/modules/project_manager.py b/gns3server/modules/project_manager.py
index 55cae7c4..87ed9288 100644
--- a/gns3server/modules/project_manager.py
+++ b/gns3server/modules/project_manager.py
@@ -54,7 +54,7 @@ class ProjectManager:
try:
UUID(project_id, version=4)
except ValueError:
- raise aiohttp.web.HTTPBadRequest(text="{} is not a valid UUID".format(project_id))
+ raise aiohttp.web.HTTPBadRequest(text="Project ID {} is not a valid UUID".format(project_id))
if project_id not in self._projects:
raise aiohttp.web.HTTPNotFound(text="Project ID {} doesn't exist".format(project_id))
diff --git a/gns3server/schemas/virtualbox.py b/gns3server/schemas/virtualbox.py
index e2fe70aa..03785691 100644
--- a/gns3server/schemas/virtualbox.py
+++ b/gns3server/schemas/virtualbox.py
@@ -28,13 +28,6 @@ VBOX_CREATE_SCHEMA = {
"maxLength": 36,
"pattern": "(^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|\d+)$"
},
- "project_id": {
- "description": "Project UUID",
- "type": "string",
- "minLength": 36,
- "maxLength": 36,
- "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
- },
"linked_clone": {
"description": "either the VM is a linked clone or not",
"type": "boolean"
@@ -82,7 +75,7 @@ VBOX_CREATE_SCHEMA = {
},
},
"additionalProperties": False,
- "required": ["name", "vmname", "linked_clone", "project_id"],
+ "required": ["name", "vmname", "linked_clone"],
}
VBOX_UPDATE_SCHEMA = {
diff --git a/gns3server/schemas/vpcs.py b/gns3server/schemas/vpcs.py
index 30238901..db446237 100644
--- a/gns3server/schemas/vpcs.py
+++ b/gns3server/schemas/vpcs.py
@@ -33,13 +33,6 @@ VPCS_CREATE_SCHEMA = {
"maxLength": 36,
"pattern": "^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}|\d+)$"
},
- "project_id": {
- "description": "Project UUID",
- "type": "string",
- "minLength": 36,
- "maxLength": 36,
- "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
- },
"console": {
"description": "console TCP port",
"minimum": 1,
@@ -52,7 +45,7 @@ VPCS_CREATE_SCHEMA = {
},
},
"additionalProperties": False,
- "required": ["name", "project_id"]
+ "required": ["name"]
}
VPCS_UPDATE_SCHEMA = {
diff --git a/tests/api/test_virtualbox.py b/tests/api/test_virtualbox.py
index 0cf2cda9..86179ff8 100644
--- a/tests/api/test_virtualbox.py
+++ b/tests/api/test_virtualbox.py
@@ -22,10 +22,9 @@ from tests.utils import asyncio_patch
@pytest.fixture(scope="module")
def vm(server, project):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.create", return_value=True) as mock:
- response = server.post("/virtualbox/vms", {"name": "VMTEST",
- "vmname": "VMTEST",
- "linked_clone": False,
- "project_id": project.id})
+ response = server.post("/{project_id}/virtualbox/vms".format(project_id=project.id), {"name": "VMTEST",
+ "vmname": "VMTEST",
+ "linked_clone": False})
assert mock.called
assert response.status == 201
return response.json
@@ -34,10 +33,9 @@ def vm(server, project):
def test_vbox_create(server, project):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.create", return_value=True):
- response = server.post("/virtualbox/vms", {"name": "VM1",
- "vmname": "VM1",
- "linked_clone": False,
- "project_id": project.id},
+ response = server.post("/{project_id}/virtualbox/vms".format(project_id=project.id), {"name": "VM1",
+ "vmname": "VM1",
+ "linked_clone": False},
example=True)
assert response.status == 201
assert response.json["name"] == "VM1"
@@ -45,72 +43,74 @@ def test_vbox_create(server, project):
def test_vbox_get(server, project, vm):
- response = server.get("/virtualbox/vms/{}".format(vm["vm_id"]), example=True)
+ response = server.get("/{project_id}/virtualbox/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 200
- assert response.route == "/virtualbox/vms/{vm_id}"
+ assert response.route == "/{project_id}/virtualbox/vms/{vm_id}"
assert response.json["name"] == "VMTEST"
assert response.json["project_id"] == project.id
def test_vbox_start(server, vm):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.start", return_value=True) as mock:
- response = server.post("/virtualbox/vms/{}/start".format(vm["vm_id"]))
+ response = server.post("/{project_id}/virtualbox/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vbox_stop(server, vm):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.stop", return_value=True) as mock:
- response = server.post("/virtualbox/vms/{}/stop".format(vm["vm_id"]))
+ response = server.post("/{project_id}/virtualbox/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vbox_suspend(server, vm):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.suspend", return_value=True) as mock:
- response = server.post("/virtualbox/vms/{}/suspend".format(vm["vm_id"]))
+ response = server.post("/{project_id}/virtualbox/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vbox_resume(server, vm):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.resume", return_value=True) as mock:
- response = server.post("/virtualbox/vms/{}/resume".format(vm["vm_id"]))
+ response = server.post("/{project_id}/virtualbox/vms/{vm_id}/resume".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vbox_reload(server, vm):
with asyncio_patch("gns3server.modules.virtualbox.virtualbox_vm.VirtualBoxVM.reload", return_value=True) as mock:
- response = server.post("/virtualbox/vms/{}/reload".format(vm["vm_id"]))
+ response = server.post("/{project_id}/virtualbox/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vbox_nio_create_udp(server, vm):
- response = server.post("/virtualbox/vms/{}/adapters/0/nio".format(vm["vm_id"]), {"type": "nio_udp",
- "lport": 4242,
- "rport": 4343,
- "rhost": "127.0.0.1"},
+ response = server.post("/{project_id}/virtualbox/vms/{vm_id}/adapters/0/nio".format(project_id=vm["project_id"],
+ vm_id=vm["vm_id"]), {"type": "nio_udp",
+ "lport": 4242,
+ "rport": 4343,
+ "rhost": "127.0.0.1"},
example=True)
assert response.status == 201
- assert response.route == "/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio"
+ assert response.route == "/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio"
assert response.json["type"] == "nio_udp"
def test_vbox_delete_nio(server, vm):
- server.post("/virtualbox/vms/{}/adapters/0/nio".format(vm["vm_id"]), {"type": "nio_udp",
- "lport": 4242,
- "rport": 4343,
- "rhost": "127.0.0.1"})
- response = server.delete("/virtualbox/vms/{}/adapters/0/nio".format(vm["vm_id"]), example=True)
+ server.post("/{project_id}/virtualbox/vms/{vm_id}/adapters/0/nio".format(project_id=vm["project_id"],
+ vm_id=vm["vm_id"]), {"type": "nio_udp",
+ "lport": 4242,
+ "rport": 4343,
+ "rhost": "127.0.0.1"})
+ response = server.delete("/{project_id}/virtualbox/vms/{vm_id}/adapters/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 204
- assert response.route == "/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio"
+ assert response.route == "/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio"
-def test_vpcs_update(server, vm, free_console_port):
- response = server.put("/virtualbox/vms/{}".format(vm["vm_id"]), {"name": "test",
- "console": free_console_port})
+def test_vbox_update(server, vm, free_console_port):
+ response = server.put("/{project_id}/virtualbox/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
+ "console": free_console_port})
assert response.status == 200
assert response.json["name"] == "test"
assert response.json["console"] == free_console_port
diff --git a/tests/api/test_vpcs.py b/tests/api/test_vpcs.py
index afdb578e..fb614693 100644
--- a/tests/api/test_vpcs.py
+++ b/tests/api/test_vpcs.py
@@ -23,108 +23,108 @@ from unittest.mock import patch
@pytest.fixture(scope="module")
def vm(server, project):
- response = server.post("/vpcs/vms", {"name": "PC TEST 1", "project_id": project.id})
+ response = server.post("/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1"})
assert response.status == 201
return response.json
def test_vpcs_create(server, project):
- response = server.post("/vpcs/vms", {"name": "PC TEST 1", "project_id": project.id}, example=True)
+ response = server.post("/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1"}, example=True)
assert response.status == 201
- assert response.route == "/vpcs/vms"
+ assert response.route == "/{project_id}/vpcs/vms"
assert response.json["name"] == "PC TEST 1"
assert response.json["project_id"] == project.id
assert response.json["script_file"] is None
def test_vpcs_get(server, project, vm):
- response = server.get("/vpcs/vms/{}".format(vm["vm_id"]), example=True)
+ response = server.get("/{project_id}/vpcs/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 200
- assert response.route == "/vpcs/vms/{vm_id}"
+ assert response.route == "/{project_id}/vpcs/vms/{vm_id}"
assert response.json["name"] == "PC TEST 1"
assert response.json["project_id"] == project.id
def test_vpcs_create_startup_script(server, project):
- response = server.post("/vpcs/vms", {"name": "PC TEST 1", "project_id": project.id, "startup_script": "ip 192.168.1.2\necho TEST"})
+ response = server.post("/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1", "startup_script": "ip 192.168.1.2\necho TEST"})
assert response.status == 201
- assert response.route == "/vpcs/vms"
+ assert response.route == "/{project_id}/vpcs/vms"
assert response.json["name"] == "PC TEST 1"
assert response.json["project_id"] == project.id
assert response.json["startup_script"] == "ip 192.168.1.2\necho TEST"
def test_vpcs_create_port(server, project, free_console_port):
- response = server.post("/vpcs/vms", {"name": "PC TEST 1", "project_id": project.id, "console": free_console_port})
+ response = server.post("/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1", "console": free_console_port})
assert response.status == 201
- assert response.route == "/vpcs/vms"
+ assert response.route == "/{project_id}/vpcs/vms"
assert response.json["name"] == "PC TEST 1"
assert response.json["project_id"] == project.id
assert response.json["console"] == free_console_port
def test_vpcs_nio_create_udp(server, vm):
- response = server.post("/vpcs/vms/{}/ports/0/nio".format(vm["vm_id"]), {"type": "nio_udp",
- "lport": 4242,
- "rport": 4343,
- "rhost": "127.0.0.1"},
+ response = server.post("/{project_id}/vpcs/vms/{vm_id}/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_udp",
+ "lport": 4242,
+ "rport": 4343,
+ "rhost": "127.0.0.1"},
example=True)
assert response.status == 201
- assert response.route == "/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio"
+ assert response.route == "/{project_id}/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp"
def test_vpcs_nio_create_tap(server, vm):
with patch("gns3server.modules.base_manager.BaseManager._has_privileged_access", return_value=True):
- response = server.post("/vpcs/vms/{}/ports/0/nio".format(vm["vm_id"]), {"type": "nio_tap",
- "tap_device": "test"})
+ response = server.post("/{project_id}/vpcs/vms/{vm_id}/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_tap",
+ "tap_device": "test"})
assert response.status == 201
- assert response.route == "/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio"
+ assert response.route == "/{project_id}/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_tap"
def test_vpcs_delete_nio(server, vm):
- server.post("/vpcs/vms/{}/ports/0/nio".format(vm["vm_id"]), {"type": "nio_udp",
- "lport": 4242,
- "rport": 4343,
- "rhost": "127.0.0.1"})
- response = server.delete("/vpcs/vms/{}/ports/0/nio".format(vm["vm_id"]), example=True)
+ server.post("/{project_id}/vpcs/vms/{vm_id}/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_udp",
+ "lport": 4242,
+ "rport": 4343,
+ "rhost": "127.0.0.1"})
+ response = server.delete("/{project_id}/vpcs/vms/{vm_id}/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 204
- assert response.route == "/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio"
+ assert response.route == "/{project_id}/vpcs/vms/{vm_id}/ports/{port_number:\d+}/nio"
def test_vpcs_start(server, vm):
with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM.start", return_value=True) as mock:
- response = server.post("/vpcs/vms/{}/start".format(vm["vm_id"]))
+ response = server.post("/{project_id}/vpcs/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vpcs_stop(server, vm):
with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM.stop", return_value=True) as mock:
- response = server.post("/vpcs/vms/{}/stop".format(vm["vm_id"]))
+ response = server.post("/{project_id}/vpcs/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vpcs_reload(server, vm):
with asyncio_patch("gns3server.modules.vpcs.vpcs_vm.VPCSVM.reload", return_value=True) as mock:
- response = server.post("/vpcs/vms/{}/reload".format(vm["vm_id"]))
+ response = server.post("/{project_id}/vpcs/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vpcs_delete(server, vm):
with asyncio_patch("gns3server.modules.vpcs.VPCS.delete_vm", return_value=True) as mock:
- response = server.delete("/vpcs/vms/{}".format(vm["vm_id"]))
+ response = server.delete("/{project_id}/vpcs/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 204
def test_vpcs_update(server, vm, tmpdir, free_console_port):
- response = server.put("/vpcs/vms/{}".format(vm["vm_id"]), {"name": "test",
- "console": free_console_port,
- "startup_script": "ip 192.168.1.1"})
+ response = server.put("/{project_id}/vpcs/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
+ "console": free_console_port,
+ "startup_script": "ip 192.168.1.1"})
assert response.status == 200
assert response.json["name"] == "test"
assert response.json["console"] == free_console_port