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.


RESTful API Reference

CloudEngine 8800, 7800, 6800, and 5800 V200R002C50

This document describes the OPS APIs supported by the device, including OPS-supported operations, request examples, elements in the requests, response examples, elements in the responses, and response status codes.
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).
Execute Commands

Execute Commands

  • Function Description

    The OPS allows the system to use the Python script to open a CLI channel and execute commands.

  • Command Prototype

    ops.cli.execute(fd, command, choice=None)

  • Parameter Description
    Table 3-857  Parameters supported by APIs for executing commands




    Specifies an OPS object. It is obtained using ops.ops() in instance mode.


    Specifies a command handle. It is generated by


    Specifies a command to be executed, for example, system-view im. You do not need to press Enter; the CLI automatically adds the Enter function. The value can only be one command.


    Specifies a lexical type, used for auto reply for interactive commands.choice = {"Continue?": "n", "save": "n"}. A maximum of eight options are supported. Multiple lines are entered for multi-line commands, such as header login information, for example, choice={"": "a\r\nb\r\n\a"}.

  • Description of Return Values

    First return value: If None is returned, the command fails to be issued to the CLI or command execution times out. Otherwise, the command output is returned. Each data package is 32 KB in size, separated at a carriage return.

    Second return value: If Next is 0, no more output will be displayed. If Next is 1, more output will be displayed, and this function is still called for obtaining the next batch of data, except that you must set command=None and choice=None.

    Third return value: result description expressed in character strings

  • Example
    import ops
    import igpcomm
    def ops_condition(_ops):
        return ret
    def ops_execute(_ops):
        handle, err_desp=
        choice = {"Continue": "y", "save": "n"}
        _ops.cli.execute(handle,"undo statistics-task a",choice)
        ret = _ops.cli.close(handle)
        print 'test2 =',ret
        return 0
    1. When the front end executes the script, the CLI channel is opened, and the CLI terminal displays the user view.
    2. Run the system-view command to enter the system view.
    3. Run the pm command to enter the PM view.
    4. Run the undo statistics-task a command so the system operates based on the choice variable value. This command is an interactive command.
    5. Run the commit command to commit the configuration.
    6. Close the CLI channel.
Updated: 2019-03-21

Document ID: EDOC1000166567

Views: 30110

Downloads: 127

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