mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
parent
d16a389d1f
commit
7efb7c2978
@ -952,8 +952,13 @@ class IOUVM(BaseVM):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
script_file = os.path.join(self.working_dir, "initial-config.cfg")
|
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:
|
with open(script_file, 'w+') as f:
|
||||||
if initial_config is None:
|
if len(initial_config) == 0:
|
||||||
f.write('')
|
f.write('')
|
||||||
else:
|
else:
|
||||||
initial_config = initial_config.replace("%h", self._name)
|
initial_config = initial_config.replace("%h", self._name)
|
||||||
|
@ -265,6 +265,18 @@ def test_update_initial_config(vm):
|
|||||||
assert f.read() == content
|
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):
|
def test_update_initial_config_h(vm):
|
||||||
content = "hostname %h\n"
|
content = "hostname %h\n"
|
||||||
vm.name = "pc1"
|
vm.name = "pc1"
|
||||||
|
Loading…
Reference in New Issue
Block a user