< Home

(Optional) Configuring the User-defined Environment Variable

Context

An environment variable consists of a name and a value. In a Python script, you can input an environment variable name in the location where a parameter needs to be input to indicate that an environment variable value needs to be referenced. When the system is running a Python script, it replaces an environment variable name with an environment variable value. To change the value, you can directly change it on the device without having to change and install the Python script. You can define and use user-defined environment variables to simplify the configuration and improve flexibility and feasibility of the Python script.

User-define environment variables start with letters, can contain letters, digits, and _, apply to all types of events, and can be used in subscription and execution phases. The value of a user-defined environment variable can be configured using the environment command. You can create, modify, and delete user-defined variables.

For example, a user wants to subscribe to changes of OSPF routes on the network segment 10.2.1.0/24 in the Python script, and then needs to subscribe to changes of OSPF routes on the network segment 10.2.2.0/24. To omit the process of uninstalling the original script and installing a new script, you can define an environment variable in the subscription phase, and specify the value of the environment variable using the environment command.

If you use a user-defined environment variable in the Python script, you need to set the value of the user-defined environment variable.

Procedure

  1. Run system-view

    The system view is displayed.

  2. Run ops

    The OPS view is displayed.

  3. Run environment variable-name variable-value

    The user-defined environment variable is configured.

    By default, no user-defined environment variable is configured.

    A maximum of 100 user-defined environment variables can be supported on a device.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >