In the previous episode #4 , we discussed the programmatic way to find the ONTAPI (ZAPI) usage against a cluster and to find the equivalent ONTAP® REST APIs for ONTAPI calls. In this episode, we look at how private CLI passthrough can be leveraged for ONTAPI to REST gaps.
What is private CLI passthrough?
A CLI command can be executed as an ONTAP REST API call. In order to execute the advanced and diagnostic mode commands, or to get advanced attributes as per use cases, users can drill down to the CLI to execute the commands. This option helps many customers and partners to address the existing ONTAPI to REST APIs gaps in completing their automation story.
How does it work?
Verbs used in the CLI for create, show, update, and delete operations map to corresponding http methods, as shown in the following table. (See “A simple example,” below, in which show in CLI gets converted to a GET call in REST APIs.)
REST APIs Verb
Any space in a full CLI command becomes a forward slash in this private REST API endpoint, with the default prefix /api/private/cli/
CLI passthrough is an advanced approach that helps customers and partners to execute even advanced and diagnostic mode commands in CLI. However, there are certain restrictions in CLI passthrough. The primary limitation is that private CLI passthrough doesn't handle any “systemshell”, “node run”, or “statistics” commands, or any commands that ask for non confirmation user input, like passwords. Any command that requires interactive input that doesn't have an alternative way to pass that data, like a hidden parameter, will fail.
The following CLI command with a space gets replaced by a forward slash, and show turns into a GET call in REST code (Note the color indications for better understanding.) Since it’s a CLI command, /api/private/cli is a prefix in http call.
CLI Command: >> System node power show
def get_system_node_power(cluster, headers_inc): "Get system node power CLI command"