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.

RESTful API Reference
CloudEngine 12800 and 12800E V200R003C00

This document describes the OPS APIs supported by the device, including OPS-supported operations, request examples, elements in the requests, response examples, elements in the responses, and response status codes.

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).
Subscribe to Command Events

Subscribe to Command Events

  • Function Description

    The OPS ERE provides command event subscription.

    After you subscribe to command events, if the entered character strings of a command match the regular expression, the system executes the ops_execute() function in the Python script.

    This API can only be used in the ops_condition() function of the maintenance assistant script.

  • Command Prototype

    opsObj.cli.subscribe(tag, pattern, enter=False, sync=True, async_skip=False, sync_wait=30)

  • Parameter Description
    Table 3-908  Parameters supported by command event subscription APIs




    Specifies an OPS object. It is obtained using ops.ops() in instance mode.


    Specifies a condition ID. The value is a string of 1 to 8 case-sensitive characters that starts with a letter and contains letters, digits, or underscores (_). Enter quotation marks ("") or None for the only one condition. tag cannot be set to andor, or not.


    Specifies a regular expression for matching commands.


    The value can be True or False.

    • True: matches a regular expression immediately after you press Enter.
    • False: matches a regular expression only after the system completes the keyword.


    Indicates whether the CLI terminal waits for script execution after a command event is triggered.

    • True: The CLI terminal waits for script execution.
    • False: The CLI terminal does not wait for script execution.


    Indicates whether the original command is skipped. (This setting takes effect only when sync is set to False.) The value can be True or False.

    • True: The original command is not executed.
    • False: The original command is executed.


    Indicates the time when the CLI terminal waits for script execution. (This setting takes effect only when sync is set to True.) The value is an integer ranging from 1 to 100.

  • Description of Return Values

    First return value: The value 0 indicates a success; the value 1 indicates a failure.

    Second return value: This value describes success or failure reasons, expressed in character strings.

  • Example
    def ops_condition(_ops):
    def ops_execute(_ops):
        print "Hello World"
        return 0

    After you enter iproute on the CLI terminal, the terminal outputs "Hello World".

Updated: 2019-05-05

Document ID: EDOC1100004147

Views: 59996

Downloads: 28

Average rating:
This Document Applies to these Products

Related Version

Related Documents

Previous Next