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

Command Reference

AR500, AR510, and AR530 V200R007

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

NOTE:

The OPS function is supported by the AR510 series, AR530 series, AR503GW-LM7, AR503GW-LcM7, AR509G-L-D-H, AR509GW-L-D-H.

assistant scheduler suspend

Function

The assistant scheduler suspend command disables the maintenance assistant function.

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

By default, the 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 maintenance assistant function is no longer needed, you can run the assistant scheduler suspend command to disable this function. After you run this command, none of assistants will run again.

This command applies to the following scenarios:
  • Before deleting configured assistants one by one, run this command to disable the maintenance assistant function to prevent the assistants from running.

  • If you do not need the functions provided by assistants, for example, preventive maintenance and upgrade functions, run this command to disable the maintenance assistant function.

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

Example

# Disable the maintenance assistant function.

<Huawei> system-view
[Huawei] ops
[Huawei-ops] assistant scheduler suspend
Info: OPS function disable.

clear ops running context

Function

The clear ops running context command clears saved contexts.

Format

clear ops running context [ context-name ]

Parameters

Parameter

Description

Value

context-name

Specifies the context name.

If context-name is not specified, all contexts will be cleared.

The value is a string of 1 to 16 case-sensitive characters without spaces.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

When a Python script uses an ops.context.save(varName, value) API, the device saves specified variables in the script as contexts. In another script, the device can use the ops.context.retrieve(varName) API to obtain the saved context variables and then clear the contexts to transmit variables between two scripts.

You can also run this command to clear context variables and unused contexts.

To check the contexts saved on the device, run the display ops running context command.

Example

# Clear all the contexts on the device

<Huawei> system-view
[Huawei] ops
[Huawei-ops] clear ops running context
Info: All OPS context cleared.  

display ops assistant

Function

The display ops assistant command displays information about OPS assistants.

Format

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

Parameters

Parameter

Description

Value

current

Displays brief information about the current status of assistants.

-

verbose

Displays detailed information about the current status of assistants.

-

history

Displays historical operation records of assistants.

-

name assistant-name

Specifies an assistant name, namely, a Python script name for an assistant.

The value is a string of 1 to 118 case-sensitive characters without spaces. The file name extension of a Python script is .py.

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 an assistant, including the assistant name, running status, and execution result. The command can display a maximum of 100 latest assistant records.

Example

# Display brief information about the current status of assistants.

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

Item

Description

Assistant

Name of an assistant.

State

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

Condition

Trigger condition for the assistant:
  • cli: CLI event
  • multimulti: complex event
  • UAM: routing event
  • timer: timer event
  • trap: alarm event
  • iclog: log event
  • ADP_NQA: NQA test event
  • IFM_IFPDT: interface status event

# Display detailed information about the current status of 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-69  Description of the display ops assistant current verbose command output

Item

Description

Assistant information

Assistance task information.

Name

Name of an assistant.

State

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

Running statistics

Detailed running information about the assistant.

Running times

Number of running times.

Queue size/(free)

Number of buffered assistants. If the number of buffered assistants reaches the maximum value, subsequent 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 of the assistant. The Condition information field is displayed only for a complex event script.

Condition tag

Condition name.

Condition type

Trigger condition type. The value is multi.

Threshold

Maximum number of times 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 trigger 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 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                :2015-06-25 19:48:51                            
    Execute start time          :2015-06-25 19:48:51                            
    Execute end time            :2015-06-25 19:48:53                            
    Execute result              :normal 
Table 3-70  Description of the display ops assistant history command output

Item

Description

Assistant history information

Assistant task historical information.

Name

Name of an assistant.

Running information

Running information about the assistant.

Trigger condition

Task trigger condition for the assistant:
  • cli: CLI event
  • multi: complex event
  • UAM: routing event
  • timer: timer event
  • trap: alarm event
  • iclog: log event
  • ADP_NQA: NQA test event
  • IFM_IFPDT: interface status event

Trigger event name

Triggered task name for the assistant.

Trigger time

Trigger time of the assistant.

Execute start time

