Explicit ID names, remove {uuid} from URLs and add vms in URLs for VMs.

This commit is contained in:
Jeremy committed 2015-02-04 13:48:29 -07:00
1 parent 568e203580
commit 1bea78194c
22 files changed
+336 -344

No files matched your search

+8 -8
View File
@@ -42,18 +42,18 @@ def vm(project, manager):
def test_affect_uuid():
p = Project()
assert len(p.uuid) == 36
assert len(p.id) == 36
p = Project(uuid='00010203-0405-0607-0809-0a0b0c0d0e0f')
assert p.uuid == '00010203-0405-0607-0809-0a0b0c0d0e0f'
p = Project(project_id='00010203-0405-0607-0809-0a0b0c0d0e0f')
assert p.id == '00010203-0405-0607-0809-0a0b0c0d0e0f'
def test_path(tmpdir):
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
p = Project(location=str(tmpdir))
assert p.path == os.path.join(str(tmpdir), p.uuid)
assert os.path.exists(os.path.join(str(tmpdir), p.uuid))
assert os.path.exists(os.path.join(str(tmpdir), p.uuid, 'vms'))
assert p.path == os.path.join(str(tmpdir), p.id)
assert os.path.exists(os.path.join(str(tmpdir), p.id))
assert os.path.exists(os.path.join(str(tmpdir), p.id, 'vms'))
assert not os.path.exists(os.path.join(p.path, '.gns3_temporary'))
@@ -79,14 +79,14 @@ def test_changing_location_not_allowed(tmpdir):
def test_json(tmpdir):
p = Project()
assert p.__json__() == {"location": p.location, "project_id": p.uuid, "temporary": False}
assert p.__json__() == {"location": p.location, "project_id": p.id, "temporary": False}
def test_vm_working_directory(tmpdir, vm):
with patch("gns3server.config.Config.get_section_config", return_value={"local": True}):
p = Project(location=str(tmpdir))
assert os.path.exists(p.vm_working_directory(vm))
assert os.path.exists(os.path.join(str(tmpdir), p.uuid, vm.module_name, vm.uuid))
assert os.path.exists(os.path.join(str(tmpdir), p.id, vm.module_name, vm.id))
def test_mark_vm_for_destruction(vm):
+1 -1
View File
@@ -22,7 +22,7 @@ from gns3server.modules.project_manager import ProjectManager
def test_create_project():
pm = ProjectManager.instance()
project = pm.create_project(uuid='00010203-0405-0607-0809-0a0b0c0d0e0f')
project = pm.create_project(project_id='00010203-0405-0607-0809-0a0b0c0d0e0f')
assert project == pm.get_project('00010203-0405-0607-0809-0a0b0c0d0e0f')
@@ -39,7 +39,7 @@ def vm(project, manager):
def test_vm(project, manager):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
assert vm.name == "test"
assert vm.uuid == "00010203-0405-0607-0809-0a0b0c0d0e0f"
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
assert vm.vmname == "test"
+23 -23
View File
@@ -30,17 +30,17 @@ def test_get_mac_id(loop, project, port_manager):
VPCS._instance = None
vpcs = VPCS.instance()
vpcs.port_manager = port_manager
vm1_uuid = str(uuid.uuid4())
vm2_uuid = str(uuid.uuid4())
vm3_uuid = str(uuid.uuid4())
loop.run_until_complete(vpcs.create_vm("PC 1", project.uuid, vm1_uuid))
loop.run_until_complete(vpcs.create_vm("PC 2", project.uuid, vm2_uuid))
assert vpcs.get_mac_id(vm1_uuid) == 0
assert vpcs.get_mac_id(vm1_uuid) == 0
assert vpcs.get_mac_id(vm2_uuid) == 1
loop.run_until_complete(vpcs.delete_vm(vm1_uuid))
loop.run_until_complete(vpcs.create_vm("PC 3", project.uuid, vm3_uuid))
assert vpcs.get_mac_id(vm3_uuid) == 0
vm1_id = str(uuid.uuid4())
vm2_id = str(uuid.uuid4())
vm3_id = str(uuid.uuid4())
loop.run_until_complete(vpcs.create_vm("PC 1", project.id, vm1_id))
loop.run_until_complete(vpcs.create_vm("PC 2", project.id, vm2_id))
assert vpcs.get_mac_id(vm1_id) == 0
assert vpcs.get_mac_id(vm1_id) == 0
assert vpcs.get_mac_id(vm2_id) == 1
loop.run_until_complete(vpcs.delete_vm(vm1_id))
loop.run_until_complete(vpcs.create_vm("PC 3", project.id, vm3_id))
assert vpcs.get_mac_id(vm3_id) == 0
def test_get_mac_id_multiple_project(loop, port_manager):
@@ -48,17 +48,17 @@ def test_get_mac_id_multiple_project(loop, port_manager):
VPCS._instance = None
vpcs = VPCS.instance()
vpcs.port_manager = port_manager
vm1_uuid = str(uuid.uuid4())
vm2_uuid = str(uuid.uuid4())
vm3_uuid = str(uuid.uuid4())
vm1_id = str(uuid.uuid4())
vm2_id = str(uuid.uuid4())
vm3_id = str(uuid.uuid4())
project1 = ProjectManager.instance().create_project()
project2 = ProjectManager.instance().create_project()
loop.run_until_complete(vpcs.create_vm("PC 1", project1.uuid, vm1_uuid))
loop.run_until_complete(vpcs.create_vm("PC 2", project1.uuid, vm2_uuid))
loop.run_until_complete(vpcs.create_vm("PC 2", project2.uuid, vm3_uuid))
assert vpcs.get_mac_id(vm1_uuid) == 0
assert vpcs.get_mac_id(vm2_uuid) == 1
assert vpcs.get_mac_id(vm3_uuid) == 0
loop.run_until_complete(vpcs.create_vm("PC 1", project1.id, vm1_id))
loop.run_until_complete(vpcs.create_vm("PC 2", project1.id, vm2_id))
loop.run_until_complete(vpcs.create_vm("PC 2", project2.id, vm3_id))
assert vpcs.get_mac_id(vm1_id) == 0
assert vpcs.get_mac_id(vm2_id) == 1
assert vpcs.get_mac_id(vm3_id) == 0
def test_get_mac_id_no_id_available(loop, project, port_manager):
@@ -68,6 +68,6 @@ def test_get_mac_id_no_id_available(loop, project, port_manager):
vpcs.port_manager = port_manager
with pytest.raises(VPCSError):
for i in range(0, 256):
vm_uuid = str(uuid.uuid4())
loop.run_until_complete(vpcs.create_vm("PC {}".format(i), project.uuid, vm_uuid))
assert vpcs.get_mac_id(vm_uuid) == i
vm_id = str(uuid.uuid4())
loop.run_until_complete(vpcs.create_vm("PC {}".format(i), project.id, vm_id))
assert vpcs.get_mac_id(vm_id) == i
+3 -3
View File
@@ -43,7 +43,7 @@ def vm(project, manager):
def test_vm(project, manager):
vm = VPCSVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager)
assert vm.name == "test"
assert vm.uuid == "00010203-0405-0607-0809-0a0b0c0d0e0f"
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
def test_vm_invalid_vpcs_version(loop, project, manager):
@@ -54,7 +54,7 @@ def test_vm_invalid_vpcs_version(loop, project, manager):
vm.port_add_nio_binding(0, nio)
loop.run_until_complete(asyncio.async(vm.start()))
assert vm.name == "test"
assert vm.uuid == "00010203-0405-0607-0809-0a0b0c0d0e0f"
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0f"
@patch("gns3server.config.Config.get_section_config", return_value={"vpcs_path": "/bin/test_fake"})
@@ -65,7 +65,7 @@ def test_vm_invalid_vpcs_path(project, manager, loop):
vm.port_add_nio_binding(0, nio)
loop.run_until_complete(asyncio.async(vm.start()))
assert vm.name == "test"
assert vm.uuid == "00010203-0405-0607-0809-0a0b0c0d0e0e"
assert vm.id == "00010203-0405-0607-0809-0a0b0c0d0e0e"
def test_start(loop, vm):