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

CloudEngine 12800 and 12800E V200R003C00

This document describes the configurations of Device Management, including device status query, hardware management, Information Center Configuration, NTP, Synchronous Ethernet Configuration, Fault Management Configuration, Energy-Saving Management Configuration, Performance Management Configuration, Maintenance Assistant Configuration, and OPS Configuration.

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).
Configuring a Script Assistant

Configuring a Script Assistant


Python scripts can be run by being associated with script assistants to run. In a script assistant, trigger conditions are defined using the ops_condition() function in a Python script, and then tasks are defined using the ops_execute() function in the script. The trigger conditions supported by a script assistant include the CLI event, timer event, and route change event. For the method of subscribing events, see "Python API" in RESTful API Reference.

The following example is a Python script. The content in bold defines trigger conditions and tasks, which can be edited as required.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Define the function of the trigger condition.
def ops_condition(_ops):
	_ops.timer.cron("con1","0 1 * * * *")      # Set the timer event.
	_ops.correlate("con1")      # Subscribe the timer event.

# Define the functions of tasks.
def ops_execute(_ops):
	handle, err_desp  =      # Open the CLI channel.
	_ops.cli.execute(handle,"display device > health.txt")      # Execute CLIs.
	_ops.cli.execute(handle,"display health >> health.txt")
	_ops.cli.execute(handle,"display ip routing-table >> health.txt")
	_ops.cli.execute(handle,"display lldp neighbor brief >> health.txt")
	_ops.cli.execute(handle,"tftp put health.txt")
	ret = _ops.cli.close(handle)      # Close the CLI channel.
	return 0

The ops_condition() and ops_execute() functions have been defined in the Python script to define trigger conditions and tasks.

This configuration process is supported only on the Admin-VS.


  1. Upload a Python script to the device. For details on how to upload a file to the device, see File Management in the CloudEngine 12800 and 12800E Series Switches Configuration Guide - Basic Configuration.
  2. Run the ops install file file [ destination directory ] command in the user view to install the Python script.

    If you do not specify destination directory in the command, the Python script is loaded to the default path flash:/$_user/. If this parameter is specified, the Python script is loaded to the path flash:/$_user/directory/. If the specified directory does not exist, the system automatically creates the directory. A maximum of seven levels of subdirectories can be created under flash:/$_user/.

  3. Run the system-view command to enter the system view.
  4. Run the ops command to enter the OPS view.
  5. Run the assistant task-name command to create a command assistant.
  6. Run the script-assistant python file-name command to create a Python script assistant.

    A script assistant is enabled by default after being created. When the trigger condition specified in a Python script is met, the tasks specified in the script will be automatically executed.

  7. Run the commit command to commit the configuration.

Verifying the Configuration

Run the display ops assistant { history | current | verbose } [ default ] [ name task-name ] command to check information about an assistant.

Updated: 2019-05-05

Document ID: EDOC1100004193

Views: 70959

Downloads: 26

Average rating:
This Document Applies to these Products

Related Version

Related Documents

Previous Next