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:
YueGuobin committed 2026-08-21 21:41:42 +08:00
1 parent 300c53e6fb
commit 92d4e3d378
5 files changed
+125

No files matched your search

+6
View File
@@ -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