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).
Obtaining Environment Variable

Obtaining Environment Variable

Interface Name

Obtaining environment variable

Application Phase

Subscription and execution phases

API Prototype

result1_value, result2_description = ops.environment.get(envName)






Indicates the name of an environment variable.

The value is a string of 1 to 31 case-sensitive characters without spaces. It can contain only letters, digits, and underscores (_).

  • A user-defined environment variable name starts with a letter.

  • A system environment variable name starts with an underscore (_).

Return Value

The result1_value and result2_description in the API prototype indicate return values.

The first return value is an environment variable value, and is a character string or digit. If the first return value is a digit, it must be converted through int(). If the first return value is a character string, None indicates a failure.

The second return value is a string of characters indicating the results. When the first return value is the environment variable value, Success is displayed. If the first return value is None, the failure cause is displayed.

Usage Description

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.

    Table 8-4 shows system environment variables currently supported by the OPS.

    Table 8-4  System environment variables


    Environment Variable Name

    Environment Variable Description

    Application Phase

    All events


    Event name

    Execution phase


    Time when an event is received

    Execution phase


    Assistant name, or script name

    Subscription and execution phases


    Device name

    Subscription and execution phases


    Script execution phase

    Subscription and execution phases


    Number of times the current event occurs within the last period

    Execution phase



    Command entered by a user (an incomplete keyword, such as dis dev)

    Execution phase


    User entered command (a complete keyword, such as display device)

    Execution phase


    CLI view name

    Execution phase


    CLI triggering point

    Execution phase


    User channel

    Execution phase


    User channel IP address

    Execution phase



    Timer type

    Execution phase

    Route change


    Network prefix

    Execution phase


    Network mask

    Execution phase


    Network protocol

    Execution phase


    Change type

    Execution phase


    Next hop

    Execution phase


    Interface name

    Execution phase



    Log module name

    Execution phase


    Log severity

    Execution phase


    Log alias

    Execution phase


    Log contents

    Execution phase


    Log generation time

    Execution phase



    Trap module name

    Execution phase


    Trap severity

    Execution phase


    Trap alias

    Execution phase


    Trap contents

    Execution phase


    Trap generation time

    Execution phase


    Trap OID

    Execution phase

    LLDP neighbor change


    Interface on which the neighbor status changes

    Execution phase


    Type of a neighbor device

    Execution phase


    Event triggering type

    Execution phase

    Stack status change


    Event name

    Execution phase


    Stack ID

    Execution phase

  • 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.

If the subscription event does not occur, some environment variables related to the event cannot be obtained.


Using the Command Line Event Subscription API, you can subscribe to commands run on a device. When a subscription event is matched, the user wants to view information about the command.

value, loginfo = ops.environment.get("_cli_view")
Updated: 2019-04-20

Document ID: EDOC1100065674

Views: 76109

Downloads: 513

Average rating:
This Document Applies to these Products

Related Version

Related Documents

Previous Next