Session Management APIs for C and C++

The Session Management APIs are used to open or close the server connection, and to set and retrieve the server session parameters, such as transport type, authentication style and so on.

This page contains information about the Session Management APIs for C and C++, including the description and syntax, and the input, input types, input description, and input return values.

na_server_open

Prototype

na_server_t* na_server_open(const char* server, int major, int minor);

Description

Sets the server context and assigns default values to the session parameters.

Following are the default values:

username= ""

password= ""

style= NA_STYLE_LOGIN_PASSWORD

port= 80

transport= NA_SERVER_TRANSPORT_HTTP

servertype= NA_SERVER_TYPE_FILER

You can overwrite the default values by using the na_server* Core APIs.

 

Input

Type

Description

server

const char*

The name or the IP address of the server in IPv4 or IPv6 format.

major

int

The major version of the Data ONTAP API.

minor

int

The minor version of the Data ONTAP API.

Return value

[top]

na_server_style

Prototype

void na_server_style(na_server_t* srv, na_style_t style);

Description

Sets the authentication mechanism to be used for communicating with the given server.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

style

na_style_t

The communication style that is to be set.

Following are the supported values:

NA_STYLE_LOGIN_PASSWORD

NA_STYLE_RPC

NA_STYLE_HOSTSEQUIV

If style=NA_STYLE_LOGIN_PASSWORD, you must furnish an administrator user name and password with na_server_adminuser().

If style=NA_STYLE_RPC, your code should run on a Windows system, so that a native Windows authentication based on remote procedure call is used.

If style=NA_STYLE_HOSTSEQUIV, the server context authenticates against the /etc/hosts.equiv file on the NetApp storage system. You do not have to set the administrator user name and password in this case.

Return value

None

[top]

na_server_set_server_type

Prototype

int na_server_set_server_type(na_server_t *srv, na_server_type_t type)

Description

Sets the type of system you are connecting to.

 

Input

Type

Description

srv

na_server_t*

Pointer to the server element.

type

na_server_type_t

The server type to be set.

Following are the supported values:

  •  NA_SERVER_TYPE_FILER—to connect to a NetApp storage system.

  •  NA_SERVER_TYPE_NETCACHE—to connect to a NetCache appliance.

  •      NA_SERVER_TYPE_DFM—to connect to a DataFabric Manager server.

The default server type is NA_SERVER_TYPE_FILER.

Return value

[top]

na_server_adminuser

Prototype

int na_server_adminuser(na_server_t* srv, const char* login, const char* pwd);

Description

Sets the user name and password for a server context, where authentication style is NA_STYLE_LOGIN_PASSWORD.

The user that you specify should have administrative privilege on the storage system.

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

login

const char*

The login name.

pwd

const char*

The password.

Return value

[top]

na_server_set_transport_type

Prototype

int na_server_set_transport_type(na_server_t* srv, na_server_transport_t transport, const union zfd_setopt* transportarg);

Description

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

transport

na_server_transport_t

The transport type.

Following are the supported transport types:

  • NA_SERVER_TRANSPORT_HTTP

  • NA_SERVER_TRANSPORT_HTTPS

The default transport type is NA_SERVER_TRANSPORT_HTTP. For secure transport, use NA_SERVER_TRANSPORT_HTTPS as the transport type.

transportarg

const union zfd_setopt*

The transport argument.

You should set transportarg to zero for both the HTTP and HTTPS transport protocols.

Return value

[top]

na_server_set_vfiler

Prototype

int na_server_set_vfiler(na_server_t* srv, char * vfilerserver);

Description

Sets the name of the vFiler unit on which the API commands need to be invoked for the given server context.

After the command is set, all the API commands are executed on the vFiler unit through the actual storage system.

This API supports the vFiler tunneling feature.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

vfilerserver

char *

The name of the vFiler unit that is to be set.

Return value

[top]

na_server_set_port

Prototype

int na_server_set_port(na_server_t* srv, int port);

Description

Sets the port on which the API commands need to be invoked for the given server context.

Following is the default port on the storage system for Data ONTAP API communication:

HTTP=80

HTTPS=443

Set this port number to port, if Data ONTAP has the default port settings.

Depending on the transport type settings, use the above port numbers as input to this API if Data ONTAP has default port settings.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

port

int

The port number that is to be set.

Return value

[top]

na_server_set_timeout

Prototype

int na_server_set_timeout(na_server_t* srv, int timeout);

Description

Sets a connection timeout for the following actions:

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

timeout

int

The timeout value.

This value is in seconds and should be zero or a positive number.

If it is non-zero, the server uses non-blocking socket connection. If it is zero, the server uses blocking connection, which is the default behavior.

Return value

[top]

na_server_invoke

Prototype

na_elem_t*  na_server_invoke(na_server_t* srv, const char* api, ...);

Description

Invokes any Data ONTAP API on the given server.

Input the name-value pairs and terminate the list with NULL. You can input only an even number of arguments to this function. The name-value pairs take only strings. All the elements are assembled and sent to the server.

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

api

const char *

The name of the API that is to be invoked.

...

char *

The input arguments as a name-value pair.

Return value

The pointer to the input output element containing the server response

[top]

na_server_invoke_elem

Prototype

na_elem_t* na_server_invoke_elem(na_server_t* srv, na_elem_t* elt);

Description

Sends the API request in the form of input output element, which has the embedded Data ONTAP API command and its input arguments.

After the API call ends, you must free the element elt by invoking na_elem_free().

While processing optional inputs from a dialog box, it is recommended that you construct an element chain instead of using na_server_invoke().

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

elt

na_elem_t*

The pointer to the element chain.

Return value

The pointer to the element containing the server's reply

[top]

na_server_close

Prototype

int na_server_close(na_server_t* srv);

Description

Clears the server context opened by na_server_open().This is done by freeing all the allocated resources for that server context.

You can have multiple server contexts opened at the same time and each opened server context has to be closed individually.

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

Return value

[top]

na_server_set_debugstyle

Prototype

void na_server_set_debugstyle(na_server_t * srv, na_debug_style_t style);

Description

Sets the debug style for the given server context.

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

style

na_debug_style_t

The debug style that is to be set.

It sets the debug style to NA_PRINT_DONT_PARSE to print the raw XML output from the server with the API na_server_get_raw_xml_output. Following are the supported values for style:

·         NA_NO_DEBUG

·         NA_PRINT_DONT_PARSE

·         NA_DONT_PRINT_DONT_PARSE

Return value

None

[top]

na_server_get_style

Prototype

na_style_t na_server_get_style(na_server_t* srv);

Description

Gets the authentication style used by the given server context.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

Return value

The server style.

Following are the possible return values:

[top]

na_server_get_transport_type

Prototype

na_server_transport_t na_server_get_transport_type(na_server_t* srv)

Description

Gets the transport type used by the given server context.

 

Input

Type

Description

srv

na_server_t*

The pointer to the server element.

Return value

The current transport type used for the given server context.

Following are the possible return values:

[top]

na_server_get_port

Prototype

int na_server_get_port (na_server_t * srv);

Description

Gets the port number for the given server context used for invoking API commands.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

Return value

None

[top]

na_server_get_timeout

Prototype

int na_server_get_timeout(na_server_t *srv);

Description

Gets the connection timeout value of the given server context.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

Return value

The connection timeout value (in seconds)

[top]

na_server_get_raw_xml_output

Prototype

char * na_server_get_raw_xml_output(na_server_t * srv);

Description

Gets the output of the API invoked in raw XML format.

The debug style of the server should be set to NA_PRINT_DONT_PARSE before using this API.

 

Input

Type

Description

srv

na_server_t *

The pointer to the server element.

Return value

The raw XML output