appliance

class appliance.Appliance

An appliance represents CDS or SKY actifio product.

As a general rule use cmd method for all udsinfo and udstask commands. This allows them to be changed dynamically at runtime. If you are sending a hidden rest command use rest and if you are sending a command that can’t be sent over rest use raw.

Usage:
a = Appliance(ip_address=‘172.27.4.0’ r = a.cmd(‘udsinfo lshost -filtervalue hostname=dog&hosttype=puppey’) hostid = r.parse(k=’id’)

The API for this object is aided by dynamic_keywords. If we call a method with a name matching the conversion table in keyword_prefixes, we will attempt to build a simple call and check method. This avoids writing a lot of boilerplate and filters all calls through a specific naming convention and methods, so it can be monkeypatched if a feature changes or a bug is found.

__init__(hostname=None, ip_address=None, connection_type="rest", appliance_type=None, version=None, ssh_args=None, rest_params=None)

Setup config info as well as permissions

ssh_args should normally have username, password, port as keys. rest_params should normally have name, password, vendorkey as keys.

Parameters:
  • hostname – DNS name of machine to connect to (hostname or ip_address required)
  • ip_address – Ip address of machine to connect to (hostname or ip_address required)
  • connection_type – Default way to connect to appliance (options: cli, rest)
  • appliance_type – Category of appliance
  • ssh_args – Dictionary of ssh connection args to send to paramiko’s connect method
  • rest_params – Dictionary of connection params to send alongside RESTful requests
__enter__()
__exit__(exc_type, exc_val, exc_tb)
_make_connections()
cmd(operation, **update_cmds)

Connect to the machine using the classes connection type and send the given command.

If an argument needs to be sent in the operation and not in kwargs with argument make sure it is first in the series of commands.

Parameters:
  • operation – CLI-like command to send
  • update_cmds – add or overwrite commands in the operation. Will not add if value is none.
Returns:

ActResponse object

rest(operation, **update_cmds)

Use when you explicitly want to connect over RESTful API.

Parameters:
  • operation – CLI-like command to be sent. ex. udsinfo lshost
  • update_cmds – keyword arguments to be sent with command
Returns:

cli(operation, **update_cmds)

Use when you explicitly want to connect over ssh.

Parameters:
  • operation – CLI-like command to be sent. ex. udsinfo lshost
  • update_cmds – keyword arguments to be sent with command
Returns:

ActResponse object

raw(command, *args, **kwargs)

Use when you explicitly want to connect over ssh and send raw ssh commands.

This houses the functionality unlike rest method because I want to avoid passing around the client to retain channels. :param command: :return: stdout, stderr, exit status

ui_call(method, url_suffix, params=None, data=None, **kwargs)

Used to send Actifio desktop rest calls.

Parameters:
  • method – type of rest call to make. ie. GET, POST
  • url_suffix – What follows actifio in the UI call. i.e. https://<some_hostname>/actifio/<url_suffix here>
Returns:

teardown()
appliance_type()
get_appliance_type()

Find the appliance’s type. ex. sky, cds

version()
get_version()
new_user(new_name, new_password=None)

This is an idempotent way to select and sign in as a new user with default rights.

Parameters:
  • new_name – New username to create or find
  • new_password – New password to set or use
Returns:

New Appliance object with the new user information based off of the current instance