2013-12-22 00:42:33 +00:00
|
|
|
from gns3server.modules.dynamips import HypervisorManager
|
|
|
|
import pytest
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def hypervisor(request):
|
|
|
|
|
2014-08-08 13:32:32 +00:00
|
|
|
dynamips_path = '/usr/bin/dynamips'
|
2013-12-22 00:42:33 +00:00
|
|
|
print("\nStarting Dynamips Hypervisor: {}".format(dynamips_path))
|
2014-08-08 13:32:32 +00:00
|
|
|
manager = HypervisorManager(dynamips_path, "/tmp", "127.0.0.1")
|
2013-12-22 00:42:33 +00:00
|
|
|
hypervisor = manager.start_new_hypervisor()
|
|
|
|
|
|
|
|
def stop():
|
|
|
|
print("\nStopping Dynamips Hypervisor")
|
|
|
|
manager.stop_all_hypervisors()
|
|
|
|
|
|
|
|
request.addfinalizer(stop)
|
|
|
|
return hypervisor
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def image(request):
|
|
|
|
|
|
|
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
image_path = os.path.join(cwd, "c3725.image")
|
2014-04-11 20:48:30 +00:00
|
|
|
if not os.path.isfile(image_path):
|
2013-12-22 00:42:33 +00:00
|
|
|
return None
|
|
|
|
return image_path
|