1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

If not script file is setted we use the default from VPCS

This commit is contained in:
Julien Duponchelle 2015-01-30 14:57:25 +01:00
parent 4b62d4d82c
commit 8bc26420b7
2 changed files with 22 additions and 1 deletions

View File

@ -165,8 +165,15 @@ class VPCSVM(BaseVM):
@property
def startup_script(self):
"""Return the content of the current startup script"""
if self._script_file is None:
# If the default VPCS file exist we use it
path = os.path.join(self.working_dir, 'startup.vpc')
if os.path.exists(path):
self._script_file = path
else:
return None
try:
with open(self._script_file) as f:
return f.read()

View File

@ -155,6 +155,20 @@ def test_get_startup_script(vm):
assert vm.startup_script == content
def test_get_startup_script_using_default_script(vm):
content = "echo GNS3 VPCS\nip 192.168.1.2\n"
# Reset script file location
vm.script_file = None
filepath = os.path.join(vm.working_dir, 'startup.vpc')
with open(filepath, 'w+') as f:
assert f.write(content)
assert vm.startup_script == content
assert vm.script_file == filepath
def test_change_console_port(vm, port_manager):
port1 = port_manager.get_free_console_port()
port2 = port_manager.get_free_console_port()