Execution start time of an assistant task.

Execute end time

Task execution end time of the assistant.

Execute result

Execution result of an assistant task.

display ops environment

Function

The display ops environment command displays information about OPS environment variables.

Format

display ops environment

Parameters

None

Views

All views

Default Level

3: Management level

Usage Guidelines

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

User-defined environment variables are displayed in alphabetical order.

Example

# Display user-defined environment variables

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

Item

Description

No.

Environment variable number. The value ranges from 1 to 100.

Name

Indicates an environment variable name.

To configure this parameter, run the environment command.

Value

Indicates an environment variable value.

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 an assistant name, namely, a Python script name for an assistant.

The value is a string of 1 to 118 case-sensitive characters without spaces. The file name extension of a Python script is .py.

Views

All views

Default Level

3: Management level

Usage Guidelines

You can use this command to check execution errors of all scripts or a specified script. According to the command output, you can correct the errors.

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(o)                                                      
  File "sd1:$_user/test12.py", line 7, in ops_execute                           
    status, err_context = o.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(o)                                                      
  File "sd1:$_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-72  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 "sd1:$_user/test12.py", line 7, in ops_execute

Location where an error occurs.

status, err_context = o.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 running context

Function

The display ops running context command displays existing contexts on the device.

Format

display ops running context

Parameters

None

Views

All views

Default Level

3: Management level

Usage Guidelines

When a Python script uses an ops.context.save(varName, value) API, the device saves specified variables in the script as contexts. In another script, the device can use the ops.context.retrieve(varName) API to obtain the saved context variables and then clear the contexts to transmit variables between two scripts.

To check the contexts that are saved but not obtained by the device, run the display ops running context command.

To clear saved contexts, run the clear ops running context command.

Example

# Display existing contexts on the device.

<Huawei> display ops running context
Name              Type      Value                                               
varName1          digit     1234                                                
varName2          string    5678 
Table 3-73  Description of the display ops running context command output

Item

Description

Name

Indicates a variable name.

Type

Type of a variable value:
  • digit: an integer

  • string: a string

Value

Indicates a variable value.

environment

Function

The environment command configures user-defined environment variables.

The undo environment command deletes user-defined environment variables.

By default, no environment variable is configured.

Format

environment variable-name [ variable-value ]

undo environment variable-name

Parameters

Parameter

Description

Value

variable-name

Specifies the name of an 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 an environment variable.

The value is a string of 1 to 31 case-sensitive characters without spaces.

NOTE:

