mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
If not script file is setted we use the default from VPCS
This commit is contained in:
parent
4b62d4d82c
commit
8bc26420b7
@ -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:
|
||||
return 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()
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user