mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
nodes: per-node default credentials seeded from the template
Add default_username/default_password as controller-only node properties (the netmiko_device_type pattern): they are not sent to the compute, persist with the project topology and can be updated or cleared per node. Creating a node from a template seeds them from the template appliance metadata, and the metadata itself is dropped there so it never leaks into the node properties.
This commit is contained in:
5 files changed
+125
No files matched your search
@@ -584,6 +584,12 @@ class Project:
|
||||
default_name_format = template.pop("default_name_format", "{name}-{0}")
|
||||
if name is None:
|
||||
name = default_name_format.replace("{name}", template_name)
|
||||
# the appliance metadata stays template level: only the default
|
||||
# credentials are seeded on the node (where they can be overridden)
|
||||
appliance_metadata = template.pop("appliance_metadata", None) or {}
|
||||
for field in ("default_username", "default_password"):
|
||||
if appliance_metadata.get(field):
|
||||
template[field] = appliance_metadata[field]
|
||||
node_id = str(uuid.uuid4())
|
||||
node = await self.add_node(compute, name, node_id, node_type=node_type, **template)
|
||||
return node
|
||||
|
||||
Reference in new issue
Block a user