Configuring a Script Assistant

This section describes how to configure a script assistant.


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 such as the CLI event, timer event, and route change event.

  • The ops_condition() and ops_execute() functions must be defined in the Python script of a script assistant to set trigger conditions and tasks.
  • This configuration process is supported only by the admin VS.


  1. Upload a Python script to the device. For details about how to upload a file to the device, see File System Management.
  2. In the user view, run ops install file file [ destination directory ]

    The Python script is installed.

    If you do not specify destination directory in the command, the Python script is loaded to the default path cfcard:/$_user/. If this parameter is specified, the Python script is loaded to the path cfcard:/$_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 cfcard:/$_user/.

  3. Run system-view

    The system view is displayed.

  4. Run ops

    The OPS view is displayed.

  5. Run enable

    OPS is enabled.

  6. (Optional) Run environment env-name env-value

    An environment variable is configured.

    The OPS supports the following environment variables:
    • System environment variables: environment variables that are automatically generated during system running.

    • User environment variables: environment variables that are configured using the environment command.

    Intermediate data generated during Python script running is lost after the Python is shut down. You can run the environment command to configure the Python script's running variable as an environment variable so that data is saved or used by other users.

  7. Run script-assistant python script-name

    A Python script assistant is configured.

    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.

  8. Run commit

    The configuration is committed.

Verifying the Configuration

Run the display ops assistant current command to check current information about maintenance assistants.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >