Create VPCS VM on controller

This commit is contained in:
Julien Duponchelle committed 2016-03-11 15:06:14 +01:00
1 parent 4326d412f9
commit be4aa41dda
13 files changed
+76 -34

No files matched your search

+1 -1
View File
@@ -79,7 +79,7 @@ def test_addProject_with_hypervisor(controller, async_run):
hypervisor = Hypervisor("test1")
hypervisor.post = MagicMock()
controller._hypervisors = {"test1": hypervisor }
controller._hypervisors = {"test1": hypervisor}
project1 = async_run(controller.addProject(project_id=uuid1))
hypervisor.post.assert_called_with("/projects", project1)
+10
View File
@@ -18,6 +18,7 @@
import pytest
import json
import aiohttp
from unittest.mock import patch, MagicMock
from gns3server.controller.project import Project
@@ -58,6 +59,15 @@ def test_hypervisor_httpQuery(hypervisor, async_run):
mock.assert_called_with("POST", "https://example.com:84/v2/hypervisor/projects", data='{"a": "b"}', headers={'content-type': 'application/json'})
def test_hypervisor_httpQueryError(hypervisor, async_run):
response = MagicMock()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
response.status = 409
with pytest.raises(aiohttp.errors.HttpProcessingError):
async_run(hypervisor.post("/projects", {"a": "b"}))
def test_hypervisor_httpQuery_project(hypervisor, async_run):
response = MagicMock()
with asyncio_patch("aiohttp.ClientSession.request", return_value=response) as mock:
+7 -2
View File
@@ -38,5 +38,10 @@ def test_json(tmpdir):
def test_addVM(async_run):
hypervisor = MagicMock()
project = Project()
vm = async_run(project.addVM(hypervisor, None, name="test", vm_type="vpcs", startup_config="test.cfg"))
hypervisor.post.assert_called_with('/projects/{}/vpcs/vms'.format(project.id), data={'console': None, 'vm_id': vm.id, 'console_type': 'telnet', 'startup_config': 'test.cfg'})
vm = async_run(project.addVM(hypervisor, None, name="test", vm_type="vpcs", properties= {"startup_config": "test.cfg"}))
hypervisor.post.assert_called_with('/projects/{}/vpcs/vms'.format(project.id),
data={'console': None,
'vm_id': vm.id,
'console_type': 'telnet',
'startup_config': 'test.cfg',
'name': 'test'})
+6 -2
View File
@@ -38,13 +38,15 @@ def vm(hypervisor):
name="demo",
vm_id=str(uuid.uuid4()),
vm_type="vpcs",
console_type="vnc")
console_type="vnc",
properties={"startup_script": "echo test"})
return vm
def test_json(vm, hypervisor):
assert vm.__json__() == {
"hypervisor_id": hypervisor.id,
"project_id": vm.project.id,
"vm_id": vm.id,
"vm_type": vm.vm_type,
"name": "demo",
@@ -66,6 +68,8 @@ def test_create(vm, hypervisor, project, async_run):
data = {
"console": None,
"console_type": "vnc",
"vm_id": vm.id
"vm_id": vm.id,
"startup_script": "echo test",
"name": "demo"
}
hypervisor.post.assert_called_with("/projects/{}/vpcs/vms".format(vm.project.id), data=data)