diff --git a/gns3server/hypervisor/__init__.py b/gns3server/compute/__init__.py
similarity index 100%
rename from gns3server/hypervisor/__init__.py
rename to gns3server/compute/__init__.py
diff --git a/gns3server/hypervisor/adapters/__init__.py b/gns3server/compute/adapters/__init__.py
similarity index 100%
rename from gns3server/hypervisor/adapters/__init__.py
rename to gns3server/compute/adapters/__init__.py
diff --git a/gns3server/hypervisor/adapters/adapter.py b/gns3server/compute/adapters/adapter.py
similarity index 100%
rename from gns3server/hypervisor/adapters/adapter.py
rename to gns3server/compute/adapters/adapter.py
diff --git a/gns3server/hypervisor/adapters/ethernet_adapter.py b/gns3server/compute/adapters/ethernet_adapter.py
similarity index 100%
rename from gns3server/hypervisor/adapters/ethernet_adapter.py
rename to gns3server/compute/adapters/ethernet_adapter.py
diff --git a/gns3server/hypervisor/adapters/serial_adapter.py b/gns3server/compute/adapters/serial_adapter.py
similarity index 100%
rename from gns3server/hypervisor/adapters/serial_adapter.py
rename to gns3server/compute/adapters/serial_adapter.py
diff --git a/gns3server/hypervisor/base_manager.py b/gns3server/compute/base_manager.py
similarity index 100%
rename from gns3server/hypervisor/base_manager.py
rename to gns3server/compute/base_manager.py
diff --git a/gns3server/hypervisor/base_vm.py b/gns3server/compute/base_vm.py
similarity index 100%
rename from gns3server/hypervisor/base_vm.py
rename to gns3server/compute/base_vm.py
diff --git a/gns3server/hypervisor/docker/__init__.py b/gns3server/compute/docker/__init__.py
similarity index 100%
rename from gns3server/hypervisor/docker/__init__.py
rename to gns3server/compute/docker/__init__.py
diff --git a/gns3server/hypervisor/docker/docker_error.py b/gns3server/compute/docker/docker_error.py
similarity index 100%
rename from gns3server/hypervisor/docker/docker_error.py
rename to gns3server/compute/docker/docker_error.py
diff --git a/gns3server/hypervisor/docker/docker_vm.py b/gns3server/compute/docker/docker_vm.py
similarity index 100%
rename from gns3server/hypervisor/docker/docker_vm.py
rename to gns3server/compute/docker/docker_vm.py
diff --git a/gns3server/hypervisor/docker/resources/etc/udhcpc/default.script b/gns3server/compute/docker/resources/etc/udhcpc/default.script
similarity index 100%
rename from gns3server/hypervisor/docker/resources/etc/udhcpc/default.script
rename to gns3server/compute/docker/resources/etc/udhcpc/default.script
diff --git a/gns3server/hypervisor/docker/resources/init.sh b/gns3server/compute/docker/resources/init.sh
similarity index 100%
rename from gns3server/hypervisor/docker/resources/init.sh
rename to gns3server/compute/docker/resources/init.sh
diff --git a/gns3server/hypervisor/dynamips/__init__.py b/gns3server/compute/dynamips/__init__.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/__init__.py
rename to gns3server/compute/dynamips/__init__.py
diff --git a/gns3server/hypervisor/dynamips/adapters/__init__.py b/gns3server/compute/dynamips/adapters/__init__.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/__init__.py
rename to gns3server/compute/dynamips/adapters/__init__.py
diff --git a/gns3server/hypervisor/dynamips/adapters/adapter.py b/gns3server/compute/dynamips/adapters/adapter.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/adapter.py
rename to gns3server/compute/dynamips/adapters/adapter.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c1700_mb_1fe.py b/gns3server/compute/dynamips/adapters/c1700_mb_1fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c1700_mb_1fe.py
rename to gns3server/compute/dynamips/adapters/c1700_mb_1fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c1700_mb_wic1.py b/gns3server/compute/dynamips/adapters/c1700_mb_wic1.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c1700_mb_wic1.py
rename to gns3server/compute/dynamips/adapters/c1700_mb_wic1.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c2600_mb_1e.py b/gns3server/compute/dynamips/adapters/c2600_mb_1e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c2600_mb_1e.py
rename to gns3server/compute/dynamips/adapters/c2600_mb_1e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c2600_mb_1fe.py b/gns3server/compute/dynamips/adapters/c2600_mb_1fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c2600_mb_1fe.py
rename to gns3server/compute/dynamips/adapters/c2600_mb_1fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c2600_mb_2e.py b/gns3server/compute/dynamips/adapters/c2600_mb_2e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c2600_mb_2e.py
rename to gns3server/compute/dynamips/adapters/c2600_mb_2e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c2600_mb_2fe.py b/gns3server/compute/dynamips/adapters/c2600_mb_2fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c2600_mb_2fe.py
rename to gns3server/compute/dynamips/adapters/c2600_mb_2fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c7200_io_2fe.py b/gns3server/compute/dynamips/adapters/c7200_io_2fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c7200_io_2fe.py
rename to gns3server/compute/dynamips/adapters/c7200_io_2fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c7200_io_fe.py b/gns3server/compute/dynamips/adapters/c7200_io_fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c7200_io_fe.py
rename to gns3server/compute/dynamips/adapters/c7200_io_fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/c7200_io_ge_e.py b/gns3server/compute/dynamips/adapters/c7200_io_ge_e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/c7200_io_ge_e.py
rename to gns3server/compute/dynamips/adapters/c7200_io_ge_e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/gt96100_fe.py b/gns3server/compute/dynamips/adapters/gt96100_fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/gt96100_fe.py
rename to gns3server/compute/dynamips/adapters/gt96100_fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/leopard_2fe.py b/gns3server/compute/dynamips/adapters/leopard_2fe.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/leopard_2fe.py
rename to gns3server/compute/dynamips/adapters/leopard_2fe.py
diff --git a/gns3server/hypervisor/dynamips/adapters/nm_16esw.py b/gns3server/compute/dynamips/adapters/nm_16esw.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/nm_16esw.py
rename to gns3server/compute/dynamips/adapters/nm_16esw.py
diff --git a/gns3server/hypervisor/dynamips/adapters/nm_1e.py b/gns3server/compute/dynamips/adapters/nm_1e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/nm_1e.py
rename to gns3server/compute/dynamips/adapters/nm_1e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/nm_1fe_tx.py b/gns3server/compute/dynamips/adapters/nm_1fe_tx.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/nm_1fe_tx.py
rename to gns3server/compute/dynamips/adapters/nm_1fe_tx.py
diff --git a/gns3server/hypervisor/dynamips/adapters/nm_4e.py b/gns3server/compute/dynamips/adapters/nm_4e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/nm_4e.py
rename to gns3server/compute/dynamips/adapters/nm_4e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/nm_4t.py b/gns3server/compute/dynamips/adapters/nm_4t.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/nm_4t.py
rename to gns3server/compute/dynamips/adapters/nm_4t.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_2fe_tx.py b/gns3server/compute/dynamips/adapters/pa_2fe_tx.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_2fe_tx.py
rename to gns3server/compute/dynamips/adapters/pa_2fe_tx.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_4e.py b/gns3server/compute/dynamips/adapters/pa_4e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_4e.py
rename to gns3server/compute/dynamips/adapters/pa_4e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_4t.py b/gns3server/compute/dynamips/adapters/pa_4t.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_4t.py
rename to gns3server/compute/dynamips/adapters/pa_4t.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_8e.py b/gns3server/compute/dynamips/adapters/pa_8e.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_8e.py
rename to gns3server/compute/dynamips/adapters/pa_8e.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_8t.py b/gns3server/compute/dynamips/adapters/pa_8t.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_8t.py
rename to gns3server/compute/dynamips/adapters/pa_8t.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_a1.py b/gns3server/compute/dynamips/adapters/pa_a1.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_a1.py
rename to gns3server/compute/dynamips/adapters/pa_a1.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_fe_tx.py b/gns3server/compute/dynamips/adapters/pa_fe_tx.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_fe_tx.py
rename to gns3server/compute/dynamips/adapters/pa_fe_tx.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_ge.py b/gns3server/compute/dynamips/adapters/pa_ge.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_ge.py
rename to gns3server/compute/dynamips/adapters/pa_ge.py
diff --git a/gns3server/hypervisor/dynamips/adapters/pa_pos_oc3.py b/gns3server/compute/dynamips/adapters/pa_pos_oc3.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/pa_pos_oc3.py
rename to gns3server/compute/dynamips/adapters/pa_pos_oc3.py
diff --git a/gns3server/hypervisor/dynamips/adapters/wic_1enet.py b/gns3server/compute/dynamips/adapters/wic_1enet.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/wic_1enet.py
rename to gns3server/compute/dynamips/adapters/wic_1enet.py
diff --git a/gns3server/hypervisor/dynamips/adapters/wic_1t.py b/gns3server/compute/dynamips/adapters/wic_1t.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/wic_1t.py
rename to gns3server/compute/dynamips/adapters/wic_1t.py
diff --git a/gns3server/hypervisor/dynamips/adapters/wic_2t.py b/gns3server/compute/dynamips/adapters/wic_2t.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/adapters/wic_2t.py
rename to gns3server/compute/dynamips/adapters/wic_2t.py
diff --git a/gns3server/hypervisor/dynamips/dynamips_device.py b/gns3server/compute/dynamips/dynamips_device.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/dynamips_device.py
rename to gns3server/compute/dynamips/dynamips_device.py
diff --git a/gns3server/hypervisor/dynamips/dynamips_error.py b/gns3server/compute/dynamips/dynamips_error.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/dynamips_error.py
rename to gns3server/compute/dynamips/dynamips_error.py
diff --git a/gns3server/hypervisor/dynamips/dynamips_hypervisor.py b/gns3server/compute/dynamips/dynamips_hypervisor.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/dynamips_hypervisor.py
rename to gns3server/compute/dynamips/dynamips_hypervisor.py
diff --git a/gns3server/hypervisor/dynamips/dynamips_vm.py b/gns3server/compute/dynamips/dynamips_vm.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/dynamips_vm.py
rename to gns3server/compute/dynamips/dynamips_vm.py
diff --git a/gns3server/hypervisor/dynamips/hypervisor.py b/gns3server/compute/dynamips/hypervisor.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/hypervisor.py
rename to gns3server/compute/dynamips/hypervisor.py
diff --git a/gns3server/hypervisor/dynamips/nios/__init__.py b/gns3server/compute/dynamips/nios/__init__.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/__init__.py
rename to gns3server/compute/dynamips/nios/__init__.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio.py b/gns3server/compute/dynamips/nios/nio.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio.py
rename to gns3server/compute/dynamips/nios/nio.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_generic_ethernet.py b/gns3server/compute/dynamips/nios/nio_generic_ethernet.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_generic_ethernet.py
rename to gns3server/compute/dynamips/nios/nio_generic_ethernet.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_linux_ethernet.py b/gns3server/compute/dynamips/nios/nio_linux_ethernet.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_linux_ethernet.py
rename to gns3server/compute/dynamips/nios/nio_linux_ethernet.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_null.py b/gns3server/compute/dynamips/nios/nio_null.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_null.py
rename to gns3server/compute/dynamips/nios/nio_null.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_tap.py b/gns3server/compute/dynamips/nios/nio_tap.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_tap.py
rename to gns3server/compute/dynamips/nios/nio_tap.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_udp.py b/gns3server/compute/dynamips/nios/nio_udp.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_udp.py
rename to gns3server/compute/dynamips/nios/nio_udp.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_unix.py b/gns3server/compute/dynamips/nios/nio_unix.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_unix.py
rename to gns3server/compute/dynamips/nios/nio_unix.py
diff --git a/gns3server/hypervisor/dynamips/nios/nio_vde.py b/gns3server/compute/dynamips/nios/nio_vde.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nios/nio_vde.py
rename to gns3server/compute/dynamips/nios/nio_vde.py
diff --git a/gns3server/hypervisor/dynamips/nodes/__init__.py b/gns3server/compute/dynamips/nodes/__init__.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/__init__.py
rename to gns3server/compute/dynamips/nodes/__init__.py
diff --git a/gns3server/hypervisor/dynamips/nodes/atm_switch.py b/gns3server/compute/dynamips/nodes/atm_switch.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/atm_switch.py
rename to gns3server/compute/dynamips/nodes/atm_switch.py
diff --git a/gns3server/hypervisor/dynamips/nodes/bridge.py b/gns3server/compute/dynamips/nodes/bridge.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/bridge.py
rename to gns3server/compute/dynamips/nodes/bridge.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c1700.py b/gns3server/compute/dynamips/nodes/c1700.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c1700.py
rename to gns3server/compute/dynamips/nodes/c1700.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c2600.py b/gns3server/compute/dynamips/nodes/c2600.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c2600.py
rename to gns3server/compute/dynamips/nodes/c2600.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c2691.py b/gns3server/compute/dynamips/nodes/c2691.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c2691.py
rename to gns3server/compute/dynamips/nodes/c2691.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c3600.py b/gns3server/compute/dynamips/nodes/c3600.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c3600.py
rename to gns3server/compute/dynamips/nodes/c3600.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c3725.py b/gns3server/compute/dynamips/nodes/c3725.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c3725.py
rename to gns3server/compute/dynamips/nodes/c3725.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c3745.py b/gns3server/compute/dynamips/nodes/c3745.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c3745.py
rename to gns3server/compute/dynamips/nodes/c3745.py
diff --git a/gns3server/hypervisor/dynamips/nodes/c7200.py b/gns3server/compute/dynamips/nodes/c7200.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/c7200.py
rename to gns3server/compute/dynamips/nodes/c7200.py
diff --git a/gns3server/hypervisor/dynamips/nodes/device.py b/gns3server/compute/dynamips/nodes/device.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/device.py
rename to gns3server/compute/dynamips/nodes/device.py
diff --git a/gns3server/hypervisor/dynamips/nodes/ethernet_hub.py b/gns3server/compute/dynamips/nodes/ethernet_hub.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/ethernet_hub.py
rename to gns3server/compute/dynamips/nodes/ethernet_hub.py
diff --git a/gns3server/hypervisor/dynamips/nodes/ethernet_switch.py b/gns3server/compute/dynamips/nodes/ethernet_switch.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/ethernet_switch.py
rename to gns3server/compute/dynamips/nodes/ethernet_switch.py
diff --git a/gns3server/hypervisor/dynamips/nodes/frame_relay_switch.py b/gns3server/compute/dynamips/nodes/frame_relay_switch.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/frame_relay_switch.py
rename to gns3server/compute/dynamips/nodes/frame_relay_switch.py
diff --git a/gns3server/hypervisor/dynamips/nodes/router.py b/gns3server/compute/dynamips/nodes/router.py
similarity index 100%
rename from gns3server/hypervisor/dynamips/nodes/router.py
rename to gns3server/compute/dynamips/nodes/router.py
diff --git a/gns3server/hypervisor/iou/__init__.py b/gns3server/compute/iou/__init__.py
similarity index 100%
rename from gns3server/hypervisor/iou/__init__.py
rename to gns3server/compute/iou/__init__.py
diff --git a/gns3server/hypervisor/iou/iou_error.py b/gns3server/compute/iou/iou_error.py
similarity index 100%
rename from gns3server/hypervisor/iou/iou_error.py
rename to gns3server/compute/iou/iou_error.py
diff --git a/gns3server/hypervisor/iou/iou_vm.py b/gns3server/compute/iou/iou_vm.py
similarity index 100%
rename from gns3server/hypervisor/iou/iou_vm.py
rename to gns3server/compute/iou/iou_vm.py
diff --git a/gns3server/hypervisor/iou/ioucon.py b/gns3server/compute/iou/ioucon.py
similarity index 100%
rename from gns3server/hypervisor/iou/ioucon.py
rename to gns3server/compute/iou/ioucon.py
diff --git a/gns3server/hypervisor/iou/utils/__init__.py b/gns3server/compute/iou/utils/__init__.py
similarity index 100%
rename from gns3server/hypervisor/iou/utils/__init__.py
rename to gns3server/compute/iou/utils/__init__.py
diff --git a/gns3server/hypervisor/iou/utils/iou_export.py b/gns3server/compute/iou/utils/iou_export.py
similarity index 100%
rename from gns3server/hypervisor/iou/utils/iou_export.py
rename to gns3server/compute/iou/utils/iou_export.py
diff --git a/gns3server/hypervisor/iou/utils/iou_import.py b/gns3server/compute/iou/utils/iou_import.py
similarity index 100%
rename from gns3server/hypervisor/iou/utils/iou_import.py
rename to gns3server/compute/iou/utils/iou_import.py
diff --git a/gns3server/hypervisor/nios/__init__.py b/gns3server/compute/nios/__init__.py
similarity index 100%
rename from gns3server/hypervisor/nios/__init__.py
rename to gns3server/compute/nios/__init__.py
diff --git a/gns3server/hypervisor/nios/nio.py b/gns3server/compute/nios/nio.py
similarity index 100%
rename from gns3server/hypervisor/nios/nio.py
rename to gns3server/compute/nios/nio.py
diff --git a/gns3server/hypervisor/nios/nio_generic_ethernet.py b/gns3server/compute/nios/nio_generic_ethernet.py
similarity index 100%
rename from gns3server/hypervisor/nios/nio_generic_ethernet.py
rename to gns3server/compute/nios/nio_generic_ethernet.py
diff --git a/gns3server/hypervisor/nios/nio_nat.py b/gns3server/compute/nios/nio_nat.py
similarity index 100%
rename from gns3server/hypervisor/nios/nio_nat.py
rename to gns3server/compute/nios/nio_nat.py
diff --git a/gns3server/hypervisor/nios/nio_tap.py b/gns3server/compute/nios/nio_tap.py
similarity index 100%
rename from gns3server/hypervisor/nios/nio_tap.py
rename to gns3server/compute/nios/nio_tap.py
diff --git a/gns3server/hypervisor/nios/nio_udp.py b/gns3server/compute/nios/nio_udp.py
similarity index 100%
rename from gns3server/hypervisor/nios/nio_udp.py
rename to gns3server/compute/nios/nio_udp.py
diff --git a/gns3server/hypervisor/notification_manager.py b/gns3server/compute/notification_manager.py
similarity index 97%
rename from gns3server/hypervisor/notification_manager.py
rename to gns3server/compute/notification_manager.py
index d412b27d..35336623 100644
--- a/gns3server/hypervisor/notification_manager.py
+++ b/gns3server/compute/notification_manager.py
@@ -24,7 +24,7 @@ from ..notification_queue import NotificationQueue
class NotificationManager:
"""
Manage the notification queue where the controller
- will connect to get notifications from hypervisors
+ will connect to get notifications from computes
"""
def __init__(self):
diff --git a/gns3server/hypervisor/port_manager.py b/gns3server/compute/port_manager.py
similarity index 100%
rename from gns3server/hypervisor/port_manager.py
rename to gns3server/compute/port_manager.py
diff --git a/gns3server/hypervisor/project.py b/gns3server/compute/project.py
similarity index 98%
rename from gns3server/hypervisor/project.py
rename to gns3server/compute/project.py
index 75817d46..3e7f5d9a 100644
--- a/gns3server/hypervisor/project.py
+++ b/gns3server/compute/project.py
@@ -130,7 +130,7 @@ class Project:
@asyncio.coroutine
def clean_old_path(self, old_path):
"""
- Called after a project location change. All the hypervisor should
+ Called after a project location change. All the compute should
have been notified before
"""
if self._temporary:
@@ -323,10 +323,10 @@ class Project:
Closes the project, but keep information on disk
"""
- for module in self.hypervisor():
+ for module in self.compute():
yield from module.instance().project_closing(self)
yield from self._close_and_clean(self._temporary)
- for module in self.hypervisor():
+ for module in self.compute():
yield from module.instance().project_closed(self)
@asyncio.coroutine
@@ -380,7 +380,7 @@ class Project:
vm = self._vms_to_destroy.pop()
yield from vm.delete()
self.remove_vm(vm)
- for module in self.hypervisor():
+ for module in self.compute():
yield from module.instance().project_committed(self)
@asyncio.coroutine
@@ -389,10 +389,10 @@ class Project:
Removes project from disk
"""
- for module in self.hypervisor():
+ for module in self.compute():
yield from module.instance().project_closing(self)
yield from self._close_and_clean(True)
- for module in self.hypervisor():
+ for module in self.compute():
yield from module.instance().project_closed(self)
@classmethod
@@ -410,13 +410,13 @@ class Project:
log.warning("Purge old temporary project {}".format(project))
shutil.rmtree(path)
- def hypervisor(self):
+ def compute(self):
"""
- Returns all loaded VM hypervisor.
+ Returns all loaded VM compute.
"""
# We import it at the last time to avoid circular dependencies
- from ..hypervisor import MODULES
+ from ..compute import MODULES
return MODULES
def emit(self, action, event):
diff --git a/gns3server/hypervisor/project_manager.py b/gns3server/compute/project_manager.py
similarity index 100%
rename from gns3server/hypervisor/project_manager.py
rename to gns3server/compute/project_manager.py
diff --git a/gns3server/hypervisor/qemu/__init__.py b/gns3server/compute/qemu/__init__.py
similarity index 100%
rename from gns3server/hypervisor/qemu/__init__.py
rename to gns3server/compute/qemu/__init__.py
diff --git a/gns3server/hypervisor/qemu/qcow2.py b/gns3server/compute/qemu/qcow2.py
similarity index 100%
rename from gns3server/hypervisor/qemu/qcow2.py
rename to gns3server/compute/qemu/qcow2.py
diff --git a/gns3server/hypervisor/qemu/qemu_error.py b/gns3server/compute/qemu/qemu_error.py
similarity index 100%
rename from gns3server/hypervisor/qemu/qemu_error.py
rename to gns3server/compute/qemu/qemu_error.py
diff --git a/gns3server/hypervisor/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py
similarity index 100%
rename from gns3server/hypervisor/qemu/qemu_vm.py
rename to gns3server/compute/qemu/qemu_vm.py
diff --git a/gns3server/hypervisor/virtualbox/__init__.py b/gns3server/compute/virtualbox/__init__.py
similarity index 100%
rename from gns3server/hypervisor/virtualbox/__init__.py
rename to gns3server/compute/virtualbox/__init__.py
diff --git a/gns3server/hypervisor/virtualbox/virtualbox_error.py b/gns3server/compute/virtualbox/virtualbox_error.py
similarity index 100%
rename from gns3server/hypervisor/virtualbox/virtualbox_error.py
rename to gns3server/compute/virtualbox/virtualbox_error.py
diff --git a/gns3server/hypervisor/virtualbox/virtualbox_vm.py b/gns3server/compute/virtualbox/virtualbox_vm.py
similarity index 100%
rename from gns3server/hypervisor/virtualbox/virtualbox_vm.py
rename to gns3server/compute/virtualbox/virtualbox_vm.py
diff --git a/gns3server/hypervisor/vm_error.py b/gns3server/compute/vm_error.py
similarity index 100%
rename from gns3server/hypervisor/vm_error.py
rename to gns3server/compute/vm_error.py
diff --git a/gns3server/hypervisor/vmware/__init__.py b/gns3server/compute/vmware/__init__.py
similarity index 99%
rename from gns3server/hypervisor/vmware/__init__.py
rename to gns3server/compute/vmware/__init__.py
index 3dac122e..1d49f0c2 100644
--- a/gns3server/hypervisor/vmware/__init__.py
+++ b/gns3server/compute/vmware/__init__.py
@@ -35,10 +35,10 @@ from pkg_resources import parse_version
log = logging.getLogger(__name__)
-from gns3server.hypervisor.base_manager import BaseManager
-from gns3server.hypervisor.vmware.vmware_vm import VMwareVM
-from gns3server.hypervisor.vmware.vmware_error import VMwareError
-from gns3server.hypervisor.vmware.nio_vmnet import NIOVMNET
+from gns3server.compute.base_manager import BaseManager
+from gns3server.compute.vmware.vmware_vm import VMwareVM
+from gns3server.compute.vmware.vmware_error import VMwareError
+from gns3server.compute.vmware.nio_vmnet import NIOVMNET
class VMware(BaseManager):
diff --git a/gns3server/hypervisor/vmware/nio_vmnet.py b/gns3server/compute/vmware/nio_vmnet.py
similarity index 100%
rename from gns3server/hypervisor/vmware/nio_vmnet.py
rename to gns3server/compute/vmware/nio_vmnet.py
diff --git a/gns3server/hypervisor/vmware/vmware_error.py b/gns3server/compute/vmware/vmware_error.py
similarity index 100%
rename from gns3server/hypervisor/vmware/vmware_error.py
rename to gns3server/compute/vmware/vmware_error.py
diff --git a/gns3server/hypervisor/vmware/vmware_vm.py b/gns3server/compute/vmware/vmware_vm.py
similarity index 100%
rename from gns3server/hypervisor/vmware/vmware_vm.py
rename to gns3server/compute/vmware/vmware_vm.py
diff --git a/gns3server/hypervisor/vpcs/__init__.py b/gns3server/compute/vpcs/__init__.py
similarity index 100%
rename from gns3server/hypervisor/vpcs/__init__.py
rename to gns3server/compute/vpcs/__init__.py
diff --git a/gns3server/hypervisor/vpcs/vpcs_error.py b/gns3server/compute/vpcs/vpcs_error.py
similarity index 100%
rename from gns3server/hypervisor/vpcs/vpcs_error.py
rename to gns3server/compute/vpcs/vpcs_error.py
diff --git a/gns3server/hypervisor/vpcs/vpcs_vm.py b/gns3server/compute/vpcs/vpcs_vm.py
similarity index 100%
rename from gns3server/hypervisor/vpcs/vpcs_vm.py
rename to gns3server/compute/vpcs/vpcs_vm.py
diff --git a/gns3server/config.py b/gns3server/config.py
index a118d1bf..b91c4677 100644
--- a/gns3server/config.py
+++ b/gns3server/config.py
@@ -16,7 +16,7 @@
# along with this program. If not, see .
"""
-Reads the configuration file and store the settings for the server & hypervisor.
+Reads the configuration file and store the settings for the controller & compute.
"""
import sys
diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py
index ca2a1fd1..557ad20f 100644
--- a/gns3server/controller/__init__.py
+++ b/gns3server/controller/__init__.py
@@ -20,14 +20,14 @@ import aiohttp
from ..config import Config
from .project import Project
-from .hypervisor import Hypervisor
+from .compute import Compute
class Controller:
- """The controller manage multiple gns3 hypervisors"""
+ """The controller manage multiple gns3 computes"""
def __init__(self):
- self._hypervisors = {}
+ self._computes = {}
self._projects = {}
def isEnabled(self):
@@ -38,32 +38,32 @@ class Controller:
return Config.instance().get_section_config("Server").getboolean("controller")
@asyncio.coroutine
- def addHypervisor(self, hypervisor_id, **kwargs):
+ def addCompute(self, compute_id, **kwargs):
"""
- Add a server to the dictionnary of hypervisors controlled by GNS3
+ Add a server to the dictionnary of computes controlled by GNS3
- :param kwargs: See the documentation of Hypervisor
+ :param kwargs: See the documentation of Compute
"""
- if hypervisor_id not in self._hypervisors:
- hypervisor = Hypervisor(hypervisor_id=hypervisor_id, controller=self, **kwargs)
- self._hypervisors[hypervisor_id] = hypervisor
- return self._hypervisors[hypervisor_id]
+ if compute_id not in self._computes:
+ compute = Compute(compute_id=compute_id, controller=self, **kwargs)
+ self._computes[compute_id] = compute
+ return self._computes[compute_id]
@property
- def hypervisors(self):
+ def computes(self):
"""
- :returns: The dictionnary of hypervisors managed by GNS3
+ :returns: The dictionnary of computes managed by GNS3
"""
- return self._hypervisors
+ return self._computes
- def getHypervisor(self, hypervisor_id):
+ def getCompute(self, compute_id):
"""
- Return an hypervisor or raise a 404
+ Return an compute or raise a 404
"""
try:
- return self._hypervisors[hypervisor_id]
+ return self._computes[compute_id]
except KeyError:
- raise aiohttp.web.HTTPNotFound(text="Hypervisor ID {} doesn't exist".format(hypervisor_id))
+ raise aiohttp.web.HTTPNotFound(text="Compute ID {} doesn't exist".format(compute_id))
@asyncio.coroutine
def addProject(self, project_id=None, **kwargs):
@@ -75,8 +75,8 @@ class Controller:
if project_id not in self._projects:
project = Project(project_id=project_id, **kwargs)
self._projects[project.id] = project
- for hypervisor in self._hypervisors.values():
- yield from project.addHypervisor(hypervisor)
+ for compute in self._computes.values():
+ yield from project.addCompute(compute)
return self._projects[project.id]
return self._projects[project_id]
@@ -95,7 +95,7 @@ class Controller:
@property
def projects(self):
"""
- :returns: The dictionnary of hypervisors managed by GNS3
+ :returns: The dictionnary of computes managed by GNS3
"""
return self._projects
diff --git a/gns3server/controller/hypervisor.py b/gns3server/controller/compute.py
similarity index 85%
rename from gns3server/controller/hypervisor.py
rename to gns3server/controller/compute.py
index 5f2bcec4..fc39fd35 100644
--- a/gns3server/controller/hypervisor.py
+++ b/gns3server/controller/compute.py
@@ -29,19 +29,19 @@ import logging
log = logging.getLogger(__name__)
-class HypervisorError(ControllerError):
+class ComputeError(ControllerError):
pass
-class Hypervisor:
+class Compute:
"""
- A GNS3 hypervisor.
+ A GNS3 compute.
"""
- def __init__(self, hypervisor_id, controller=None, protocol="http", host="localhost", port=8000, user=None, password=None):
+ def __init__(self, compute_id, controller=None, protocol="http", host="localhost", port=8000, user=None, password=None):
assert controller is not None
- log.info("Create hypervisor %s", hypervisor_id)
- self._id = hypervisor_id
+ log.info("Create compute %s", compute_id)
+ self._id = compute_id
self._protocol = protocol
self._host = host
self._port = port
@@ -50,11 +50,12 @@ class Hypervisor:
self._connected = False
self._controller = controller
self._setAuth(user, password)
+ self._session = aiohttp.ClientSession()
- # If the hypervisor is local but the hypervisor id is local
+ # If the compute is local but the compute id is local
# it's a configuration issue
- if hypervisor_id == "local" and Config.instance().get_section_config("Server")["local"] is False:
- raise HypervisorError("The local hypervisor is started without --local")
+ if compute_id == "local" and Config.instance().get_section_config("Server")["local"] is False:
+ raise ComputeError("The local compute is started without --local")
asyncio.async(self._connect())
@@ -71,19 +72,18 @@ class Hypervisor:
self._auth = aiohttp.BasicAuth(self._user, self._password)
else:
self._auth = None
- self._session = aiohttp.ClientSession(auth=self._auth)
@property
def id(self):
"""
- :returns: Hypervisor identifier (string)
+ :returns: Compute identifier (string)
"""
return self._id
@property
def host(self):
"""
- :returns: Hypervisor host (string)
+ :returns: Compute host (string)
"""
return self._host
@@ -105,7 +105,7 @@ class Hypervisor:
def __json__(self):
return {
- "hypervisor_id": self._id,
+ "compute_id": self._id,
"protocol": self._protocol,
"host": self._host,
"port": self._port,
@@ -150,10 +150,10 @@ class Hypervisor:
msg = json.loads(response.data)
action = msg.pop("action")
event = msg.pop("event")
- self._controller.emit(action, event, hypervisor_id=self.id, **msg)
+ self._controller.emit(action, event, compute_id=self.id, **msg)
def _getUrl(self, path):
- return "{}://{}:{}/v2/hypervisor{}".format(self._protocol, self._host, self._port, path)
+ return "{}://{}:{}/v2/compute{}".format(self._protocol, self._host, self._port, path)
@asyncio.coroutine
def _runHttpQuery(self, method, path, data=None):
@@ -167,7 +167,7 @@ class Hypervisor:
data = data.__json__()
data = json.dumps(data)
- response = yield from self._session.request(method, url, headers=headers, data=data)
+ response = yield from self._session.request(method, url, headers=headers, data=data, auth=self._auth)
body = yield from response.read()
if body:
body = body.decode()
@@ -176,11 +176,11 @@ class Hypervisor:
if response.status == 400:
raise aiohttp.web.HTTPBadRequest(text="Bad request {} {}".format(url, body))
elif response.status == 401:
- raise aiohttp.web.HTTPUnauthorized(text="Invalid authentication for hypervisor {}".format(self.id))
+ raise aiohttp.web.HTTPUnauthorized(text="Invalid authentication for compute {}".format(self.id))
elif response.status == 403:
raise aiohttp.web.HTTPForbidden(text="Forbidden {} {}".format(url, body))
elif response.status == 404:
- raise aiohttp.web.HTTPNotFound(text="{} not found on hypervisor".format(url))
+ raise aiohttp.web.HTTPNotFound(text="{} not found on compute".format(url))
elif response.status == 409:
raise aiohttp.web.HTTPConflict(text="Conflict {} {}".format(url, body))
else:
diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py
index b3466acb..51ecc5e7 100644
--- a/gns3server/controller/project.py
+++ b/gns3server/controller/project.py
@@ -47,7 +47,7 @@ class Project:
self._id = project_id
self._path = path
self._temporary = temporary
- self._hypervisors = set()
+ self._computes = set()
self._vms = {}
self._links = {}
self._listeners = set()
@@ -69,19 +69,19 @@ class Project:
return self._path
@asyncio.coroutine
- def addHypervisor(self, hypervisor):
- self._hypervisors.add(hypervisor)
- yield from hypervisor.post("/projects", self)
+ def addCompute(self, compute):
+ self._computes.add(compute)
+ yield from compute.post("/projects", self)
@asyncio.coroutine
- def addVM(self, hypervisor, vm_id, **kwargs):
+ def addVM(self, compute, vm_id, **kwargs):
"""
Create a vm or return an existing vm
:param kwargs: See the documentation of VM
"""
if vm_id not in self._vms:
- vm = VM(self, hypervisor, vm_id=vm_id, **kwargs)
+ vm = VM(self, compute, vm_id=vm_id, **kwargs)
yield from vm.create()
self._vms[vm.id] = vm
return vm
@@ -130,18 +130,18 @@ class Project:
@asyncio.coroutine
def close(self):
- for hypervisor in self._hypervisors:
- yield from hypervisor.post("/projects/{}/close".format(self._id))
+ for compute in self._computes:
+ yield from compute.post("/projects/{}/close".format(self._id))
@asyncio.coroutine
def commit(self):
- for hypervisor in self._hypervisors:
- yield from hypervisor.post("/projects/{}/commit".format(self._id))
+ for compute in self._computes:
+ yield from compute.post("/projects/{}/commit".format(self._id))
@asyncio.coroutine
def delete(self):
- for hypervisor in self._hypervisors:
- yield from hypervisor.delete("/projects/{}".format(self._id))
+ for compute in self._computes:
+ yield from compute.delete("/projects/{}".format(self._id))
@contextmanager
def queue(self):
diff --git a/gns3server/controller/udp_link.py b/gns3server/controller/udp_link.py
index 37317b8d..5133997e 100644
--- a/gns3server/controller/udp_link.py
+++ b/gns3server/controller/udp_link.py
@@ -40,15 +40,15 @@ class UDPLink(Link):
port_number2 = self._vms[1]["port_number"]
# Reserve a UDP port on both side
- response = yield from vm1.hypervisor.post("/projects/{}/ports/udp".format(self._project.id))
+ response = yield from vm1.compute.post("/projects/{}/ports/udp".format(self._project.id))
self._vm1_port = response.json["udp_port"]
- response = yield from vm2.hypervisor.post("/projects/{}/ports/udp".format(self._project.id))
+ response = yield from vm2.compute.post("/projects/{}/ports/udp".format(self._project.id))
self._vm2_port = response.json["udp_port"]
# Create the tunnel on both side
data = {
"lport": self._vm1_port,
- "rhost": vm2.hypervisor.host,
+ "rhost": vm2.compute.host,
"rport": self._vm2_port,
"type": "nio_udp"
}
@@ -56,7 +56,7 @@ class UDPLink(Link):
data = {
"lport": self._vm2_port,
- "rhost": vm1.hypervisor.host,
+ "rhost": vm1.compute.host,
"rport": self._vm1_port,
"type": "nio_udp"
}
diff --git a/gns3server/controller/vm.py b/gns3server/controller/vm.py
index 18ac6e5b..23ca7840 100644
--- a/gns3server/controller/vm.py
+++ b/gns3server/controller/vm.py
@@ -23,10 +23,10 @@ import uuid
class VM:
- def __init__(self, project, hypervisor, vm_id=None, vm_type=None, name=None, console=None, console_type="telnet", properties={}):
+ def __init__(self, project, compute, vm_id=None, vm_type=None, name=None, console=None, console_type="telnet", properties={}):
"""
:param project: Project of the VM
- :param hypervisor: Hypervisor server where the server will run
+ :param compute: Hypervisor server where the server will run
:param vm_id: UUID of the vm. Integer id
:param vm_type: Type of emulator
:param name: Name of the vm
@@ -42,7 +42,7 @@ class VM:
self._name = name
self._project = project
- self._hypervisor = hypervisor
+ self._compute = compute
self._vm_type = vm_type
self._console = console
self._console_type = console_type
@@ -77,15 +77,15 @@ class VM:
return self._project
@property
- def hypervisor(self):
- return self._hypervisor
+ def compute(self):
+ return self._compute
@property
def host(self):
"""
:returns: Domain or ip for console connection
"""
- return self._hypervisor.host
+ return self._compute.host
@asyncio.coroutine
def create(self):
@@ -100,7 +100,7 @@ class VM:
if data[key] is None:
del data[key]
- response = yield from self._hypervisor.post("/projects/{}/{}/vms".format(self._project.id, self._vm_type), data=data)
+ response = yield from self._compute.post("/projects/{}/{}/vms".format(self._project.id, self._vm_type), data=data)
for key, value in response.json.items():
if key == "console":
@@ -132,22 +132,25 @@ class VM:
yield from self.post("/suspend")
@asyncio.coroutine
- def post(self, path, data={}):
+ def post(self, path, data=None):
"""
HTTP post on the VM
"""
- return (yield from self._hypervisor.post("/projects/{}/{}/vms/{}{}".format(self._project.id, self._vm_type, self._id, path), data=data))
+ if data:
+ return (yield from self._compute.post("/projects/{}/{}/vms/{}{}".format(self._project.id, self._vm_type, self._id, path), data=data))
+ else:
+ return (yield from self._compute.post("/projects/{}/{}/vms/{}{}".format(self._project.id, self._vm_type, self._id, path)))
@asyncio.coroutine
def delete(self, path):
"""
HTTP post on the VM
"""
- return (yield from self._hypervisor.delete("/projects/{}/{}/vms/{}{}".format(self._project.id, self._vm_type, self._id, path)))
+ return (yield from self._compute.delete("/projects/{}/{}/vms/{}{}".format(self._project.id, self._vm_type, self._id, path)))
def __json__(self):
return {
- "hypervisor_id": self._hypervisor.id,
+ "compute_id": self._compute.id,
"project_id": self._project.id,
"vm_id": self._id,
"vm_type": self._vm_type,
diff --git a/gns3server/handlers/__init__.py b/gns3server/handlers/__init__.py
index 6b55323c..a0f7e11a 100644
--- a/gns3server/handlers/__init__.py
+++ b/gns3server/handlers/__init__.py
@@ -19,4 +19,4 @@ from gns3server.handlers.upload_handler import UploadHandler
from gns3server.handlers.index_handler import IndexHandler
from gns3server.handlers.api.controller import *
-from gns3server.handlers.api.hypervisor import *
+from gns3server.handlers.api.compute import *
diff --git a/gns3server/handlers/api/hypervisor/__init__.py b/gns3server/handlers/api/compute/__init__.py
similarity index 100%
rename from gns3server/handlers/api/hypervisor/__init__.py
rename to gns3server/handlers/api/compute/__init__.py
diff --git a/gns3server/handlers/api/hypervisor/config_handler.py b/gns3server/handlers/api/compute/config_handler.py
similarity index 100%
rename from gns3server/handlers/api/hypervisor/config_handler.py
rename to gns3server/handlers/api/compute/config_handler.py
diff --git a/gns3server/handlers/api/hypervisor/docker_handler.py b/gns3server/handlers/api/compute/docker_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/docker_handler.py
rename to gns3server/handlers/api/compute/docker_handler.py
index 6964fb26..e54af945 100644
--- a/gns3server/handlers/api/hypervisor/docker_handler.py
+++ b/gns3server/handlers/api/compute/docker_handler.py
@@ -19,7 +19,7 @@ import os
from aiohttp.web import HTTPConflict
from ....web.route import Route
-from ....hypervisor.docker import Docker
+from ....compute.docker import Docker
from ....schemas.docker import (
DOCKER_CREATE_SCHEMA,
diff --git a/gns3server/handlers/api/hypervisor/dynamips_device_handler.py b/gns3server/handlers/api/compute/dynamips_device_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/dynamips_device_handler.py
rename to gns3server/handlers/api/compute/dynamips_device_handler.py
index 41fb2e52..3bfc96fc 100644
--- a/gns3server/handlers/api/hypervisor/dynamips_device_handler.py
+++ b/gns3server/handlers/api/compute/dynamips_device_handler.py
@@ -23,7 +23,7 @@ from ....schemas.dynamips_device import DEVICE_UPDATE_SCHEMA
from ....schemas.dynamips_device import DEVICE_OBJECT_SCHEMA
from ....schemas.dynamips_device import DEVICE_NIO_SCHEMA
from ....schemas.vm import VM_CAPTURE_SCHEMA
-from ....hypervisor.dynamips import Dynamips
+from ....compute.dynamips import Dynamips
class DynamipsDeviceHandler:
diff --git a/gns3server/handlers/api/hypervisor/dynamips_vm_handler.py b/gns3server/handlers/api/compute/dynamips_vm_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/dynamips_vm_handler.py
rename to gns3server/handlers/api/compute/dynamips_vm_handler.py
index dd381f23..c1a026c0 100644
--- a/gns3server/handlers/api/hypervisor/dynamips_vm_handler.py
+++ b/gns3server/handlers/api/compute/dynamips_vm_handler.py
@@ -27,9 +27,9 @@ from ....schemas.dynamips_vm import VM_UPDATE_SCHEMA
from ....schemas.dynamips_vm import VM_OBJECT_SCHEMA
from ....schemas.dynamips_vm import VM_CONFIGS_SCHEMA
from ....schemas.vm import VM_CAPTURE_SCHEMA
-from ....hypervisor.dynamips import Dynamips
-from ....hypervisor.dynamips.dynamips_error import DynamipsError
-from ....hypervisor.project_manager import ProjectManager
+from ....compute.dynamips import Dynamips
+from ....compute.dynamips.dynamips_error import DynamipsError
+from ....compute.project_manager import ProjectManager
DEFAULT_CHASSIS = {
"c1700": "1720",
diff --git a/gns3server/handlers/api/hypervisor/file_handler.py b/gns3server/handlers/api/compute/file_handler.py
similarity index 100%
rename from gns3server/handlers/api/hypervisor/file_handler.py
rename to gns3server/handlers/api/compute/file_handler.py
diff --git a/gns3server/handlers/api/hypervisor/iou_handler.py b/gns3server/handlers/api/compute/iou_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/iou_handler.py
rename to gns3server/handlers/api/compute/iou_handler.py
index 466054e8..f816471c 100644
--- a/gns3server/handlers/api/hypervisor/iou_handler.py
+++ b/gns3server/handlers/api/compute/iou_handler.py
@@ -27,7 +27,7 @@ from ....schemas.iou import IOU_OBJECT_SCHEMA
from ....schemas.iou import IOU_CONFIGS_SCHEMA
from ....schemas.vm import VM_LIST_IMAGES_SCHEMA
from ....schemas.vm import VM_CAPTURE_SCHEMA
-from ....hypervisor.iou import IOU
+from ....compute.iou import IOU
class IOUHandler:
diff --git a/gns3server/handlers/api/hypervisor/network_handler.py b/gns3server/handlers/api/compute/network_handler.py
similarity index 94%
rename from gns3server/handlers/api/hypervisor/network_handler.py
rename to gns3server/handlers/api/compute/network_handler.py
index 28e90f09..e2da87ad 100644
--- a/gns3server/handlers/api/hypervisor/network_handler.py
+++ b/gns3server/handlers/api/compute/network_handler.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
from ....web.route import Route
-from ....hypervisor.port_manager import PortManager
-from ....hypervisor.project_manager import ProjectManager
+from ....compute.port_manager import PortManager
+from ....compute.project_manager import ProjectManager
from ....utils.interfaces import interfaces
diff --git a/gns3server/handlers/api/hypervisor/notification_handler.py b/gns3server/handlers/api/compute/notification_handler.py
similarity index 95%
rename from gns3server/handlers/api/hypervisor/notification_handler.py
rename to gns3server/handlers/api/compute/notification_handler.py
index 46a04f19..e0903f29 100644
--- a/gns3server/handlers/api/hypervisor/notification_handler.py
+++ b/gns3server/handlers/api/compute/notification_handler.py
@@ -18,7 +18,7 @@
import asyncio
from ....web.route import Route
-from ....hypervisor.notification_manager import NotificationManager
+from ....compute.notification_manager import NotificationManager
from aiohttp.web import WebSocketResponse
diff --git a/gns3server/handlers/api/hypervisor/project_handler.py b/gns3server/handlers/api/compute/project_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/project_handler.py
rename to gns3server/handlers/api/compute/project_handler.py
index 7af2eb57..24991ba3 100644
--- a/gns3server/handlers/api/hypervisor/project_handler.py
+++ b/gns3server/handlers/api/compute/project_handler.py
@@ -24,8 +24,8 @@ import tempfile
from ....web.route import Route
from ....schemas.project import PROJECT_OBJECT_SCHEMA, PROJECT_CREATE_SCHEMA, PROJECT_UPDATE_SCHEMA, PROJECT_FILE_LIST_SCHEMA, PROJECT_LIST_SCHEMA
-from ....hypervisor.project_manager import ProjectManager
-from ....hypervisor import MODULES
+from ....compute.project_manager import ProjectManager
+from ....compute import MODULES
import logging
log = logging.getLogger()
diff --git a/gns3server/handlers/api/hypervisor/qemu_handler.py b/gns3server/handlers/api/compute/qemu_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/qemu_handler.py
rename to gns3server/handlers/api/compute/qemu_handler.py
index 370826d0..f376217c 100644
--- a/gns3server/handlers/api/hypervisor/qemu_handler.py
+++ b/gns3server/handlers/api/compute/qemu_handler.py
@@ -20,7 +20,7 @@ import os.path
from aiohttp.web import HTTPConflict
from ....web.route import Route
-from ....hypervisor.project_manager import ProjectManager
+from ....compute.project_manager import ProjectManager
from ....schemas.nio import NIO_SCHEMA
from ....schemas.qemu import QEMU_CREATE_SCHEMA
from ....schemas.qemu import QEMU_UPDATE_SCHEMA
@@ -30,7 +30,7 @@ from ....schemas.qemu import QEMU_BINARY_LIST_SCHEMA
from ....schemas.qemu import QEMU_CAPABILITY_LIST_SCHEMA
from ....schemas.qemu import QEMU_IMAGE_CREATE_SCHEMA
from ....schemas.vm import VM_LIST_IMAGES_SCHEMA
-from ....hypervisor.qemu import Qemu
+from ....compute.qemu import Qemu
from ....config import Config
diff --git a/gns3server/handlers/api/hypervisor/version_handler.py b/gns3server/handlers/api/compute/version_handler.py
similarity index 100%
rename from gns3server/handlers/api/hypervisor/version_handler.py
rename to gns3server/handlers/api/compute/version_handler.py
diff --git a/gns3server/handlers/api/hypervisor/virtualbox_handler.py b/gns3server/handlers/api/compute/virtualbox_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/virtualbox_handler.py
rename to gns3server/handlers/api/compute/virtualbox_handler.py
index 7065a20a..ccfd2311 100644
--- a/gns3server/handlers/api/hypervisor/virtualbox_handler.py
+++ b/gns3server/handlers/api/compute/virtualbox_handler.py
@@ -24,8 +24,8 @@ from ....schemas.virtualbox import VBOX_CREATE_SCHEMA
from ....schemas.virtualbox import VBOX_UPDATE_SCHEMA
from ....schemas.virtualbox import VBOX_OBJECT_SCHEMA
from ....schemas.vm import VM_CAPTURE_SCHEMA
-from ....hypervisor.virtualbox import VirtualBox
-from ....hypervisor.project_manager import ProjectManager
+from ....compute.virtualbox import VirtualBox
+from ....compute.project_manager import ProjectManager
class VirtualBoxHandler:
diff --git a/gns3server/handlers/api/hypervisor/vmware_handler.py b/gns3server/handlers/api/compute/vmware_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/vmware_handler.py
rename to gns3server/handlers/api/compute/vmware_handler.py
index faecf764..7f00e4fa 100644
--- a/gns3server/handlers/api/hypervisor/vmware_handler.py
+++ b/gns3server/handlers/api/compute/vmware_handler.py
@@ -24,8 +24,8 @@ from ....schemas.vmware import VMWARE_UPDATE_SCHEMA
from ....schemas.vmware import VMWARE_OBJECT_SCHEMA
from ....schemas.vm import VM_CAPTURE_SCHEMA
from ....schemas.nio import NIO_SCHEMA
-from ....hypervisor.vmware import VMware
-from ....hypervisor.project_manager import ProjectManager
+from ....compute.vmware import VMware
+from ....compute.project_manager import ProjectManager
class VMwareHandler:
diff --git a/gns3server/handlers/api/hypervisor/vpcs_handler.py b/gns3server/handlers/api/compute/vpcs_handler.py
similarity index 99%
rename from gns3server/handlers/api/hypervisor/vpcs_handler.py
rename to gns3server/handlers/api/compute/vpcs_handler.py
index c3256cb5..8abd225e 100644
--- a/gns3server/handlers/api/hypervisor/vpcs_handler.py
+++ b/gns3server/handlers/api/compute/vpcs_handler.py
@@ -21,7 +21,7 @@ from ....schemas.nio import NIO_SCHEMA
from ....schemas.vpcs import VPCS_CREATE_SCHEMA
from ....schemas.vpcs import VPCS_UPDATE_SCHEMA
from ....schemas.vpcs import VPCS_OBJECT_SCHEMA
-from ....hypervisor.vpcs import VPCS
+from ....compute.vpcs import VPCS
class VPCSHandler:
diff --git a/gns3server/handlers/api/controller/__init__.py b/gns3server/handlers/api/controller/__init__.py
index 9ddd4f7b..09520889 100644
--- a/gns3server/handlers/api/controller/__init__.py
+++ b/gns3server/handlers/api/controller/__init__.py
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .hypervisor_handler import HypervisorHandler
+from .compute_handler import ComputeHandler
from .project_handler import ProjectHandler
from .version_handler import VersionHandler
from .vm_handler import VMHandler
diff --git a/gns3server/handlers/api/controller/hypervisor_handler.py b/gns3server/handlers/api/controller/compute_handler.py
similarity index 68%
rename from gns3server/handlers/api/controller/hypervisor_handler.py
rename to gns3server/handlers/api/controller/compute_handler.py
index 6250286f..fcebc552 100644
--- a/gns3server/handlers/api/controller/hypervisor_handler.py
+++ b/gns3server/handlers/api/controller/compute_handler.py
@@ -20,47 +20,47 @@ from aiohttp.web import HTTPForbidden
from ....web.route import Route
from ....config import Config
-from ....hypervisor.project_manager import ProjectManager
-from ....schemas.hypervisor import HYPERVISOR_CREATE_SCHEMA, HYPERVISOR_OBJECT_SCHEMA
+from ....compute.project_manager import ProjectManager
+from ....schemas.compute import COMPUTE_CREATE_SCHEMA, COMPUTE_OBJECT_SCHEMA
from ....controller import Controller
-from ....controller.hypervisor import Hypervisor
+from ....controller.compute import Compute
import logging
log = logging.getLogger(__name__)
-class HypervisorHandler:
- """API entry points for hypervisor management."""
+class ComputeHandler:
+ """API entry points for compute management."""
@classmethod
@Route.post(
- r"/hypervisors",
- description="Register a hypervisor",
+ r"/computes",
+ description="Register a compute",
status_codes={
- 201: "Hypervisor added"
+ 201: "Compute added"
},
- input=HYPERVISOR_CREATE_SCHEMA,
- output=HYPERVISOR_OBJECT_SCHEMA)
+ input=COMPUTE_CREATE_SCHEMA,
+ output=COMPUTE_OBJECT_SCHEMA)
def create(request, response):
- hypervisor = yield from Controller.instance().addHypervisor(**request.json)
+ compute = yield from Controller.instance().addCompute(**request.json)
response.set_status(201)
- response.json(hypervisor)
+ response.json(compute)
@classmethod
@Route.post(
- r"/hypervisors/shutdown",
- description="Shutdown the local hypervisor",
+ r"/computes/shutdown",
+ description="Shutdown the local compute",
status_codes={
- 201: "Hypervisor is shutting down",
- 403: "Hypervisor shutdown refused"
+ 201: "Compute is shutting down",
+ 403: "Compute shutdown refused"
})
def shutdown(request, response):
config = Config.instance()
- if config.get_section_config("Hypervisor").getboolean("local", False) is False:
- raise HTTPForbidden(text="You can only stop a local hypervisor")
+ if config.get_section_config("Server").getboolean("local", False) is False:
+ raise HTTPForbidden(text="You can only stop a local server")
# close all the projects first
pm = ProjectManager.instance()
@@ -79,7 +79,7 @@ class HypervisorHandler:
log.error("Could not close project {}".format(e), exc_info=1)
continue
- # then shutdown the hypervisor itself
+ # then shutdown the compute itself
from gns3server.web.web_server import WebServer
server = WebServer.instance()
asyncio.async(server.shutdown_server())
diff --git a/gns3server/handlers/api/controller/vm_handler.py b/gns3server/handlers/api/controller/vm_handler.py
index b7655af6..dd259cbc 100644
--- a/gns3server/handlers/api/controller/vm_handler.py
+++ b/gns3server/handlers/api/controller/vm_handler.py
@@ -42,9 +42,9 @@ class VMHandler:
def create(request, response):
controller = Controller.instance()
- hypervisor = controller.getHypervisor(request.json.pop("hypervisor_id"))
+ compute = controller.getCompute(request.json.pop("compute_id"))
project = controller.getProject(request.match_info["project_id"])
- vm = yield from project.addVM(hypervisor, request.json.pop("vm_id", None), **request.json)
+ vm = yield from project.addVM(compute, request.json.pop("vm_id", None), **request.json)
response.set_status(201)
response.json(vm)
diff --git a/gns3server/handlers/index_handler.py b/gns3server/handlers/index_handler.py
index 08489b13..bba7f25d 100644
--- a/gns3server/handlers/index_handler.py
+++ b/gns3server/handlers/index_handler.py
@@ -17,8 +17,8 @@
from ..web.route import Route
from ..controller import Controller
-from ..hypervisor.port_manager import PortManager
-from ..hypervisor.project_manager import ProjectManager
+from ..compute.port_manager import PortManager
+from ..compute.project_manager import ProjectManager
from ..version import __version__
@@ -34,14 +34,15 @@ class IndexHandler:
@classmethod
@Route.get(
- r"/hypervisor",
+ r"/compute",
description="Ressources used by GNS3 Hypervisor"
)
- def hypervisor(request, response):
- response.template("hypervisor.html",
+ def compute(request, response):
+ response.template("compute.html",
port_manager=PortManager.instance(),
project_manager=ProjectManager.instance()
)
+
@classmethod
@Route.get(
r"/controller",
diff --git a/gns3server/main.py b/gns3server/main.py
index 85a72dec..e1f3aa44 100644
--- a/gns3server/main.py
+++ b/gns3server/main.py
@@ -21,7 +21,7 @@ Entry point of the server. It's support daemonize the process
"""
# WARNING
-# Due to buggy user machines we choose to put this as the first loading hypervisor
+# Due to buggy user machines we choose to put this as the first loading
# otherwise the egg cache is initialized in his standard location and
# if is not writetable the application crash. It's the user fault
# because one day the user as used sudo to run an egg and break his
diff --git a/gns3server/run.py b/gns3server/run.py
index 9338e73b..5eb87609 100644
--- a/gns3server/run.py
+++ b/gns3server/run.py
@@ -32,7 +32,7 @@ from gns3server.web.web_server import WebServer
from gns3server.web.logger import init_logger
from gns3server.version import __version__
from gns3server.config import Config
-from gns3server.hypervisor.project import Project
+from gns3server.compute.project import Project
from gns3server.crash_report import CrashReport
import logging
@@ -99,7 +99,6 @@ def parse_arguments(argv):
parser.add_argument("-A", "--allow", action="store_true", help="allow remote connections to local console ports")
parser.add_argument("-q", "--quiet", action="store_true", help="do not show logs on stdout")
parser.add_argument("-d", "--debug", action="store_true", help="show debug logs")
- parser.add_argument("--live", action="store_true", help="enable code live reload")
parser.add_argument("--shell", action="store_true", help="start a shell inside the server (debugging purpose only you need to install ptpython before)")
parser.add_argument("--log", help="send output to logfile instead of console")
parser.add_argument("--daemon", action="store_true", help="start as a daemon")
@@ -122,7 +121,6 @@ def parse_arguments(argv):
"allow": config.getboolean("allow_remote_console", False),
"quiet": config.getboolean("quiet", False),
"debug": config.getboolean("debug", False),
- "live": config.getboolean("live", False),
"logfile": config.getboolean("logfile", ""),
}
@@ -144,7 +142,6 @@ def set_config(args):
server_config["certkey"] = args.certkey
server_config["record"] = args.record
server_config["debug"] = str(args.debug)
- server_config["live"] = str(args.live)
server_config["shell"] = str(args.shell)
config.set_section_config("Server", server_config)
diff --git a/gns3server/schemas/hypervisor.py b/gns3server/schemas/compute.py
similarity index 82%
rename from gns3server/schemas/hypervisor.py
rename to gns3server/schemas/compute.py
index ab91307d..80f5d5de 100644
--- a/gns3server/schemas/hypervisor.py
+++ b/gns3server/schemas/compute.py
@@ -16,12 +16,12 @@
# along with this program. If not, see .
-HYPERVISOR_CREATE_SCHEMA = {
+COMPUTE_CREATE_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to register a GNS3 hypervisor instance",
+ "description": "Request validation to register a GNS3 compute instance",
"type": "object",
"properties": {
- "hypervisor_id": {
+ "compute_id": {
"description": "Server identifier",
"type": "string"
},
@@ -47,15 +47,15 @@ HYPERVISOR_CREATE_SCHEMA = {
}
},
"additionalProperties": False,
- "required": ["hypervisor_id", "protocol", "host", "port"]
+ "required": ["compute_id", "protocol", "host", "port"]
}
-HYPERVISOR_OBJECT_SCHEMA = {
+COMPUTE_OBJECT_SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to a GNS3 hypervisor object instance",
+ "description": "Request validation to a GNS3 compute object instance",
"type": "object",
"properties": {
- "hypervisor_id": {
+ "compute_id": {
"description": "Server identifier",
"type": "string"
},
@@ -76,14 +76,14 @@ HYPERVISOR_OBJECT_SCHEMA = {
"type": "string"
},
"connected": {
- "description": "True if controller is connected to the hypervisor",
+ "description": "True if controller is connected to the compute",
"type": "boolean"
},
"version": {
- "description": "Version of the GNS3 remote hypervisor",
+ "description": "Version of the GNS3 remote compute",
"type": ["string", "null"]
}
},
"additionalProperties": False,
- "required": ["hypervisor_id", "protocol", "host", "port"]
+ "required": ["compute_id", "protocol", "host", "port"]
}
diff --git a/gns3server/schemas/vm.py b/gns3server/schemas/vm.py
index 4c54b26f..89c9c8b5 100644
--- a/gns3server/schemas/vm.py
+++ b/gns3server/schemas/vm.py
@@ -69,7 +69,7 @@ VM_OBJECT_SCHEMA = {
"description": "A VM object",
"type": "object",
"properties": {
- "hypervisor_id": {
+ "compute_id": {
"description": "Hypervisor identifier",
"type": "string"
},
@@ -109,5 +109,5 @@ VM_OBJECT_SCHEMA = {
}
},
"additionalProperties": False,
- "required": ["name", "vm_type", "hypervisor_id"]
+ "required": ["name", "vm_type", "compute_id"]
}
diff --git a/gns3server/templates/hypervisor.html b/gns3server/templates/compute.html
similarity index 100%
rename from gns3server/templates/hypervisor.html
rename to gns3server/templates/compute.html
diff --git a/gns3server/templates/controller.html b/gns3server/templates/controller.html
index f2315dea..a9064f16 100644
--- a/gns3server/templates/controller.html
+++ b/gns3server/templates/controller.html
@@ -19,24 +19,23 @@ in futur GNS3 versions.
{{project.name}} |
{{project.id}} |
- {{project.vms|length}} |
- {{project.links|length}} |
+ {{project.vms|length}} |
+ {{project.links|length}} |
{% endfor %}
-Hypervisors
+Computes
ID
|
-{% for hypervisor in controller.hypervisors.values() %}
+{% for compute in controller.computes.values() %}
- {{hypervisor.id}} |
+ {{compute.id}} |
{% endfor %}
{%endblock%}
-
diff --git a/gns3server/web/documentation.py b/gns3server/web/documentation.py
index 31f9f744..3f8d0baa 100644
--- a/gns3server/web/documentation.py
+++ b/gns3server/web/documentation.py
@@ -36,7 +36,7 @@ class Documentation(object):
self._directory = directory
def write(self):
- self.write_documentation("hypervisor")
+ self.write_documentation("compute")
# Controller documentation
self.write_documentation("controller")
@@ -49,8 +49,8 @@ class Documentation(object):
for handler_name in sorted(self._documentation):
if "controller." in handler_name:
server_type = "controller"
- elif "hypervisor." in handler_name:
- server_type = "hypervisor"
+ elif "compute" in handler_name:
+ server_type = "compute"
else:
server_type = "root"
@@ -122,7 +122,7 @@ class Documentation(object):
f.write("\n\n.. literalinclude:: ../../../examples/{}\n\n".format(query_path))
def _file_path(self, path):
- path = path.replace("hypervisor", "")
+ path = path.replace("compute", "")
path = path.replace("controller", "")
return re.sub("^v2", "", re.sub("[^a-z0-9]", "", path))
diff --git a/gns3server/web/route.py b/gns3server/web/route.py
index cf89ca0f..4fa56339 100644
--- a/gns3server/web/route.py
+++ b/gns3server/web/route.py
@@ -25,7 +25,7 @@ import traceback
log = logging.getLogger(__name__)
-from ..hypervisor.vm_error import VMError
+from ..compute.vm_error import VMError
from ..controller.controller_error import ControllerError
from ..ubridge.ubridge_error import UbridgeError
from .response import Response
@@ -127,8 +127,8 @@ class Route(object):
# Add the type of server to the route
if "controller" in func.__module__:
route = "/v{version}{path}".format(path=path, version=api_version)
- elif "hypervisor" in func.__module__:
- route = "/v{version}/hypervisor{path}".format(path=path, version=api_version)
+ elif "compute" in func.__module__:
+ route = "/v{version}/compute{path}".format(path=path, version=api_version)
else:
route = path
@@ -243,7 +243,7 @@ class Route(object):
if vm_id is None:
vm_id = request.match_info["device_id"]
- if "hypervisor" in request.path:
+ if "compute" in request.path:
type = "compute"
else:
type = "controller"
diff --git a/gns3server/web/web_server.py b/gns3server/web/web_server.py
index ab921f37..348ede1d 100644
--- a/gns3server/web/web_server.py
+++ b/gns3server/web/web_server.py
@@ -32,8 +32,8 @@ import atexit
from .route import Route
from .request_handler import RequestHandler
from ..config import Config
-from ..hypervisor import MODULES
-from ..hypervisor.port_manager import PortManager
+from ..compute import MODULES
+from ..compute.port_manager import PortManager
# do not delete this import
import gns3server.handlers
@@ -124,34 +124,6 @@ class WebServer:
else:
self._loop.add_signal_handler(getattr(signal, signal_name), callback)
- def _reload_hook(self):
-
- @asyncio.coroutine
- def reload():
-
- log.info("Reloading")
- yield from self.shutdown_server()
- os.execv(sys.executable, [sys.executable] + sys.argv)
-
- # code extracted from tornado
- for module in sys.hypervisor.values():
- # Some hypervisor play games with sys.hypervisor (e.g. email/__init__.py
- # in the standard library), and occasionally this can cause strange
- # failures in getattr. Just ignore anything that's not an ordinary
- # module.
- if not isinstance(module, types.ModuleType):
- continue
- path = getattr(module, "__file__", None)
- if not path:
- continue
- if path.endswith(".pyc") or path.endswith(".pyo"):
- path = path[:-1]
- modified = os.stat(path).st_mtime
- if modified > self._start_time:
- log.debug("File {} has been modified".format(path))
- asyncio.async(reload())
- self._loop.call_later(1, self._reload_hook)
-
def _create_ssl_context(self, server_config):
import ssl
@@ -245,10 +217,6 @@ class WebServer:
self._signal_handling()
self._exit_handling()
- if server_config.getboolean("live"):
- log.info("Code live reload is enabled, watching for file changes")
- self._loop.call_later(1, self._reload_hook)
-
if server_config.getboolean("shell"):
asyncio.async(self.start_shell())
diff --git a/tests/hypervisor/docker/test_docker.py b/tests/compute/docker/test_docker.py
similarity index 95%
rename from tests/hypervisor/docker/test_docker.py
rename to tests/compute/docker/test_docker.py
index 396f1b58..9d878198 100644
--- a/tests/hypervisor/docker/test_docker.py
+++ b/tests/compute/docker/test_docker.py
@@ -20,8 +20,8 @@ import asyncio
from unittest.mock import MagicMock
from tests.utils import asyncio_patch
-from gns3server.hypervisor.docker import Docker
-from gns3server.hypervisor.docker.docker_error import DockerError
+from gns3server.compute.docker import Docker
+from gns3server.compute.docker.docker_error import DockerError
def test_query_success(loop):
@@ -125,7 +125,7 @@ def test_list_images(loop):
}
]
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
images = loop.run_until_complete(asyncio.async(Docker.instance().list_images()))
mock.assert_called_with("GET", "images/json", params={"all": 0})
assert len(images) == 5
diff --git a/tests/hypervisor/docker/test_docker_vm.py b/tests/compute/docker/test_docker_vm.py
similarity index 79%
rename from tests/hypervisor/docker/test_docker_vm.py
rename to tests/compute/docker/test_docker_vm.py
index 79bc1b0c..be06ff9a 100644
--- a/tests/hypervisor/docker/test_docker_vm.py
+++ b/tests/compute/docker/test_docker_vm.py
@@ -22,9 +22,9 @@ import os
from tests.utils import asyncio_patch, AsyncioMagicMock
from gns3server.ubridge.ubridge_error import UbridgeNamespaceError
-from gns3server.hypervisor.docker.docker_vm import DockerVM
-from gns3server.hypervisor.docker.docker_error import *
-from gns3server.hypervisor.docker import Docker
+from gns3server.compute.docker.docker_vm import DockerVM
+from gns3server.compute.docker.docker_error import *
+from gns3server.compute.docker import Docker
from gns3server.utils.get_resource import get_resource
@@ -79,8 +79,8 @@ def test_create(loop, project, manager):
"Id": "e90e34656806",
"Warnings": []
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu")
loop.run_until_complete(asyncio.async(vm.create()))
mock.assert_called_with("POST", "containers/create", data={
@@ -115,8 +115,8 @@ def test_create_vnc(loop, project, manager):
"Warnings": []
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu", console_type="vnc", console=5900)
vm._start_vnc = MagicMock()
vm._display = 42
@@ -155,8 +155,8 @@ def test_create_start_cmd(loop, project, manager):
"Id": "e90e34656806",
"Warnings": []
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu")
vm._start_command = "/bin/ls"
loop.run_until_complete(asyncio.async(vm.create()))
@@ -191,8 +191,8 @@ def test_create_environment(loop, project, manager):
"Id": "e90e34656806",
"Warnings": []
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu")
vm.environment = "YES=1\nNO=0"
loop.run_until_complete(asyncio.async(vm.create()))
@@ -243,8 +243,8 @@ def test_create_image_not_available(loop, project, manager):
vm._get_image_informations = MagicMock()
vm._get_image_informations.side_effect = informations
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM.pull_image", return_value=True) as mock_pull:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.DockerVM.pull_image", return_value=True) as mock_pull:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
loop.run_until_complete(asyncio.async(vm.create()))
mock.assert_called_with("POST", "containers/create", data={
"Tty": True,
@@ -286,17 +286,17 @@ def test_get_container_state(loop, vm):
"StartedAt": "2015-01-06T15:47:32.072697474Z"
}
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
assert loop.run_until_complete(asyncio.async(vm._get_container_state())) == "running"
response["State"]["Running"] = False
response["State"]["Paused"] = True
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
assert loop.run_until_complete(asyncio.async(vm._get_container_state())) == "paused"
response["State"]["Running"] = False
response["State"]["Paused"] = False
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
assert loop.run_until_complete(asyncio.async(vm._get_container_state())) == "exited"
@@ -307,17 +307,17 @@ def test_is_running(loop, vm):
"Paused": False
}
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
assert loop.run_until_complete(asyncio.async(vm.is_running())) is False
response["State"]["Running"] = True
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
assert loop.run_until_complete(asyncio.async(vm.is_running())) is True
def test_pause(loop, vm):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock:
loop.run_until_complete(asyncio.async(vm.pause()))
mock.assert_called_with("POST", "containers/e90e34656842/pause")
@@ -326,7 +326,7 @@ def test_pause(loop, vm):
def test_unpause(loop, vm):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock:
loop.run_until_complete(asyncio.async(vm.unpause()))
mock.assert_called_with("POST", "containers/e90e34656842/unpause")
@@ -349,7 +349,7 @@ def test_start(loop, vm, manager, free_console_port):
nio = manager.create_nio(0, {"type": "nio_udp", "lport": free_console_port, "rport": free_console_port, "rhost": "127.0.0.1"})
loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
loop.run_until_complete(asyncio.async(vm.start()))
mock_query.assert_called_with("POST", "containers/e90e34656842/start")
@@ -368,12 +368,12 @@ def test_start_namespace_failed(loop, vm, manager, free_console_port):
nio = manager.create_nio(0, {"type": "nio_udp", "lport": free_console_port, "rport": free_console_port, "rhost": "127.0.0.1"})
loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._start_ubridge") as mock_start_ubridge:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_namespace", return_value=42) as mock_namespace:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._add_ubridge_connection", side_effect=UbridgeNamespaceError()) as mock_add_ubridge_connection:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_log", return_value='Hello not available') as mock_log:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._start_ubridge") as mock_start_ubridge:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_namespace", return_value=42) as mock_namespace:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._add_ubridge_connection", side_effect=UbridgeNamespaceError()) as mock_add_ubridge_connection:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_log", return_value='Hello not available') as mock_log:
with pytest.raises(DockerError):
loop.run_until_complete(asyncio.async(vm.start()))
@@ -392,12 +392,12 @@ def test_start_without_nio(loop, vm, manager, free_console_port):
assert vm.status != "started"
vm.adapters = 1
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._start_ubridge") as mock_start_ubridge:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_namespace", return_value=42) as mock_namespace:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._add_ubridge_connection") as mock_add_ubridge_connection:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._start_console") as mock_start_console:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._start_ubridge") as mock_start_ubridge:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_namespace", return_value=42) as mock_namespace:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._add_ubridge_connection") as mock_add_ubridge_connection:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._start_console") as mock_start_console:
loop.run_until_complete(asyncio.async(vm.start()))
mock_query.assert_called_with("POST", "containers/e90e34656842/start")
@@ -409,8 +409,8 @@ def test_start_without_nio(loop, vm, manager, free_console_port):
def test_start_unpause(loop, vm, manager, free_console_port):
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="paused"):
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM.unpause", return_value="paused") as mock:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="paused"):
+ with asyncio_patch("gns3server.compute.docker.DockerVM.unpause", return_value="paused") as mock:
loop.run_until_complete(asyncio.async(vm.start()))
assert mock.called
assert vm.status == "started"
@@ -418,7 +418,7 @@ def test_start_unpause(loop, vm, manager, free_console_port):
def test_restart(loop, vm):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock:
loop.run_until_complete(asyncio.async(vm.restart()))
mock.assert_called_with("POST", "containers/e90e34656842/restart")
@@ -428,8 +428,8 @@ def test_stop(loop, vm):
vm._ubridge_hypervisor = MagicMock()
vm._ubridge_hypervisor.is_running.return_value = True
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="running"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="running"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
loop.run_until_complete(asyncio.async(vm.stop()))
mock_query.assert_called_with("POST", "containers/e90e34656842/stop", params={"t": 5})
assert vm._ubridge_hypervisor.stop.called
@@ -437,9 +437,9 @@ def test_stop(loop, vm):
def test_stop_paused_container(loop, vm):
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="paused"):
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM.unpause") as mock_unpause:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="paused"):
+ with asyncio_patch("gns3server.compute.docker.DockerVM.unpause") as mock_unpause:
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
loop.run_until_complete(asyncio.async(vm.stop()))
mock_query.assert_called_with("POST", "containers/e90e34656842/stop", params={"t": 5})
assert mock_unpause.called
@@ -455,9 +455,9 @@ def test_update(loop, vm):
original_console = vm.console
original_aux = vm.aux
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock_query:
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query:
loop.run_until_complete(asyncio.async(vm.update()))
mock_query.assert_any_call("DELETE", "containers/e90e34656842", params={"force": 1})
@@ -500,10 +500,10 @@ def test_update_vnc(loop, vm):
original_console = vm.console
original_aux = vm.aux
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._start_vnc"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._start_vnc"):
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query:
loop.run_until_complete(asyncio.async(vm.update()))
assert vm.console == original_console
@@ -520,9 +520,9 @@ def test_update_running(loop, vm):
original_console = vm.console
vm.start = MagicMock()
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="running"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock_query:
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="running"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query:
loop.run_until_complete(asyncio.async(vm.update()))
mock_query.assert_any_call("DELETE", "containers/e90e34656842", params={"force": 1})
@@ -555,8 +555,8 @@ def test_update_running(loop, vm):
def test_delete(loop, vm):
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
loop.run_until_complete(asyncio.async(vm.delete()))
mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1})
@@ -569,8 +569,8 @@ def test_close(loop, vm, port_manager):
nio = vm.manager.create_nio(0, nio)
loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
loop.run_until_complete(asyncio.async(vm.close()))
mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1})
@@ -584,8 +584,8 @@ def test_close_vnc(loop, vm, port_manager):
vm._x11vnc_process = MagicMock()
vm._xvfb_process = MagicMock()
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._get_container_state", return_value="stopped"):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query") as mock_query:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._get_container_state", return_value="stopped"):
+ with asyncio_patch("gns3server.compute.docker.Docker.query") as mock_query:
loop.run_until_complete(asyncio.async(vm.close()))
mock_query.assert_called_with("DELETE", "containers/e90e34656842", params={"force": 1})
@@ -599,7 +599,7 @@ def test_get_namespace(loop, vm):
"Pid": 42
}
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock_query:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock_query:
assert loop.run_until_complete(asyncio.async(vm._get_namespace())) == 42
mock_query.assert_called_with("GET", "containers/e90e34656842/json")
@@ -717,7 +717,7 @@ def test_adapter_remove_nio_binding(vm, loop):
"rhost": "127.0.0.1"}
nio = vm.manager.create_nio(0, nio)
loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
- with asyncio_patch("gns3server.hypervisor.docker.DockerVM._delete_ubridge_connection") as delete_ubridge_mock:
+ with asyncio_patch("gns3server.compute.docker.DockerVM._delete_ubridge_connection") as delete_ubridge_mock:
loop.run_until_complete(asyncio.async(vm.adapter_remove_nio_binding(0)))
assert vm._ethernet_adapters[0].get_nio(0) is None
delete_ubridge_mock.assert_called_with(0)
@@ -750,7 +750,7 @@ def test_pull_image(loop, vm):
mock_query = MagicMock()
mock_query.content.return_value = Response()
- with asyncio_patch("gns3server.hypervisor.docker.Docker.http_query", return_value=mock_query) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.http_query", return_value=mock_query) as mock:
images = loop.run_until_complete(asyncio.async(vm.pull_image("ubuntu")))
mock.assert_called_with("POST", "images/create", params={"fromImage": "ubuntu"})
@@ -783,7 +783,7 @@ def test_get_log(loop, vm):
mock_query = MagicMock()
mock_query.read = read
- with asyncio_patch("gns3server.hypervisor.docker.Docker.http_query", return_value=mock_query) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.http_query", return_value=mock_query) as mock:
images = loop.run_until_complete(asyncio.async(vm._get_log()))
mock.assert_called_with("GET", "containers/e90e34656842/logs", params={"stderr": 1, "stdout": 1}, data={})
@@ -791,7 +791,7 @@ def test_get_log(loop, vm):
def test_get_image_informations(project, manager, loop):
response = {
}
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value=response) as mock:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value=response) as mock:
vm = DockerVM("test", str(uuid.uuid4()), project, manager, "ubuntu")
loop.run_until_complete(asyncio.async(vm._get_image_informations()))
mock.assert_called_with("GET", "images/ubuntu/json")
@@ -819,7 +819,7 @@ def test_mount_binds(vm, tmpdir):
def test_start_vnc(vm, loop):
vm.console_resolution = "1280x1024"
with patch("shutil.which", return_value="/bin/x"):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.wait_for_file_creation") as mock_wait:
+ with asyncio_patch("gns3server.compute.docker.docker_vm.wait_for_file_creation") as mock_wait:
with asyncio_patch("asyncio.create_subprocess_exec") as mock_exec:
loop.run_until_complete(asyncio.async(vm._start_vnc()))
assert vm._display is not None
diff --git a/tests/hypervisor/dynamips/test_dynamips_manager.py b/tests/compute/dynamips/test_dynamips_manager.py
similarity index 96%
rename from tests/hypervisor/dynamips/test_dynamips_manager.py
rename to tests/compute/dynamips/test_dynamips_manager.py
index 459201fc..7caf1c52 100644
--- a/tests/hypervisor/dynamips/test_dynamips_manager.py
+++ b/tests/compute/dynamips/test_dynamips_manager.py
@@ -23,8 +23,8 @@ import uuid
import os
import asyncio
-from gns3server.hypervisor.dynamips import Dynamips
-from gns3server.hypervisor.dynamips.dynamips_error import DynamipsError
+from gns3server.compute.dynamips import Dynamips
+from gns3server.compute.dynamips.dynamips_error import DynamipsError
from unittest.mock import patch
diff --git a/tests/hypervisor/dynamips/test_dynamips_router.py b/tests/compute/dynamips/test_dynamips_router.py
similarity index 90%
rename from tests/hypervisor/dynamips/test_dynamips_router.py
rename to tests/compute/dynamips/test_dynamips_router.py
index 320246fd..1fe3ee59 100644
--- a/tests/hypervisor/dynamips/test_dynamips_router.py
+++ b/tests/compute/dynamips/test_dynamips_router.py
@@ -20,9 +20,9 @@ import asyncio
import configparser
from unittest.mock import patch
-from gns3server.hypervisor.dynamips.nodes.router import Router
-from gns3server.hypervisor.dynamips.dynamips_error import DynamipsError
-from gns3server.hypervisor.dynamips import Dynamips
+from gns3server.compute.dynamips.nodes.router import Router
+from gns3server.compute.dynamips.dynamips_error import DynamipsError
+from gns3server.compute.dynamips import Dynamips
from gns3server.config import Config
diff --git a/tests/hypervisor/iou/test_iou_manager.py b/tests/compute/iou/test_iou_manager.py
similarity index 94%
rename from tests/hypervisor/iou/test_iou_manager.py
rename to tests/compute/iou/test_iou_manager.py
index 68b47026..be4d8902 100644
--- a/tests/hypervisor/iou/test_iou_manager.py
+++ b/tests/compute/iou/test_iou_manager.py
@@ -25,10 +25,10 @@ import sys
pytestmark = pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
if not sys.platform.startswith("win"):
- from gns3server.hypervisor.iou import IOU
- from gns3server.hypervisor.iou.iou_error import IOUError
+ from gns3server.compute.iou import IOU
+ from gns3server.compute.iou.iou_error import IOUError
-from gns3server.hypervisor.project_manager import ProjectManager
+from gns3server.compute.project_manager import ProjectManager
@pytest.fixture(scope="function")
diff --git a/tests/hypervisor/iou/test_iou_vm.py b/tests/compute/iou/test_iou_vm.py
similarity index 89%
rename from tests/hypervisor/iou/test_iou_vm.py
rename to tests/compute/iou/test_iou_vm.py
index 5d620434..9e0d4cee 100644
--- a/tests/hypervisor/iou/test_iou_vm.py
+++ b/tests/compute/iou/test_iou_vm.py
@@ -32,9 +32,9 @@ from unittest.mock import patch, MagicMock, PropertyMock
pytestmark = pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
if not sys.platform.startswith("win"):
- from gns3server.hypervisor.iou.iou_vm import IOUVM
- from gns3server.hypervisor.iou.iou_error import IOUError
- from gns3server.hypervisor.iou import IOU
+ from gns3server.compute.iou.iou_vm import IOUVM
+ from gns3server.compute.iou.iou_error import IOUError
+ from gns3server.compute.iou import IOU
from gns3server.config import Config
@@ -108,10 +108,10 @@ def test_vm_invalid_iouyap_path(project, manager, loop, fake_iou_bin):
def test_start(loop, vm, monkeypatch):
mock_process = MagicMock()
- with patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_requirements", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_iou_licence", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
+ with patch("gns3server.compute.iou.iou_vm.IOUVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_iou_licence", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=mock_process) as mock_exec:
mock_process.returncode = None
loop.run_until_complete(asyncio.async(vm.start()))
@@ -126,10 +126,10 @@ def test_start_with_iourc(loop, vm, monkeypatch, tmpdir):
f.write("1")
mock_process = MagicMock()
with patch("gns3server.config.Config.get_section_config", return_value={"iourc_path": fake_file, "iouyap_path": vm.iouyap_path}):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_requirements", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_iou_licence", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_iou_licence", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=mock_process) as exec_mock:
mock_process.returncode = None
loop.run_until_complete(asyncio.async(vm.start()))
@@ -162,9 +162,9 @@ def test_stop(loop, vm):
future.set_result(True)
process.wait.return_value = future
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_requirements", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
loop.run_until_complete(asyncio.async(vm.start()))
@@ -184,9 +184,9 @@ def test_reload(loop, vm, fake_iou_bin):
process.wait.return_value = future
process.returncode = None
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_requirements", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_ioucon", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._start_iouyap", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
with asyncio_patch("gns3server.utils.asyncio.wait_for_process_termination"):
loop.run_until_complete(asyncio.async(vm.start()))
@@ -197,7 +197,7 @@ def test_reload(loop, vm, fake_iou_bin):
def test_close(vm, port_manager, loop):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
vm.start()
port = vm.console
diff --git a/tests/hypervisor/qemu/test_qemu_manager.py b/tests/compute/qemu/test_qemu_manager.py
similarity index 89%
rename from tests/hypervisor/qemu/test_qemu_manager.py
rename to tests/compute/qemu/test_qemu_manager.py
index d79152b1..e2baf1b7 100644
--- a/tests/hypervisor/qemu/test_qemu_manager.py
+++ b/tests/compute/qemu/test_qemu_manager.py
@@ -22,8 +22,8 @@ import sys
import pytest
import platform
-from gns3server.hypervisor.qemu import Qemu
-from gns3server.hypervisor.qemu.qemu_error import QemuError
+from gns3server.compute.qemu import Qemu
+from gns3server.compute.qemu.qemu_error import QemuError
from tests.utils import asyncio_patch
from unittest.mock import patch, MagicMock
@@ -40,7 +40,7 @@ def fake_qemu_img_binary(tmpdir):
def test_get_qemu_version(loop):
- with asyncio_patch("gns3server.hypervisor.qemu.subprocess_check_output", return_value="QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
+ with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="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")))
if sys.platform.startswith("win"):
assert version == ""
@@ -58,7 +58,7 @@ def test_binary_list(loop):
f.write("1")
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
- with asyncio_patch("gns3server.hypervisor.qemu.subprocess_check_output", return_value="QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
+ with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="QEMU emulator version 2.2.0, Copyright (c) 2003-2008 Fabrice Bellard") as mock:
if sys.platform.startswith("win"):
version = ""
else:
@@ -97,7 +97,7 @@ def test_img_binary_list(loop):
f.write("1")
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
- with asyncio_patch("gns3server.hypervisor.qemu.subprocess_check_output", return_value="qemu-img version 2.2.0, Copyright (c) 2004-2008 Fabrice Bellard") as mock:
+ with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="qemu-img version 2.2.0, Copyright (c) 2004-2008 Fabrice Bellard") as mock:
qemus = loop.run_until_complete(asyncio.async(Qemu.img_binary_list()))
version = "2.2.0"
@@ -151,7 +151,7 @@ def test_create_image_relative_path(loop, tmpdir, fake_qemu_img_binary):
"size": 100
}
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
- with patch("gns3server.hypervisor.qemu.Qemu.get_images_directory", return_value=str(tmpdir)):
+ with patch("gns3server.compute.qemu.Qemu.get_images_directory", return_value=str(tmpdir)):
loop.run_until_complete(asyncio.async(Qemu.instance().create_disk(fake_qemu_img_binary, "hda.qcow2", options)))
args, kwargs = process.call_args
assert args == (
@@ -172,7 +172,7 @@ def test_create_image_exist(loop, tmpdir, fake_qemu_img_binary):
"size": 100
}
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
- with patch("gns3server.hypervisor.qemu.Qemu.get_images_directory", return_value=str(tmpdir)):
+ with patch("gns3server.compute.qemu.Qemu.get_images_directory", return_value=str(tmpdir)):
with pytest.raises(QemuError):
loop.run_until_complete(asyncio.async(Qemu.instance().create_disk(fake_qemu_img_binary, "hda.qcow2", options)))
assert not process.called
diff --git a/tests/hypervisor/qemu/test_qemu_vm.py b/tests/compute/qemu/test_qemu_vm.py
similarity index 96%
rename from tests/hypervisor/qemu/test_qemu_vm.py
rename to tests/compute/qemu/test_qemu_vm.py
index 8d0152da..cd808c86 100644
--- a/tests/hypervisor/qemu/test_qemu_vm.py
+++ b/tests/compute/qemu/test_qemu_vm.py
@@ -28,11 +28,11 @@ from tests.utils import asyncio_patch
from unittest import mock
from unittest.mock import patch, MagicMock
-from gns3server.hypervisor.qemu.qemu_vm import QemuVM
-from gns3server.hypervisor.qemu.qemu_error import QemuError
-from gns3server.hypervisor.qemu import Qemu
+from gns3server.compute.qemu.qemu_vm import QemuVM
+from gns3server.compute.qemu.qemu_error import QemuError
+from gns3server.compute.qemu import Qemu
from gns3server.utils import force_unix_path
-from gns3server.hypervisor.notification_manager import NotificationManager
+from gns3server.compute.notification_manager import NotificationManager
@pytest.fixture(scope="module")
@@ -177,7 +177,7 @@ def test_termination_callback_error(vm, tmpdir, async_run):
def test_reload(loop, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.QemuVM._control_vm") as mock:
+ with asyncio_patch("gns3server.compute.qemu.QemuVM._control_vm") as mock:
loop.run_until_complete(asyncio.async(vm.reload()))
assert mock.called_with("system_reset")
@@ -186,7 +186,7 @@ def test_suspend(loop, vm):
control_vm_result = MagicMock()
control_vm_result.match.group.decode.return_value = "running"
- with asyncio_patch("gns3server.hypervisor.qemu.QemuVM._control_vm", return_value=control_vm_result) as mock:
+ with asyncio_patch("gns3server.compute.qemu.QemuVM._control_vm", return_value=control_vm_result) as mock:
loop.run_until_complete(asyncio.async(vm.suspend()))
assert mock.called_with("system_reset")
@@ -199,7 +199,7 @@ def test_add_nio_binding_udp(vm, loop):
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
def test_add_nio_binding_ethernet(vm, loop, ethernet_device):
- with patch("gns3server.hypervisor.base_manager.BaseManager.has_privileged_access", return_value=True):
+ with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
nio = Qemu.instance().create_nio(vm.qemu_path, {"type": "nio_generic_ethernet", "ethernet_device": ethernet_device})
loop.run_until_complete(asyncio.async(vm.adapter_add_nio_binding(0, nio)))
assert nio.ethernet_device == ethernet_device
@@ -307,7 +307,7 @@ def test_set_qemu_path_kvm_binary(vm, tmpdir, fake_qemu_binary):
def test_set_platform(project, manager):
with patch("shutil.which", return_value="/bin/qemu-system-x86_64") as which_mock:
- with patch("gns3server.hypervisor.qemu.QemuVM._check_qemu_path"):
+ with patch("gns3server.compute.qemu.QemuVM._check_qemu_path"):
vm = QemuVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, platform="x86_64")
if sys.platform.startswith("win"):
which_mock.assert_called_with("qemu-system-x86_64w.exe", path=mock.ANY)
@@ -506,7 +506,7 @@ def test_initrd(vm, tmpdir):
vm.manager.config.set("Server", "images_path", str(tmpdir))
- with patch("gns3server.hypervisor.project.Project.emit") as mock:
+ with patch("gns3server.compute.project.Project.emit") as mock:
vm.initrd = str(tmpdir / "test")
assert vm.initrd == force_unix_path(str(tmpdir / "test"))
vm.initrd = "test"
@@ -518,7 +518,7 @@ def test_initrd_asa(vm, tmpdir):
vm.manager.config.set("Server", "images_path", str(tmpdir))
- with patch("gns3server.hypervisor.project.Project.emit") as mock:
+ with patch("gns3server.compute.project.Project.emit") as mock:
vm.initrd = str(tmpdir / "asa842-initrd.gz")
assert vm.initrd == force_unix_path(str(tmpdir / "asa842-initrd.gz"))
vm.initrd = "asa842-initrd.gz"
diff --git a/tests/hypervisor/test_base_vm.py b/tests/compute/test_base_vm.py
similarity index 93%
rename from tests/hypervisor/test_base_vm.py
rename to tests/compute/test_base_vm.py
index aea8fa42..e62fca06 100644
--- a/tests/hypervisor/test_base_vm.py
+++ b/tests/compute/test_base_vm.py
@@ -23,11 +23,11 @@ from tests.utils import asyncio_patch
from unittest.mock import patch, MagicMock
-from gns3server.hypervisor.vpcs.vpcs_vm import VPCSVM
-from gns3server.hypervisor.docker.docker_vm import DockerVM
-from gns3server.hypervisor.vpcs.vpcs_error import VPCSError
-from gns3server.hypervisor.vm_error import VMError
-from gns3server.hypervisor.vpcs import VPCS
+from gns3server.compute.vpcs.vpcs_vm import VPCSVM
+from gns3server.compute.docker.docker_vm import DockerVM
+from gns3server.compute.vpcs.vpcs_error import VPCSError
+from gns3server.compute.vm_error import VMError
+from gns3server.compute.vpcs import VPCS
@pytest.fixture(scope="module")
diff --git a/tests/hypervisor/test_manager.py b/tests/compute/test_manager.py
similarity index 92%
rename from tests/hypervisor/test_manager.py
rename to tests/compute/test_manager.py
index f9d11df0..435347cf 100644
--- a/tests/hypervisor/test_manager.py
+++ b/tests/compute/test_manager.py
@@ -21,9 +21,9 @@ import pytest
from unittest.mock import patch
-from gns3server.hypervisor.vpcs import VPCS
-from gns3server.hypervisor.qemu import Qemu
-from gns3server.hypervisor.vm_error import VMError
+from gns3server.compute.vpcs import VPCS
+from gns3server.compute.qemu import Qemu
+from gns3server.compute.vm_error import VMError
from gns3server.utils import force_unix_path
@@ -67,7 +67,7 @@ def test_create_vm_new_topology_without_uuid(loop, project, vpcs):
def test_create_vm_old_topology(loop, project, tmpdir, vpcs):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
# Create an old topology directory
project_dir = str(tmpdir / "testold")
vm_dir = os.path.join(project_dir, "testold-files", "vpcs", "pc-1")
@@ -158,7 +158,7 @@ def test_list_images(loop, qemu, tmpdir):
with open(str(tmpdir / image), "w+") as f:
f.write("1")
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir)):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir)):
assert loop.run_until_complete(qemu.list_images()) == [
{"filename": "a.bin", "path": "a.bin"},
{"filename": "b.bin", "path": "b.bin"}
@@ -177,7 +177,7 @@ def test_list_images_recursives(loop, qemu, tmpdir):
with open(str(tmpdir / "c" / image), "w+") as f:
f.write("1")
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir)):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir)):
assert loop.run_until_complete(qemu.list_images()) == [
{"filename": "a.bin", "path": "a.bin"},
{"filename": "b.bin", "path": "b.bin"},
@@ -186,10 +186,10 @@ def test_list_images_recursives(loop, qemu, tmpdir):
def test_list_images_empty(loop, qemu, tmpdir):
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir)):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir)):
assert loop.run_until_complete(qemu.list_images()) == []
def test_list_images_directory_not_exist(loop, qemu):
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value="/bla"):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value="/bla"):
assert loop.run_until_complete(qemu.list_images()) == []
diff --git a/tests/hypervisor/test_notification_manager.py b/tests/compute/test_notification_manager.py
similarity index 97%
rename from tests/hypervisor/test_notification_manager.py
rename to tests/compute/test_notification_manager.py
index 444bc805..1c41a75c 100644
--- a/tests/hypervisor/test_notification_manager.py
+++ b/tests/compute/test_notification_manager.py
@@ -17,7 +17,7 @@
import uuid
-from gns3server.hypervisor.notification_manager import NotificationManager
+from gns3server.compute.notification_manager import NotificationManager
def test_queue(async_run):
diff --git a/tests/hypervisor/test_port_manager.py b/tests/compute/test_port_manager.py
similarity index 84%
rename from tests/hypervisor/test_port_manager.py
rename to tests/compute/test_port_manager.py
index 9e4750e0..6710a342 100644
--- a/tests/hypervisor/test_port_manager.py
+++ b/tests/compute/test_port_manager.py
@@ -21,15 +21,15 @@ import sys
import uuid
from unittest.mock import patch
-from gns3server.hypervisor.port_manager import PortManager
-from gns3server.hypervisor.project import Project
+from gns3server.compute.port_manager import PortManager
+from gns3server.compute.project import Project
def test_reserve_tcp_port():
pm = PortManager()
project = Project(project_id=str(uuid.uuid4()))
pm.reserve_tcp_port(2001, project)
- with patch("gns3server.hypervisor.project.Project.emit") as mock_emit:
+ with patch("gns3server.compute.project.Project.emit") as mock_emit:
port = pm.reserve_tcp_port(2001, project)
assert port != 2001
@@ -37,7 +37,7 @@ def test_reserve_tcp_port():
def test_reserve_tcp_port_outside_range():
pm = PortManager()
project = Project(project_id=str(uuid.uuid4()))
- with patch("gns3server.hypervisor.project.Project.emit") as mock_emit:
+ with patch("gns3server.compute.project.Project.emit") as mock_emit:
port = pm.reserve_tcp_port(80, project)
assert port != 80
@@ -50,7 +50,7 @@ def test_reserve_tcp_port_already_used_by_another_program():
pm = PortManager()
project = Project(project_id=str(uuid.uuid4()))
- with patch("gns3server.hypervisor.port_manager.PortManager._check_port") as mock_check:
+ with patch("gns3server.compute.port_manager.PortManager._check_port") as mock_check:
def execute_mock(host, port, *args):
if port == 2001:
@@ -60,7 +60,7 @@ def test_reserve_tcp_port_already_used_by_another_program():
mock_check.side_effect = execute_mock
- with patch("gns3server.hypervisor.project.Project.emit") as mock_emit:
+ with patch("gns3server.compute.project.Project.emit") as mock_emit:
port = pm.reserve_tcp_port(2001, project)
assert port != 2001
@@ -73,7 +73,7 @@ def test_reserve_tcp_port_already_used():
pm = PortManager()
project = Project(project_id=str(uuid.uuid4()))
- with patch("gns3server.hypervisor.port_manager.PortManager._check_port") as mock_check:
+ with patch("gns3server.compute.port_manager.PortManager._check_port") as mock_check:
def execute_mock(host, port, *args):
if port == 2001:
@@ -83,7 +83,7 @@ def test_reserve_tcp_port_already_used():
mock_check.side_effect = execute_mock
- with patch("gns3server.hypervisor.project.Project.emit") as mock_emit:
+ with patch("gns3server.compute.project.Project.emit") as mock_emit:
port = pm.reserve_tcp_port(2001, project)
assert port != 2001
diff --git a/tests/hypervisor/test_project.py b/tests/compute/test_project.py
similarity index 94%
rename from tests/hypervisor/test_project.py
rename to tests/compute/test_project.py
index 44b87252..bc43d489 100644
--- a/tests/hypervisor/test_project.py
+++ b/tests/compute/test_project.py
@@ -27,9 +27,9 @@ from uuid import uuid4
from unittest.mock import patch
from tests.utils import asyncio_patch
-from gns3server.hypervisor.project import Project
-from gns3server.hypervisor.notification_manager import NotificationManager
-from gns3server.hypervisor.vpcs import VPCS, VPCSVM
+from gns3server.compute.project import Project
+from gns3server.compute.notification_manager import NotificationManager
+from gns3server.compute.vpcs import VPCS, VPCSVM
from gns3server.config import Config
@@ -55,8 +55,8 @@ def test_path(tmpdir):
directory = Config.instance().get_section_config("Server").get("project_directory")
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
- with patch("gns3server.hypervisor.project.Project._get_default_project_directory", return_value=directory):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
+ with patch("gns3server.compute.project.Project._get_default_project_directory", return_value=directory):
p = Project(project_id=str(uuid4()))
assert p.path == os.path.join(directory, p.id)
assert os.path.exists(os.path.join(directory, p.id))
@@ -65,14 +65,14 @@ def test_path(tmpdir):
def test_init_path(tmpdir):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
p = Project(path=str(tmpdir), project_id=str(uuid4()))
assert p.path == str(tmpdir)
def test_changing_path_temporary_flag(tmpdir):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
p = Project(temporary=True, project_id=str(uuid4()))
assert os.path.exists(p.path)
original_path = p.path
@@ -96,14 +96,14 @@ def test_remove_temporary_flag():
def test_changing_path_not_allowed(tmpdir):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=False):
+ with patch("gns3server.compute.project.Project.is_local", return_value=False):
with pytest.raises(aiohttp.web.HTTPForbidden):
p = Project(project_id=str(uuid4()))
p.path = str(tmpdir)
def test_changing_path_with_quote_not_allowed(tmpdir):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
with pytest.raises(aiohttp.web.HTTPForbidden):
p = Project(project_id=str(uuid4()))
p.path = str(tmpdir / "project\"53")
@@ -117,7 +117,7 @@ def test_json(tmpdir):
def test_vm_working_directory(tmpdir, vm):
directory = Config.instance().get_section_config("Server").get("project_directory")
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
p = Project(project_id=str(uuid4()))
assert p.vm_working_directory(vm) == os.path.join(directory, p.id, 'project-files', vm.module_name, vm.id)
assert os.path.exists(p.vm_working_directory(vm))
@@ -186,7 +186,7 @@ def test_project_add_vm(manager):
def test_project_close(loop, vm, project):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM.close") as mock:
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM.close") as mock:
loop.run_until_complete(asyncio.async(project.close()))
assert mock.called
assert vm.id not in vm.manager._vms
@@ -372,7 +372,7 @@ def test_export_with_images(tmpdir):
with open(os.path.join(path, "test.gns3"), 'w+') as f:
json.dump(topology, f)
- with patch("gns3server.hypervisor.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),):
+ with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),):
z = project.export(include_images=True)
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f:
for data in z:
diff --git a/tests/hypervisor/test_project_manager.py b/tests/compute/test_project_manager.py
similarity index 94%
rename from tests/hypervisor/test_project_manager.py
rename to tests/compute/test_project_manager.py
index 7d359a99..bcdf5399 100644
--- a/tests/hypervisor/test_project_manager.py
+++ b/tests/compute/test_project_manager.py
@@ -17,7 +17,7 @@
import aiohttp
import pytest
-from gns3server.hypervisor.project_manager import ProjectManager
+from gns3server.compute.project_manager import ProjectManager
def test_create_project():
diff --git a/tests/hypervisor/virtualbox/test_virtualbox_manager.py b/tests/compute/virtualbox/test_virtualbox_manager.py
similarity index 93%
rename from tests/hypervisor/virtualbox/test_virtualbox_manager.py
rename to tests/compute/virtualbox/test_virtualbox_manager.py
index c0f4f855..fffe2c78 100644
--- a/tests/hypervisor/virtualbox/test_virtualbox_manager.py
+++ b/tests/compute/virtualbox/test_virtualbox_manager.py
@@ -25,8 +25,8 @@ import asyncio
from unittest.mock import patch
-from gns3server.hypervisor.virtualbox import VirtualBox
-from gns3server.hypervisor.virtualbox.virtualbox_error import VirtualBoxError
+from gns3server.compute.virtualbox import VirtualBox
+from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from tests.utils import asyncio_patch
@@ -90,7 +90,7 @@ def test_list_images(manager, loop):
return ["memory=256"]
assert False, "Unknow {} {}".format(cmd, args)
- with asyncio_patch("gns3server.hypervisor.virtualbox.VirtualBox.execute") as mock:
+ with asyncio_patch("gns3server.compute.virtualbox.VirtualBox.execute") as mock:
mock.side_effect = execute_mock
vms = loop.run_until_complete(asyncio.async(manager.list_images()))
assert vms == [
diff --git a/tests/hypervisor/virtualbox/test_virtualbox_vm.py b/tests/compute/virtualbox/test_virtualbox_vm.py
similarity index 84%
rename from tests/hypervisor/virtualbox/test_virtualbox_vm.py
rename to tests/compute/virtualbox/test_virtualbox_vm.py
index 5a2ed514..799ae0ee 100644
--- a/tests/hypervisor/virtualbox/test_virtualbox_vm.py
+++ b/tests/compute/virtualbox/test_virtualbox_vm.py
@@ -19,9 +19,9 @@ import pytest
import asyncio
from tests.utils import asyncio_patch
-from gns3server.hypervisor.virtualbox.virtualbox_vm import VirtualBoxVM
-from gns3server.hypervisor.virtualbox.virtualbox_error import VirtualBoxError
-from gns3server.hypervisor.virtualbox import VirtualBox
+from gns3server.compute.virtualbox.virtualbox_vm import VirtualBoxVM
+from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
+from gns3server.compute.virtualbox import VirtualBox
@pytest.fixture(scope="module")
@@ -44,13 +44,13 @@ def test_vm(project, manager):
def test_vm_valid_virtualbox_api_version(loop, project, manager):
- with asyncio_patch("gns3server.hypervisor.virtualbox.VirtualBox.execute", return_value=["API version: 4_3"]):
+ with asyncio_patch("gns3server.compute.virtualbox.VirtualBox.execute", return_value=["API version: 4_3"]):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
loop.run_until_complete(asyncio.async(vm.create()))
def test_vm_invalid_virtualbox_api_version(loop, project, manager):
- with asyncio_patch("gns3server.hypervisor.virtualbox.VirtualBox.execute", return_value=["API version: 4_2"]):
+ with asyncio_patch("gns3server.compute.virtualbox.VirtualBox.execute", return_value=["API version: 4_2"]):
with pytest.raises(VirtualBoxError):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
loop.run_until_complete(asyncio.async(vm.create()))
diff --git a/tests/hypervisor/vmware/test_vmware_manager.py b/tests/compute/vmware/test_vmware_manager.py
similarity index 96%
rename from tests/hypervisor/vmware/test_vmware_manager.py
rename to tests/compute/vmware/test_vmware_manager.py
index 89025af6..c83a130e 100644
--- a/tests/hypervisor/vmware/test_vmware_manager.py
+++ b/tests/compute/vmware/test_vmware_manager.py
@@ -25,7 +25,7 @@ import asyncio
from unittest.mock import patch
-from gns3server.hypervisor.vmware import VMware
+from gns3server.compute.vmware import VMware
from tests.utils import asyncio_patch
diff --git a/tests/hypervisor/vmware/test_vmware_vm.py b/tests/compute/vmware/test_vmware_vm.py
similarity index 93%
rename from tests/hypervisor/vmware/test_vmware_vm.py
rename to tests/compute/vmware/test_vmware_vm.py
index cd56f5ee..58c8482a 100644
--- a/tests/hypervisor/vmware/test_vmware_vm.py
+++ b/tests/compute/vmware/test_vmware_vm.py
@@ -19,9 +19,9 @@ import pytest
import asyncio
from tests.utils import asyncio_patch
-from gns3server.hypervisor.vmware.vmware_vm import VMwareVM
-from gns3server.hypervisor.vmware.vmware_error import VMwareError
-from gns3server.hypervisor.vmware import VMware
+from gns3server.compute.vmware.vmware_vm import VMwareVM
+from gns3server.compute.vmware.vmware_error import VMwareError
+from gns3server.compute.vmware import VMware
@pytest.fixture(scope="module")
diff --git a/tests/hypervisor/vpcs/test_vpcs_manager.py b/tests/compute/vpcs/test_vpcs_manager.py
similarity index 93%
rename from tests/hypervisor/vpcs/test_vpcs_manager.py
rename to tests/compute/vpcs/test_vpcs_manager.py
index cabc4fab..50aeb596 100644
--- a/tests/hypervisor/vpcs/test_vpcs_manager.py
+++ b/tests/compute/vpcs/test_vpcs_manager.py
@@ -20,9 +20,9 @@ import pytest
import uuid
-from gns3server.hypervisor.vpcs import VPCS
-from gns3server.hypervisor.vpcs.vpcs_error import VPCSError
-from gns3server.hypervisor.project_manager import ProjectManager
+from gns3server.compute.vpcs import VPCS
+from gns3server.compute.vpcs.vpcs_error import VPCSError
+from gns3server.compute.project_manager import ProjectManager
def test_get_mac_id(loop, project, port_manager):
diff --git a/tests/hypervisor/vpcs/test_vpcs_vm.py b/tests/compute/vpcs/test_vpcs_vm.py
similarity index 87%
rename from tests/hypervisor/vpcs/test_vpcs_vm.py
rename to tests/compute/vpcs/test_vpcs_vm.py
index df0b042f..d5a9f24c 100644
--- a/tests/hypervisor/vpcs/test_vpcs_vm.py
+++ b/tests/compute/vpcs/test_vpcs_vm.py
@@ -25,10 +25,10 @@ from tests.utils import asyncio_patch
from pkg_resources import parse_version
from unittest.mock import patch, MagicMock
-from gns3server.hypervisor.vpcs.vpcs_vm import VPCSVM
-from gns3server.hypervisor.vpcs.vpcs_error import VPCSError
-from gns3server.hypervisor.vpcs import VPCS
-from gns3server.hypervisor.notification_manager import NotificationManager
+from gns3server.compute.vpcs.vpcs_vm import VPCSVM
+from gns3server.compute.vpcs.vpcs_error import VPCSError
+from gns3server.compute.vpcs import VPCS
+from gns3server.compute.notification_manager import NotificationManager
@pytest.fixture(scope="module")
@@ -52,19 +52,19 @@ def test_vm(project, manager):
def test_vm_check_vpcs_version(loop, vm, manager):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.9"):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.9"):
loop.run_until_complete(asyncio.async(vm._check_vpcs_version()))
assert vm._vpcs_version == parse_version("0.9")
def test_vm_check_vpcs_version_0_6_1(loop, vm, manager):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.6.1"):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.6.1"):
loop.run_until_complete(asyncio.async(vm._check_vpcs_version()))
assert vm._vpcs_version == parse_version("0.6.1")
def test_vm_invalid_vpcs_version(loop, manager, vm):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.1"):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.subprocess_check_output", return_value="Welcome to Virtual PC Simulator, version 0.1"):
with pytest.raises(VPCSError):
nio = manager.create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
@@ -74,7 +74,7 @@ def test_vm_invalid_vpcs_version(loop, manager, vm):
def test_vm_invalid_vpcs_path(vm, manager, loop):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM.vpcs_path", return_value="/tmp/fake/path/vpcs"):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM.vpcs_path", return_value="/tmp/fake/path/vpcs"):
with pytest.raises(VPCSError):
nio = manager.create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
@@ -90,7 +90,7 @@ def test_start(loop, vm, async_run):
with NotificationManager.instance().queue() as queue:
async_run(queue.get(0)) # Ping
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
@@ -125,7 +125,7 @@ def test_start_0_6_1(loop, vm):
process.returncode = None
vm._vpcs_version = parse_version("0.6.1")
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process) as mock_exec:
nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
@@ -156,7 +156,7 @@ def test_stop(loop, vm, async_run):
process.returncode = None
with NotificationManager.instance().queue() as queue:
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
@@ -190,7 +190,7 @@ def test_reload(loop, vm):
process.wait.return_value = future
process.returncode = None
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_udp", "lport": 4242, "rport": 4243, "rhost": "127.0.0.1"})
vm.port_add_nio_binding(0, nio)
@@ -215,14 +215,14 @@ def test_add_nio_binding_udp(vm):
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
def test_add_nio_binding_tap(vm, ethernet_device):
- with patch("gns3server.hypervisor.base_manager.BaseManager.has_privileged_access", return_value=True):
+ with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_tap", "tap_device": ethernet_device})
vm.port_add_nio_binding(0, nio)
assert nio.tap_device == ethernet_device
# def test_add_nio_binding_tap_no_privileged_access(vm):
-# with patch("gns3server.hypervisor.base_manager.BaseManager.has_privileged_access", return_value=False):
+# with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=False):
# with pytest.raises(aiohttp.web.HTTPForbidden):
# nio = VPCS.instance().create_nio(vm.vpcs_path, {"type": "nio_tap", "tap_device": "test"})
# vm.port_add_nio_binding(0, nio)
@@ -286,7 +286,7 @@ def test_change_name(vm, tmpdir):
def test_close(vm, port_manager, loop):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM._check_requirements", return_value=True):
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
vm.start()
loop.run_until_complete(asyncio.async(vm.close()))
diff --git a/tests/conftest.py b/tests/conftest.py
index 9c2f7a3e..369ca488 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -37,9 +37,9 @@ from gns3server.config import Config
from gns3server.web.route import Route
# TODO: get rid of *
from gns3server.handlers import *
-from gns3server.hypervisor import MODULES
-from gns3server.hypervisor.port_manager import PortManager
-from gns3server.hypervisor.project_manager import ProjectManager
+from gns3server.compute import MODULES
+from gns3server.compute.port_manager import PortManager
+from gns3server.compute.project_manager import ProjectManager
from gns3server.controller import Controller
from tests.handlers.api.base import Query
@@ -105,7 +105,7 @@ def http_server(request, loop, port_manager, monkeypatch):
def tear_down():
for module in MODULES:
instance = module.instance()
- monkeypatch.setattr('gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.close', lambda self: True)
+ monkeypatch.setattr('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.close', lambda self: True)
loop.run_until_complete(instance.unload())
srv.close()
srv.wait_closed()
@@ -132,12 +132,12 @@ def http_controller(loop, http_server):
@pytest.fixture
-def http_hypervisor(loop, http_server):
+def http_compute(loop, http_server):
"""
Return an helper allowing you to call the hypervisor API via HTTP
"""
host, port = http_server
- return Query(loop, host=host, port=port, prefix="/hypervisor", api_version=2)
+ return Query(loop, host=host, port=port, prefix="/compute", api_version=2)
@pytest.fixture(scope="function")
@@ -204,7 +204,7 @@ def run_around_tests(monkeypatch, port_manager, controller):
# Force turn off KVM because it's not available on CI
config.set("Qemu", "enable_kvm", False)
- monkeypatch.setattr("gns3server.hypervisor.project.Project._get_default_project_directory", lambda *args: os.path.join(tmppath, 'projects'))
+ monkeypatch.setattr("gns3server.compute.project.Project._get_default_project_directory", lambda *args: os.path.join(tmppath, 'projects'))
# Force sys.platform to the original value. Because it seem not be restore correctly at each tests
sys.platform = sys.original_platform
diff --git a/tests/controller/test_hypervisor.py b/tests/controller/test_compute.py
similarity index 52%
rename from tests/controller/test_hypervisor.py
rename to tests/controller/test_compute.py
index a640e598..babc7445 100644
--- a/tests/controller/test_hypervisor.py
+++ b/tests/controller/test_compute.py
@@ -23,124 +23,124 @@ import asyncio
from unittest.mock import patch, MagicMock
from gns3server.controller.project import Project
-from gns3server.controller.hypervisor import Hypervisor, HypervisorError
+from gns3server.controller.compute import Compute, ComputeError
from gns3server.version import __version__
from tests.utils import asyncio_patch, AsyncioMagicMock
@pytest.fixture
-def hypervisor():
- hypervisor = Hypervisor("my_hypervisor_id", protocol="https", host="example.com", port=84, controller=MagicMock())
- hypervisor._connected = True
- return hypervisor
+def compute():
+ compute = Compute("my_compute_id", protocol="https", host="example.com", port=84, controller=MagicMock())
+ compute._connected = True
+ return compute
-def test_init(hypervisor):
- assert hypervisor.id == "my_hypervisor_id"
+def test_init(compute):
+ assert compute.id == "my_compute_id"
-def test_hypervisor_local(hypervisor):
+def test_compute_local(compute):
"""
- If the hypervisor is local but the hypervisor id is local
+ If the compute is local but the compute id is local
it's a configuration issue
"""
with patch("gns3server.config.Config.get_section_config", return_value={"local": False}):
- with pytest.raises(HypervisorError):
- s = Hypervisor("local", controller=MagicMock())
+ with pytest.raises(ComputeError):
+ s = Compute("local", controller=MagicMock())
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
- s = Hypervisor("test", controller=MagicMock())
+ s = Compute("test", controller=MagicMock())
-def test_hypervisor_httpQuery(hypervisor, async_run):
+def test_compute_httpQuery(compute, async_run):
response = MagicMock()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
response.status = 200
- async_run(hypervisor.post("/projects", {"a": "b"}))
- mock.assert_called_with("POST", "https://example.com:84/v2/hypervisor/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None)
- assert hypervisor._auth is None
+ async_run(compute.post("/projects", {"a": "b"}))
+ mock.assert_called_with("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None)
+ assert compute._auth is None
-def test_hypervisor_httpQueryAuth(hypervisor, async_run):
+def test_compute_httpQueryAuth(compute, async_run):
response = MagicMock()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
response.status = 200
- hypervisor.user = "root"
- hypervisor.password = "toor"
- async_run(hypervisor.post("/projects", {"a": "b"}))
- mock.assert_called_with("POST", "https://example.com:84/v2/hypervisor/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=hypervisor._auth)
- assert hypervisor._auth.login == "root"
- assert hypervisor._auth.password == "toor"
+ compute.user = "root"
+ compute.password = "toor"
+ async_run(compute.post("/projects", {"a": "b"}))
+ mock.assert_called_with("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=compute._auth)
+ assert compute._auth.login == "root"
+ assert compute._auth.password == "toor"
-def test_hypervisor_httpQueryNotConnected(hypervisor, async_run):
- hypervisor._connected = False
+def test_compute_httpQueryNotConnected(compute, async_run):
+ compute._connected = False
response = AsyncioMagicMock()
response.read = AsyncioMagicMock(return_value=json.dumps({"version": __version__}).encode())
response.status = 200
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
- async_run(hypervisor.post("/projects", {"a": "b"}))
- mock.assert_any_call("GET", "https://example.com:84/v2/hypervisor/version", headers={'content-type': 'application/json'}, data=None, auth=None)
- mock.assert_any_call("POST", "https://example.com:84/v2/hypervisor/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None)
- assert hypervisor._connected
+ async_run(compute.post("/projects", {"a": "b"}))
+ mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None)
+ mock.assert_any_call("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None)
+ assert compute._connected
-def test_hypervisor_httpQueryNotConnectedInvalidVersion(hypervisor, async_run):
- hypervisor._connected = False
+def test_compute_httpQueryNotConnectedInvalidVersion(compute, async_run):
+ compute._connected = False
response = AsyncioMagicMock()
response.read = AsyncioMagicMock(return_value=json.dumps({"version": "1.42.4"}).encode())
response.status = 200
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
with pytest.raises(aiohttp.web.HTTPConflict):
- async_run(hypervisor.post("/projects", {"a": "b"}))
- mock.assert_any_call("GET", "https://example.com:84/v2/hypervisor/version", headers={'content-type': 'application/json'}, data=None, auth=None)
+ async_run(compute.post("/projects", {"a": "b"}))
+ mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None)
-def test_hypervisor_httpQueryNotConnectedNonGNS3Server(hypervisor, async_run):
- hypervisor._connected = False
+def test_compute_httpQueryNotConnectedNonGNS3Server(compute, async_run):
+ compute._connected = False
response = AsyncioMagicMock()
response.read = AsyncioMagicMock(return_value=b'Blocked by super antivirus')
response.status = 200
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
with pytest.raises(aiohttp.web.HTTPConflict):
- async_run(hypervisor.post("/projects", {"a": "b"}))
- mock.assert_any_call("GET", "https://example.com:84/v2/hypervisor/version", headers={'content-type': 'application/json'}, data=None, auth=None)
+ async_run(compute.post("/projects", {"a": "b"}))
+ mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None)
-def test_hypervisor_httpQueryNotConnectedNonGNS3Server2(hypervisor, async_run):
- hypervisor._connected = False
+def test_compute_httpQueryNotConnectedNonGNS3Server2(compute, async_run):
+ compute._connected = False
response = AsyncioMagicMock()
response.read = AsyncioMagicMock(return_value=b'{}')
response.status = 200
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
with pytest.raises(aiohttp.web.HTTPConflict):
- async_run(hypervisor.post("/projects", {"a": "b"}))
- mock.assert_any_call("GET", "https://example.com:84/v2/hypervisor/version", headers={'content-type': 'application/json'}, data=None, auth=None)
+ async_run(compute.post("/projects", {"a": "b"}))
+ mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None)
-def test_hypervisor_httpQueryError(hypervisor, async_run):
+def test_compute_httpQueryError(compute, async_run):
response = MagicMock()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
response.status = 409
with pytest.raises(aiohttp.web.HTTPConflict):
- async_run(hypervisor.post("/projects", {"a": "b"}))
+ async_run(compute.post("/projects", {"a": "b"}))
-def test_hypervisor_httpQuery_project(hypervisor, async_run):
+def test_compute_httpQuery_project(compute, async_run):
response = MagicMock()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
response.status = 200
project = Project()
- async_run(hypervisor.post("/projects", project))
- mock.assert_called_with("POST", "https://example.com:84/v2/hypervisor/projects", data=json.dumps(project.__json__()), headers={'content-type': 'application/json'}, auth=None)
+ async_run(compute.post("/projects", project))
+ mock.assert_called_with("POST", "https://example.com:84/v2/compute/projects", data=json.dumps(project.__json__()), headers={'content-type': 'application/json'}, auth=None)
-def test_connectNotification(hypervisor, async_run):
+def test_connectNotification(compute, async_run):
ws_mock = AsyncioMagicMock()
call = 0
@@ -159,20 +159,20 @@ def test_connectNotification(hypervisor, async_run):
response.tp = aiohttp.MsgType.closed
return response
- hypervisor._controller = MagicMock()
- hypervisor._session = AsyncioMagicMock(return_value=ws_mock)
- hypervisor._session.ws_connect = AsyncioMagicMock(return_value=ws_mock)
+ compute._controller = MagicMock()
+ compute._session = AsyncioMagicMock(return_value=ws_mock)
+ compute._session.ws_connect = AsyncioMagicMock(return_value=ws_mock)
ws_mock.receive = receive
- async_run(hypervisor._connectNotification())
+ async_run(compute._connectNotification())
- hypervisor._controller.emit.assert_called_with('test', {'a': 1}, hypervisor_id=hypervisor.id, project_id='42')
- assert hypervisor._connected is False
+ compute._controller.emit.assert_called_with('test', {'a': 1}, compute_id=compute.id, project_id='42')
+ assert compute._connected is False
-def test_json(hypervisor):
- hypervisor.user = "test"
- assert hypervisor.__json__() == {
- "hypervisor_id": "my_hypervisor_id",
+def test_json(compute):
+ compute.user = "test"
+ assert compute.__json__() == {
+ "compute_id": "my_compute_id",
"protocol": "https",
"host": "example.com",
"port": 84,
diff --git a/tests/controller/test_controller.py b/tests/controller/test_controller.py
index 6f1d2ad8..90fd057a 100644
--- a/tests/controller/test_controller.py
+++ b/tests/controller/test_controller.py
@@ -22,7 +22,7 @@ from unittest.mock import MagicMock
from gns3server.controller import Controller
-from gns3server.controller.hypervisor import Hypervisor
+from gns3server.controller.compute import Compute
from gns3server.controller.project import Project
from gns3server.config import Config
@@ -34,22 +34,22 @@ def test_isEnabled(controller):
assert controller.isEnabled()
-def test_addHypervisor(controller, async_run):
- async_run(controller.addHypervisor("test1"))
- assert len(controller.hypervisors) == 1
- async_run(controller.addHypervisor("test1"))
- assert len(controller.hypervisors) == 1
- async_run(controller.addHypervisor("test2"))
- assert len(controller.hypervisors) == 2
+def test_addCompute(controller, async_run):
+ async_run(controller.addCompute("test1"))
+ assert len(controller.computes) == 1
+ async_run(controller.addCompute("test1"))
+ assert len(controller.computes) == 1
+ async_run(controller.addCompute("test2"))
+ assert len(controller.computes) == 2
-def test_getHypervisor(controller, async_run):
+def test_getCompute(controller, async_run):
- hypervisor = async_run(controller.addHypervisor("test1"))
+ compute = async_run(controller.addCompute("test1"))
- assert controller.getHypervisor("test1") == hypervisor
+ assert controller.getCompute("test1") == compute
with pytest.raises(aiohttp.web.HTTPNotFound):
- assert controller.getHypervisor("dsdssd")
+ assert controller.getCompute("dsdssd")
def test_addProject(controller, async_run):
@@ -74,15 +74,15 @@ def test_removeProject(controller, async_run):
assert len(controller.projects) == 0
-def test_addProject_with_hypervisor(controller, async_run):
+def test_addProject_with_compute(controller, async_run):
uuid1 = str(uuid.uuid4())
- hypervisor = Hypervisor("test1", controller=MagicMock())
- hypervisor.post = MagicMock()
- controller._hypervisors = {"test1": hypervisor}
+ compute = Compute("test1", controller=MagicMock())
+ compute.post = MagicMock()
+ controller._computes = {"test1": compute}
project1 = async_run(controller.addProject(project_id=uuid1))
- hypervisor.post.assert_called_with("/projects", project1)
+ compute.post.assert_called_with("/projects", project1)
def test_getProject(controller, async_run):
diff --git a/tests/controller/test_link.py b/tests/controller/test_link.py
index 5b942826..4c509711 100644
--- a/tests/controller/test_link.py
+++ b/tests/controller/test_link.py
@@ -20,7 +20,7 @@ from unittest.mock import MagicMock
from gns3server.controller.link import Link
from gns3server.controller.vm import VM
-from gns3server.controller.hypervisor import Hypervisor
+from gns3server.controller.compute import Compute
from gns3server.controller.project import Project
@@ -30,12 +30,12 @@ def project():
@pytest.fixture
-def hypervisor():
- return Hypervisor("example.com", controller=MagicMock())
+def compute():
+ return Compute("example.com", controller=MagicMock())
-def test_addVM(async_run, project, hypervisor):
- vm1 = VM(project, hypervisor)
+def test_addVM(async_run, project, compute):
+ vm1 = VM(project, compute)
link = Link(project)
async_run(link.addVM(vm1, 0, 4))
@@ -48,9 +48,9 @@ def test_addVM(async_run, project, hypervisor):
]
-def test_json(async_run, project, hypervisor):
- vm1 = VM(project, hypervisor)
- vm2 = VM(project, hypervisor)
+def test_json(async_run, project, compute):
+ vm1 = VM(project, compute)
+ vm2 = VM(project, compute)
link = Link(project)
async_run(link.addVM(vm1, 0, 4))
diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py
index 51bc1204..27dac1e6 100644
--- a/tests/controller/test_project.py
+++ b/tests/controller/test_project.py
@@ -39,31 +39,31 @@ def test_json(tmpdir):
def test_addVM(async_run):
- hypervisor = MagicMock()
+ compute = MagicMock()
project = Project()
response = MagicMock()
response.json = {"console": 2048}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
- vm = async_run(project.addVM(hypervisor, None, name="test", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
+ vm = async_run(project.addVM(compute, None, name="test", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
- hypervisor.post.assert_called_with('/projects/{}/vpcs/vms'.format(project.id),
- data={'vm_id': vm.id,
- 'console_type': 'telnet',
- 'startup_config': 'test.cfg',
- 'name': 'test'})
+ compute.post.assert_called_with('/projects/{}/vpcs/vms'.format(project.id),
+ data={'vm_id': vm.id,
+ 'console_type': 'telnet',
+ 'startup_config': 'test.cfg',
+ 'name': 'test'})
def test_getVM(async_run):
- hypervisor = MagicMock()
+ compute = MagicMock()
project = Project()
response = MagicMock()
response.json = {"console": 2048}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
- vm = async_run(project.addVM(hypervisor, None, name="test", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
+ vm = async_run(project.addVM(compute, None, name="test", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
assert project.getVM(vm.id) == vm
with pytest.raises(aiohttp.web_exceptions.HTTPNotFound):
@@ -71,15 +71,15 @@ def test_getVM(async_run):
def test_addLink(async_run):
- hypervisor = MagicMock()
+ compute = MagicMock()
project = Project()
response = MagicMock()
response.json = {"console": 2048}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
- vm1 = async_run(project.addVM(hypervisor, None, name="test1", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
- vm2 = async_run(project.addVM(hypervisor, None, name="test2", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
+ vm1 = async_run(project.addVM(compute, None, name="test1", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
+ vm2 = async_run(project.addVM(compute, None, name="test2", vm_type="vpcs", properties={"startup_config": "test.cfg"}))
link = async_run(project.addLink())
async_run(link.addVM(vm1, 3, 1))
async_run(link.addVM(vm2, 4, 2))
@@ -87,12 +87,12 @@ def test_addLink(async_run):
def test_getLink(async_run):
- hypervisor = MagicMock()
+ compute = MagicMock()
project = Project()
response = MagicMock()
response.json = {"console": 2048}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
link = async_run(project.addLink())
assert project.getLink(link.id) == link
diff --git a/tests/controller/test_udp_link.py b/tests/controller/test_udp_link.py
index 7335bc51..8bb2ca3e 100644
--- a/tests/controller/test_udp_link.py
+++ b/tests/controller/test_udp_link.py
@@ -21,7 +21,7 @@ import aiohttp
from unittest.mock import MagicMock
from gns3server.controller.project import Project
-from gns3server.controller.hypervisor import Hypervisor
+from gns3server.controller.compute import Compute
from gns3server.controller.udp_link import UDPLink
from gns3server.controller.vm import VM
@@ -32,18 +32,18 @@ def project():
def test_create(async_run, project):
- hypervisor1 = MagicMock()
- hypervisor2 = MagicMock()
+ compute1 = MagicMock()
+ compute2 = MagicMock()
- vm1 = VM(project, hypervisor1, vm_type="vpcs")
- vm2 = VM(project, hypervisor2, vm_type="vpcs")
+ vm1 = VM(project, compute1, vm_type="vpcs")
+ vm2 = VM(project, compute2, vm_type="vpcs")
link = UDPLink(project)
async_run(link.addVM(vm1, 0, 4))
async_run(link.addVM(vm2, 3, 1))
@asyncio.coroutine
- def hypervisor1_callback(path, data={}):
+ def compute1_callback(path, data={}):
"""
Fake server
"""
@@ -53,7 +53,7 @@ def test_create(async_run, project):
return response
@asyncio.coroutine
- def hypervisor2_callback(path, data={}):
+ def compute2_callback(path, data={}):
"""
Fake server
"""
@@ -62,32 +62,32 @@ def test_create(async_run, project):
response.json = {"udp_port": 2048}
return response
- hypervisor1.post.side_effect = hypervisor1_callback
- hypervisor1.host = "example.com"
- hypervisor2.post.side_effect = hypervisor2_callback
- hypervisor2.host = "example.org"
+ compute1.post.side_effect = compute1_callback
+ compute1.host = "example.com"
+ compute2.post.side_effect = compute2_callback
+ compute2.host = "example.org"
async_run(link.create())
- hypervisor1.post.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/0/ports/4/nio".format(project.id, vm1.id), data={
+ compute1.post.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/0/ports/4/nio".format(project.id, vm1.id), data={
"lport": 1024,
- "rhost": hypervisor2.host,
+ "rhost": compute2.host,
"rport": 2048,
"type": "nio_udp"
})
- hypervisor2.post.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/3/ports/1/nio".format(project.id, vm2.id), data={
+ compute2.post.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/3/ports/1/nio".format(project.id, vm2.id), data={
"lport": 2048,
- "rhost": hypervisor1.host,
+ "rhost": compute1.host,
"rport": 1024,
"type": "nio_udp"
})
def test_delete(async_run, project):
- hypervisor1 = MagicMock()
- hypervisor2 = MagicMock()
+ compute1 = MagicMock()
+ compute2 = MagicMock()
- vm1 = VM(project, hypervisor1, vm_type="vpcs")
- vm2 = VM(project, hypervisor2, vm_type="vpcs")
+ vm1 = VM(project, compute1, vm_type="vpcs")
+ vm2 = VM(project, compute2, vm_type="vpcs")
link = UDPLink(project)
async_run(link.addVM(vm1, 0, 4))
@@ -95,5 +95,5 @@ def test_delete(async_run, project):
async_run(link.delete())
- hypervisor1.delete.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/0/ports/4/nio".format(project.id, vm1.id))
- hypervisor2.delete.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/3/ports/1/nio".format(project.id, vm2.id))
+ compute1.delete.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/0/ports/4/nio".format(project.id, vm1.id))
+ compute2.delete.assert_any_call("/projects/{}/vpcs/vms/{}/adapters/3/ports/1/nio".format(project.id, vm2.id))
diff --git a/tests/controller/test_vm.py b/tests/controller/test_vm.py
index bc649f43..d36ccaf9 100644
--- a/tests/controller/test_vm.py
+++ b/tests/controller/test_vm.py
@@ -28,16 +28,16 @@ from gns3server.controller.project import Project
@pytest.fixture
-def hypervisor():
+def compute():
s = AsyncioMagicMock()
s.id = "http://test.com:42"
return s
@pytest.fixture
-def vm(hypervisor):
+def vm(compute):
project = Project(str(uuid.uuid4()))
- vm = VM(project, hypervisor,
+ vm = VM(project, compute,
name="demo",
vm_id=str(uuid.uuid4()),
vm_type="vpcs",
@@ -46,9 +46,9 @@ def vm(hypervisor):
return vm
-def test_json(vm, hypervisor):
+def test_json(vm, compute):
assert vm.__json__() == {
- "hypervisor_id": hypervisor.id,
+ "compute_id": compute.id,
"project_id": vm.project.id,
"vm_id": vm.id,
"vm_type": vm.vm_type,
@@ -59,19 +59,19 @@ def test_json(vm, hypervisor):
}
-def test_init_without_uuid(project, hypervisor):
- vm = VM(project, hypervisor,
+def test_init_without_uuid(project, compute):
+ vm = VM(project, compute,
vm_type="vpcs",
console_type="vnc")
assert vm.id is not None
-def test_create(vm, hypervisor, project, async_run):
+def test_create(vm, compute, project, async_run):
vm._console = 2048
response = MagicMock()
response.json = {"console": 2048}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
async_run(vm.create())
data = {
@@ -81,43 +81,43 @@ def test_create(vm, hypervisor, project, async_run):
"startup_script": "echo test",
"name": "demo"
}
- hypervisor.post.assert_called_with("/projects/{}/vpcs/vms".format(vm.project.id), data=data)
+ compute.post.assert_called_with("/projects/{}/vpcs/vms".format(vm.project.id), data=data)
assert vm._console == 2048
assert vm._properties == {"startup_script": "echo test"}
-def test_start(vm, hypervisor, project, async_run):
+def test_start(vm, compute, project, async_run):
- hypervisor.post = AsyncioMagicMock()
+ compute.post = AsyncioMagicMock()
async_run(vm.start())
- hypervisor.post.assert_called_with("/projects/{}/vpcs/vms/{}/start".format(vm.project.id, vm.id))
+ compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/start".format(vm.project.id, vm.id))
-def test_stop(vm, hypervisor, project, async_run):
+def test_stop(vm, compute, project, async_run):
- hypervisor.post = AsyncioMagicMock()
+ compute.post = AsyncioMagicMock()
async_run(vm.stop())
- hypervisor.post.assert_called_with("/projects/{}/vpcs/vms/{}/stop".format(vm.project.id, vm.id))
+ compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/stop".format(vm.project.id, vm.id))
-def test_suspend(vm, hypervisor, project, async_run):
+def test_suspend(vm, compute, project, async_run):
- hypervisor.post = AsyncioMagicMock()
+ compute.post = AsyncioMagicMock()
async_run(vm.suspend())
- hypervisor.post.assert_called_with("/projects/{}/vpcs/vms/{}/suspend".format(vm.project.id, vm.id))
+ compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/suspend".format(vm.project.id, vm.id))
-def test_create_without_console(vm, hypervisor, project, async_run):
+def test_create_without_console(vm, compute, project, async_run):
"""
None properties should be send. Because it can mean the emulator doesn"t support it
"""
response = MagicMock()
response.json = {"console": 2048, "test_value": "success"}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
async_run(vm.create())
data = {
@@ -126,16 +126,16 @@ def test_create_without_console(vm, hypervisor, project, async_run):
"startup_script": "echo test",
"name": "demo"
}
- hypervisor.post.assert_called_with("/projects/{}/vpcs/vms".format(vm.project.id), data=data)
+ compute.post.assert_called_with("/projects/{}/vpcs/vms".format(vm.project.id), data=data)
assert vm._console == 2048
assert vm._properties == {"test_value": "success", "startup_script": "echo test"}
-def test_post(vm, hypervisor, async_run):
+def test_post(vm, compute, async_run):
async_run(vm.post("/test", {"a": "b"}))
- hypervisor.post.assert_called_with("/projects/{}/vpcs/vms/{}/test".format(vm.project.id, vm.id), data={"a": "b"})
+ compute.post.assert_called_with("/projects/{}/vpcs/vms/{}/test".format(vm.project.id, vm.id), data={"a": "b"})
-def test_delete(vm, hypervisor, async_run):
+def test_delete(vm, compute, async_run):
async_run(vm.delete("/test"))
- hypervisor.delete.assert_called_with("/projects/{}/vpcs/vms/{}/test".format(vm.project.id, vm.id))
+ compute.delete.assert_called_with("/projects/{}/vpcs/vms/{}/test".format(vm.project.id, vm.id))
diff --git a/tests/handlers/api/base.py b/tests/handlers/api/base.py
index 28499c8a..0b2c0667 100644
--- a/tests/handlers/api/base.py
+++ b/tests/handlers/api/base.py
@@ -32,7 +32,7 @@ class Query:
def __init__(self, loop, host='localhost', port=8001, prefix='', api_version=None):
"""
- :param prefix: Prefix added before path (ex: /hypervisor)
+ :param prefix: Prefix added before path (ex: /compute)
:param api_version: Version of the api
"""
self._loop = loop
@@ -110,6 +110,8 @@ class Query:
response.route = x_route.replace("/v{}".format(self._api_version), "")
response.route = response.route .replace(self._prefix, "")
+ response.json = {}
+ response.html = ""
if response.body is not None:
if response.headers.get("CONTENT-TYPE", "") == "application/json":
try:
@@ -121,9 +123,7 @@ class Query:
response.html = response.body.decode("utf-8")
except UnicodeDecodeError:
response.html = None
- else:
- response.json = {}
- response.html = ""
+
if kwargs.get('example') and os.environ.get("PYTEST_BUILD_DOCUMENTATION") == "1":
self._dump_example(method, response.route, path, body, response)
return response
diff --git a/tests/handlers/api/hypervisor/__init__.py b/tests/handlers/api/compute/__init__.py
similarity index 100%
rename from tests/handlers/api/hypervisor/__init__.py
rename to tests/handlers/api/compute/__init__.py
diff --git a/tests/handlers/api/hypervisor/test_config.py b/tests/handlers/api/compute/test_config.py
similarity index 85%
rename from tests/handlers/api/hypervisor/test_config.py
rename to tests/handlers/api/compute/test_config.py
index 0d6c6ea0..53efbb9c 100644
--- a/tests/handlers/api/hypervisor/test_config.py
+++ b/tests/handlers/api/compute/test_config.py
@@ -19,7 +19,7 @@ from unittest.mock import MagicMock, patch
from gns3server.config import Config
-def test_reload_accepted(http_hypervisor):
+def test_reload_accepted(http_compute):
gns_config = MagicMock()
config = Config.instance()
@@ -27,17 +27,17 @@ def test_reload_accepted(http_hypervisor):
gns_config.get_section_config.return_value = config.get_section_config("Server")
with patch("gns3server.config.Config.instance", return_value=gns_config):
- response = http_hypervisor.post('/config/reload', example=True)
+ response = http_compute.post('/config/reload', example=True)
assert response.status == 201
assert gns_config.reload.called
-def test_reload_forbidden(http_hypervisor):
+def test_reload_forbidden(http_compute):
config = Config.instance()
config.set("Server", "local", "false")
- response = http_hypervisor.post('/config/reload')
+ response = http_compute.post('/config/reload')
assert response.status == 403
diff --git a/tests/handlers/api/compute/test_docker.py b/tests/handlers/api/compute/test_docker.py
new file mode 100644
index 00000000..15654e11
--- /dev/null
+++ b/tests/handlers/api/compute/test_docker.py
@@ -0,0 +1,185 @@
+# -*- 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 .
+
+import pytest
+import os
+import stat
+import sys
+import uuid
+import aiohttp
+
+from tests.utils import asyncio_patch
+from unittest.mock import patch, MagicMock, PropertyMock
+from gns3server.compute.docker import Docker
+
+
+@pytest.fixture
+def base_params():
+ """Return standard parameters"""
+ return {"name": "PC TEST 1", "image": "nginx", "start_command": "nginx-daemon", "adapters": 2, "environment": "YES=1\nNO=0", "console_type": "telnet", "console_resolution": "1280x1024"}
+
+
+@pytest.yield_fixture(autouse=True)
+def mock_connection():
+ docker = Docker.instance()
+ docker._connected = True
+ docker._connector = MagicMock()
+ yield
+ Docker._instance = None
+
+
+@pytest.fixture
+def vm(http_compute, project, base_params):
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "nginx"}]) as mock_list:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value={"Id": "8bd8153ea8f5"}) as mock:
+ response = http_compute.post("/projects/{project_id}/docker/vms".format(project_id=project.id), base_params)
+ if response.status != 201:
+ print(response.body)
+ assert response.status == 201
+ return response.json
+
+
+def test_docker_create(http_compute, project, base_params):
+ with asyncio_patch("gns3server.compute.docker.Docker.list_images", return_value=[{"image": "nginx"}]) as mock_list:
+ with asyncio_patch("gns3server.compute.docker.Docker.query", return_value={"Id": "8bd8153ea8f5"}) as mock:
+ response = http_compute.post("/projects/{project_id}/docker/vms".format(project_id=project.id), base_params)
+ assert response.status == 201
+ assert response.route == "/projects/{project_id}/docker/vms"
+ assert response.json["name"] == "PC TEST 1"
+ assert response.json["project_id"] == project.id
+ assert response.json["container_id"] == "8bd8153ea8f5"
+ assert response.json["image"] == "nginx"
+ assert response.json["adapters"] == 2
+ assert response.json["environment"] == "YES=1\nNO=0"
+ assert response.json["console_resolution"] == "1280x1024"
+
+
+def test_docker_start(http_compute, vm):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.start", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ assert mock.called
+ assert response.status == 204
+
+
+def test_docker_stop(http_compute, vm):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.stop", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ assert mock.called
+ assert response.status == 204
+
+
+def test_docker_reload(http_compute, vm):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.restart", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ assert mock.called
+ assert response.status == 204
+
+
+def test_docker_delete(http_compute, vm):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.delete", return_value=True) as mock:
+ response = http_compute.delete("/projects/{project_id}/docker/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ assert mock.called
+ assert response.status == 204
+
+
+def test_docker_reload(http_compute, vm):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.pause", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ assert mock.called
+ assert response.status == 204
+
+
+def test_docker_nio_create_udp(http_compute, vm):
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/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 == "/projects/{project_id}/docker/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
+ assert response.json["type"] == "nio_udp"
+
+
+def test_docker_delete_nio(http_compute, vm):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.adapter_remove_nio_binding") as mock:
+ response = http_compute.delete("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ assert response.status == 204
+ assert response.route == "/projects/{project_id}/docker/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
+
+
+def test_docker_update(http_compute, vm, tmpdir, free_console_port):
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.update") as mock:
+ response = http_compute.put("/projects/{project_id}/docker/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
+ "console": free_console_port,
+ "start_command": "yes",
+ "environment": "GNS3=1\nGNS4=0"},
+ example=True)
+ assert mock.called
+ assert response.status == 200
+ assert response.json["name"] == "test"
+ assert response.json["console"] == free_console_port
+ assert response.json["start_command"] == "yes"
+ assert response.json["environment"] == "GNS3=1\nGNS4=0"
+
+
+def test_docker_start_capture(http_compute, vm, tmpdir, project):
+
+ with patch("gns3server.compute.docker.docker_vm.DockerVM.is_running", return_value=True) as mock:
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.start_capture") as start_capture:
+
+ params = {"capture_file_name": "test.pcap", "data_link_type": "DLT_EN10MB"}
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params, example=True)
+
+ assert response.status == 200
+
+ assert start_capture.called
+ assert "test.pcap" in response.json["pcap_file_path"]
+
+
+def test_docker_start_capture_not_started(http_compute, vm, tmpdir):
+
+ with patch("gns3server.compute.docker.docker_vm.DockerVM.is_running", return_value=False) as mock:
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.start_capture") as start_capture:
+
+ params = {"capture_file_name": "test.pcap", "data_link_type": "DLT_EN10MB"}
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params)
+
+ assert not start_capture.called
+ assert response.status == 409
+
+
+def test_docker_stop_capture(http_compute, vm, tmpdir, project):
+
+ with patch("gns3server.compute.docker.docker_vm.DockerVM.is_running", return_value=True) as mock:
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.stop_capture") as stop_capture:
+
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+
+ assert response.status == 204
+
+ assert stop_capture.called
+
+
+def test_docker_stop_capture_not_started(http_compute, vm, tmpdir):
+
+ with patch("gns3server.compute.docker.docker_vm.DockerVM.is_running", return_value=False) as mock:
+ with asyncio_patch("gns3server.compute.docker.docker_vm.DockerVM.stop_capture") as stop_capture:
+
+ response = http_compute.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+
+ assert not stop_capture.called
+ assert response.status == 409
diff --git a/tests/handlers/api/hypervisor/test_dynamips.py b/tests/handlers/api/compute/test_dynamips.py
similarity index 57%
rename from tests/handlers/api/hypervisor/test_dynamips.py
rename to tests/handlers/api/compute/test_dynamips.py
index 81de3f72..bee95dc3 100644
--- a/tests/handlers/api/hypervisor/test_dynamips.py
+++ b/tests/handlers/api/compute/test_dynamips.py
@@ -24,25 +24,25 @@ from tests.utils import asyncio_patch
# @pytest.yield_fixture(scope="module")
-# def vm(http_hypervisor, project):
+# def vm(http_compute, project):
#
# dynamips_path = "/fake/dynamips"
-# with asyncio_patch("gns3server.hypervisor.dynamips.nodes.router.Router.create", return_value=True) as mock:
-# response = http_hypervisor.post("/projects/{project_id}/dynamips/vms".format(project_id=project.id), {"name": "My router",
+# with asyncio_patch("gns3server.compute.dynamips.nodes.router.Router.create", return_value=True) as mock:
+# response = http_compute.post("/projects/{project_id}/dynamips/vms".format(project_id=project.id), {"name": "My router",
# "platform": "c3745",
# "image": "somewhere",
# "ram": 128})
# assert mock.called
# assert response.status == 201
#
-# with asyncio_patch("gns3server.hypervisor.dynamips.Dynamips.find_dynamips", return_value=dynamips_path):
+# with asyncio_patch("gns3server.compute.dynamips.Dynamips.find_dynamips", return_value=dynamips_path):
# yield response.json
#
#
-# def test_dynamips_vm_create(http_hypervisor, project):
+# def test_dynamips_vm_create(http_compute, project):
#
-# with asyncio_patch("gns3server.hypervisor.dynamips.nodes.router.Router.create", return_value=True):
-# response = http_hypervisor.post("/projects/{project_id}/dynamips/vms".format(project_id=project.id), {"name": "My router",
+# with asyncio_patch("gns3server.compute.dynamips.nodes.router.Router.create", return_value=True):
+# response = http_compute.post("/projects/{project_id}/dynamips/vms".format(project_id=project.id), {"name": "My router",
# "platform": "c3745",
# "image": "somewhere",
# "ram": 128},
@@ -53,46 +53,46 @@ from tests.utils import asyncio_patch
# assert response.json["dynamips_id"]
#
#
-# def test_dynamips_vm_get(http_hypervisor, project, vm):
-# response = http_hypervisor.get("/projects/{project_id}/dynamips/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+# def test_dynamips_vm_get(http_compute, project, vm):
+# response = http_compute.get("/projects/{project_id}/dynamips/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
# assert response.status == 200
# assert response.route == "/projects/{project_id}/dynamips/vms/{vm_id}"
# assert response.json["name"] == "My router"
# assert response.json["project_id"] == project.id
#
#
-# def test_dynamips_vm_start(http_hypervisor, vm):
-# with asyncio_patch("gns3server.hypervisor.dynamips.nodes.router.Router.start", return_value=True) as mock:
-# response = http_hypervisor.post("/projects/{project_id}/dynamips/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+# def test_dynamips_vm_start(http_compute, vm):
+# with asyncio_patch("gns3server.compute.dynamips.nodes.router.Router.start", return_value=True) as mock:
+# response = http_compute.post("/projects/{project_id}/dynamips/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
# assert mock.called
# assert response.status == 204
#
#
-# def test_dynamips_vm_stop(http_hypervisor, vm):
-# with asyncio_patch("gns3server.hypervisor.dynamips.nodes.router.Router.stop", return_value=True) as mock:
-# response = http_hypervisor.post("/projects/{project_id}/dynamips/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+# def test_dynamips_vm_stop(http_compute, vm):
+# with asyncio_patch("gns3server.compute.dynamips.nodes.router.Router.stop", return_value=True) as mock:
+# response = http_compute.post("/projects/{project_id}/dynamips/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
# assert mock.called
# assert response.status == 204
#
#
-# def test_dynamips_vm_suspend(http_hypervisor, vm):
-# with asyncio_patch("gns3server.hypervisor.dynamips.nodes.router.Router.suspend", return_value=True) as mock:
-# response = http_hypervisor.post("/projects/{project_id}/dynamips/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+# def test_dynamips_vm_suspend(http_compute, vm):
+# with asyncio_patch("gns3server.compute.dynamips.nodes.router.Router.suspend", return_value=True) as mock:
+# response = http_compute.post("/projects/{project_id}/dynamips/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
# assert mock.called
# assert response.status == 204
#
#
-# def test_dynamips_vm_resume(http_hypervisor, vm):
-# with asyncio_patch("gns3server.hypervisor.dynamips.nodes.router.Router.resume", return_value=True) as mock:
-# response = http_hypervisor.post("/projects/{project_id}/dynamips/vms/{vm_id}/resume".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+# def test_dynamips_vm_resume(http_compute, vm):
+# with asyncio_patch("gns3server.compute.dynamips.nodes.router.Router.resume", return_value=True) as mock:
+# response = http_compute.post("/projects/{project_id}/dynamips/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_nio_create_udp(http_hypervisor, vm):
+# def test_vbox_nio_create_udp(http_compute, vm):
#
-# with asyncio_patch('gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_add_nio_binding') as mock:
-# response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/nio".format(project_id=vm["project_id"],
+# with asyncio_patch('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_add_nio_binding') as mock:
+# response = http_compute.post("/projects/{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,
@@ -108,10 +108,10 @@ from tests.utils import asyncio_patch
# assert response.json["type"] == "nio_udp"
#
#
-# def test_vbox_delete_nio(http_hypervisor, vm):
+# def test_vbox_delete_nio(http_compute, vm):
#
-# with asyncio_patch('gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_remove_nio_binding') as mock:
-# response = http_hypervisor.delete("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+# with asyncio_patch('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_remove_nio_binding') as mock:
+# response = http_compute.delete("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
#
# assert mock.called
# args, kwgars = mock.call_args
@@ -121,8 +121,8 @@ from tests.utils import asyncio_patch
# assert response.route == "/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_id:\d+}/nio"
#
#
-# def test_vbox_update(http_hypervisor, vm, free_console_port):
-# response = http_hypervisor.put("/projects/{project_id}/virtualbox/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
+# def test_vbox_update(http_compute, vm, free_console_port):
+# response = http_compute.put("/projects/{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"
@@ -151,17 +151,17 @@ def fake_file(tmpdir):
return path
-def test_vms(http_hypervisor, tmpdir, fake_dynamips, fake_file):
+def test_vms(http_compute, tmpdir, fake_dynamips, fake_file):
- with patch("gns3server.hypervisor.Dynamips.get_images_directory", return_value=str(tmpdir), example=True):
- response = http_hypervisor.get("/dynamips/vms")
+ with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir), example=True):
+ response = http_compute.get("/dynamips/vms")
assert response.status == 200
assert response.json == [{"filename": "7200.bin", "path": "7200.bin"}]
-def test_upload_vm(http_hypervisor, tmpdir):
- with patch("gns3server.hypervisor.Dynamips.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/dynamips/vms/test2", body="TEST", raw=True)
+def test_upload_vm(http_compute, tmpdir):
+ with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/dynamips/vms/test2", body="TEST", raw=True)
assert response.status == 204
with open(str(tmpdir / "test2")) as f:
@@ -172,11 +172,11 @@ def test_upload_vm(http_hypervisor, tmpdir):
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
-def test_upload_vm_permission_denied(http_hypervisor, tmpdir):
+def test_upload_vm_permission_denied(http_compute, tmpdir):
with open(str(tmpdir / "test2"), "w+") as f:
f.write("")
os.chmod(str(tmpdir / "test2"), 0)
- with patch("gns3server.hypervisor.Dynamips.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/dynamips/vms/test2", body="TEST", raw=True)
+ with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/dynamips/vms/test2", body="TEST", raw=True)
assert response.status == 409
diff --git a/tests/handlers/api/hypervisor/test_file.py b/tests/handlers/api/compute/test_file.py
similarity index 83%
rename from tests/handlers/api/hypervisor/test_file.py
rename to tests/handlers/api/compute/test_file.py
index 1c86a85d..76b692a4 100644
--- a/tests/handlers/api/hypervisor/test_file.py
+++ b/tests/handlers/api/compute/test_file.py
@@ -26,14 +26,14 @@ import aiohttp
from gns3server.version import __version__
-def test_stream(http_hypervisor, tmpdir, loop):
+def test_stream(http_compute, tmpdir, loop):
with open(str(tmpdir / "test"), 'w+') as f:
f.write("hello")
def go(future):
query = json.dumps({"location": str(tmpdir / "test")})
headers = {'content-type': 'application/json'}
- response = yield from aiohttp.request("GET", http_hypervisor.get_url("/files/stream"), data=query, headers=headers)
+ response = yield from aiohttp.request("GET", http_compute.get_url("/files/stream"), data=query, headers=headers)
response.body = yield from response.content.read(5)
with open(str(tmpdir / "test"), 'a') as f:
f.write("world")
@@ -48,11 +48,11 @@ def test_stream(http_hypervisor, tmpdir, loop):
assert response.body == b'helloworld'
-def test_stream_file_not_found(http_hypervisor, tmpdir, loop):
+def test_stream_file_not_found(http_compute, tmpdir, loop):
def go(future):
query = json.dumps({"location": str(tmpdir / "test")})
headers = {'content-type': 'application/json'}
- response = yield from aiohttp.request("GET", http_hypervisor.get_url("/files/stream"), data=query, headers=headers)
+ response = yield from aiohttp.request("GET", http_compute.get_url("/files/stream"), data=query, headers=headers)
response.close()
future.set_result(response)
diff --git a/tests/handlers/api/hypervisor/test_iou.py b/tests/handlers/api/compute/test_iou.py
similarity index 55%
rename from tests/handlers/api/hypervisor/test_iou.py
rename to tests/handlers/api/compute/test_iou.py
index 69e359ea..531133b9 100644
--- a/tests/handlers/api/hypervisor/test_iou.py
+++ b/tests/handlers/api/compute/test_iou.py
@@ -46,8 +46,8 @@ def base_params(tmpdir, fake_iou_bin):
@pytest.fixture
-def vm(http_hypervisor, project, base_params):
- response = http_hypervisor.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
+def vm(http_compute, project, base_params):
+ response = http_compute.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
assert response.status == 201
return response.json
@@ -58,8 +58,8 @@ def startup_config_file(project, vm):
return os.path.join(directory, "startup-config.cfg")
-def test_iou_create(http_hypervisor, project, base_params):
- response = http_hypervisor.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
+def test_iou_create(http_compute, project, base_params):
+ response = http_compute.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
assert response.status == 201
assert response.route == "/projects/{project_id}/iou/vms"
assert response.json["name"] == "PC TEST 1"
@@ -71,7 +71,7 @@ def test_iou_create(http_hypervisor, project, base_params):
assert response.json["l1_keepalives"] is False
-def test_iou_create_with_params(http_hypervisor, project, base_params):
+def test_iou_create_with_params(http_compute, project, base_params):
params = base_params
params["ram"] = 1024
params["nvram"] = 512
@@ -82,7 +82,7 @@ def test_iou_create_with_params(http_hypervisor, project, base_params):
params["use_default_iou_values"] = True
params["iourc_content"] = "test"
- response = http_hypervisor.post("/projects/{project_id}/iou/vms".format(project_id=project.id), params, example=True)
+ response = http_compute.post("/projects/{project_id}/iou/vms".format(project_id=project.id), params, example=True)
assert response.status == 201
assert response.route == "/projects/{project_id}/iou/vms"
assert response.json["name"] == "PC TEST 1"
@@ -101,7 +101,7 @@ def test_iou_create_with_params(http_hypervisor, project, base_params):
assert "iourc" in response.json["iourc_path"]
-def test_iou_create_startup_config_already_exist(http_hypervisor, project, base_params):
+def test_iou_create_startup_config_already_exist(http_compute, project, base_params):
"""We don't erase a startup-config if already exist at project creation"""
vm_id = str(uuid.uuid4())
@@ -113,7 +113,7 @@ def test_iou_create_startup_config_already_exist(http_hypervisor, project, base_
params["vm_id"] = vm_id
params["startup_config_content"] = "hostname test"
- response = http_hypervisor.post("/projects/{project_id}/iou/vms".format(project_id=project.id), params, example=True)
+ response = http_compute.post("/projects/{project_id}/iou/vms".format(project_id=project.id), params, example=True)
assert response.status == 201
assert response.route == "/projects/{project_id}/iou/vms"
@@ -122,8 +122,8 @@ def test_iou_create_startup_config_already_exist(http_hypervisor, project, base_
assert f.read() == "echo hello"
-def test_iou_get(http_hypervisor, project, vm):
- response = http_hypervisor.get("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_iou_get(http_compute, project, vm):
+ response = http_compute.get("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 200
assert response.route == "/projects/{project_id}/iou/vms/{vm_id}"
assert response.json["name"] == "PC TEST 1"
@@ -135,50 +135,50 @@ def test_iou_get(http_hypervisor, project, vm):
assert response.json["l1_keepalives"] is False
-def test_iou_start(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.start", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+def test_iou_start(http_compute, vm):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.start", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert mock.called
assert response.status == 200
assert response.json["name"] == "PC TEST 1"
-def test_iou_start_with_iourc(http_hypervisor, vm, tmpdir):
+def test_iou_start_with_iourc(http_compute, vm, tmpdir):
body = {"iourc_content": "test"}
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.start", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=body, example=True)
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.start", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=body, example=True)
assert mock.called
assert response.status == 200
- response = http_hypervisor.get("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ response = http_compute.get("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert response.status == 200
with open(response.json["iourc_path"]) as f:
assert f.read() == "test"
-def test_iou_stop(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.stop", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_iou_stop(http_compute, vm):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.stop", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_iou_reload(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.reload", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_iou_reload(http_compute, vm):
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.reload", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_iou_delete(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.iou.IOU.delete_vm", return_value=True) as mock:
- response = http_hypervisor.delete("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_iou_delete(http_compute, vm):
+ with asyncio_patch("gns3server.compute.iou.IOU.delete_vm", return_value=True) as mock:
+ response = http_compute.delete("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_iou_update(http_hypervisor, vm, tmpdir, free_console_port, project):
+def test_iou_update(http_compute, vm, tmpdir, free_console_port, project):
params = {
"name": "test",
"console": free_console_port,
@@ -191,7 +191,7 @@ def test_iou_update(http_hypervisor, vm, tmpdir, free_console_port, project):
"use_default_iou_values": True,
"iourc_content": "test"
}
- response = http_hypervisor.put("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), params, example=True)
+ response = http_compute.put("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), params, example=True)
assert response.status == 200
assert response.json["name"] == "test"
assert response.json["console"] == free_console_port
@@ -208,65 +208,65 @@ def test_iou_update(http_hypervisor, vm, tmpdir, free_console_port, project):
assert "iourc" in response.json["iourc_path"]
-def test_iou_nio_create_udp(http_hypervisor, vm):
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/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)
+def test_iou_nio_create_udp(http_compute, vm):
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/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 == "/projects/{project_id}/iou/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp"
-def test_iou_nio_create_ethernet(http_hypervisor, vm, ethernet_device):
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet",
- "ethernet_device": ethernet_device,
- },
- example=True)
+def test_iou_nio_create_ethernet(http_compute, vm, ethernet_device):
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet",
+ "ethernet_device": ethernet_device,
+ },
+ example=True)
assert response.status == 201
assert response.route == "/projects/{project_id}/iou/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_generic_ethernet"
assert response.json["ethernet_device"] == ethernet_device
-def test_iou_nio_create_ethernet_different_port(http_hypervisor, vm, ethernet_device):
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/3/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet",
- "ethernet_device": ethernet_device,
- },
- example=False)
+def test_iou_nio_create_ethernet_different_port(http_compute, vm, ethernet_device):
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/3/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet",
+ "ethernet_device": ethernet_device,
+ },
+ example=False)
assert response.status == 201
assert response.route == "/projects/{project_id}/iou/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_generic_ethernet"
assert response.json["ethernet_device"] == ethernet_device
-def test_iou_nio_create_tap(http_hypervisor, vm, ethernet_device):
- with patch("gns3server.hypervisor.base_manager.BaseManager.has_privileged_access", return_value=True):
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_tap",
- "tap_device": ethernet_device})
+def test_iou_nio_create_tap(http_compute, vm, ethernet_device):
+ with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_tap",
+ "tap_device": ethernet_device})
assert response.status == 201
assert response.route == "/projects/{project_id}/iou/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_tap"
-def test_iou_delete_nio(http_hypervisor, vm):
- http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/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 = http_hypervisor.delete("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_iou_delete_nio(http_compute, vm):
+ http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/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 = http_compute.delete("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 204
assert response.route == "/projects/{project_id}/iou/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
-def test_iou_start_capture(http_hypervisor, vm, tmpdir, project):
+def test_iou_start_capture(http_compute, vm, tmpdir, project):
- with patch("gns3server.hypervisor.iou.iou_vm.IOUVM.is_running", return_value=True) as mock:
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.start_capture") as start_capture:
+ with patch("gns3server.compute.iou.iou_vm.IOUVM.is_running", return_value=True) as mock:
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.start_capture") as start_capture:
params = {"capture_file_name": "test.pcap", "data_link_type": "DLT_EN10MB"}
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params, example=True)
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params, example=True)
assert response.status == 200
@@ -274,71 +274,71 @@ def test_iou_start_capture(http_hypervisor, vm, tmpdir, project):
assert "test.pcap" in response.json["pcap_file_path"]
-def test_iou_start_capture_not_started(http_hypervisor, vm, tmpdir):
+def test_iou_start_capture_not_started(http_compute, vm, tmpdir):
- with patch("gns3server.hypervisor.iou.iou_vm.IOUVM.is_running", return_value=False) as mock:
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.start_capture") as start_capture:
+ with patch("gns3server.compute.iou.iou_vm.IOUVM.is_running", return_value=False) as mock:
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.start_capture") as start_capture:
params = {"capture_file_name": "test.pcap", "data_link_type": "DLT_EN10MB"}
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params)
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params)
assert not start_capture.called
assert response.status == 409
-def test_iou_stop_capture(http_hypervisor, vm, tmpdir, project):
+def test_iou_stop_capture(http_compute, vm, tmpdir, project):
- with patch("gns3server.hypervisor.iou.iou_vm.IOUVM.is_running", return_value=True) as mock:
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.stop_capture") as stop_capture:
+ with patch("gns3server.compute.iou.iou_vm.IOUVM.is_running", return_value=True) as mock:
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.stop_capture") as stop_capture:
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 204
assert stop_capture.called
-def test_iou_stop_capture_not_started(http_hypervisor, vm, tmpdir):
+def test_iou_stop_capture_not_started(http_compute, vm, tmpdir):
- with patch("gns3server.hypervisor.iou.iou_vm.IOUVM.is_running", return_value=False) as mock:
- with asyncio_patch("gns3server.hypervisor.iou.iou_vm.IOUVM.stop_capture") as stop_capture:
+ with patch("gns3server.compute.iou.iou_vm.IOUVM.is_running", return_value=False) as mock:
+ with asyncio_patch("gns3server.compute.iou.iou_vm.IOUVM.stop_capture") as stop_capture:
- response = http_hypervisor.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
+ response = http_compute.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
assert not stop_capture.called
assert response.status == 409
-def test_get_configs_without_configs_file(http_hypervisor, vm):
+def test_get_configs_without_configs_file(http_compute, vm):
- response = http_hypervisor.get("/projects/{project_id}/iou/vms/{vm_id}/configs".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ response = http_compute.get("/projects/{project_id}/iou/vms/{vm_id}/configs".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 200
assert "startup_config" not in response.json
assert "private_config" not in response.json
-def test_get_configs_with_startup_config_file(http_hypervisor, project, vm):
+def test_get_configs_with_startup_config_file(http_compute, project, vm):
path = startup_config_file(project, vm)
with open(path, "w+") as f:
f.write("TEST")
- response = http_hypervisor.get("/projects/{project_id}/iou/vms/{vm_id}/configs".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ response = http_compute.get("/projects/{project_id}/iou/vms/{vm_id}/configs".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 200
assert response.json["startup_config_content"] == "TEST"
-def test_vms(http_hypervisor, tmpdir, fake_iou_bin):
+def test_vms(http_compute, tmpdir, fake_iou_bin):
- with patch("gns3server.hypervisor.IOU.get_images_directory", return_value=str(tmpdir)):
- response = http_hypervisor.get("/iou/vms", example=True)
+ with patch("gns3server.compute.IOU.get_images_directory", return_value=str(tmpdir)):
+ response = http_compute.get("/iou/vms", example=True)
assert response.status == 200
assert response.json == [{"filename": "iou.bin", "path": "iou.bin"}]
-def test_upload_vm(http_hypervisor, tmpdir):
- with patch("gns3server.hypervisor.IOU.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/iou/vms/test2", body="TEST", raw=True)
+def test_upload_vm(http_compute, tmpdir):
+ with patch("gns3server.compute.IOU.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/iou/vms/test2", body="TEST", raw=True)
assert response.status == 204
with open(str(tmpdir / "test2")) as f:
@@ -349,11 +349,11 @@ def test_upload_vm(http_hypervisor, tmpdir):
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
-def test_upload_vm_permission_denied(http_hypervisor, tmpdir):
+def test_upload_vm_permission_denied(http_compute, tmpdir):
with open(str(tmpdir / "test2"), "w+") as f:
f.write("")
os.chmod(str(tmpdir / "test2"), 0)
- with patch("gns3server.hypervisor.IOU.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/iou/vms/test2", body="TEST", raw=True)
+ with patch("gns3server.compute.IOU.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/iou/vms/test2", body="TEST", raw=True)
assert response.status == 409
diff --git a/tests/handlers/api/hypervisor/test_network.py b/tests/handlers/api/compute/test_network.py
similarity index 80%
rename from tests/handlers/api/hypervisor/test_network.py
rename to tests/handlers/api/compute/test_network.py
index ccaf7958..32d0502a 100644
--- a/tests/handlers/api/hypervisor/test_network.py
+++ b/tests/handlers/api/compute/test_network.py
@@ -19,15 +19,15 @@ import os
import pytest
-def test_udp_allocation(http_hypervisor, project):
- response = http_hypervisor.post('/projects/{}/ports/udp'.format(project.id), {}, example=True)
+def test_udp_allocation(http_compute, project):
+ response = http_compute.post('/projects/{}/ports/udp'.format(project.id), {}, example=True)
assert response.status == 201
assert response.json['udp_port'] is not None
# Netfifaces is not available on Travis
@pytest.mark.skipif(os.environ.get("TRAVIS", False) is not False, reason="Not supported on Travis")
-def test_interfaces(http_hypervisor):
- response = http_hypervisor.get('/interfaces', example=True)
+def test_interfaces(http_compute):
+ response = http_compute.get('/interfaces', example=True)
assert response.status == 200
assert isinstance(response.json, list)
diff --git a/tests/handlers/api/hypervisor/test_notification.py b/tests/handlers/api/compute/test_notification.py
similarity index 81%
rename from tests/handlers/api/hypervisor/test_notification.py
rename to tests/handlers/api/compute/test_notification.py
index 0613b69f..5b2ee245 100644
--- a/tests/handlers/api/hypervisor/test_notification.py
+++ b/tests/handlers/api/compute/test_notification.py
@@ -17,11 +17,11 @@
import json
-from gns3server.hypervisor.notification_manager import NotificationManager
+from gns3server.compute.notification_manager import NotificationManager
-def test_notification_ws(http_hypervisor, async_run):
- ws = http_hypervisor.websocket("/notifications/ws")
+def test_notification_ws(http_compute, async_run):
+ ws = http_compute.websocket("/notifications/ws")
answer = async_run(ws.receive())
answer = json.loads(answer.data)
assert answer["action"] == "ping"
@@ -32,4 +32,4 @@ def test_notification_ws(http_hypervisor, async_run):
answer = json.loads(answer.data)
assert answer["action"] == "test"
- async_run(http_hypervisor.close())
+ async_run(http_compute.close())
diff --git a/tests/handlers/api/hypervisor/test_project.py b/tests/handlers/api/compute/test_project.py
similarity index 54%
rename from tests/handlers/api/hypervisor/test_project.py
rename to tests/handlers/api/compute/test_project.py
index c8a11832..497e6f03 100644
--- a/tests/handlers/api/hypervisor/test_project.py
+++ b/tests/handlers/api/compute/test_project.py
@@ -28,97 +28,96 @@ import zipfile
from unittest.mock import patch
from tests.utils import asyncio_patch
-from gns3server.handlers.api.hypervisor.project_handler import ProjectHandler
-from gns3server.hypervisor.project_manager import ProjectManager
+from gns3server.handlers.api.compute.project_handler import ProjectHandler
+from gns3server.compute.project_manager import ProjectManager
-def test_create_project_with_path(http_hypervisor, tmpdir):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
- response = http_hypervisor.post("/projects", {"name": "test", "path": str(tmpdir), "project_id": "00010203-0405-0607-0809-0a0b0c0d0e0f"})
+def test_create_project_with_path(http_compute, tmpdir):
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
+ response = http_compute.post("/projects", {"name": "test", "path": str(tmpdir), "project_id": "00010203-0405-0607-0809-0a0b0c0d0e0f"})
assert response.status == 201
- assert response.json["name"] == "test"
assert response.json["project_id"] == "00010203-0405-0607-0809-0a0b0c0d0e0f"
-def test_create_project_without_dir(http_hypervisor):
+def test_create_project_without_dir(http_compute):
query = {"name": "test", "project_id": "10010203-0405-0607-0809-0a0b0c0d0e0f"}
- response = http_hypervisor.post("/projects", query, example=True)
+ response = http_compute.post("/projects", query, example=True)
assert response.status == 201
assert response.json["project_id"] == "10010203-0405-0607-0809-0a0b0c0d0e0f"
assert response.json["temporary"] is False
assert response.json["name"] == "test"
-def test_create_temporary_project(http_hypervisor):
+def test_create_temporary_project(http_compute):
query = {"name": "test", "temporary": True, "project_id": "20010203-0405-0607-0809-0a0b0c0d0e0f"}
- response = http_hypervisor.post("/projects", query)
+ response = http_compute.post("/projects", query)
assert response.status == 201
assert response.json["project_id"] == "20010203-0405-0607-0809-0a0b0c0d0e0f"
assert response.json["temporary"] is True
assert response.json["name"] == "test"
-def test_create_project_with_uuid(http_hypervisor):
+def test_create_project_with_uuid(http_compute):
query = {"name": "test", "project_id": "30010203-0405-0607-0809-0a0b0c0d0e0f"}
- response = http_hypervisor.post("/projects", query)
+ response = http_compute.post("/projects", query)
assert response.status == 201
assert response.json["project_id"] == "30010203-0405-0607-0809-0a0b0c0d0e0f"
assert response.json["name"] == "test"
-def test_show_project(http_hypervisor):
+def test_show_project(http_compute):
query = {"name": "test", "project_id": "40010203-0405-0607-0809-0a0b0c0d0e02", "temporary": False}
- response = http_hypervisor.post("/projects", query)
+ response = http_compute.post("/projects", query)
assert response.status == 201
- response = http_hypervisor.get("/projects/40010203-0405-0607-0809-0a0b0c0d0e02", example=True)
+ response = http_compute.get("/projects/40010203-0405-0607-0809-0a0b0c0d0e02", example=True)
assert len(response.json.keys()) == 3
assert response.json["project_id"] == "40010203-0405-0607-0809-0a0b0c0d0e02"
assert response.json["temporary"] is False
assert response.json["name"] == "test"
-def test_show_project_invalid_uuid(http_hypervisor):
- response = http_hypervisor.get("/projects/50010203-0405-0607-0809-0a0b0c0d0e42")
+def test_show_project_invalid_uuid(http_compute):
+ response = http_compute.get("/projects/50010203-0405-0607-0809-0a0b0c0d0e42")
assert response.status == 404
-def test_list_projects(http_hypervisor):
+def test_list_projects(http_compute):
ProjectManager.instance()._projects = {}
query = {"name": "test", "project_id": "51010203-0405-0607-0809-0a0b0c0d0e0f"}
- response = http_hypervisor.post("/projects", query)
+ response = http_compute.post("/projects", query)
assert response.status == 201
query = {"name": "test", "project_id": "52010203-0405-0607-0809-0a0b0c0d0e0b"}
- response = http_hypervisor.post("/projects", query)
+ response = http_compute.post("/projects", query)
assert response.status == 201
- response = http_hypervisor.get("/projects", example=True)
+ response = http_compute.get("/projects", example=True)
assert response.status == 200
assert len(response.json) == 2
assert "51010203-0405-0607-0809-0a0b0c0d0e0f" in [p["project_id"] for p in response.json]
-def test_update_temporary_project(http_hypervisor):
+def test_update_temporary_project(http_compute):
query = {"name": "test", "temporary": True, "project_id": "60010203-0405-0607-0809-0a0b0c0d0e0b"}
- response = http_hypervisor.post("/projects", query)
+ response = http_compute.post("/projects", query)
assert response.status == 201
query = {"name": "test", "temporary": False}
- response = http_hypervisor.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
+ response = http_compute.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
assert response.status == 200
assert response.json["temporary"] is False
-def test_update_path_project_temporary(http_hypervisor, tmpdir):
+def test_update_path_project_temporary(http_compute, tmpdir):
os.makedirs(str(tmpdir / "a"))
os.makedirs(str(tmpdir / "b"))
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
- response = http_hypervisor.post("/projects", {"name": "first_name", "path": str(tmpdir / "a"), "temporary": True, "project_id": "70010203-0405-0607-0809-0a0b0c0d0e0b"})
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
+ response = http_compute.post("/projects", {"name": "first_name", "path": str(tmpdir / "a"), "temporary": True, "project_id": "70010203-0405-0607-0809-0a0b0c0d0e0b"})
assert response.status == 201
assert response.json["name"] == "first_name"
query = {"name": "second_name", "path": str(tmpdir / "b")}
- response = http_hypervisor.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
+ response = http_compute.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
assert response.status == 200
assert response.json["name"] == "second_name"
@@ -126,17 +125,17 @@ def test_update_path_project_temporary(http_hypervisor, tmpdir):
assert os.path.exists(str(tmpdir / "b"))
-def test_update_path_project_non_temporary(http_hypervisor, tmpdir):
+def test_update_path_project_non_temporary(http_compute, tmpdir):
os.makedirs(str(tmpdir / "a"))
os.makedirs(str(tmpdir / "b"))
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=True):
- response = http_hypervisor.post("/projects", {"name": "first_name", "path": str(tmpdir / "a"), "project_id": "80010203-0405-0607-0809-0a0b0c0d0e0b"})
+ with patch("gns3server.compute.project.Project.is_local", return_value=True):
+ response = http_compute.post("/projects", {"name": "first_name", "path": str(tmpdir / "a"), "project_id": "80010203-0405-0607-0809-0a0b0c0d0e0b"})
assert response.status == 201
assert response.json["name"] == "first_name"
query = {"name": "second_name", "path": str(tmpdir / "b")}
- response = http_hypervisor.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
+ response = http_compute.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
assert response.status == 200
assert response.json["name"] == "second_name"
@@ -144,63 +143,63 @@ def test_update_path_project_non_temporary(http_hypervisor, tmpdir):
assert os.path.exists(str(tmpdir / "b"))
-def test_update_path_project_non_local(http_hypervisor, tmpdir):
+def test_update_path_project_non_local(http_compute, tmpdir):
- with patch("gns3server.hypervisor.project.Project.is_local", return_value=False):
- response = http_hypervisor.post("/projects", {"name": "first_name", "project_id": "90010203-0405-0607-0809-0a0b0c0d0e0b"})
+ with patch("gns3server.compute.project.Project.is_local", return_value=False):
+ response = http_compute.post("/projects", {"name": "first_name", "project_id": "90010203-0405-0607-0809-0a0b0c0d0e0b"})
assert response.status == 201
query = {"name": "second_name", "path": str(tmpdir)}
- response = http_hypervisor.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
+ response = http_compute.put("/projects/{project_id}".format(project_id=response.json["project_id"]), query, example=True)
assert response.status == 403
-def test_commit_project(http_hypervisor, project):
- with asyncio_patch("gns3server.hypervisor.project.Project.commit", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/commit".format(project_id=project.id), example=True)
+def test_commit_project(http_compute, project):
+ with asyncio_patch("gns3server.compute.project.Project.commit", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/commit".format(project_id=project.id), example=True)
assert response.status == 204
assert mock.called
-def test_commit_project_invalid_uuid(http_hypervisor):
- response = http_hypervisor.post("/projects/{project_id}/commit".format(project_id=uuid.uuid4()))
+def test_commit_project_invalid_uuid(http_compute):
+ response = http_compute.post("/projects/{project_id}/commit".format(project_id=uuid.uuid4()))
assert response.status == 404
-def test_delete_project(http_hypervisor, project):
- with asyncio_patch("gns3server.hypervisor.project.Project.delete", return_value=True) as mock:
- response = http_hypervisor.delete("/projects/{project_id}".format(project_id=project.id), example=True)
+def test_delete_project(http_compute, project):
+ with asyncio_patch("gns3server.compute.project.Project.delete", return_value=True) as mock:
+ response = http_compute.delete("/projects/{project_id}".format(project_id=project.id), example=True)
assert response.status == 204
assert mock.called
-def test_delete_project_invalid_uuid(http_hypervisor):
- response = http_hypervisor.delete("/projects/{project_id}".format(project_id=uuid.uuid4()))
+def test_delete_project_invalid_uuid(http_compute):
+ response = http_compute.delete("/projects/{project_id}".format(project_id=uuid.uuid4()))
assert response.status == 404
-def test_close_project(http_hypervisor, project):
- with asyncio_patch("gns3server.hypervisor.project.Project.close", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/close".format(project_id=project.id), example=True)
+def test_close_project(http_compute, project):
+ with asyncio_patch("gns3server.compute.project.Project.close", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/close".format(project_id=project.id), example=True)
assert response.status == 204
assert mock.called
-def test_close_project_two_client_connected(http_hypervisor, project):
+def test_close_project_two_client_connected(http_compute, project):
ProjectHandler._notifications_listening = {project.id: 2}
- with asyncio_patch("gns3server.hypervisor.project.Project.close", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/close".format(project_id=project.id), example=True)
+ with asyncio_patch("gns3server.compute.project.Project.close", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/close".format(project_id=project.id), example=True)
assert response.status == 204
assert not mock.called
-def test_close_project_invalid_uuid(http_hypervisor):
- response = http_hypervisor.post("/projects/{project_id}/close".format(project_id=uuid.uuid4()))
+def test_close_project_invalid_uuid(http_compute):
+ response = http_compute.post("/projects/{project_id}/close".format(project_id=uuid.uuid4()))
assert response.status == 404
-def test_get_file(http_hypervisor, tmpdir):
+def test_get_file(http_compute, tmpdir):
with patch("gns3server.config.Config.get_section_config", return_value={"project_directory": str(tmpdir)}):
project = ProjectManager.instance().create_project(project_id="01010203-0405-0607-0809-0a0b0c0d0e0b")
@@ -208,24 +207,24 @@ def test_get_file(http_hypervisor, tmpdir):
with open(os.path.join(project.path, "hello"), "w+") as f:
f.write("world")
- response = http_hypervisor.get("/projects/{project_id}/files/hello".format(project_id=project.id), raw=True)
+ response = http_compute.get("/projects/{project_id}/files/hello".format(project_id=project.id), raw=True)
assert response.status == 200
assert response.body == b"world"
- response = http_hypervisor.get("/projects/{project_id}/files/false".format(project_id=project.id), raw=True)
+ response = http_compute.get("/projects/{project_id}/files/false".format(project_id=project.id), raw=True)
assert response.status == 404
- response = http_hypervisor.get("/projects/{project_id}/files/../hello".format(project_id=project.id), raw=True)
+ response = http_compute.get("/projects/{project_id}/files/../hello".format(project_id=project.id), raw=True)
assert response.status == 403
-def test_export(http_hypervisor, tmpdir, loop, project):
+def test_export(http_compute, tmpdir, loop, project):
os.makedirs(project.path, exist_ok=True)
with open(os.path.join(project.path, 'a'), 'w+') as f:
f.write('hello')
- response = http_hypervisor.get("/projects/{project_id}/export".format(project_id=project.id), raw=True)
+ response = http_compute.get("/projects/{project_id}/export".format(project_id=project.id), raw=True)
assert response.status == 200
assert response.headers['CONTENT-TYPE'] == 'application/gns3z'
assert response.headers['CONTENT-DISPOSITION'] == 'attachment; filename="{}.gns3z"'.format(project.name)
@@ -239,7 +238,7 @@ def test_export(http_hypervisor, tmpdir, loop, project):
assert content == b"hello"
-def test_import(http_hypervisor, tmpdir, loop, project):
+def test_import(http_compute, tmpdir, loop, project):
with zipfile.ZipFile(str(tmpdir / "test.zip"), 'w') as myzip:
myzip.writestr("demo", b"hello")
@@ -247,7 +246,7 @@ def test_import(http_hypervisor, tmpdir, loop, project):
project_id = project.id
with open(str(tmpdir / "test.zip"), "rb") as f:
- response = http_hypervisor.post("/projects/{project_id}/import".format(project_id=project_id), body=f.read(), raw=True)
+ response = http_compute.post("/projects/{project_id}/import".format(project_id=project_id), body=f.read(), raw=True)
assert response.status == 201
project = ProjectManager.instance().get_project(project_id=project_id)
diff --git a/tests/handlers/api/hypervisor/test_qemu.py b/tests/handlers/api/compute/test_qemu.py
similarity index 53%
rename from tests/handlers/api/hypervisor/test_qemu.py
rename to tests/handlers/api/compute/test_qemu.py
index 5bd37ad1..849a4789 100644
--- a/tests/handlers/api/hypervisor/test_qemu.py
+++ b/tests/handlers/api/compute/test_qemu.py
@@ -57,14 +57,14 @@ def base_params(tmpdir, fake_qemu_bin):
@pytest.fixture
-def vm(http_hypervisor, project, base_params):
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params)
+def vm(http_compute, project, base_params):
+ response = http_compute.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params)
assert response.status == 201
return response.json
-def test_qemu_create(http_hypervisor, project, base_params, fake_qemu_bin):
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params)
+def test_qemu_create(http_compute, project, base_params, fake_qemu_bin):
+ response = http_compute.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params)
assert response.status == 201
assert response.route == "/projects/{project_id}/qemu/vms"
assert response.json["name"] == "PC TEST 1"
@@ -73,11 +73,11 @@ def test_qemu_create(http_hypervisor, project, base_params, fake_qemu_bin):
assert response.json["platform"] == "x86_64"
-def test_qemu_create_platform(http_hypervisor, project, base_params, fake_qemu_bin):
+def test_qemu_create_platform(http_compute, project, base_params, fake_qemu_bin):
base_params["qemu_path"] = None
base_params["platform"] = "x86_64"
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params)
+ response = http_compute.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), base_params)
assert response.status == 201
assert response.route == "/projects/{project_id}/qemu/vms"
assert response.json["name"] == "PC TEST 1"
@@ -86,12 +86,12 @@ def test_qemu_create_platform(http_hypervisor, project, base_params, fake_qemu_b
assert response.json["platform"] == "x86_64"
-def test_qemu_create_with_params(http_hypervisor, project, base_params, fake_qemu_vm):
+def test_qemu_create_with_params(http_compute, project, base_params, fake_qemu_vm):
params = base_params
params["ram"] = 1024
params["hda_disk_image"] = "linux载.img"
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), params, example=True)
+ response = http_compute.post("/projects/{project_id}/qemu/vms".format(project_id=project.id), params, example=True)
assert response.status == 201
assert response.route == "/projects/{project_id}/qemu/vms"
@@ -102,8 +102,8 @@ def test_qemu_create_with_params(http_hypervisor, project, base_params, fake_qem
assert response.json["hda_disk_image_md5sum"] == "c4ca4238a0b923820dcc509a6f75849b"
-def test_qemu_get(http_hypervisor, project, vm):
- response = http_hypervisor.get("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_get(http_compute, project, vm):
+ response = http_compute.get("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 200
assert response.route == "/projects/{project_id}/qemu/vms/{vm_id}"
assert response.json["name"] == "PC TEST 1"
@@ -111,57 +111,57 @@ def test_qemu_get(http_hypervisor, project, vm):
assert response.json["vm_directory"] == os.path.join(project.path, "project-files", "qemu", vm["vm_id"])
-def test_qemu_start(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.qemu_vm.QemuVM.start", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_start(http_compute, vm):
+ with asyncio_patch("gns3server.compute.qemu.qemu_vm.QemuVM.start", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 200
assert response.json["name"] == "PC TEST 1"
-def test_qemu_stop(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.qemu_vm.QemuVM.stop", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_stop(http_compute, vm):
+ with asyncio_patch("gns3server.compute.qemu.qemu_vm.QemuVM.stop", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_qemu_reload(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.qemu_vm.QemuVM.reload", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_reload(http_compute, vm):
+ with asyncio_patch("gns3server.compute.qemu.qemu_vm.QemuVM.reload", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_qemu_suspend(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.qemu_vm.QemuVM.suspend", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_suspend(http_compute, vm):
+ with asyncio_patch("gns3server.compute.qemu.qemu_vm.QemuVM.suspend", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_qemu_resume(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.qemu_vm.QemuVM.resume", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/resume".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_resume(http_compute, vm):
+ with asyncio_patch("gns3server.compute.qemu.qemu_vm.QemuVM.resume", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/resume".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_qemu_delete(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.qemu.Qemu.delete_vm", return_value=True) as mock:
- response = http_hypervisor.delete("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_delete(http_compute, vm):
+ with asyncio_patch("gns3server.compute.qemu.Qemu.delete_vm", return_value=True) as mock:
+ response = http_compute.delete("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_qemu_update(http_hypervisor, vm, tmpdir, free_console_port, project, fake_qemu_vm):
+def test_qemu_update(http_compute, vm, tmpdir, free_console_port, project, fake_qemu_vm):
params = {
"name": "test",
"console": free_console_port,
"ram": 1024,
"hdb_disk_image": "linux.img"
}
- response = http_hypervisor.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), params, example=True)
+ response = http_compute.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), params, example=True)
assert response.status == 200
assert response.json["name"] == "test"
assert response.json["console"] == free_console_port
@@ -169,71 +169,71 @@ def test_qemu_update(http_hypervisor, vm, tmpdir, free_console_port, project, fa
assert response.json["ram"] == 1024
-def test_qemu_nio_create_udp(http_hypervisor, vm):
- http_hypervisor.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2})
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/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)
+def test_qemu_nio_create_udp(http_compute, vm):
+ http_compute.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2})
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/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 == "/projects/{project_id}/qemu/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp"
-def test_qemu_nio_create_ethernet(http_hypervisor, vm):
- http_hypervisor.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2})
- response = http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet",
- "ethernet_device": "eth0",
- },
- example=True)
+def test_qemu_nio_create_ethernet(http_compute, vm):
+ http_compute.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2})
+ response = http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_generic_ethernet",
+ "ethernet_device": "eth0",
+ },
+ example=True)
assert response.status == 409
-def test_qemu_delete_nio(http_hypervisor, vm):
- http_hypervisor.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2})
- http_hypervisor.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/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 = http_hypervisor.delete("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_qemu_delete_nio(http_compute, vm):
+ http_compute.put("/projects/{project_id}/qemu/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"adapters": 2})
+ http_compute.post("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/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 = http_compute.delete("/projects/{project_id}/qemu/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 204
assert response.route == "/projects/{project_id}/qemu/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
-def test_qemu_list_binaries(http_hypervisor, vm):
+def test_qemu_list_binaries(http_compute, vm):
ret = [{"path": "/tmp/1", "version": "2.2.0"},
{"path": "/tmp/2", "version": "2.1.0"}]
- with asyncio_patch("gns3server.hypervisor.qemu.Qemu.binary_list", return_value=ret) as mock:
- response = http_hypervisor.get("/qemu/binaries".format(project_id=vm["project_id"]), example=True)
+ with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
+ response = http_compute.get("/qemu/binaries".format(project_id=vm["project_id"]), example=True)
assert mock.called_with(None)
assert response.status == 200
assert response.json == ret
-def test_qemu_list_binaries_filter(http_hypervisor, vm):
+def test_qemu_list_binaries_filter(http_compute, vm):
ret = [
{"path": "/tmp/x86_64", "version": "2.2.0"},
{"path": "/tmp/alpha", "version": "2.1.0"},
{"path": "/tmp/i386", "version": "2.1.0"}
]
- with asyncio_patch("gns3server.hypervisor.qemu.Qemu.binary_list", return_value=ret) as mock:
- response = http_hypervisor.get("/qemu/binaries".format(project_id=vm["project_id"]), body={"archs": ["i386"]}, example=True)
+ with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock:
+ response = http_compute.get("/qemu/binaries".format(project_id=vm["project_id"]), body={"archs": ["i386"]}, example=True)
assert response.status == 200
assert mock.called_with(["i386"])
assert response.json == ret
-def test_vms(http_hypervisor, tmpdir, fake_qemu_vm):
+def test_vms(http_compute, tmpdir, fake_qemu_vm):
- response = http_hypervisor.get("/qemu/vms")
+ response = http_compute.get("/qemu/vms")
assert response.status == 200
assert response.json == [{"filename": "linux载.img", "path": "linux载.img"}]
-def test_upload_vm(http_hypervisor, tmpdir):
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/qemu/vms/test2", body="TEST", raw=True)
+def test_upload_vm(http_compute, tmpdir):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/qemu/vms/test2", body="TEST", raw=True)
assert response.status == 204
with open(str(tmpdir / "test2")) as f:
@@ -244,9 +244,9 @@ def test_upload_vm(http_hypervisor, tmpdir):
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
-def test_upload_vm_ova(http_hypervisor, tmpdir):
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/qemu/vms/test2.ova/test2.vmdk", body="TEST", raw=True)
+def test_upload_vm_ova(http_compute, tmpdir):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/qemu/vms/test2.ova/test2.vmdk", body="TEST", raw=True)
assert response.status == 204
with open(str(tmpdir / "test2.ova" / "test2.vmdk")) as f:
@@ -257,23 +257,23 @@ def test_upload_vm_ova(http_hypervisor, tmpdir):
assert checksum == "033bd94b1168d7e4f0d644c3c95e35bf"
-def test_upload_vm_forbiden_location(http_hypervisor, tmpdir):
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/qemu/vms/../../test2", body="TEST", raw=True)
+def test_upload_vm_forbiden_location(http_compute, tmpdir):
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/qemu/vms/../../test2", body="TEST", raw=True)
assert response.status == 403
-def test_upload_vm_permission_denied(http_hypervisor, tmpdir):
+def test_upload_vm_permission_denied(http_compute, tmpdir):
with open(str(tmpdir / "test2"), "w+") as f:
f.write("")
os.chmod(str(tmpdir / "test2"), 0)
- with patch("gns3server.hypervisor.Qemu.get_images_directory", return_value=str(tmpdir),):
- response = http_hypervisor.post("/qemu/vms/test2", body="TEST", raw=True)
+ with patch("gns3server.compute.Qemu.get_images_directory", return_value=str(tmpdir),):
+ response = http_compute.post("/qemu/vms/test2", body="TEST", raw=True)
assert response.status == 409
-def test_create_img_relative(http_hypervisor):
+def test_create_img_relative(http_compute):
body = {
"qemu_img": "/tmp/qemu-img",
"path": "hda.qcow2",
@@ -284,13 +284,13 @@ def test_create_img_relative(http_hypervisor):
"lazy_refcounts": "off",
"size": 100
}
- with asyncio_patch("gns3server.hypervisor.Qemu.create_disk"):
- response = http_hypervisor.post("/qemu/img", body=body, example=True)
+ with asyncio_patch("gns3server.compute.Qemu.create_disk"):
+ response = http_compute.post("/qemu/img", body=body, example=True)
assert response.status == 201
-def test_create_img_absolute_non_local(http_hypervisor):
+def test_create_img_absolute_non_local(http_compute):
config = Config.instance()
config.set("Server", "local", "false")
@@ -305,13 +305,13 @@ def test_create_img_absolute_non_local(http_hypervisor):
"lazy_refcounts": "off",
"size": 100
}
- with asyncio_patch("gns3server.hypervisor.Qemu.create_disk"):
- response = http_hypervisor.post("/qemu/img", body=body, example=True)
+ with asyncio_patch("gns3server.compute.Qemu.create_disk"):
+ response = http_compute.post("/qemu/img", body=body, example=True)
assert response.status == 403
-def test_create_img_absolute_local(http_hypervisor):
+def test_create_img_absolute_local(http_compute):
config = Config.instance()
config.set("Server", "local", "true")
@@ -326,13 +326,13 @@ def test_create_img_absolute_local(http_hypervisor):
"lazy_refcounts": "off",
"size": 100
}
- with asyncio_patch("gns3server.hypervisor.Qemu.create_disk"):
- response = http_hypervisor.post("/qemu/img", body=body, example=True)
+ with asyncio_patch("gns3server.compute.Qemu.create_disk"):
+ response = http_compute.post("/qemu/img", body=body, example=True)
assert response.status == 201
-def test_capabilities(http_hypervisor):
- with asyncio_patch("gns3server.hypervisor.Qemu.get_kvm_archs", return_value=["x86_64"]):
- response = http_hypervisor.get("/qemu/capabilities", example=True)
+def test_capabilities(http_compute):
+ with asyncio_patch("gns3server.compute.Qemu.get_kvm_archs", return_value=["x86_64"]):
+ response = http_compute.get("/qemu/capabilities", example=True)
assert response.json["kvm"] == ["x86_64"]
diff --git a/tests/handlers/api/hypervisor/test_version.py b/tests/handlers/api/compute/test_version.py
similarity index 74%
rename from tests/handlers/api/hypervisor/test_version.py
rename to tests/handlers/api/compute/test_version.py
index 59fa5424..da42188e 100644
--- a/tests/handlers/api/hypervisor/test_version.py
+++ b/tests/handlers/api/compute/test_version.py
@@ -25,37 +25,37 @@ from gns3server.config import Config
from gns3server.version import __version__
-def test_version_output(http_hypervisor):
+def test_version_output(http_compute):
config = Config.instance()
config.set("Server", "local", "true")
- response = http_hypervisor.get('/version', example=True)
+ response = http_compute.get('/version', example=True)
assert response.status == 200
assert response.json == {'local': True, 'version': __version__}
-def test_version_input(http_hypervisor):
+def test_version_input(http_compute):
query = {'version': __version__}
- response = http_hypervisor.post('/version', query, example=True)
+ response = http_compute.post('/version', query, example=True)
assert response.status == 200
assert response.json == {'version': __version__}
-def test_version_invalid_input(http_hypervisor):
+def test_version_invalid_input(http_compute):
query = {'version': "0.4.2"}
- response = http_hypervisor.post('/version', query)
+ response = http_compute.post('/version', query)
assert response.status == 409
assert response.json == {'message': 'Client version 0.4.2 differs with server version {}'.format(__version__),
'status': 409}
-def test_version_invalid_input_schema(http_hypervisor):
+def test_version_invalid_input_schema(http_compute):
query = {'version': "0.4.2", "bla": "blu"}
- response = http_hypervisor.post('/version', query)
+ response = http_compute.post('/version', query)
assert response.status == 400
-def test_version_invalid_json(http_hypervisor):
+def test_version_invalid_json(http_compute):
query = "BOUM"
- response = http_hypervisor.post('/version', query, raw=True)
+ response = http_compute.post('/version', query, raw=True)
assert response.status == 400
diff --git a/tests/handlers/api/compute/test_virtualbox.py b/tests/handlers/api/compute/test_virtualbox.py
new file mode 100644
index 00000000..256398b6
--- /dev/null
+++ b/tests/handlers/api/compute/test_virtualbox.py
@@ -0,0 +1,133 @@
+# -*- 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 .
+
+import pytest
+from tests.utils import asyncio_patch
+from unittest.mock import patch
+
+
+@pytest.yield_fixture(scope="function")
+def vm(http_compute, project, monkeypatch):
+
+ vboxmanage_path = "/fake/VboxManage"
+
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.create", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms".format(project_id=project.id), {"name": "VMTEST",
+ "vmname": "VMTEST",
+ "linked_clone": False})
+ assert mock.called
+ assert response.status == 201
+
+ with patch("gns3server.compute.virtualbox.VirtualBox.find_vboxmanage", return_value=vboxmanage_path):
+ yield response.json
+
+
+def test_vbox_create(http_compute, project):
+
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.create", return_value=True):
+ response = http_compute.post("/projects/{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"
+ assert response.json["project_id"] == project.id
+
+
+def test_vbox_get(http_compute, project, vm):
+ response = http_compute.get("/projects/{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 == "/projects/{project_id}/virtualbox/vms/{vm_id}"
+ assert response.json["name"] == "VMTEST"
+ assert response.json["project_id"] == project.id
+
+
+def test_vbox_start(http_compute, vm):
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.check_hw_virtualization", return_value=True) as mock:
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.start", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ assert mock.called
+ assert response.status == 204
+
+
+def test_vbox_stop(http_compute, vm):
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.stop", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ assert mock.called
+ assert response.status == 204
+
+
+def test_vbox_suspend(http_compute, vm):
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.suspend", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ assert mock.called
+ assert response.status == 204
+
+
+def test_vbox_resume(http_compute, vm):
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.resume", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms/{vm_id}/resume".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ assert mock.called
+ assert response.status == 204
+
+
+def test_vbox_reload(http_compute, vm):
+ with asyncio_patch("gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.reload", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ assert mock.called
+ assert response.status == 204
+
+
+def test_vbox_nio_create_udp(http_compute, vm):
+
+ with asyncio_patch('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_add_nio_binding') as mock:
+ response = http_compute.post("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/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 mock.called
+ args, kwgars = mock.call_args
+ assert args[0] == 0
+
+ assert response.status == 201
+ assert response.route == "/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
+ assert response.json["type"] == "nio_udp"
+
+
+def test_vbox_delete_nio(http_compute, vm):
+
+ with asyncio_patch('gns3server.compute.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_remove_nio_binding') as mock:
+ response = http_compute.delete("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+
+ assert mock.called
+ args, kwgars = mock.call_args
+ assert args[0] == 0
+
+ assert response.status == 204
+ assert response.route == "/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
+
+
+def test_vbox_update(http_compute, vm, free_console_port):
+ response = http_compute.put("/projects/{project_id}/virtualbox/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
+ "console": free_console_port},
+ example=True)
+ assert response.status == 200
+ assert response.json["name"] == "test"
+ assert response.json["console"] == free_console_port
diff --git a/tests/handlers/api/hypervisor/test_vpcs.py b/tests/handlers/api/compute/test_vpcs.py
similarity index 53%
rename from tests/handlers/api/hypervisor/test_vpcs.py
rename to tests/handlers/api/compute/test_vpcs.py
index 64e97614..071a68de 100644
--- a/tests/handlers/api/hypervisor/test_vpcs.py
+++ b/tests/handlers/api/compute/test_vpcs.py
@@ -23,22 +23,22 @@ from unittest.mock import patch
@pytest.fixture(scope="function")
-def vm(http_hypervisor, project):
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1"})
+def vm(http_compute, project):
+ response = http_compute.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1"})
assert response.status == 201
return response.json
-def test_vpcs_create(http_hypervisor, project):
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1"}, example=True)
+def test_vpcs_create(http_compute, project):
+ response = http_compute.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1"}, example=True)
assert response.status == 201
assert response.route == "/projects/{project_id}/vpcs/vms"
assert response.json["name"] == "PC TEST 1"
assert response.json["project_id"] == project.id
-def test_vpcs_get(http_hypervisor, project, vm):
- response = http_hypervisor.get("/projects/{project_id}/vpcs/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_vpcs_get(http_compute, project, vm):
+ response = http_compute.get("/projects/{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 == "/projects/{project_id}/vpcs/vms/{vm_id}"
assert response.json["name"] == "PC TEST 1"
@@ -47,8 +47,8 @@ def test_vpcs_get(http_hypervisor, project, vm):
assert response.json["status"] == "stopped"
-def test_vpcs_create_startup_script(http_hypervisor, project):
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1", "startup_script": "ip 192.168.1.2\necho TEST"})
+def test_vpcs_create_startup_script(http_compute, project):
+ response = http_compute.post("/projects/{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 == "/projects/{project_id}/vpcs/vms"
assert response.json["name"] == "PC TEST 1"
@@ -57,8 +57,8 @@ def test_vpcs_create_startup_script(http_hypervisor, project):
assert response.json["startup_script_path"] == "startup.vpc"
-def test_vpcs_create_port(http_hypervisor, project, free_console_port):
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1", "console": free_console_port})
+def test_vpcs_create_port(http_compute, project, free_console_port):
+ response = http_compute.post("/projects/{project_id}/vpcs/vms".format(project_id=project.id), {"name": "PC TEST 1", "console": free_console_port})
assert response.status == 201
assert response.route == "/projects/{project_id}/vpcs/vms"
assert response.json["name"] == "PC TEST 1"
@@ -66,72 +66,72 @@ def test_vpcs_create_port(http_hypervisor, project, free_console_port):
assert response.json["console"] == free_console_port
-def test_vpcs_nio_create_udp(http_hypervisor, vm):
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/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)
+def test_vpcs_nio_create_udp(http_compute, vm):
+ response = http_compute.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/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 == "/projects/{project_id}/vpcs/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_udp"
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
-def test_vpcs_nio_create_tap(http_hypervisor, vm, ethernet_device):
- with patch("gns3server.hypervisor.base_manager.BaseManager.has_privileged_access", return_value=True):
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_tap",
- "tap_device": ethernet_device})
+def test_vpcs_nio_create_tap(http_compute, vm, ethernet_device):
+ with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
+ response = http_compute.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_tap",
+ "tap_device": ethernet_device})
assert response.status == 201
assert response.route == "/projects/{project_id}/vpcs/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
assert response.json["type"] == "nio_tap"
-def test_vpcs_delete_nio(http_hypervisor, vm):
- http_hypervisor.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/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 = http_hypervisor.delete("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_vpcs_delete_nio(http_compute, vm):
+ http_compute.post("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/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 = http_compute.delete("/projects/{project_id}/vpcs/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert response.status == 204
assert response.route == "/projects/{project_id}/vpcs/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
-def test_vpcs_start(http_hypervisor, vm):
+def test_vpcs_start(http_compute, vm):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM.start", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM.start", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/vpcs/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 200
assert response.json["name"] == "PC TEST 1"
-def test_vpcs_stop(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM.stop", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_vpcs_stop(http_compute, vm):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM.stop", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/vpcs/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_vpcs_reload(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.vpcs.vpcs_vm.VPCSVM.reload", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/vpcs/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_vpcs_reload(http_compute, vm):
+ with asyncio_patch("gns3server.compute.vpcs.vpcs_vm.VPCSVM.reload", return_value=True) as mock:
+ response = http_compute.post("/projects/{project_id}/vpcs/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_vpcs_delete(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.vpcs.VPCS.delete_vm", return_value=True) as mock:
- response = http_hypervisor.delete("/projects/{project_id}/vpcs/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
+def test_vpcs_delete(http_compute, vm):
+ with asyncio_patch("gns3server.compute.vpcs.VPCS.delete_vm", return_value=True) as mock:
+ response = http_compute.delete("/projects/{project_id}/vpcs/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
assert mock.called
assert response.status == 204
-def test_vpcs_update(http_hypervisor, vm, tmpdir, free_console_port):
- response = http_hypervisor.put("/projects/{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"},
- example=True)
+def test_vpcs_update(http_compute, vm, tmpdir, free_console_port):
+ response = http_compute.put("/projects/{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"},
+ example=True)
assert response.status == 200
assert response.json["name"] == "test"
assert response.json["console"] == free_console_port
diff --git a/tests/handlers/api/controller/test_hypervisor.py b/tests/handlers/api/controller/test_compute.py
similarity index 74%
rename from tests/handlers/api/controller/test_hypervisor.py
rename to tests/handlers/api/controller/test_compute.py
index 1f214d59..cfc786b3 100644
--- a/tests/handlers/api/controller/test_hypervisor.py
+++ b/tests/handlers/api/controller/test_compute.py
@@ -16,21 +16,21 @@
# along with this program. If not, see .
-def test_hypervisor_create(http_controller, controller):
+def test_compute_create(http_controller, controller):
params = {
- "hypervisor_id": "my_hypervisor_id",
+ "compute_id": "my_compute_id",
"protocol": "http",
"host": "example.com",
"port": 84,
"user": "julien",
"password": "secure"
}
- response = http_controller.post("/hypervisors", params, example=True)
+ response = http_controller.post("/computes", params, example=True)
assert response.status == 201
- assert response.route == "/hypervisors"
+ assert response.route == "/computes"
assert response.json["user"] == "julien"
assert "password" not in response.json
- assert len(controller.hypervisors) == 1
- assert controller.hypervisors["my_hypervisor_id"].host == "example.com"
+ assert len(controller.computes) == 1
+ assert controller.computes["my_compute_id"].host == "example.com"
diff --git a/tests/handlers/api/controller/test_vm.py b/tests/handlers/api/controller/test_vm.py
index 16bccb94..ead90f73 100644
--- a/tests/handlers/api/controller/test_vm.py
+++ b/tests/handlers/api/controller/test_vm.py
@@ -35,11 +35,11 @@ from gns3server.controller.vm import VM
@pytest.fixture
-def hypervisor(http_controller, async_run):
- hypervisor = MagicMock()
- hypervisor.id = "example.com"
- Controller.instance()._hypervisors = {"example.com": hypervisor}
- return hypervisor
+def compute(http_controller, async_run):
+ compute = MagicMock()
+ compute.id = "example.com"
+ Controller.instance()._computes = {"example.com": compute}
+ return compute
@pytest.fixture
@@ -48,21 +48,21 @@ def project(http_controller, async_run):
@pytest.fixture
-def vm(project, hypervisor, async_run):
- vm = VM(project, hypervisor, name="test", vm_type="vpcs")
+def vm(project, compute, async_run):
+ vm = VM(project, compute, name="test", vm_type="vpcs")
project._vms[vm.id] = vm
return vm
-def test_create_vm(http_controller, tmpdir, project, hypervisor):
+def test_create_vm(http_controller, tmpdir, project, compute):
response = MagicMock()
response.json = {"console": 2048}
- hypervisor.post = AsyncioMagicMock(return_value=response)
+ compute.post = AsyncioMagicMock(return_value=response)
response = http_controller.post("/projects/{}/vms".format(project.id), {
"name": "test",
"vm_type": "vpcs",
- "hypervisor_id": "example.com",
+ "compute_id": "example.com",
"properties": {
"startup_script": "echo test"
}
@@ -72,27 +72,27 @@ def test_create_vm(http_controller, tmpdir, project, hypervisor):
assert "name" not in response.json["properties"]
-def test_start_vm(http_controller, tmpdir, project, hypervisor, vm):
+def test_start_vm(http_controller, tmpdir, project, compute, vm):
response = MagicMock()
- hypervisor.post = AsyncioMagicMock()
+ compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/vms/{}/start".format(project.id, vm.id), example=True)
assert response.status == 201
assert response.json["name"] == vm.name
-def test_stop_vm(http_controller, tmpdir, project, hypervisor, vm):
+def test_stop_vm(http_controller, tmpdir, project, compute, vm):
response = MagicMock()
- hypervisor.post = AsyncioMagicMock()
+ compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/vms/{}/stop".format(project.id, vm.id), example=True)
assert response.status == 201
assert response.json["name"] == vm.name
-def test_suspend_vm(http_controller, tmpdir, project, hypervisor, vm):
+def test_suspend_vm(http_controller, tmpdir, project, compute, vm):
response = MagicMock()
- hypervisor.post = AsyncioMagicMock()
+ compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/vms/{}/suspend".format(project.id, vm.id), example=True)
assert response.status == 201
diff --git a/tests/handlers/api/hypervisor/test_docker.py b/tests/handlers/api/hypervisor/test_docker.py
deleted file mode 100644
index 6aeee271..00000000
--- a/tests/handlers/api/hypervisor/test_docker.py
+++ /dev/null
@@ -1,185 +0,0 @@
-# -*- 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 .
-
-import pytest
-import os
-import stat
-import sys
-import uuid
-import aiohttp
-
-from tests.utils import asyncio_patch
-from unittest.mock import patch, MagicMock, PropertyMock
-from gns3server.hypervisor.docker import Docker
-
-
-@pytest.fixture
-def base_params():
- """Return standard parameters"""
- return {"name": "PC TEST 1", "image": "nginx", "start_command": "nginx-daemon", "adapters": 2, "environment": "YES=1\nNO=0", "console_type": "telnet", "console_resolution": "1280x1024"}
-
-
-@pytest.yield_fixture(autouse=True)
-def mock_connection():
- docker = Docker.instance()
- docker._connected = True
- docker._connector = MagicMock()
- yield
- Docker._instance = None
-
-
-@pytest.fixture
-def vm(http_hypervisor, project, base_params):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "nginx"}]) as mock_list:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value={"Id": "8bd8153ea8f5"}) as mock:
- response = http_hypervisor.post("/projects/{project_id}/docker/vms".format(project_id=project.id), base_params)
- if response.status != 201:
- print(response.body)
- assert response.status == 201
- return response.json
-
-
-def test_docker_create(http_hypervisor, project, base_params):
- with asyncio_patch("gns3server.hypervisor.docker.Docker.list_images", return_value=[{"image": "nginx"}]) as mock_list:
- with asyncio_patch("gns3server.hypervisor.docker.Docker.query", return_value={"Id": "8bd8153ea8f5"}) as mock:
- response = http_hypervisor.post("/projects/{project_id}/docker/vms".format(project_id=project.id), base_params)
- assert response.status == 201
- assert response.route == "/projects/{project_id}/docker/vms"
- assert response.json["name"] == "PC TEST 1"
- assert response.json["project_id"] == project.id
- assert response.json["container_id"] == "8bd8153ea8f5"
- assert response.json["image"] == "nginx"
- assert response.json["adapters"] == 2
- assert response.json["environment"] == "YES=1\nNO=0"
- assert response.json["console_resolution"] == "1280x1024"
-
-
-def test_docker_start(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.start", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
- assert mock.called
- assert response.status == 204
-
-
-def test_docker_stop(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.stop", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
- assert mock.called
- assert response.status == 204
-
-
-def test_docker_reload(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.restart", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
- assert mock.called
- assert response.status == 204
-
-
-def test_docker_delete(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.delete", return_value=True) as mock:
- response = http_hypervisor.delete("/projects/{project_id}/docker/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
- assert mock.called
- assert response.status == 204
-
-
-def test_docker_reload(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.pause", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
- assert mock.called
- assert response.status == 204
-
-
-def test_docker_nio_create_udp(http_hypervisor, vm):
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/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 == "/projects/{project_id}/docker/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
- assert response.json["type"] == "nio_udp"
-
-
-def test_docker_delete_nio(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.adapter_remove_nio_binding") as mock:
- response = http_hypervisor.delete("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
- assert response.status == 204
- assert response.route == "/projects/{project_id}/docker/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
-
-
-def test_docker_update(http_hypervisor, vm, tmpdir, free_console_port):
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.update") as mock:
- response = http_hypervisor.put("/projects/{project_id}/docker/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
- "console": free_console_port,
- "start_command": "yes",
- "environment": "GNS3=1\nGNS4=0"},
- example=True)
- assert mock.called
- assert response.status == 200
- assert response.json["name"] == "test"
- assert response.json["console"] == free_console_port
- assert response.json["start_command"] == "yes"
- assert response.json["environment"] == "GNS3=1\nGNS4=0"
-
-
-def test_docker_start_capture(http_hypervisor, vm, tmpdir, project):
-
- with patch("gns3server.hypervisor.docker.docker_vm.DockerVM.is_running", return_value=True) as mock:
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.start_capture") as start_capture:
-
- params = {"capture_file_name": "test.pcap", "data_link_type": "DLT_EN10MB"}
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params, example=True)
-
- assert response.status == 200
-
- assert start_capture.called
- assert "test.pcap" in response.json["pcap_file_path"]
-
-
-def test_docker_start_capture_not_started(http_hypervisor, vm, tmpdir):
-
- with patch("gns3server.hypervisor.docker.docker_vm.DockerVM.is_running", return_value=False) as mock:
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.start_capture") as start_capture:
-
- params = {"capture_file_name": "test.pcap", "data_link_type": "DLT_EN10MB"}
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/start_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), body=params)
-
- assert not start_capture.called
- assert response.status == 409
-
-
-def test_docker_stop_capture(http_hypervisor, vm, tmpdir, project):
-
- with patch("gns3server.hypervisor.docker.docker_vm.DockerVM.is_running", return_value=True) as mock:
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.stop_capture") as stop_capture:
-
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
-
- assert response.status == 204
-
- assert stop_capture.called
-
-
-def test_docker_stop_capture_not_started(http_hypervisor, vm, tmpdir):
-
- with patch("gns3server.hypervisor.docker.docker_vm.DockerVM.is_running", return_value=False) as mock:
- with asyncio_patch("gns3server.hypervisor.docker.docker_vm.DockerVM.stop_capture") as stop_capture:
-
- response = http_hypervisor.post("/projects/{project_id}/docker/vms/{vm_id}/adapters/0/ports/0/stop_capture".format(project_id=vm["project_id"], vm_id=vm["vm_id"]))
-
- assert not stop_capture.called
- assert response.status == 409
diff --git a/tests/handlers/api/hypervisor/test_virtualbox.py b/tests/handlers/api/hypervisor/test_virtualbox.py
deleted file mode 100644
index 1c931c9f..00000000
--- a/tests/handlers/api/hypervisor/test_virtualbox.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# -*- 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 .
-
-import pytest
-from tests.utils import asyncio_patch
-from unittest.mock import patch
-
-
-@pytest.yield_fixture(scope="function")
-def vm(http_hypervisor, project, monkeypatch):
-
- vboxmanage_path = "/fake/VboxManage"
-
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.create", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms".format(project_id=project.id), {"name": "VMTEST",
- "vmname": "VMTEST",
- "linked_clone": False})
- assert mock.called
- assert response.status == 201
-
- with patch("gns3server.hypervisor.virtualbox.VirtualBox.find_vboxmanage", return_value=vboxmanage_path):
- yield response.json
-
-
-def test_vbox_create(http_hypervisor, project):
-
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.create", return_value=True):
- response = http_hypervisor.post("/projects/{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"
- assert response.json["project_id"] == project.id
-
-
-def test_vbox_get(http_hypervisor, project, vm):
- response = http_hypervisor.get("/projects/{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 == "/projects/{project_id}/virtualbox/vms/{vm_id}"
- assert response.json["name"] == "VMTEST"
- assert response.json["project_id"] == project.id
-
-
-def test_vbox_start(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.check_hw_virtualization", return_value=True) as mock:
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.start", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/start".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
- assert mock.called
- assert response.status == 204
-
-
-def test_vbox_stop(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.stop", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/stop".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
- assert mock.called
- assert response.status == 204
-
-
-def test_vbox_suspend(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.suspend", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/suspend".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
- assert mock.called
- assert response.status == 204
-
-
-def test_vbox_resume(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.resume", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/resume".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
- assert mock.called
- assert response.status == 204
-
-
-def test_vbox_reload(http_hypervisor, vm):
- with asyncio_patch("gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.reload", return_value=True) as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/reload".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
- assert mock.called
- assert response.status == 204
-
-
-def test_vbox_nio_create_udp(http_hypervisor, vm):
-
- with asyncio_patch('gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_add_nio_binding') as mock:
- response = http_hypervisor.post("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/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 mock.called
- args, kwgars = mock.call_args
- assert args[0] == 0
-
- assert response.status == 201
- assert response.route == "/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
- assert response.json["type"] == "nio_udp"
-
-
-def test_vbox_delete_nio(http_hypervisor, vm):
-
- with asyncio_patch('gns3server.hypervisor.virtualbox.virtualbox_vm.VirtualBoxVM.adapter_remove_nio_binding') as mock:
- response = http_hypervisor.delete("/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/0/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), example=True)
-
- assert mock.called
- args, kwgars = mock.call_args
- assert args[0] == 0
-
- assert response.status == 204
- assert response.route == "/projects/{project_id}/virtualbox/vms/{vm_id}/adapters/{adapter_number:\d+}/ports/{port_number:\d+}/nio"
-
-
-def test_vbox_update(http_hypervisor, vm, free_console_port):
- response = http_hypervisor.put("/projects/{project_id}/virtualbox/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"name": "test",
- "console": free_console_port},
- example=True)
- assert response.status == 200
- assert response.json["name"] == "test"
- assert response.json["console"] == free_console_port
diff --git a/tests/handlers/test_index.py b/tests/handlers/test_index.py
index 26515f33..eaa7f22a 100644
--- a/tests/handlers/test_index.py
+++ b/tests/handlers/test_index.py
@@ -39,8 +39,8 @@ def test_controller(http_root, async_run):
assert response.status == 200
-def test_hypervisor(http_root):
- response = http_root.get('/hypervisor')
+def test_compute(http_root):
+ response = http_root.get('/compute')
assert response.status == 200
diff --git a/tests/web/test_documentation.py b/tests/web/test_documentation.py
index 7011aae4..bb764144 100644
--- a/tests/web/test_documentation.py
+++ b/tests/web/test_documentation.py
@@ -24,19 +24,19 @@ from gns3server.web.route import Route
def test_documentation_write(tmpdir):
os.makedirs(str(tmpdir / "api/examples"))
- with open(str(tmpdir / "api/examples/hypervisor_post_projectsprojectidvirtualboxvms.txt"), "w+") as f:
+ with open(str(tmpdir / "api/examples/compute_post_projectsprojectidvirtualboxvms.txt"), "w+") as f:
f.write("curl test")
Documentation(Route, str(tmpdir)).write()
assert os.path.exists(str(tmpdir / "api"))
- assert os.path.exists(str(tmpdir / "api" / "v2" / "hypervisor"))
- assert os.path.exists(str(tmpdir / "api" / "v2" / "hypervisor" / "virtualbox.rst"))
- assert os.path.exists(str(tmpdir / "api" / "v2" / "hypervisor" / "virtualbox"))
- assert os.path.exists(str(tmpdir / "api" / "v2" / "hypervisor" / "virtualbox" / "virtualboxvms.rst"))
- with open(str(tmpdir / "api" / "v2" / "hypervisor" / "virtualbox" / "projectsprojectidvirtualboxvms.rst")) as f:
+ assert os.path.exists(str(tmpdir / "api" / "v2" / "compute"))
+ assert os.path.exists(str(tmpdir / "api" / "v2" / "compute" / "virtualbox.rst"))
+ assert os.path.exists(str(tmpdir / "api" / "v2" / "compute" / "virtualbox"))
+ assert os.path.exists(str(tmpdir / "api" / "v2" / "compute" / "virtualbox" / "virtualboxvms.rst"))
+ with open(str(tmpdir / "api" / "v2" / "compute" / "virtualbox" / "projectsprojectidvirtualboxvms.rst")) as f:
content = f.read()
assert "Sample session" in content
- assert "literalinclude:: ../../../examples/hypervisor_post_projectsprojectidvirtualboxvms.txt" in content
+ assert "literalinclude:: ../../../examples/compute_post_projectsprojectidvirtualboxvms.txt" in content
- assert os.path.exists(str(tmpdir / "api" / "v2" / "controller" / "hypervisor.rst"))
+ assert os.path.exists(str(tmpdir / "api" / "v2" / "controller" / "compute.rst"))