mirror of https://github.com/GNS3/gns3-server
parent
90f71e7581
commit
8aa5514890
@ -0,0 +1,8 @@
|
||||
Qemu
|
||||
---------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
qemu/*
|
@ -0,0 +1,70 @@
|
||||
/v1/projects/{project_id}/qemu/vms
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
POST /v1/projects/**{project_id}**/qemu/vms
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Create a new Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **201**: Instance created
|
||||
- **409**: Conflict
|
||||
|
||||
Input
|
||||
*******
|
||||
.. raw:: html
|
||||
|
||||
<table>
|
||||
<tr> <th>Name</th> <th>Mandatory</th> <th>Type</th> <th>Description</th> </tr>
|
||||
<tr><td>adapter_type</td> <td> </td> <td>['string', 'null']</td> <td>QEMU adapter type</td> </tr>
|
||||
<tr><td>adapters</td> <td> </td> <td>['integer', 'null']</td> <td>number of adapters</td> </tr>
|
||||
<tr><td>console</td> <td> </td> <td>['integer', 'null']</td> <td>console TCP port</td> </tr>
|
||||
<tr><td>cpu_throttling</td> <td> </td> <td>['integer', 'null']</td> <td>Percentage of CPU allowed for QEMU</td> </tr>
|
||||
<tr><td>hda_disk_image</td> <td> </td> <td>['string', 'null']</td> <td>QEMU hda disk image path</td> </tr>
|
||||
<tr><td>hdb_disk_image</td> <td> </td> <td>['string', 'null']</td> <td>QEMU hdb disk image path</td> </tr>
|
||||
<tr><td>initrd</td> <td> </td> <td>['string', 'null']</td> <td>QEMU initrd path</td> </tr>
|
||||
<tr><td>kernel_command_line</td> <td> </td> <td>['string', 'null']</td> <td>QEMU kernel command line</td> </tr>
|
||||
<tr><td>kernel_image</td> <td> </td> <td>['string', 'null']</td> <td>QEMU kernel image path</td> </tr>
|
||||
<tr><td>legacy_networking</td> <td> </td> <td>['boolean', 'null']</td> <td>Use QEMU legagy networking commands (-net syntax)</td> </tr>
|
||||
<tr><td>monitor</td> <td> </td> <td>['integer', 'null']</td> <td>monitor TCP port</td> </tr>
|
||||
<tr><td>name</td> <td>✔</td> <td>string</td> <td>QEMU VM instance name</td> </tr>
|
||||
<tr><td>options</td> <td> </td> <td>['string', 'null']</td> <td>Additional QEMU options</td> </tr>
|
||||
<tr><td>process_priority</td> <td> </td> <td>enum</td> <td>Possible values: realtime, very high, high, normal, low, very low, null</td> </tr>
|
||||
<tr><td>qemu_path</td> <td>✔</td> <td>string</td> <td>Path to QEMU</td> </tr>
|
||||
<tr><td>ram</td> <td> </td> <td>['integer', 'null']</td> <td>amount of RAM in MB</td> </tr>
|
||||
<tr><td>vm_id</td> <td> </td> <td>['string', 'null']</td> <td>QEMU VM UUID</td> </tr>
|
||||
</table>
|
||||
|
||||
Output
|
||||
*******
|
||||
.. raw:: html
|
||||
|
||||
<table>
|
||||
<tr> <th>Name</th> <th>Mandatory</th> <th>Type</th> <th>Description</th> </tr>
|
||||
<tr><td>adapter_type</td> <td>✔</td> <td>string</td> <td>QEMU adapter type</td> </tr>
|
||||
<tr><td>adapters</td> <td>✔</td> <td>integer</td> <td>number of adapters</td> </tr>
|
||||
<tr><td>console</td> <td>✔</td> <td>integer</td> <td>console TCP port</td> </tr>
|
||||
<tr><td>cpu_throttling</td> <td>✔</td> <td>integer</td> <td>Percentage of CPU allowed for QEMU</td> </tr>
|
||||
<tr><td>hda_disk_image</td> <td>✔</td> <td>string</td> <td>QEMU hda disk image path</td> </tr>
|
||||
<tr><td>hdb_disk_image</td> <td>✔</td> <td>string</td> <td>QEMU hdb disk image path</td> </tr>
|
||||
<tr><td>initrd</td> <td>✔</td> <td>string</td> <td>QEMU initrd path</td> </tr>
|
||||
<tr><td>kernel_command_line</td> <td>✔</td> <td>string</td> <td>QEMU kernel command line</td> </tr>
|
||||
<tr><td>kernel_image</td> <td>✔</td> <td>string</td> <td>QEMU kernel image path</td> </tr>
|
||||
<tr><td>legacy_networking</td> <td>✔</td> <td>boolean</td> <td>Use QEMU legagy networking commands (-net syntax)</td> </tr>
|
||||
<tr><td>monitor</td> <td>✔</td> <td>integer</td> <td>monitor TCP port</td> </tr>
|
||||
<tr><td>name</td> <td>✔</td> <td>string</td> <td>QEMU VM instance name</td> </tr>
|
||||
<tr><td>options</td> <td>✔</td> <td>string</td> <td>Additional QEMU options</td> </tr>
|
||||
<tr><td>process_priority</td> <td>✔</td> <td>enum</td> <td>Possible values: realtime, very high, high, normal, low, very low</td> </tr>
|
||||
<tr><td>project_id</td> <td>✔</td> <td>string</td> <td>Project uuid</td> </tr>
|
||||
<tr><td>qemu_path</td> <td>✔</td> <td>string</td> <td>path to QEMU</td> </tr>
|
||||
<tr><td>ram</td> <td>✔</td> <td>integer</td> <td>amount of RAM in MB</td> </tr>
|
||||
<tr><td>vm_id</td> <td>✔</td> <td>string</td> <td>QEMU VM uuid</td> </tr>
|
||||
</table>
|
||||
|
@ -0,0 +1,129 @@
|
||||
/v1/projects/{project_id}/qemu/vms/{vm_id}
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
GET /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Get a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **200**: Success
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
|
||||
Output
|
||||
*******
|
||||
.. raw:: html
|
||||
|
||||
<table>
|
||||
<tr> <th>Name</th> <th>Mandatory</th> <th>Type</th> <th>Description</th> </tr>
|
||||
<tr><td>adapter_type</td> <td>✔</td> <td>string</td> <td>QEMU adapter type</td> </tr>
|
||||
<tr><td>adapters</td> <td>✔</td> <td>integer</td> <td>number of adapters</td> </tr>
|
||||
<tr><td>console</td> <td>✔</td> <td>integer</td> <td>console TCP port</td> </tr>
|
||||
<tr><td>cpu_throttling</td> <td>✔</td> <td>integer</td> <td>Percentage of CPU allowed for QEMU</td> </tr>
|
||||
<tr><td>hda_disk_image</td> <td>✔</td> <td>string</td> <td>QEMU hda disk image path</td> </tr>
|
||||
<tr><td>hdb_disk_image</td> <td>✔</td> <td>string</td> <td>QEMU hdb disk image path</td> </tr>
|
||||
<tr><td>initrd</td> <td>✔</td> <td>string</td> <td>QEMU initrd path</td> </tr>
|
||||
<tr><td>kernel_command_line</td> <td>✔</td> <td>string</td> <td>QEMU kernel command line</td> </tr>
|
||||
<tr><td>kernel_image</td> <td>✔</td> <td>string</td> <td>QEMU kernel image path</td> </tr>
|
||||
<tr><td>legacy_networking</td> <td>✔</td> <td>boolean</td> <td>Use QEMU legagy networking commands (-net syntax)</td> </tr>
|
||||
<tr><td>monitor</td> <td>✔</td> <td>integer</td> <td>monitor TCP port</td> </tr>
|
||||
<tr><td>name</td> <td>✔</td> <td>string</td> <td>QEMU VM instance name</td> </tr>
|
||||
<tr><td>options</td> <td>✔</td> <td>string</td> <td>Additional QEMU options</td> </tr>
|
||||
<tr><td>process_priority</td> <td>✔</td> <td>enum</td> <td>Possible values: realtime, very high, high, normal, low, very low</td> </tr>
|
||||
<tr><td>project_id</td> <td>✔</td> <td>string</td> <td>Project uuid</td> </tr>
|
||||
<tr><td>qemu_path</td> <td>✔</td> <td>string</td> <td>path to QEMU</td> </tr>
|
||||
<tr><td>ram</td> <td>✔</td> <td>integer</td> <td>amount of RAM in MB</td> </tr>
|
||||
<tr><td>vm_id</td> <td>✔</td> <td>string</td> <td>QEMU VM uuid</td> </tr>
|
||||
</table>
|
||||
|
||||
|
||||
PUT /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Update a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **200**: Instance updated
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **409**: Conflict
|
||||
|
||||
Input
|
||||
*******
|
||||
.. raw:: html
|
||||
|
||||
<table>
|
||||
<tr> <th>Name</th> <th>Mandatory</th> <th>Type</th> <th>Description</th> </tr>
|
||||
<tr><td>adapter_type</td> <td> </td> <td>['string', 'null']</td> <td>QEMU adapter type</td> </tr>
|
||||
<tr><td>adapters</td> <td> </td> <td>['integer', 'null']</td> <td>number of adapters</td> </tr>
|
||||
<tr><td>console</td> <td> </td> <td>['integer', 'null']</td> <td>console TCP port</td> </tr>
|
||||
<tr><td>cpu_throttling</td> <td> </td> <td>['integer', 'null']</td> <td>Percentage of CPU allowed for QEMU</td> </tr>
|
||||
<tr><td>hda_disk_image</td> <td> </td> <td>['string', 'null']</td> <td>QEMU hda disk image path</td> </tr>
|
||||
<tr><td>hdb_disk_image</td> <td> </td> <td>['string', 'null']</td> <td>QEMU hdb disk image path</td> </tr>
|
||||
<tr><td>initrd</td> <td> </td> <td>['string', 'null']</td> <td>QEMU initrd path</td> </tr>
|
||||
<tr><td>kernel_command_line</td> <td> </td> <td>['string', 'null']</td> <td>QEMU kernel command line</td> </tr>
|
||||
<tr><td>kernel_image</td> <td> </td> <td>['string', 'null']</td> <td>QEMU kernel image path</td> </tr>
|
||||
<tr><td>legacy_networking</td> <td> </td> <td>['boolean', 'null']</td> <td>Use QEMU legagy networking commands (-net syntax)</td> </tr>
|
||||
<tr><td>monitor</td> <td> </td> <td>['integer', 'null']</td> <td>monitor TCP port</td> </tr>
|
||||
<tr><td>name</td> <td> </td> <td>['string', 'null']</td> <td>QEMU VM instance name</td> </tr>
|
||||
<tr><td>options</td> <td> </td> <td>['string', 'null']</td> <td>Additional QEMU options</td> </tr>
|
||||
<tr><td>process_priority</td> <td> </td> <td>enum</td> <td>Possible values: realtime, very high, high, normal, low, very low, null</td> </tr>
|
||||
<tr><td>qemu_path</td> <td> </td> <td>['string', 'null']</td> <td>Path to QEMU</td> </tr>
|
||||
<tr><td>ram</td> <td> </td> <td>['integer', 'null']</td> <td>amount of RAM in MB</td> </tr>
|
||||
</table>
|
||||
|
||||
Output
|
||||
*******
|
||||
.. raw:: html
|
||||
|
||||
<table>
|
||||
<tr> <th>Name</th> <th>Mandatory</th> <th>Type</th> <th>Description</th> </tr>
|
||||
<tr><td>adapter_type</td> <td>✔</td> <td>string</td> <td>QEMU adapter type</td> </tr>
|
||||
<tr><td>adapters</td> <td>✔</td> <td>integer</td> <td>number of adapters</td> </tr>
|
||||
<tr><td>console</td> <td>✔</td> <td>integer</td> <td>console TCP port</td> </tr>
|
||||
<tr><td>cpu_throttling</td> <td>✔</td> <td>integer</td> <td>Percentage of CPU allowed for QEMU</td> </tr>
|
||||
<tr><td>hda_disk_image</td> <td>✔</td> <td>string</td> <td>QEMU hda disk image path</td> </tr>
|
||||
<tr><td>hdb_disk_image</td> <td>✔</td> <td>string</td> <td>QEMU hdb disk image path</td> </tr>
|
||||
<tr><td>initrd</td> <td>✔</td> <td>string</td> <td>QEMU initrd path</td> </tr>
|
||||
<tr><td>kernel_command_line</td> <td>✔</td> <td>string</td> <td>QEMU kernel command line</td> </tr>
|
||||
<tr><td>kernel_image</td> <td>✔</td> <td>string</td> <td>QEMU kernel image path</td> </tr>
|
||||
<tr><td>legacy_networking</td> <td>✔</td> <td>boolean</td> <td>Use QEMU legagy networking commands (-net syntax)</td> </tr>
|
||||
<tr><td>monitor</td> <td>✔</td> <td>integer</td> <td>monitor TCP port</td> </tr>
|
||||
<tr><td>name</td> <td>✔</td> <td>string</td> <td>QEMU VM instance name</td> </tr>
|
||||
<tr><td>options</td> <td>✔</td> <td>string</td> <td>Additional QEMU options</td> </tr>
|
||||
<tr><td>process_priority</td> <td>✔</td> <td>enum</td> <td>Possible values: realtime, very high, high, normal, low, very low</td> </tr>
|
||||
<tr><td>project_id</td> <td>✔</td> <td>string</td> <td>Project uuid</td> </tr>
|
||||
<tr><td>qemu_path</td> <td>✔</td> <td>string</td> <td>path to QEMU</td> </tr>
|
||||
<tr><td>ram</td> <td>✔</td> <td>integer</td> <td>amount of RAM in MB</td> </tr>
|
||||
<tr><td>vm_id</td> <td>✔</td> <td>string</td> <td>QEMU VM uuid</td> </tr>
|
||||
</table>
|
||||
|
||||
|
||||
DELETE /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Delete a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **204**: Instance deleted
|
||||
|
@ -0,0 +1,40 @@
|
||||
/v1/projects/{project_id}/qemu/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
POST /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**/adapters/**{adapter_number:\d+}**/ports/**{port_number:\d+}**/nio
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Add a NIO to a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
- **adapter_number**: Network adapter where the nio is located
|
||||
- **port_number**: Port where the nio should be added
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **201**: NIO created
|
||||
- **404**: Instance doesn't exist
|
||||
|
||||
|
||||
DELETE /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**/adapters/**{adapter_number:\d+}**/ports/**{port_number:\d+}**/nio
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Remove a NIO from a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
- **adapter_number**: Network adapter where the nio is located
|
||||
- **port_number**: Port from where the nio should be removed
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **204**: NIO deleted
|
||||
|
@ -0,0 +1,20 @@
|
||||
/v1/projects/{project_id}/qemu/vms/{vm_id}/reload
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
POST /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**/reload
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Reload a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **204**: Instance reloaded
|
||||
|
@ -0,0 +1,20 @@
|
||||
/v1/projects/{project_id}/qemu/vms/{vm_id}/start
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
POST /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**/start
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Start a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **204**: Instance started
|
||||
|
@ -0,0 +1,20 @@
|
||||
/v1/projects/{project_id}/qemu/vms/{vm_id}/stop
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
POST /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**/stop
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Stop a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **204**: Instance stopped
|
||||
|
@ -0,0 +1,20 @@
|
||||
/v1/projects/{project_id}/qemu/vms/{vm_id}/suspend
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
.. contents::
|
||||
|
||||
POST /v1/projects/**{project_id}**/qemu/vms/**{vm_id}**/suspend
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Reload a Qemu.instance
|
||||
|
||||
Parameters
|
||||
**********
|
||||
- **project_id**: UUID for the project
|
||||
- **vm_id**: UUID for the instance
|
||||
|
||||
Response status codes
|
||||
**********************
|
||||
- **400**: Invalid request
|
||||
- **404**: Instance doesn't exist
|
||||
- **204**: Instance suspended
|
||||
|
@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2015 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import stat
|
||||
import asyncio
|
||||
|
||||
from gns3server.modules.qemu import Qemu
|
||||
from tests.utils import asyncio_patch
|
||||
|
||||
|
||||
def test_get_qemu_version(loop):
|
||||
|
||||
with asyncio_patch("gns3server.modules.qemu.subprocess_check_output", return_value=b"QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
|
||||
version = loop.run_until_complete(asyncio.async(Qemu._get_qemu_version("/tmp/qemu-test")))
|
||||
assert version == "2.2.0"
|
||||
|
||||
|
||||
def test_binary_list(loop):
|
||||
|
||||
files_to_create = ["qemu-system-x86", "qemu-system-x42", "hello"]
|
||||
|
||||
for file_to_create in files_to_create:
|
||||
path = os.path.join(os.environ["PATH"], file_to_create)
|
||||
with open(path, "w+") as f:
|
||||
f.write("1")
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
|
||||
with asyncio_patch("gns3server.modules.qemu.subprocess_check_output", return_value=b"QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
|
||||
qemus = loop.run_until_complete(asyncio.async(Qemu.binary_list()))
|
||||
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x86"), "version": "2.2.0"} in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x42"), "version": "2.2.0"} in qemus
|
||||
assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": "2.2.0"} not in qemus
|
||||
|
||||
|
||||
def test_get_legacy_vm_workdir_name():
|
||||
|
||||
assert Qemu.get_legacy_vm_workdir_name(42) == "vm-42"
|
Loading…
Reference in new issue