If the string is enclosed within double quotation marks ("), the string can contain spaces.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

Application 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 environment variables to simplify the configuration and improve flexibility and feasibility of the Python script.

To define environment variables, run the environment command.

Precautions

  • If variable-name is specified multiple times, the system will prompt that the configured environment variable already exists. You can choose whether to overwrite the existing variable value.

  • The environment command can configure a maximum of 100 environment variables.

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

Example

# Set the value of the 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 assistants in the OPS view.

Example

# Display the OPS view.

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

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 save a Python script to the root directory of a device, you only need to specify the file name of the script.

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

The value is a string of 1 to 118 case-sensitive characters without spaces. The file name extension of a Python script is .py.

NOTE:

file-name cannot be set to the file name of a built-in Python script, such as cli.py, context.py, environment.py, farg.py, frame.py, iclog.py, interface.py, nqa.py, ops.py, route.py, snmp.py, spr.py, terminal.py, timer.py, trap.py, site.py, os.py, posixpath.py, stat.py, genericpath.py, warnings.py, linecache.py, types.py, UserDict.py, _abcoll.py, abc.py, _weakrefset.py, copy_reg.py, traceback.py, sysconfig.py, re.py, sre_compile.py, sre_parse.py, sre_constants.py, getopt.py, io.py, _pyio.py, __builtin__.py, __main__.py, _ast.py, _codecs.py, _ops.py, _sre.py, _symtable.py, _warnings.py, _weakref.py, errno.py, exceptions.py, gc.py, imp.py, marshal.py, posix.py, pwd.py, signal.py, sys.py, thread.py, xxsubtype.py, and zipimport.py.

destination directory

Specifies the installation directory of a Python script.

The value is a string of 1 to 45 case-insensitive characters without 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.

Views

User view

Default Level

3: Management level

Usage Guidelines

Application Scenario

OPS allows you to run the scripts you make. You can run the scripts after installing them. Before binding a Python script to an assistant, install the script.

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

Precautions

  • Before installing a Python script, upload the script to the device.
  • 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.
  • To install Python 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 board.
  • Before reinstalling a script, run the ops uninstall file command to uninstall the script.
  • The maximum size of a script is 1 MB.
  • It is recommended that the total size of files installed in $_user be smaller than 100 MB. If the total file size exceeds 100 MB, performance of data synchronization between the active and standby boards may deteriorate.

Example

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

<Huawei> ops install file config.py

# Install the script config.py in the sd1: root directory to the specific directory sd1:/$_user/user.

<Huawei> ops install file config.py destination user

# Install the script config.py in the sd1:/admin directory to the default directory sd1:/$_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 file name of the script to be uninstalled.

The value is a string of 1 to 118 case-sensitive characters without spaces and can contain a file directory.

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

Views

User view

Default Level

3: Management level

Usage Guidelines

Application Scenario

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

Precautions

  • This command cannot uninstall a script that has been bound to an assistant. To uninstall the script, unbind it from assistant first.
  • If the script bound to an assistant calls other scripts, the called scripts can be uninstalled using this command. Therefore, it is recommended that you use one script to implement required functions.

Example

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

<Huawei> ops uninstall file config.py

# Uninstall the script config.py in the specific directory sd1:/$_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 an assistant name, namely, a Python script name for an assistant.

The value is a string of 1 to 118 case-sensitive characters without spaces. The file name extension of a Python script is .py.

NOTE:

script-name cannot be set to the file name of a built-in Python script, such as cli.py, context.py, environment.py, farg.py, frame.py, iclog.py, interface.py, nqa.py, ops.py, route.py, snmp.py, spr.py, terminal.py, timer.py, trap.py, site.py, os.py, posixpath.py, stat.py, genericpath.py, warnings.py, linecache.py, types.py, UserDict.py, _abcoll.py, abc.py, _weakrefset.py, copy_reg.py, traceback.py, sysconfig.py, re.py, sre_compile.py, sre_parse.py, sre_constants.py, getopt.py, io.py, _pyio.py, __builtin__.py, __main__.py, _ast.py, _codecs.py, _ops.py, _sre.py, _symtable.py, _warnings.py, _weakref.py, errno.py, exceptions.py, gc.py, imp.py, marshal.py, posix.py, pwd.py, signal.py, sys.py, thread.py, xxsubtype.py, and zipimport.py.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

Application Scenario

Traditional network devices provide only limited functions and predefined services, failing to meet the requirements for diversified services as the network develops. OPS allows you to run scripts to implement customized functions, meeting these requirements.

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.

Pre-configuration Tasks

The Python 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.
  • The system does not check correctness of the Python script.
  • The script-assistant python command can be used to configure a maximum of 100 scripts.

Example

# Configure an assistant for the script config.py.

<Huawei> ops install file config.py
<Huawei> system-view
[Huawei] ops
[Huawei-ops] script-assistant python config.py
Info: Succeeded in installing script assistant config.py.

shutdown script-assistant

Function

The shutdown script-assistant command stops an assistant.

The undo shutdown script-assistant command starts an assistant.

By default, an assistant is started.

Format

shutdown script-assistant script-name

undo shutdown script-assistant script-name

Parameters

Parameter

Description

Value

script-name

Specifies an assistant name, namely, a Python script name for an assistant.

The value is a string of 1 to 118 case-sensitive characters without spaces. The file name extension of a Python script is .py.

Views

OPS view

Default Level

3: Management level

Usage Guidelines

Application Scenario

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

Precautions

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

Example

# Stop an 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-02-18

Document ID: EDOC1000097293

Views: 36943

Downloads: 101

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