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

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).
Open a CLI Channel

Open a CLI Channel

  • Function Description

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

  • Command Prototype

    opsObj.cli.open()

  • Parameter Description
    Table 3-856  Parameters supported by APIs for opening CLI channels

    Method

    Description

    opsObj

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

  • Description of Return Values

    First return value: If None is displayed, an error has occurred. Otherwise, command handles are returned.

    Second return value: result description expressed in character strings

  • Example
    test.py
    import ops
    import igpcomm
    def ops_condition(_ops):
        _ops.cli.subscribe("con11","logbuffer1",True,True,False,10)
        _ops.correlate("con11")
        return ret
    def ops_execute(_ops):
        handle, err_desp= _ops.cli.open()
        choice = {"Continue": "y", "save": "n"}
        _ops.cli.execute(handle,"sys")
        _ops.cli.execute(handle,"pm",None)
        _ops.cli.execute(handle,"undo statistics-task a",choice)
        _ops.cli.execute(handle,"commit",None)
        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.
    NOTE:

    After the CLI channel is opened using the script, commands can be delivered to the device only when the CLI terminal displays the user view.

    The CLI channel authorities are the user authorities of the maintenance assistant created.

    A script can be used to create only one CLI channel. If an attempt is made to create a second CLI channel using this script, the system returns a failure.

    A VTY resource is consumed for every channel opened. The display users command shows that a VTY resource is consumed by an assistant (Assistant: Name). If not more than 3 VTYs are available, opening a CLI channel fails.

Translation
Download
Updated: 2019-03-21

Document ID: EDOC1000166567

Views: 27392

Downloads: 121

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