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

S12700 V200R013C00 Command Reference

This document describes all the configuration commands of the device, including the command function, syntax, parameters, views, default level, usage guidelines, examples, and related commands.
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 Configuration Commands

OPS Configuration Commands

Command Support

For details about command support, see the description of each command. If no command support information is provided, all switch models support the command by default.

assistant scheduler suspend

Function

The assistant scheduler suspend command disables the OPS maintenance assistant function.

The undo assistant scheduler suspend command enables the OPS maintenance assistant function.

By default, the OPS maintenance assistant function is enabled.

Format

assistant scheduler suspend

undo assistant scheduler suspend

Parameters

None

Views

OPS view

Default Level

3: Management level

Usage Guidelines

If the OPS maintenance assistant function is no longer needed, the assistant scheduler suspend command applies to the following scenarios:

  • Before deleting configured Python script assistants one by one, you can run this command to disable the OPS maintenance assistant function to prevent the assistants from running.

  • During system maintenance, you can run this command to disable the OPS maintenance assistant function temporarily.

After you run the assistant scheduler suspend command to disable the OPS maintenance assistant function, none of Python script assistants will run again.

Example

# Disable the OPS maintenance assistant function.

<HUAWEI> system-view
[HUAWEI] ops
[HUAWEI-ops] assistant scheduler suspend

display ops assistant

Function

The display ops assistant command displays information about Python script assistants.

Format

display ops assistant { current [ verbose ] | history } [ name assistant-name ]

Parameters

Parameter

Description

Value

current

Displays brief information about the current status of Python script assistants.

-

verbose

Displays detailed information about the current status of Python script assistants.

-

history

Displays historical operation records of Python script assistants.

-

name assistant-name

Specifies the name of a Python script assistant, namely, a Python script name for a script assistant.

The value must be the name of a script file for which the script assistant has been configured.

Views

All views

Default Level

3: Management level

Usage Guidelines

You can use this command to check the current status and historical operation record of a Python script assistant, including the Python script assistant name, running status, and execution result. The command can display a maximum of 100 latest Python script assistant records.

Example

# Display brief information about the current status of Python script assistants.

<HUAWEI> display ops assistant current
------------------------------------------------------                          
Assistant                     State          Condition                          
------------------------------------------------------                          
subscribe_cli_sync_1.py       ready          cli                                
user-correlat-10.py           ready          multi                              
------------------------------------------------------ 
Table 3-101  Description of the display ops assistant current command output

Item

Description

Assistant

Name of a Python script assistant.

State

Current status of the Python script assistant.
  • ready: The Python script assistant is waiting to be triggered.
  • pending: The Python script assistant is waiting to run.
  • waiting: A resident script is waiting to be triggered the second time.
  • running: The Python script assistant is running.
  • shutdown: The Python script assistant stops.
  • suspend: The OPS maintenance assistant function is disabled.

Condition

Triggering condition for a Python script assistant.
  • cli: command line event
  • device: card status change event
  • iclog: log event
  • ifm: interface statistics collection event event
  • lldp: LLDP neighbor change event
  • multi: complex event
  • timer: timer event
  • trap: trap event
  • URM: routing event

# Display detailed information about the current status of Python script assistants.

<HUAWEI> display ops assistant current verbose
Assistant information                                                           
  Name                          :user-correlat-10.py                            
  State                         :ready                                          
Running statistics                                                              
  Running times                 :0                                              
  Queue size/(free)             :5/(5)                                          
  Skip for queue full           :0                                              
  Skip for delay                :0                                              
  Skip for suppression          :0                                              
Condition information                                                           
  Condition tag                 :cli1                                           
    Condition type              :multi                                          
    Threshold                   :1                                              
    Period (s)                  :0                                              
    Hits in period              :0                                              
  Condition tag                 :cli2                                           
    Condition type              :multi                                          
    Threshold                   :1                                              
    Period (s)                  :0                                              
    Hits in period              :0                                              
  Condition tag                 :cli3                                           
    Condition type              :multi                                          
    Threshold                   :1                                              
    Period (s)                  :0                                              
    Hits in period              :0                                              
  Condition tag                 :cli4                                           
    Condition type              :multi                                          
    Threshold                   :1                                              
    Period (s)                  :0                                              
    Hits in period              :0                                              
  Correlate expression          :((cli1 andnot cli2) and (cli3 andnot cli4))    
  Trigger control                                                               
    Threshold                   :1                                              
    Period (s)                  :30                                             
    Delay (s)                   :0                                              
    Suppress max                :0                                              
    Hits in period              :0   
Table 3-102  Description of the display ops assistant current verbose command output

Item

Description

Assistant information

Information about a Python script assistant.

Name

Name of a Python script assistant.

State

Current status of a Python script assistant.
  • ready: The Python script assistant is waiting to be triggered.
  • pending: The Python script assistant is waiting to run.
  • waiting: A resident script is waiting to be triggered the second time.
  • running: The Python script assistant is running.
  • shutdown: The Python script assistant stops.
  • suspend: The OPS maintenance assistant function is disabled.

Running statistics

Detailed running information about a Python script assistant.

Running times

Number of running times.

Queue size/(free)

Number of buffered Python script assistants. If the number of buffered Python script assistants reaches the maximum value, excessive assistants will be discarded.

Skip for queue full

Number of tasks discarded because the queue is full.

Skip for delay

Number of tasks discarded within the delay.

Skip for suppression

Number of times the triggering of the assistant is suppressed.

Condition information

Condition information about a Python script assistant. The Condition information field is displayed only for a complex event script.

Condition tag

Condition name.

Condition type

Type of triggering condition. The value is multi.

Threshold

Maximum number of times that tasks are executed. The default value is 1.

Period (s)

Detection period, in seconds. The default value is 30.

Hits in period

Number of times the triggering condition is met in the detection period.

Correlate expression

Condition combination mode.

Trigger control

Trigger control.

Delay (s)

Delay in triggering a working task. The default value is 0 seconds.

Suppress max

Maximum number of times working tasks are triggered within the delay. The default value is 0, indicating that working tasks will not be suppressed.

# Display historical operation records of Python script assistants.

<HUAWEI> display ops assistant history
Assistant history information                                                   
  Name                          :subscribe_cli_sync_1.py                        
  Running information                                                           
    Trigger condition           :cli                                            
    Trigger event name          :cli1                                           
    Trigger time                :2017-03-25 19:48:51                            
    Execute start time          :2017-03-25 19:48:51                            
    Execute end time            :2017-03-25 19:48:53                            
    Execute result              :normal 
Table 3-103  Description of the display ops assistant history command output

Item

Description

Assistant history information

Historical information about a Python script assistant.

Name

Name of a Python script assistant.

Running information

Running information about a Python script assistant.

Trigger condition

Triggering condition for a Python script assistant.
  • cli: command line event
  • device: card status change event
  • iclog: log event
  • ifm: interface statistics collection event event
  • lldp: LLDP neighbor change event
  • multi: complex event
  • timer: timer event
  • trap: trap event
  • URM: routing event

Trigger event name

Trigger event name for a Python script assistant.

Trigger time

Triggering time of a Python script assistant.

Execute start time

Execution time of a Python script assistant.

Execute end time

End time of a Python script assistant.

Execute result

Execution result of a Python script assistant.
  • normal: The script assistant ends normally.
  • abnormal: An exception occurs in the script.
  • userCancel: A user stops the script.
  • duplicate: The script file name conflicts with the database file name.
  • os: The system kills the script process due to a script exception.

display ops environment

Function

The display ops environment command displays information about user-defined environment variables.

Format

display ops environment

Parameters

None

Views

All views

Default Level

3: Management level

Usage Guidelines

You can run the display ops environment command to check information about user-defined environment variables after user-defined environment variables are configured using the environment command.

Example

# Display user-defined environment variables.

<HUAWEI> display ops environment
No.  Name                          Value                                        
1    user                          admin                                        
Table 3-104  Description of the display ops environment command output

Item

Description

No.

User-defined environment variable number. The value ranges from 1 to 100.

Name

Name of a user-defined environment variable.

To configure this parameter, run the environment command.

Value

Value of a user-defined environment variable.

To configure this parameter, run the environment command.

Related Topics

display ops error

Function

The display ops error command displays script execution errors.

Format

display ops error [ name assistant-name ]

Parameters

Parameter

Description

Value

name assistant-name

Specifies the name of a Python script assistant, namely, a Python script name for a script assistant.

The value must be the name of a script file for which the script assistant has been configured.

Views

All views

Default Level

3: Management level

Usage Guidelines

You can run this command to view execution errors of all scripts or a specified script. According to the errors in the command output, you can modify the script.

Example

# Display execution errors of all scripts.

<HUAWEI> display ops error
--------------------------------------------------------------------------------
test12.py:                                                                      
Traceback (most recent call last):                                              
  File ".lib/frame.py", line 114, in <module>                                   
    ret = m.ops_execute(ops)                                                    
  File "flash:$_user/test12.py", line 7, in ops_execute                         
    status, err_context = ops.context.save(varName, value)                      
NameError: global name 'varName' is not defined                                 
                                                                                
--------------------------------------------------------------------------------
test13.py:                                                                      
Traceback (most recent call last):                                              
  File ".lib/frame.py", line 114, in <module>                                   
    ret = m.ops_execute(ops)                                                    
  File "flash:$_user/test13.py", line 6, in ops_execute                         
    status, err_log = ops.syslog("Syslog: Hello, World..", ops.CRITICAL, "syslog
")                                                                              
AttributeError: 'module' object has no attribute 'syslog'                       
                                                                                
--------------------------------------------------------------------------------
Table 3-105  Description of the display ops error command output

Item

Description

test12.py

Python script file name.

Traceback (most recent call last)

Last call error.

File ".lib/frame.py", line 114, in <module>

Stack where an error occurs.

File "flash:$_user/test12.py", line 7, in ops_execute

Information about location where an error occurs, including the Python script name, number of line, and phase when the error occurs.

status, err_context = ops.context.save(varName, value)

Invalid contents.

NameError

A variable error. The system is attempting to access a variable that is not declared.

AttributeError

An attribute error. The system is attempting to access an unknown object attribute.

display ops system-script

Function

The display ops system-script command displays system built-in OPS scripts.

Format

display ops system-script

Parameters

None

Views

All views

Default Level

1: Monitoring level

Usage Guidelines

Usage Scenario

When associating OIDS with OPS, you need to use OPS scripts to subscribe to OIDS events. The device provides built-in OPS scripts, which removing the need to make scripts or download scripts from websites and import the scripts to the device. To view system built-in OPS scripts, run the display ops system-script command.

Precautions

The system built-in OPS scripts are not installed by default.

Example

# Display system built-in OPS scripts.

<HUAWEI> display ops system-script
ScriptName                      Description                                                                                         
--------------------------------------------------------------------------------                                                    
huawei_oids.py                  The OIDS sample script describes the subscriptio                                                    
                                n process. The execution result of the script ha                                                    
                                s been recorded to OIDS. You can refer to this s                                                    
                                cript to implement the OIDS script process. 
Table 3-106  Description of the display ops system-script command output

Item

Description

ScriptName

Name of a script.

Description

Description of the script.

environment

Function

The environment command configures a user-defined environment variable.

The undo environment command deletes a user-defined environment variable.

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

Format

environment variable-name variable-value

undo environment variable-name

Parameters

Parameter

Description

Value

variable-name

Specifies the name of a user-defined environment variable.

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

variable-value

Specifies the value of a user-defined environment variable.

The value is a string of 1 to 64 case-sensitive characters without spaces. If the string is enclosed in double quotation marks (""), the string can contain spaces.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

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.

Precautions

If variable-name is specified multiple times, the system will prompt that the configured user-defined environment variable already exists. You can choose whether to overwrite the existing variable value. After overwriting the existing variable value, you need to run the undo script-assistant python command to delete the Python script assistant that uses the environment variable and then run the script-assistant python command to re-configure the Python script assistant.

A maximum of 100 environment variables can be configured on the device.

To check configured user-defined environment variables, run the display ops environment command.

Example

# Set the value of the user-defined environment variable user to admin.

<HUAWEI> system-view
[HUAWEI] ops
[HUAWEI-ops] environment user admin

ops

Function

The ops command displays the OPS view.

Format

ops

Parameters

None

Views

System view

Default Level

3: Management level

Usage Guidelines

You can configure the Python script assistant in the OPS view.

Example

# Display the OPS view.

<HUAWEI> system-view
[HUAWEI] ops
[HUAWEI-ops]

ops abort

Function

The ops abort command stops all OPS Python scripts.

Format

ops abort

Parameters

None

Views

All views

Default Level

3: Management level

Usage Guidelines

Usage Scenario

If commands cannot be entered on the switch due to OPS Python script exceptions, run the ops abort command to stop all OPS Python scripts to make the switch work properly.

Prerequisites

Running the ops abort command on the active MPU will not be captured by the CLI event subscription API (ops.cli.subscribe), but running this command on the standby MPU will be captured by this API.

Example

# Stop all OPS Python scripts.

<HUAWEI> ops abort

ops install file

Function

The ops install file command installs a Python script.

Format

ops install file file-name [ destination directory ]

Parameters

Parameter

Description

Value

file-name

Specifies the directory and file name of the Python script to be installed.

  • To install a Python script stored in the root directory of the device, you can directly specify the file name of the script.

  • To install a Python script that is stored a non-root directory, you need to specify both the directory and file name of the script.

The value is a string of 4 to 64 case-insensitive characters without any spaces. The file name extension of a Python script file is .py.

NOTE:

file-name cannot be set to the name of a built-in Python script file, including ConfigParser.py, copy_reg.py, locale.py, sre.py, Queue.py, decimal.py, macurl2path.py, sre_compile.py, StringIO.py, dis.py, modulefinder.py, sre_constants.py, UserDict.py, dummy_thread.py, ntpath.py, sre_parse.py, UserList.py, dummy_threading.py, nturl2path.py, stat.py, UserString.py, filecmp.py, numbers.py, string.py, __future__.py, fileinput.py, opcode.py, stringold.py, _abcoll.py, fnmatch.py, os.py, struct.py, _pyio.py, formatter.py, os2emxpath.py, subprocess.py, _strptime.py, fractions.py, pickle.py, sysconfig.py, _threading_local.py, functools.py, pkgutil.py, textwrap.py, _weakrefset.py, genericpath.py, platform.py, threading.py, abc.py, getopt.py, posixpath.py, token.py, argparse.py, getpass.py, pprint.py, tokenize.py, atexit.py, gettext.py, re.py, trace.py, base64.py, glob.py, repr.py, traceback.py, bisect.py, heapq.py, runpy.py, types.py, calendar.py, imputil.py, sched.py, user.py, codecs.py, inspect.py, sets.py, warnings.py, collections.py, io.py, shutil.py, weakref.py, contextlib.py, keyword.py, site.py, xmllib.py, copy.py, linecache.py, socket.py, _cli.py, _device.py, _frame.py, _route.py, _timer.py, _common.py, _environment.py, _iclog.py, _snmp.py, _trap.py, _context.py, _farg.py, _lldp.py, _terminal.py, and ops.py.

destination directory

Specifies the installation directory of a script.

The value is a string of 1 to 64 case-insensitive characters without any spaces.

If this parameter is not specified, the script will be installed in $_user. If this parameter is specified, the script will be installed in $_user/directory. If the directory name does not exist, a directory will be created.

NOTE:

The total length of file-name and the installation directory of the script cannot exceed 118. The total length refers to the storage path + $_user + directory name + file name.

The installation directory of the script cannot be huawei_pys.

The depth of the path specified by directory cannot exceed three levels.

Views

User view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

OPS allows you to run the scripts you make. A script can be executed after the script assistant is configured. Before configuring a script assistant, install the script.

To check information about the scripts installed in $_user, run the dir (user view) command.

Precautions

  • Before installing a script, upload the script to the root directory of flash: on the device.
  • Ensure that the device has sufficient storage space when the script is installed. Otherwise, the script fails to be installed.
  • If the specified installation directory does not exist, a directory will be created. A maximum of seven levels of subdirectories can be created in $_user.
  • The name of the script to be installed cannot be the same as an existing directory name on the device. After scripts are installed successfully, you cannot create a directory whose name is the same as that of an installed script.
  • To install scripts in $_user, you can only run the ops install file command. The scripts installed in this directory will be automatically backed up to the standby card.
  • To modify a script that has been installed, run the ops uninstall file command to uninstall the script and the delete (user view) command to delete the script file. After modifying the script, upload and reinstalling the script file.
  • It is recommended that the total size of files installed in $_user be smaller than 100 MB. If the total size of files exceeds 100 MB, performance of data synchronization between the active and standby cards may deteriorate.

Example

# Install the script file config.py in the flash: root directory to the default flash:/$_user.

<HUAWEI> ops install file config.py

# Install the script file config.py in the flash: root directory to the specified flash:/$_user/user.

<HUAWEI> ops install file config.py destination user

# Install the script file config.py in the flash:/admin directory to the default flash:/$_user.

<HUAWEI> ops install file admin/config.py
Related Topics

ops uninstall file

Function

The ops uninstall file command uninstalls a Python script.

Format

ops uninstall file file-name

Parameters

Parameter

Description

Value

file-name

Specifies the name of the script file to be uninstalled.

The value must be the name of a script file that has been installed.

If a script in a specified installation directory directory/file-name needs to be deleted, directory specifies the installation directory of the script.

NOTE:

The total length of file-name and the installation directory of the script cannot exceed 118. The total length refers to the storage path + $_user + directory name + file name.

Views

User view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

You can uninstall unnecessary scripts to release storage space on a device. If an installed script needs to be updated, uninstall it first, and reinstall it after the update.

Precautions

This command cannot uninstall a script for which a script assistant has been configured. To uninstall the script, delete the script assistant first.

If the script for which a script assistant has configured invokes another script, the called script can be uninstalled using this command. Therefore, it is recommended that you use one script to implement required functions.

Example

# Uninstall the script file config.py in the default directory flash:/$_user.

<HUAWEI> ops uninstall file config.py

# Uninstall the script file config.py in the specified directory flash:/$_user/user.

<HUAWEI> ops uninstall file user/config.py
Related Topics

script-assistant python

Function

The script-assistant python command configures a Python script assistant.

The undo script-assistant python command deletes a Python script assistant.

By default, no Python script assistant is configured.

Format

script-assistant python script-name

undo script-assistant python script-name

Parameters

Parameter

Description

Value

script-name

Specifies the name of a Python script assistant, namely, a Python script name for a script assistant.

The value must be the name of a script file that has been installed.

NOTE:

script-name cannot be set to the file name of a built-in Python script, including ConfigParser.py, copy_reg.py, locale.py, sre.py, Queue.py, decimal.py, macurl2path.py, sre_compile.py, StringIO.py, dis.py, modulefinder.py, sre_constants.py, UserDict.py, dummy_thread.py, ntpath.py, sre_parse.py, UserList.py, dummy_threading.py, nturl2path.py, stat.py, UserString.py, filecmp.py, numbers.py, string.py, __future__.py, fileinput.py, opcode.py, stringold.py, _abcoll.py, fnmatch.py, os.py, struct.py, _pyio.py, formatter.py, os2emxpath.py, subprocess.py, _strptime.py, fractions.py, pickle.py, sysconfig.py, _threading_local.py, functools.py, pkgutil.py, textwrap.py, _weakrefset.py, genericpath.py, platform.py, threading.py, abc.py, getopt.py, posixpath.py, token.py, argparse.py, getpass.py, pprint.py, tokenize.py, atexit.py, gettext.py, re.py, trace.py, base64.py, glob.py, repr.py, traceback.py, bisect.py, heapq.py, runpy.py, types.py, calendar.py, imputil.py, sched.py, user.py, codecs.py, inspect.py, sets.py, warnings.py, collections.py, io.py, shutil.py, weakref.py, contextlib.py, keyword.py, site.py, xmllib.py, copy.py, linecache.py, socket.py, _cli.py, _device.py, _frame.py, _route.py, _timer.py, _common.py, _environment.py, _iclog.py, _snmp.py, _trap.py, _context.py, _farg.py, _lldp.py, _terminal.py, and ops.py.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

As networks are developing rapidly, existing network devices provide only limited functions and predefined services, failing to meet the requirements for diversified services. You can run the script using OPS to implement customized functions.

The device supports a built-in Python script interpreter. You can run the script-assistant python command to run a Python script and register the events defined in the script.

Prerequisites

The script has been uploaded to the device and installed using the ops install file command in the user view.

Precautions

Only one assistant can be configured for a Python script. A maximum of 100 Python script assistants can be configured on the device.

The system does not check correctness of the Python script.

If you run the undo script-assistant python command to uninstall the script assistant, the corresponding Python script will be terminated.

Example

# Configure a script assistant for the script config.py.

<HUAWEI> ops install file config.py
<HUAWEI> system-view
[HUAWEI] ops
[HUAWEI-ops] script-assistant python config.py

shutdown script-assistant

Function

The shutdown script-assistant command stops a Python script assistant.

The undo shutdown script-assistant command starts a Python script assistant.

By default, the Python script assistant is started.

Format

shutdown script-assistant script-name

undo shutdown script-assistant script-name

Parameters

Parameter

Description

Value

script-name

Specifies the name of a Python script assistant, namely, a Python script name for a script assistant.

The value must be the name of a script file for which the script assistant has been configured.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

Usage Scenario

To prevent a Python script of an assistant from running, run the shutdown script-assistant command to stop the Python script assistant.

Precautions

Stopping a running assistant interrupts the task of the assistant. Exercise caution when you perform this operation.

Example

# Stop a script assistant for the script config.py.

<HUAWEI> system-view
[HUAWEI] ops
[HUAWEI-ops] shutdown script-assistant config.py
Info: Succeeded in stopping script assistant config.py.
Translation
Download
Updated: 2019-04-09

Document ID: EDOC1100065659

Views: 128101

Downloads: 88

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