< Home

Opening CLI Channel

Interface Name

Opening CLI channel

Application Phase

Execution phase

API Prototype

result1_handle, result2_description = ops.cli.open()

Description

None

Return Value

The first return value is a command line handle. The value None indicates an error, while other values indicate command line handles.

The second return value is the failure cause when the first return value is None.

Usage Description

The user level of the CLI channel opened in the script is 15.

Commands can be delivered to a device only after the CLI channel is opened in a script.

Only one CLI channel can be created in a script. If you try to create the second CLI channel, the system will display a failure message.

A VTY resource is consumed each time a CLI channel is opened. To check which VTY resources have been occupied by Assistant: Name, run the display users command. When only three or less VTY resources are available, no more CLI channels can be opened. Therefore, after the CLI channel is created and commands are executed in the script, you need to close the CLI channel in time using Closing CLI Channel API (ops.cli.close (fd)) to save VTY resources.

The first return value of the opening CLI channel API is used as the input parameter of the Executing CLI Command and Closing CLI Channel APIs. So the return value must be specified when the opening CLI channel API is used.

Example

When a subscription event is matched, you can open the CLI channel and run related commands.

handle, descri_str = ops.cli.open()          # Open the CLI channel.
result, n11, n21 = ops.cli.execute(handle,"system-view")         # Run the system-view command to enter the system view.
result, n11, n21 = ops.cli.execute(handle,"ops")         # Run the ops command to enter the OPS view.
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >