Skip to content

Commit 29c8a6d

Browse files
authored
enhance restore task for backward compatibility with old backups (#137)
1 parent f17b417 commit 29c8a6d

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Catalyst SD-WAN Lab 2.1.8 [unreleased]
2+
3+
- In restore task, add backward compatibility for restoring old backups with legacy disk naming (sdb to vdb conversion for virtio disks)
4+
- In restore task, fix deprecation warnings by replacing node.config with node.configuration
5+
16
# Catalyst SD-WAN Lab 2.1.7 [Feb 2, 2026]
27

38
- In restore task, fix issue where SD-WAN Manager might not boot properly if task is run with SD-WAN Manager username "admin"

catalyst_sdwan_lab/tasks/restore.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,36 @@ def main(
221221
for node in cml_topology_dict["nodes"]
222222
if node["node_definition"] == "cat-sdwan-manager"
223223
)
224+
225+
# Check if manager node definition uses virtio disk driver and convert old sdb naming to vdb
226+
node_definitions = cml.definitions.node_definitions()
227+
manager_node_def = next(
228+
(
229+
nd
230+
for nd in node_definitions
231+
if nd["id"] == manager_node["node_definition"]
232+
),
233+
None,
234+
)
235+
if (
236+
manager_node_def
237+
and manager_node_def.get("sim", {})
238+
.get("linux_native", {})
239+
.get("disk_driver")
240+
== "virtio"
241+
):
242+
# Replace old sdb references with vdb for virtio disk driver compatibility
243+
if "/dev/sdb" in manager_node["configuration"]:
244+
log.info(
245+
"Converting legacy disk naming (sdb) to virtio naming (vdb) in manager configuration..."
246+
)
247+
manager_node["configuration"] = manager_node["configuration"].replace(
248+
'"/dev/sdb"', '"/dev/vdb"'
249+
)
250+
manager_node["configuration"] = manager_node["configuration"].replace(
251+
"[ sdb,", "[ vdb,"
252+
)
253+
224254
existing_manager_passwords = re.findall(
225255
r"<user>[\s\S]+?<password>(\S+)</password>", manager_node["configuration"]
226256
)
@@ -337,7 +367,7 @@ def main(
337367
elif node.node_definition == "cat8000v" and node.is_booted() is False:
338368
# To workaround CML problem, after config export for this node
339369
# we need to add 'no shutdown' under all interfaces
340-
node.config = re.sub(
370+
node.configuration = re.sub(
341371
r"(interface\sGigabitEthernet\d\n)",
342372
r"\1 no shutdown\n",
343373
node.configuration,
@@ -526,7 +556,7 @@ def main(
526556
uuid = uuid_search.group(1)
527557
token = uuid_to_token[uuid]
528558
# Update node config with new otp token
529-
node.config = re.sub(
559+
node.configuration = re.sub(
530560
r"(vinitparam:[\w\W]+?otp\s:)\s(\w+)",
531561
rf"\1 {token}",
532562
node.configuration,

0 commit comments

Comments
 (0)