mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
IOU: rename startup-config to initial-config because it makes more sense.
This commit is contained in:
parent
cb763e0926
commit
587ddf7646
@ -356,7 +356,7 @@ class IOU(IModule):
|
|||||||
|
|
||||||
Optional request parameters:
|
Optional request parameters:
|
||||||
- any setting to update
|
- any setting to update
|
||||||
- startup_config_base64 (startup-config base64 encoded)
|
- initial_config_base64 (initial-config base64 encoded)
|
||||||
|
|
||||||
Response parameters:
|
Response parameters:
|
||||||
- updated settings
|
- updated settings
|
||||||
@ -373,36 +373,36 @@ class IOU(IModule):
|
|||||||
if not iou_instance:
|
if not iou_instance:
|
||||||
return
|
return
|
||||||
|
|
||||||
config_path = os.path.join(iou_instance.working_dir, "startup-config")
|
config_path = os.path.join(iou_instance.working_dir, "initial-config")
|
||||||
try:
|
try:
|
||||||
if "startup_config_base64" in request:
|
if "initial_config_base64" in request:
|
||||||
# a new startup-config has been pushed
|
# a new initial-config has been pushed
|
||||||
config = base64.decodebytes(request["startup_config_base64"].encode("utf-8")).decode("utf-8")
|
config = base64.decodebytes(request["initial_config_base64"].encode("utf-8")).decode("utf-8")
|
||||||
config = "!\n" + config.replace("\r", "")
|
config = "!\n" + config.replace("\r", "")
|
||||||
config = config.replace('%h', iou_instance.name)
|
config = config.replace('%h', iou_instance.name)
|
||||||
try:
|
try:
|
||||||
with open(config_path, "w") as f:
|
with open(config_path, "w") as f:
|
||||||
log.info("saving startup-config to {}".format(config_path))
|
log.info("saving initial-config to {}".format(config_path))
|
||||||
f.write(config)
|
f.write(config)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise IOUError("Could not save the configuration {}: {}".format(config_path, e))
|
raise IOUError("Could not save the configuration {}: {}".format(config_path, e))
|
||||||
# update the request with the new local startup-config path
|
# update the request with the new local initial-config path
|
||||||
request["startup_config"] = os.path.basename(config_path)
|
request["initial_config"] = os.path.basename(config_path)
|
||||||
elif "startup_config" in request:
|
elif "initial_config" in request:
|
||||||
if os.path.isfile(request["startup_config"]) and request["startup_config"] != config_path:
|
if os.path.isfile(request["initial_config"]) and request["initial_config"] != config_path:
|
||||||
# this is a local file set in the GUI
|
# this is a local file set in the GUI
|
||||||
try:
|
try:
|
||||||
with open(request["startup_config"], "r", errors="replace") as f:
|
with open(request["initial_config"], "r", errors="replace") as f:
|
||||||
config = f.read()
|
config = f.read()
|
||||||
with open(config_path, "w") as f:
|
with open(config_path, "w") as f:
|
||||||
config = "!\n" + config.replace("\r", "")
|
config = "!\n" + config.replace("\r", "")
|
||||||
config = config.replace('%h', iou_instance.name)
|
config = config.replace('%h', iou_instance.name)
|
||||||
f.write(config)
|
f.write(config)
|
||||||
request["startup_config"] = os.path.basename(config_path)
|
request["initial_config"] = os.path.basename(config_path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise IOUError("Could not save the configuration from {} to {}: {}".format(request["startup_config"], config_path, e))
|
raise IOUError("Could not save the configuration from {} to {}: {}".format(request["initial_config"], config_path, e))
|
||||||
elif not os.path.isfile(config_path):
|
elif not os.path.isfile(config_path):
|
||||||
raise IOUError("Startup-config {} could not be found on this server".format(request["startup_config"]))
|
raise IOUError("Startup-config {} could not be found on this server".format(request["initial_config"]))
|
||||||
except IOUError as e:
|
except IOUError as e:
|
||||||
self.send_custom_error(str(e))
|
self.send_custom_error(str(e))
|
||||||
return
|
return
|
||||||
|
@ -110,7 +110,7 @@ class IOUDevice(object):
|
|||||||
self._slots = self._ethernet_adapters + self._serial_adapters
|
self._slots = self._ethernet_adapters + self._serial_adapters
|
||||||
self._use_default_iou_values = True # for RAM & NVRAM values
|
self._use_default_iou_values = True # for RAM & NVRAM values
|
||||||
self._nvram = 128 # Kilobytes
|
self._nvram = 128 # Kilobytes
|
||||||
self._startup_config = ""
|
self._initial_config = ""
|
||||||
self._ram = 256 # Megabytes
|
self._ram = 256 # Megabytes
|
||||||
self._l1_keepalives = False # used to overcome the always-up Ethernet interfaces (not supported by all IOSes).
|
self._l1_keepalives = False # used to overcome the always-up Ethernet interfaces (not supported by all IOSes).
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
iou_defaults = {"name": self._name,
|
iou_defaults = {"name": self._name,
|
||||||
"path": self._path,
|
"path": self._path,
|
||||||
"startup_config": self._startup_config,
|
"intial_config": self._initial_config,
|
||||||
"use_default_iou_values": self._use_default_iou_values,
|
"use_default_iou_values": self._use_default_iou_values,
|
||||||
"ram": self._ram,
|
"ram": self._ram,
|
||||||
"nvram": self._nvram,
|
"nvram": self._nvram,
|
||||||
@ -208,9 +208,9 @@ class IOUDevice(object):
|
|||||||
new_working_dir,
|
new_working_dir,
|
||||||
e))
|
e))
|
||||||
|
|
||||||
if self._startup_config:
|
if self._intial_config:
|
||||||
# update the startup-config
|
# update the initial-config
|
||||||
config_path = os.path.join(self._working_dir, "startup-config")
|
config_path = os.path.join(self._working_dir, "initial-config")
|
||||||
if os.path.isfile(config_path):
|
if os.path.isfile(config_path):
|
||||||
try:
|
try:
|
||||||
with open(config_path, "r+", errors="replace") as f:
|
with open(config_path, "r+", errors="replace") as f:
|
||||||
@ -379,7 +379,7 @@ class IOUDevice(object):
|
|||||||
|
|
||||||
def clean_delete(self):
|
def clean_delete(self):
|
||||||
"""
|
"""
|
||||||
Deletes this IOU device & all files (nvram, startup-config etc.)
|
Deletes this IOU device & all files (nvram, initial-config etc.)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
@ -799,8 +799,8 @@ class IOUDevice(object):
|
|||||||
command.extend(["-n", str(self._nvram)])
|
command.extend(["-n", str(self._nvram)])
|
||||||
command.extend(["-m", str(self._ram)])
|
command.extend(["-m", str(self._ram)])
|
||||||
command.extend(["-L"]) # disable local console, use remote console
|
command.extend(["-L"]) # disable local console, use remote console
|
||||||
if self._startup_config:
|
if self._initial_config:
|
||||||
command.extend(["-c", self._startup_config])
|
command.extend(["-c", self._initial_config])
|
||||||
if self._l1_keepalives:
|
if self._l1_keepalives:
|
||||||
self._enable_l1_keepalives(command)
|
self._enable_l1_keepalives(command)
|
||||||
command.extend([str(self._id)])
|
command.extend([str(self._id)])
|
||||||
@ -910,27 +910,27 @@ class IOUDevice(object):
|
|||||||
self._nvram = nvram
|
self._nvram = nvram
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def startup_config(self):
|
def initial_config(self):
|
||||||
"""
|
"""
|
||||||
Returns the startup-config for this IOU instance.
|
Returns the initial-config for this IOU instance.
|
||||||
|
|
||||||
:returns: path to startup-config file
|
:returns: path to initial-config file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self._startup_config
|
return self._initial_config
|
||||||
|
|
||||||
@startup_config.setter
|
@initial_config.setter
|
||||||
def startup_config(self, startup_config):
|
def initial_config(self, initial_config):
|
||||||
"""
|
"""
|
||||||
Sets the startup-config for this IOU instance.
|
Sets the initial-config for this IOU instance.
|
||||||
|
|
||||||
:param startup_config: path to startup-config file
|
:param initial_config: path to initial-config file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self._startup_config = startup_config
|
self._initial_config = initial_config
|
||||||
log.info("IOU {name} [id={id}]: startup_config set to {config}".format(name=self._name,
|
log.info("IOU {name} [id={id}]: initial_config set to {config}".format(name=self._name,
|
||||||
id=self._id,
|
id=self._id,
|
||||||
config=self._startup_config))
|
config=self._initial_config))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ethernet_adapters(self):
|
def ethernet_adapters(self):
|
||||||
|
@ -79,8 +79,8 @@ IOU_UPDATE_SCHEMA = {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
"startup_config": {
|
"initial_config": {
|
||||||
"description": "path to the IOU startup configuration file",
|
"description": "path to the IOU initial configuration file",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"minLength": 1,
|
||||||
},
|
},
|
||||||
@ -118,8 +118,8 @@ IOU_UPDATE_SCHEMA = {
|
|||||||
"description": "enable or disable layer 1 keepalive messages",
|
"description": "enable or disable layer 1 keepalive messages",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"startup_config_base64": {
|
"initial_config_base64": {
|
||||||
"description": "startup configuration base64 encoded",
|
"description": "initial configuration base64 encoded",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user