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

Reminder

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

upgrade

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).
Command Line Event Subscription

Command Line Event Subscription

Interface Name

Command line event subscription

Application Phase

Subscription phase

API Prototype

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

Description

Parameter

Description

Value

tag

Indicates conditions.

The value is a string of 1 to 12 case-insensitive characters, consists of letters, digits, and underscores (_), and starts with a letter. The value cannot be one of the following: "", None, and, or, andnot. The value cannot contain \0.

pattern

Indicates the regular expression that matches commands.

The value is a string of 1 to 128 characters and cannot contain \0.

enter

Indicates the time for matching a regular expression.

The value is of the Boolean type:

  • True: A regular expression is matched immediately after Enter is pressed.

  • False: If an abbreviated keyword is specified in a command, a complete keyword will be matched against a regular expression.

The default value is False.

sync

Indicates whether to wait until the script execution is complete after the command triggers an execution action.

The value is of the Boolean type:

  • True: yes

  • False: no

The default value is True.

async_skip

Indicates whether to skip the original command when the sync value is False.

The value is of the Boolean type:

  • True: yes

  • False: no

The default value is False.

sync_wait

Indicates the time taken by a command to wait for the script execution if the sync value is True.

The value is an integer that ranges from 1 to 2147483647, in seconds. The default value is 30 seconds.

Return Value

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

The result1_value is the first return value, 0 indicates success, and 1 indicates failure.

The result2_description is the second return value, indicating the failure cause. It is returned only when the first return value is 1.

Usage Description

When the command line event subscription API (ops.cli.subscribe) is used:

  • If an original command of the switch is subscribed, sync is set to True, and the return value of ops_execute is set to 0, the original command of the switch is skipped, that is, the original CLI of the switch is invalid.

  • If an original command of the switch is subscribed, and sync and async_skip are set to False and True respectively, the original command of the switch is skipped, that is, the original CLI of the switch is invalid.

  • You are advised to specify the regular expression matching the command as a complete keyword or command.

    • If an incomplete command or keyword is used, and both enter and sync are set to True, the subscription event will be mismatched. For example, if the regular expression is set to display, any command that contains display will match the event and trigger the action in the function.

    • If an incomplete command or keyword is used, for example, dis, and enter, sync, and async_skip are set to True, False, and True respectively, all commands that contain dis will become invalid.

    • If an incomplete command or keyword is used, for example, display, and enter and sync are set to False and True respectively, any registered command that contains display will match the event and trigger the action in the function.

    • If an incomplete command or keyword is used, for example, display, and enter, sync, and async_skip are set to False, False, and True respectively, all registered commands that contain display will become invalid.

  • Do not specify the regular expression matching the command as a single space character.

    • When the regular expression is a single space character and the user enters only a single space, the action in the execution function cannot be triggered.

    • If the regular expression is a single space character, and enter, sync, and async_skip are set to True, True, and True respectively, the subscription event will be mismatched if you enter any command containing spaces.

    • If the regular expression is a single space character, and enter, sync, and async_skip are set to True, False, and True respectively, any command that contains spaces will be invalid.

  • If the regular expression matching the command contains a question mark (?), for example, "shutdow?", the subscription event cannot be matched if shutdow? is entered.

  • If the regular expression matching the command contains other special characters except for a question mark (?), the switch should perform conversion for special characters twice during Python script execution. Foe example, if the regular expression matching the command is "shutdown \\a", the regular expression becomes "shutdown \a" after the first conversion and becomes "shutdown a" after the second conversion. Therefore, the subscription event is matched if shutdown a is entered. You need to ensure that special characters become visible characters after the conversion is performed twice. Otherwise, the subscription event may not be matched because invisible characters cannot be entered in the CLI.

  • To prevent failures to copy or delete Python script files, ensure that the command lines subscribed using ops.cli.subscribe are different from the names of Python script files.

If multiple simple events are defined using the ops.cli.subscribe API in the subscription phase, but the simple events are not combined through the Multi-Condition Combination API, the Python script assistant cannot be configured.

Directly omit parameters using default values. For example, the following statements indicate that parameters enter, sync, async_skip, and sync_wait use the default values.

value, descri_str = ops.cli.subscribe("cli1", "arp broadcast disable")

The command line event subscription matches existing command lines or defines new command lines.

Example

When you run the arp broadcast disable command, the corresponding action is triggered.

value, descri_str = ops.cli.subscribe("cli1", "arp broadcast disable", enter=True, sync=True, sync_wait=60)
Translation
Download
Updated: 2019-04-20

Document ID: EDOC1100065674

Views: 34180

Downloads: 287

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next