mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
parent
d16a389d1f
commit
7efb7c2978
@ -952,8 +952,13 @@ class IOUVM(BaseVM):
|
||||
|
||||
try:
|
||||
script_file = os.path.join(self.working_dir, "initial-config.cfg")
|
||||
|
||||
# We disallow erasing the initial config file
|
||||
if len(initial_config) == 0 and os.path.exists(script_file):
|
||||
return
|
||||
|
||||
with open(script_file, 'w+') as f:
|
||||
if initial_config is None:
|
||||
if len(initial_config) == 0:
|
||||
f.write('')
|
||||
else:
|
||||
initial_config = initial_config.replace("%h", self._name)
|
||||
|
@ -265,6 +265,18 @@ def test_update_initial_config(vm):
|
||||
assert f.read() == content
|
||||
|
||||
|
||||
def test_update_initial_config_empty(vm):
|
||||
content = "service timestamps debug datetime msec\nservice timestamps log datetime msec\nno service password-encryption"
|
||||
vm.initial_config = content
|
||||
filepath = os.path.join(vm.working_dir, "initial-config.cfg")
|
||||
assert os.path.exists(filepath)
|
||||
with open(filepath) as f:
|
||||
assert f.read() == content
|
||||
vm.initial_config = ""
|
||||
with open(filepath) as f:
|
||||
assert f.read() == content
|
||||
|
||||
|
||||
def test_update_initial_config_h(vm):
|
||||
content = "hostname %h\n"
|
||||
vm.name = "pc1"
|
||||
|
Loading…
Reference in New Issue
Block a user