Add Juniper ISSU and NSSU support#400
Conversation
d366b46 to
ff4f8a5
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends the Junos device driver to support Juniper ISSU/NSSU upgrade flows and adds a system snapshot helper intended to enforce dual-partition best practices during upgrades.
Changes:
- Add
issu/nssuoptions toJunosDevice.install_os()and adjust upgrade/reboot handling logic. - Add
JunosDevice.install_os_multi()to perform multi-member (virtual-chassis) upgrades without NSSU. - Add
request_system_snapshot()plus polling-based verification for snapshot completion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| pyntc/devices/jnpr_device.py | Adds ISSU/NSSU install options, a multi-device install flow, and snapshot request/verification helpers. |
| changes/mm.added | Adds a changelog entry for the new Juniper install options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| output = self.native.cli("show system snapshot media internal") | ||
| if "snapshot" in output.lower(): | ||
| log.info("Host %s: System snapshot verified.", self.host) | ||
| return | ||
| log.debug("Host %s: Snapshot verification in progress; will retry.", self.host) |
| except Exception as exc: # pylint: disable=broad-exception-caught | ||
| log.debug("Host %s: Snapshot verification poll failed (%s); will retry.", self.host, exc) | ||
|
|
| # Capture pre-install state for validation after reboot | ||
| self._uptime = None | ||
| pre_install_uptime = self.uptime | ||
| pre_install_version = self.os_version |
| if not reboot: | ||
| log.info("Host %s: OS image %s boot options set. Reboot the device to apply", self.host, image_name) | ||
| return True | ||
|
|
||
| self.reboot(wait_for_reload=True) | ||
| if not nssu: | ||
| self.reboot(wait_for_reload=True) | ||
|
|
| except ConnectClosedError: | ||
| # Connection loss during install is expected (device reboots) | ||
| log.info( | ||
| "Host %s: Connection closed during install (expected for device reboot). " | ||
| "Waiting for device to come back online.", |
| # Capture pre-install state | ||
| self._uptime = None | ||
| pre_install_uptime = self.uptime | ||
| pre_install_version = self.os_version | ||
|
|
| @@ -0,0 +1 @@ | |||
| Added issu and nssu upgrade choices for install on juniper devices. No newline at end of file | |||
cf77af7 to
e9407cc
Compare
e9407cc to
43bb7c6
Compare
| log.info("Host %s: Rebooting device to apply OS image %s", self.host, image_name) | ||
| original_uptime = self.uptime | ||
|
|
| # Extract target version from image name for verification | ||
| # Matches formats: 15.1R7-S2, 20.4R3, 21.4X38-D10, 18.4R2.7, etc. | ||
| match = re.search(r"(\d+\.\d+[A-Z]+[\d\.]+(?:[-][A-Z]+\d+)*)", image_name) | ||
| target_version = match.group(1) if match else None | ||
|
|
| Raises: | ||
| OSInstallError: If snapshot verification fails or times out. | ||
| """ |
| """Check if device is in virtual-chassis or chassis-cluster configuration. | ||
|
|
||
| Inspects re_info from PyEZ facts to determine if multiple members are present. | ||
|
|
||
| Returns: | ||
| bool: True if multiple members are present, False otherwise. | ||
| """ |
| with self.subTest("snapshot times out"): | ||
| mock_sleep.reset_mock() | ||
| self.device.native.cli.return_value = "No snapshots found" | ||
| with self.assertRaises(TimeoutError) as ctx: | ||
| self.device._wait_for_system_snapshot(timeout=10) | ||
| self.assertIn("did not complete", str(ctx.exception)) |
Lab test findings — EX3300 2-member Virtual Chassis (15.1R7-S2 ↔ 12.3R12-S10)Ran the 1. A failed member install is masked by the
|
Follow-up lab finding —
|
New Pull Request
This PR adds Juniper install options for in-service software upgrade and nonstop software upgrade for SRX and EX devices.
This is in testing and may need some revisions.
SDK docs - https://junos-pyez.readthedocs.io/en/2.8.2/jnpr.junos.utils.html#jnpr.junos.utils.sw.SW.install
rpc.cli() - used to run commands not available in the sdk.
Change Notes
Add issu and nssu choices on install_os.
Add install_os_multi which performs an os change on multiple devices without using nssu.
Add request_system_snapshot to enforce best practices with dual partitions.
Justification