The cinder.volume.drivers.netapp.dataontap.client.api Module

NetApp API for Data ONTAP and OnCommand DFM.

Contains classes required to issue API calls to Data ONTAP and OnCommand DFM.

exception NaApiError(code='unknown', message='unknown')

Bases: exceptions.Exception

Base exception class for NetApp API errors.

class NaElement(name)

Bases: object

Class wraps basic building block for NetApp API request.

add_attr(name, value)

Add the attribute to the element.

add_attrs(**attrs)

Add multiple attributes to the element.

add_child_elem(na_element)

Add the child element to the element.

add_new_child(name, content, convert=False)

Add child with tag name and content.

Convert replaces entity refs to chars.

add_node_with_children(node, **children)

Creates named node with children.

static create_node_with_children(node, **children)

Creates and returns named node with children.

get_attr(name)

Get the attribute with the given name.

get_attr_names()

Returns the list of attribute names.

get_child_by_name(name)

Get the child element by the tag name.

get_child_content(name)

Get the content of the child.

get_children()

Get the children for the element.

get_content()

Get the text for the element.

get_name()

Returns the tag name of the element.

has_attr(name)

Checks whether element has attribute.

set_content(text)

Set the text string for the element.

to_string(pretty=False, method='xml', encoding='UTF-8')

Prints the element to string.

translate_struct(data_struct)

Convert list, tuple, dict to NaElement and appends.

Example usage: 1. <root>

<elem1>vl1</elem1> <elem2>vl2</elem2> <elem3>vl3</elem3>

</root> The above can be achieved by doing root = NaElement(‘root’) root.translate_struct({‘elem1’: ‘vl1’, ‘elem2’: ‘vl2’,

‘elem3’: ‘vl3’})

2. <root>

<elem1>vl1</elem1> <elem2>vl2</elem2> <elem1>vl3</elem1>

</root> The above can be achieved by doing root = NaElement(‘root’) root.translate_struct([{‘elem1’: ‘vl1’, ‘elem2’: ‘vl2’},

{‘elem1’: ‘vl3’}])
class NaServer(host, server_type='filer', transport_type='http', style='basic_auth', username=None, password=None, port=None)

Bases: object

Encapsulates server connection logic.

NETAPP_NS = 'http://www.netapp.com/filer/admin'
SERVER_TYPE_DFM = 'dfm'
SERVER_TYPE_FILER = 'filer'
STYLE_CERTIFICATE = 'certificate_auth'
STYLE_LOGIN_PASSWORD = 'basic_auth'
TRANSPORT_TYPE_HTTP = 'http'
TRANSPORT_TYPE_HTTPS = 'https'
URL_DFM = 'apis/XMLrequest'
URL_FILER = 'servlets/netapp.servlets.admin.XMLrequest_filer'
get_api_version()

Gets the API version tuple.

get_port()

Get the server communication port.

get_server_type()

Get the target server type.

get_style()

Get the authorization style for communicating with the server.

get_timeout()

Gets the timeout in seconds if set.

get_transport_type()

Get the transport type protocol.

get_vfiler()

Get the vfiler to use in tunneling.

get_vserver()

Get the vserver to use in tunneling.

invoke_successfully(na_element, enable_tunneling=False)

Invokes API and checks execution status as success.

Need to set enable_tunneling to True explicitly to achieve it. This helps to use same connection instance to enable or disable tunneling. The vserver or vfiler should be set before this call otherwise tunneling remains disabled.

send_http_request(*args, **kwargs)

Invoke the API on the server.

set_api_version(major, minor)

Set the API version.

set_password(password)

Set the password for authentication.

set_port(port)

Set the server communication port.

set_server_type(server_type)

Set the target server type.

Supports filer and dfm server types.

set_style(style)

Set the authorization style for communicating with the server.

Supports basic_auth for now. Certificate_auth mode to be done.

set_timeout(seconds)

Sets the timeout in seconds.

set_transport_type(transport_type)

Set the transport type protocol for API.

Supports http and https transport types.

set_username(username)

Set the user name for authentication.

set_vfiler(vfiler)

Set the vfiler to use if tunneling gets enabled.

set_vserver(vserver)

Set the vserver to use if tunneling gets enabled.

class SSHUtil(host, username, password, port=22)

Bases: object

Encapsulates connection logic and command execution for SSH client.

CONNECTION_KEEP_ALIVE = 600
MAX_CONCURRENT_SSH_CONNECTIONS = 5
RECV_TIMEOUT = 3
WAIT_ON_STDOUT_TIMEOUT = 3
execute_command(client, command_text, timeout=3)
execute_command_with_prompt(client, command, expected_prompt_text, prompt_response, timeout=3)
create_api_request(api_name, query=None, des_result=None, additional_elems=None, is_iter=False, record_step=50, tag=None)

Creates a NetApp API request.

Parameters:
  • api_name – API name string
  • query – API query as dict
  • des_result – desired result as dict
  • additional_elems – dict other than query and des_result
  • is_iter – is iterator API
  • record_step – records at a time for iter API
  • tag – next tag for iter API
invoke_api(na_server, api_name, api_family='cm', query=None, des_result=None, additional_elems=None, is_iter=False, records=0, tag=None, timeout=0, tunnel=None)

Invokes any given API call to a NetApp server.

Parameters:
  • na_server – na_server instance
  • api_name – API name string
  • api_family – cm or 7m
  • query – API query as dict
  • des_result – desired result as dict
  • additional_elems – dict other than query and des_result
  • is_iter – is iterator API
  • records – limit for records, 0 for infinite
  • timeout – timeout seconds
  • tunnel – tunnel entity, vserver or vfiler name

Previous topic

The cinder.volume.drivers.netapp.dataontap.block_cmode Module

Next topic

The cinder.volume.drivers.netapp.dataontap.client.client_7mode Module

Project Source

This Page