No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search


To have a better experience, please upgrade your IE browser.


Configuration Guide - Device Management

S2720, S5700, and S6720 V200R013C00

This document describes the configurations of Device Management, including device status query, hardware management, Stack, SVF, cloud-based management, PoE, monitoring interface, OPS, energy-saving management, information center, fault management, NTP, synchronous ethernet, PTP.

Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
OPS Operation Process

OPS Operation Process

Figure 8-2 shows the OPS operation process.

Figure 8-2  OPS operation process

The OPS operation process includes the following steps:

  1. Users make a Python script file locally and use OPS APIs to define functions.

    When making a Python script file, you can use environment variables. For detailed environment variable descriptions, see Environment Variable.

  2. Upload the Python script to the device.
  3. Install the Python script. If an installed Python script needs to be modified, uninstall it first, and reinstall it after modification. To uninstall the script for which a script assistant has been configured, delete the assistant first.
  4. If user-defined environment variables are used in the Python script, configure values of the user-defined environment variables.
  5. Configure a Python script assistant to register the subscription event in the Python script. When the specified trigger condition is met, the device automatically executes the actions defined in the script. If the subscribed contents in the Python script are incorrect, the device displays an error message to indicate the error location. You need to correct the subscribed contents, upload the script again, and then install the script.
  6. Enable the OPS maintenance assistant function. After the Python script assistant is configured, the OPS maintenance assistant function is enabled by default. If the OPS maintenance assistant function is disabled, you need to manually enable this function.

    The Python script assistance takes effect for a single Python script. Configuring the Python script assistant helps the completion of subscription event registration in the Python script.

    The OPS maintenance assistant function takes effect for all Python script assistants. If the OPS maintenance assistant function is disabled, all Python script assistants are not executed.

  7. After a script assistant is configured and the subscription event is registered successfully, the device executes the actions defined in the Python script successfully when the trigger condition is met, as long as the Python script is correct. If the script is incorrect, the device cannot execute the actions, requiring you to correct the script and then upload and install the script again.
  8. The device successfully runs the Python script to implement the user-defined functions.

Environment Variable

When subscribing to an event or defining the execution action in a Python script, you can use environment variables. Event subscription is performed in the subscription phase and action execution is performed in the execution phase.

An environment variable consists of a name and a value. Currently, OPS supports system and user-defined environment variables.

  • System environment variables

    Environment variables supported by the device by default cannot be created, deleted, or modified. A system environment variable name starts with a _, and a system environment variable value is determined by the system.

    System environment variables include:

    • Public environment variables: can be used for all types of events.

    • Non-public environment variables: can only be used for specified events. Its value is obtained when an event is triggered and indicates some information about the event.

    For system environment variables currently supported by the OPS, see Table 8-4 in Obtaining Environment Variable.

    For example, you can subscribe to a command entered on a device using the Command Line Event Subscription API. When the subscribed event is matched and you want to know about view information about the command, use the system environment variable _cli_view.
    value, loginfo = ops.environment.get("_cli_view")
  • User-defined environment variables

    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 in the Python script, and then needs to subscribe to changes of OSPF routes on the network segment 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.

    value, descri_str = ops.route.subscribe("route1", "ospf_routes", 24, minLen=None, maxLen=None, neLen=None, optype="all", protocol="ospf")  # ospf_routes is a user-defined environment variable
Updated: 2019-04-20

Document ID: EDOC1100065674

Views: 75414

Downloads: 513

Average rating:
This Document Applies to these Products

Related Version

Related Documents

Previous Next