Managing YANG Packages and Configurations During a Software Upgrade or Downgrade
Certain devices running Junos OS enable you to load custom YANG modules on the device to add data models that are not natively supported by Junos OS. When you add, update, or delete a YANG data model, Junos OS rebuilds its schema and then validates the active configuration against the updated schema.
When you upgrade or downgrade Junos OS, by default, the system validates the software package or bundle against the current configuration. During the installation, the schema for custom YANG data models is not available. As a result, if the active configuration contains dependencies on these models, the software validation fails, which causes the upgrade or downgrade to fail.
In addition, devices that are running Junos OS based on FreeBSD version 6 remove custom YANG packages from the device during the software installation process. For this Junos OS variant, if the active configuration contains dependencies on custom YANG data models, the software installation fails even if you do not validate the software against the configuration, because the configuration data cannot be validated during the initial boot-time commit.
For these reasons, before you upgrade or downgrade the Junos OS image on a device that has one or more custom YANG modules added to it, you must remove all configuration data corresponding to the custom YANG data models from the active configuration. After the software installation is complete, add the YANG packages and corresponding configuration data back to the device, if appropriate. The tasks are outlined in this topic.
You do not need to delete configuration data corresponding to OpenConfig packages before upgrading or downgrading Junos OS.
Backing up and Deleting the Configuration Data
If the configuration contains dependencies on custom YANG data models:
- If you plan to restore the configuration data that corresponds
to the nonnative YANG data models after the software is updated, save
a copy of either the entire configuration or the configuration data
corresponding to the YANG data models, as appropriate.
To save the entire configuration:user@host> show configuration | save (filename | url)
To save configuration data under a specific hierarchy level:user@host> show configuration path-to-yang-statement-hierarchy | save (filename | url)
- In configuration mode, delete the portions of the configuration
that depend on the custom YANG data models.user@host# delete path-to-yang-statement-hierarchy
Commit the changes.user@host# commit
- Prior to performing the software installation, ensure that the saved configuration data and the YANG module and script files are saved to a local or remote location that will preserve the files during the installation and that will be accessible after the installation is complete.
Restoring the YANG Packages and Configuration Data
After the software installation is complete, load the YANG packages onto the device (where required), and restore the configuration data associated with the packages, if appropriate. During a software upgrade or downgrade, devices running Junos OS with upgraded FreeBSD preserve custom YANG packages, whereas devices running Junos OS based on FreeBSD version 6 delete the packages.
- Load the YANG packages (devices running Junos OS based
on FreeBSD version 6 only).user@host> request system yang add package package-name module [modules] deviation-module [modules] translation-script [scripts] action-script [scripts]
- When the system prompts you to restart the Junos OS CLI,
press Enter to accept the default value of yes.
... WARNING: cli has been replaced by an updated version: ... Restart cli using the new version ? [yes,no] (yes) Restarting cli ...
To prevent CLI-related or configuration database errors, we recommend that you do not perform any CLI operations, change the configuration, or abort the operation while a device is in the process of adding, updating, or deleting a YANG package and modifying the schema.
- In configuration mode, load the configuration data associated
with the YANG packages.
For example, to load the configuration data from a file relative to the top level of the configuration statement hierarchy:user@host# load merge (filename | url)
For more information about loading configuration data, see the CLI User Guide.
Commit the changes.user@host# commit