initiators

Ethdrv

class otto.initiators.ethdrv.Ethdrv(get_ethdrv)[source]

A class for interacting with initiator’s debug files. Requires get_ethdrv call back function. This callback function must return the contents of the specified entity (filename) under the ethdrv parent (directory).

Basic Usage:

from otto.initiators.solaris import Solaris

i = solaris.Solaris(uname, host, passwd, prompt=None)
i.connect()
print i.ethdrv.release
i.disconnect()
acbs

Returns a dictionary of acbs in the following format:

{'141.2': {'arcnt': 0,
           'index': 186,
           'out': 0,
           'qcnt': 0,
           'resent': 0,
           'sent': 5403,
           'state': 4,
           'target': '141.2',
           'unex': 0,
           'wnd': 16}
           }
ca

Returns a dictionary of ca in the following format:

{'141.2': {'cwnd': 16,
           'index': 186,
           'out': 0,
           'rttavg': 3.8,
           'rttdev': 2.9,
           'ssthresh': 8,
           'target': '141.2',
           'wnd': 16}}
config

Returns a dictionary of config in the following format:

{'140.17': {'config': 'N/A',
            'target': '140.17'},
 '55.203': {'config': 'com.myco.hba hosts=MEGADETH',
            'target': '55.203'}}
corestats

Returns a dictionary of corestats in the following format:

{'arallocfail': 0,
 'arcnt': 0,
 'badcap': 0,
 'badcappair': 0,
 'cecdr': 0,
 'cecrx': 0,
 'cectx': 0,
 'ioqueue': 0,
 'iorequest': 0,
 'ioretire': 0,
 'iosend': 0,
 'iosubmit': 0,
 'sgallocfail': 0,
 'sgbufallocfail': 0,
 'sgbufcnt': 32778,
 'sgcnt': 23,
 'shortcap': 0,
 'srallocfail': 0,
 'srcnt': 0}
ctl

Returns a dictionary of ctl in the following format:

{'tdeadsecs': 180, 'rqsize': 8192, 'srdebug': 'off',
 'qdepth': 'n/a', 'trace': 'off'}
devices

Returns a dictionary of devices in the following format:

{'141.2': {'device': 'sd66',
           'target': '141.2',
           'size': '1000.204GB'}
}
elstats

Returns a dictionary of elstats in the following format:

{'ArpIn': 18510,
 'ArpOut': 16786,
 'DropNoAvail': 0,
 'DropNoMatch': 0,
 'DropNoSync': 0,
 'DropNoWait': 0,
 'DropQpass': 0,
 'DropReject': 0,
 'DropSeq': 0,
 'HlenErrs': 0,
 'InMsgs': 0,
 'LenErrs': 0,
 'OutMsgs': 0,
 'Retrans': 0,
 'elarp': {0: {'creason': '',
               'crto': 90,
               'deathtime': 30000,
               'delayedack': 0,
               'flags': 0,
               'id0': 2093,
               'local': '510000100401336a!17007',
               'next': 2093,
               'opens': 0,
               'outqlen': 0,
               'rcvd': 0,
               'remote': '0000000000000000!0',
               'resends': 0,
               'rid0': 0,
               'rqlen': 0,
               'rto': 90,
               'rttseq': 0,
               'rxidle': 84429880,
               'sa': 50,
               'state': 'Listen',
               'sv': 10,
               'txidle': 84429880,
               'unack': 2094},
           1: {'creason': 'connection closed: ecbclose',
               'crto': 90,
               'deathtime': 30000,
               'delayedack': 0,
               'flags': 0,
               'id0': 2093,
               'local': '510000100401336a!7',
               'next': 2093,
               'opens': 0,
               'outqlen': 0,
               'rcvd': 0,
               'remote': '0000000000000000!0',
               'resends': 0,
               'rid0': 0,
               'rqlen': 0,
               'rto': 90,
               'rttseq': 0,
               'rxidle': 84429880,
               'sa': 50,
               'state': 'Closed',
               'sv': 10,
               'txidle': 84429880,
               'unack': 2094}},
 'myeladdr': '510000100401336a'}
ifstats

See `HBA Namespace documentation`_. Some fields are chipset depentdent. Some fields are only present when non-zero.

Returns a dictionary of ifstats in the following format:

{'1': {'Broadcast Packets Transmitted': 2216, 'drdh': 470, ... }}
ports

Returns a dictionary of ports in the following format:

{0: {'currentlink': 0,
     'ea': '00100401336a',
     'index': 0,
     'maxlink': 10000,
     'name': 'EHBA-20-E-SFP'},
 1: {'currentlink': 10000,
     'ea': '00100401336b',
     'index': 1,
     'maxlink': 10000,
     'name': 'EHBA-20-E-SFP'}}
release

Returns release string

targets

Returns a dictionary list of targets in the following format:

{'200.135': [{'active': 1, 'targ': '200.135', 'ea': '0025906694a9', 'ports': 2},
             {'active': 1, 'targ': '200.135', 'ea': '0025906694a8', 'ports': 2}]
units

Returns a dictionary of units in the following format:

{'ea': '002590c23e63', 'product': 'SRX',
 'eladdr': '5100002590c15a6a', 'ports': 2}

Linux

class otto.initiators.linux.LinuxSsh(*args, **kwargs)[source]

A class for controlling a linux initiator using SSH/SFTP services directly.

This object can be instantiated with a dictionary:

lnx = {'user':'root', 'host: 'localhost','password':'passw0rd!'}
cfg = Namespace({'lnx_host1': lnx})
# the above simulates the config object
my_linux = LinuxSsh(cfg.lnx_host1)
my_linux.connect()
aoediscover()

Call the driver’s discover command. Returns ReturnCode object

aoeflush(aflag=True)

Call the driver’s flush command. Return a ReturnCode object.

aoestat

Returns a dictionary of either the ‘aoe-stat’ output, or the ‘ethdrv-stat’ output (based on self.coraid_module) in the following format:

{'1270.0': {'claim': None,
            'device': None,
            'file': 'sde',
            'ifs': [0, 1],
            'iounit': None,
            'path': '/dev/sde',
            'paths': None,
            'port': [0, 1],
            'size': '100.030GB',
            'state': None,
            'target': '1270.0',
            'targpath': {0: {'address': ['00259096645f', '00259096645e'],
                             'port': 0
                            },
                         1: {'address': ['00259096645f', '00259096645e'],
                             'port': 1
                            }
                        }
            }
}
aoeversion

Returns the version string output of the AoE driver specified by self.coraid_module.

append(filename, text, partial=False, escape=True)[source]

Append string (or list of strings) text to filename.

When a list is given, each string inside is handled independently (but in the order given.)

If text is already found in filename, the append is not run, and None is returned immediately. Otherwise, the given text is appended to the end of the given filename via e.g. echo '$text' >> $filename.

The test for whether text already exists defaults to a full line match, e.g. ^<text>$. You may override this and force partial searching (e.g. ^<text>) by specifying partial=True.

Because text is single-quoted, single quotes will be transparently backslash-escaped. This can be disabled with escape=False.

appendUUID(UUID, mnt_path, fstype)[source]
Append with UUID a device entry at the end of /etc/fstab file
Parameters:
  • UUID (str) – the UUID of a device
  • mnt_path (str) – where it should be mounted
  • fstype (str) – what kind of filesystem is on thta device
Returns:

success status

Return type:

bool

close()

Close this SSHClient and its underlying L{Transport}.

connect(timeout=10, key_file=None)

Currently this method will return False if we can’t connect. If the script ignores this return and proceeds the traceback might not be obvious as to where the problem was.

contains(filename, text, exact=False, escape=True)[source]

Return True if filename contains text (which may be a regex.)

By default, this function will consider a partial line match (i.e. where text only makes up part of the line it’s on). Specify exact=True to change this behavior so that only a line containing exactly text results in a True return value.

This function leverages egrep on the remote end (so it may not follow Python regular expression syntax perfectly), and skips env.shell wrapper by default.

If use_sudo is True, will use sudo instead of run.

If escape is False, no extra regular expression related escaping is performed (this includes overriding exact so that no ^/$ is added.)

ctl(rw, key, skip, shelf_lun, total=None)[source]

Ctl first verifies that the target exists, then reads from/writes to it using ‘ctl’.

df(mount_point)[source]

Returns the amount of disk space available a given file system containing each file name argument. Disk space is returned in human readable format (–human-readable).

disconnect()

Disconnect from the host.

distro

check what distribrution we are dealing with

e2fsck(device_path)[source]

Run e2fsck -f on a device.

exec_command(command, bufsize=-1, timeout=None, get_pty=False)

Execute a command on the SSH server. A new L{Channel} is opened and the requested command is executed. The command’s input and output streams are returned as python C{file}-like objects representing stdin, stdout, and stderr.

@param command: the command to execute @type command: str @param bufsize: interpreted the same way as by the built-in C{file()} function in python @type bufsize: int @param timeout: set command’s channel timeout. See L{Channel.settimeout}.settimeout @type timeout: int @return: the stdin, stdout, and stderr of the executing command @rtype: tuple(L{ChannelFile}, L{ChannelFile}, L{ChannelFile})

@raise SSHException: if the server fails to execute the command

exists(path)[source]

Return True if given path exists on the current remote host.

findmount(blocks)[source]

Findmount looks through mtab and returns a list of all matching mounts.

fsck(device_path, repair=False)[source]

Check and optionally repair a file system.

get(remotepath, localpath=None)[source]
Parameters:
  • remotepath
  • localpath – If None use pwd and basename
Returns:

get_UUID(dev_name)[source]

return UUID for device name

Parameters:dev_name (str) – device file name under /dev
Returns:the UUID for device
Return type:str
get_block_devices(address)[source]

return a list of all /dev/ names for a specific shelf.lun, or a list of block files for all targets on a shelf, or if address==”all”, all targets on all shelves.

get_device_size(device)[source]

Returns ReturnCode object

call linux’s ‘blockdev’ cmd-line tool to get the device size in bytes.

get_ethdrv(fname)[source]

Required function for Ethdrv class

get_host_keys()

Get the local L{HostKeys} object. This can be used to examine the local host keys or change them.

@return: the local host keys @rtype: L{HostKeys}

get_ipv4_addr(eth=0)[source]

The Linux way to get an ether’s IP address.

Given this, return the IPv4 address ‘10.220.70.4’:

[root@pickles smokemonster]# ifconfig eth0 Link encap:Ethernet HWaddr 00:25:90:0A:3C:04

inet addr:10.220.70.4 Bcast:10.220.255.255 Mask:255.255.0.0
get_mac_addr(eth=0)[source]

The Linux way to get a ether mac addr.

get_pids(name)[source]

Getpids returns a list of process IDs matching name.

get_transport()

Return the underlying L{Transport} object for this SSH connection. This can be used to perform lower-level tasks, like opening specific kinds of channels.

@return: the Transport for this connection @rtype: L{Transport}

hba_ports

Returns a dictionary of the HBA’s ports file contents:

{'0': {'link': {'max': '1000', 'speed': '0'},
    'mac': '00100401103c',
    'port': '0',
    'type': 'EHBA-2-E-RJ45'},
'1': {'link': {'max': '1000', 'speed': '1000'},
    'mac': '00100401103d',
    'port': '1',
    'type': 'EHBA-2-E-RJ45'}
}
install_rpm(package_path, timeout=30, expectation=True)[source]

This function will install the rpm

Return type:boolean
invoke_shell(term='vt100', width=80, height=24, width_pixels=0, height_pixels=0)

Start an interactive shell session on the SSH server. A new L{Channel} is opened and connected to a pseudo-terminal using the requested terminal type and size.

@param term: the terminal type to emulate (for example, C{“vt100”}) @type term: str @param width: the width (in characters) of the terminal window @type width: int @param height: the height (in characters) of the terminal window @type height: int @param width_pixels: the width (in pixels) of the terminal window @type width_pixels: int @param height_pixels: the height (in pixels) of the terminal window @type height_pixels: int @return: a new channel connected to the remote shell @rtype: L{Channel}

@raise SSHException: if the server fails to invoke a shell

ipaddr
Returns:the ip address of the interface we are connected to
Return type:str
is_package_installed(package_name)[source]

This function will find if the package is installed on the host machine and return the list of packages installed Argument : package_name (eg : ‘ethdrv’) Return : True,installed package list, or

False, []
list_dir(absolute_path)[source]

If a directory, returns a ReturnCode with status=True and a list of directory contents If not, status=False, message=list()

load_host_keys(filename)

Load host keys from a local host-key file. Host keys read with this method will be checked I{after} keys loaded via L{load_system_host_keys}, but will be saved back by L{save_host_keys} (so they can be modified). The missing host key policy L{AutoAddPolicy} adds keys to this set and saves them, when connecting to a previously-unknown server.

This method can be called multiple times. Each new set of host keys will be merged with the existing set (new replacing old if there are conflicts). When automatically saving, the last hostname is used.

@param filename: the filename to read @type filename: str

@raise IOError: if the filename could not be read

load_module(module)[source]

This function will load the module using ‘modprobe’ linux command

Return type:ReturnCode
load_system_host_keys(filename=None)

Load host keys from a system (read-only) file. Host keys read with this method will not be saved back by L{save_host_keys}.

This method can be called multiple times. Each new set of host keys will be merged with the existing set (new replacing old if there are conflicts).

If C{filename} is left as C{None}, an attempt will be made to read keys from the user’s local “known hosts” file, as used by OpenSSH, and no exception will be raised if the file can’t be read. This is probably only useful on posix.

@param filename: the filename to read, or C{None} @type filename: str

@raise IOError: if a filename was provided and the file could not be
read
ls(path=None, expectation=True)

return a list of files in path. If path is not specified cwd will be used. If path does not exist an exception will be raised unless expectation is False. Works in conjunction with the cd context manager.

lsmod()[source]

return loaded modules

Return type:list
lun_exists(lun, flush=True)[source]

If found returns a ReturnCode with status=True and lun’s aoestat dict:

{'device': 'sd379', 'port': ['1'], 'target': '91.1', 'size': '2000.398GB'}

when not, False and “<lun> not found” in message.

memory

Returns the total memory of the machine as an integer in KB.

mkfs(device, fstype='ext3', force=False, expectation=True)[source]

Create a file system on device. By default ext3 is used.

mount(source, fstype='ext3', target=None, max_attempts=1, expectation=True)[source]

Mounts a file system of a given type on a directory.

open(fname, mode='r', bufsize=-1, expectation=True)

return a file-like object of fname on the remote

open_sftp()

Open an SFTP session on the SSH server.

@return: a new SFTP session object @rtype: L{SFTPClient}

put(localpath, remotepath=None)[source]
Parameters:
  • localpath
  • remotepath – If None use pwd and basename
Returns:

rdsk

return a list of all the raw block devices. (Solaris compatibility).

Return type:list of str
reconnect(after=10, timeout=10, key_file=None, conn_attempts=10)

This method will attempt to reconnect with the host, maybe after a reboot action.

The method will have a limit of 10 attempts to connect by default, for a total of 300 seconds before it gives up with the reconnection.

static removeUUID(mnt_path)[source]

This function remove UUID from /etc/fstab file

Type:ReturnCode

TODO: use sed method

rm(path, expectation=True)

remove a file named by a string

rmdir(dirname, expectation=True)

remove a directory named by a string

run(cmd, timeout=None, bufsize=-1)
Parameters:
  • cmd (str) – command to run on remote host
  • timeout (float) – timeout on blocking read/write operations when exceeded socket error will be raised
  • bufsize (int) – byte size of the buffer for the filehandle returned
Return type:

ReturnCode

run_and_check(cmd, expectation=True, force=False, timeout=None, bufsize=-1)[source]

Run a command check the result. If the caller cares about failure, indicated by not setting expectation to False, and the command fails we raise an exception.

save_host_keys(filename)

Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved – not any host keys loaded with L{load_system_host_keys}.

@param filename: the filename to save to @type filename: str

@raise IOError: if the file could not be written

static sd2dev(sdname, path='/dev/')[source]

Return disk device or character device for a given sd name. This is included for script cross compatibility with Solaris

Parameters:sdname – the sd device name e.g. sd35
Returns:dev path
sd2targ(sd)[source]

Return the aoe target associated with an sd device. If none found None is returned.

sed(filename, before, after, limit='', backup='.bak', flags='')[source]

Run a search-and-replace on filename with given regex patterns.

Equivalent to sed -i<backup> -r -e "/<limit>/ s/<before>/<after>/<flags>g" <filename>. Setting backup to an empty string will, disable backup file creation.

For convenience, before and after will automatically escape forward slashes, single quotes and parentheses for you, so you don’t need to specify e.g. http:\/\/foo\.com, instead just using http://foo\.com is fine.

If use_sudo is True, will use sudo instead of run.

The shell argument will be eventually passed to run/sudo. It defaults to False in order to avoid problems with many nested levels of quotes and backslashes. However, setting it to True may help when using ~fabric.operations.cd to wrap explicit or implicit sudo calls. (cd by it’s nature is a shell built-in, not a standalone command, so it should be called within a shell.)

Other options may be specified with sed-compatible regex flags – for example, to make the search and replace case insensitive, specify flags="i". The g flag is always specified regardless, so you do not need to remember to include it when overriding this parameter.

set_log_channel(name)

Set the channel for logging. The default is C{“paramiko.transport”} but it can be set to anything you want.

@param name: new channel name for logging @type name: str

set_missing_host_key_policy(policy)

Set the policy to use when connecting to a server that doesn’t have a host key in either the system or local L{HostKeys} objects. The default policy is to reject all unknown servers (using L{RejectPolicy}). You may substitute L{AutoAddPolicy} or write your own policy class.

@param policy: the policy to use when receiving a host key from a
previously-unknown server

@type policy: L{MissingHostKeyPolicy}

stat(path)

returns a namespace of:

{'size' : st.st_size,
 'uid': st.st_uid,
 'gid': st.st_gid,
 'mode': st.st_mode,
 'atime': st.st_atime,
 'mtime': st.st_mtime,
 }

this can accessesed like so:

fstat= init.stat('/etc/passwd')
fstat.flags
Parameters:path (str) –
Returns:
Return type:Namespace
sync()[source]

Force changed blocks to disk, and update the super block.

targ2dev(targ)[source]

Return the device path for an aoe Target.

Parameters:targ – the aoe device e.g. ‘2.1’ or as AoEAddress type
Returns:
targ2sd(targ)[source]

Return the symbolic sd device name for the AoE Target.

target_is_available(target)[source]

Check if a target is visible

umount(pathname)[source]

Unmount a file system

Parameters:pathname (str) – directory to unmount
Return type:ReturnCode
uninstall_package(package, timeout=30)[source]

This function will uninstall the package and unload the module Return: True for successful

False for Failure
unload_module(module)[source]

This function will unload the module using ‘rmmod’ linux command Return : True or False

untar_package(src_directory, dest_directory='.')[source]

Untar the src_directory*.tar.gz in dest_directory Return : True or False

verifytarget(*args, **kwargs)[source]

Verifytarget waits for the target to show up in the aoe-stat or ethdrv-stat output, whichever is defined in self.coraid_module variable.

wait_target_is_available(*args, **kwargs)[source]

waits for the target be visible

wipe_partition_table(path=None, lun=None, count=1)[source]

If you are using a whole disk device for your physical volume, the disk must have no partition table.

For DOS disk partitions, the partition id should be set to 0x8e using the fdisk
or cfdisk command or an equivalent.
For whole disk devices only the partition table must be erased, which will
effectively destroy all data on that disk.

You can remove an existing partition table by zeroing the first sector with the following command:

# dd if=/dev/zero of=PhysicalVolume bs=512 count=1

Windows

class otto.initiators.windows.Windows(user, host, password, prompt='>')[source]

A class for interacting with the windows using ssh.

extended parameters:

expectation     (Boolean) if False the library will not raise exceptions for error: or usage:
force           (Boolean) if True the method walks through the acceptance dialog
aoediscover()[source]

Call the driver’s discover command. Returns ReturnCode object

aoeflush(aflag=True)[source]

Call the software linux driver’s or the HBA’s flush command and returns a ReturnCode object.

claim(lun)[source]

This function claims the LUN Return : False (Failure)

True (Sucess)
convert_disk_basic(disk_number)[source]

This fucntion will convert the disk to basic

convert_disk_dynamic(disk_number)[source]

This function will convert the disk to Dynamic type

convert_disk_gpt(disk_number)[source]

This function will convert the disk to GPT type.

copy_from_remote(src_host, src_user, src_passwd, src_file_loc, dest_file_loc)[source]

This function will copy the file from the remote machine to the local machine using scp Arguments: src_host - Source host IP Address

src_user - Source User name src_passwd - Source Host Password src_file_loc - Source File location dest_file_loc - Destination File Location
copy_to_remote(src, user, host, passwd, dest)[source]

SCP a file from a remote host.

create_mirror_volume(disk_numbers, size=None, disk_type=None)[source]

This function will create mirror volume on two disk. Both disk needs to be dynamic to create dynamic volume

Arguments::
disk_numbers = [Disk1,Disk2] always in list. size = size of the volume to be created disk_type = ‘mbr’ or ‘gpt’ if None, disk be default
create_spanned_volume(disk_numbers, size=None, disk_type=None)[source]

This fuction creates a simple volume and then spanned

Attributes:

disk_numbers: list of disk numbers, should always be 2 eg :: [disk1,disk2] disk1: on which the simple volume will be created disk2: on which the volume will be spanned accross size: size of the volume to be created in MBs disk_type: ‘MBR’ or ‘GPT’
create_stripe_volume(disk_numbers, disk_type, size=None)[source]

This function creates volume of stripe type.

Arguments: disk_numbers(list eg: [1,2,3]) - volume across which needs to be created.
size - size of the volume disk_type = ‘MBR’ or ‘GPT’
Return : True - Successful
False - Failure
create_volume(disk_number, size=None, volume_type=None, disk_type=None)[source]

creates the volume(Volume Simple or Partition Primary).

delete_volume(volume_number)[source]

This function deletes the volume

disks

return a list of disk on the system

format_volume(device, quick=False, fstype='NTFS', expectation=True, timeout=180)[source]

Format a volume

free_letters

Return drive letter not current used.

hba_ports

Returns a dictionary of the HBA’s ports file contents.

homedrive

This return the Home/System Drive of the windows machine

iozone(volume)[source]

perform iozone test on the given volume,vol_name(eg:c:,a:etc)

offline(object_type, object_number)[source]
offline object_type: : object_type = volume,disk
: object_number = number of object_type eg:0,1,2..
programs

This function will retrive the list of Programs installed on the Windows machine

reboot()[source]

This function will restart self.host.

release(lun_id, force=None)[source]

This function will release the claim: Argument : LUN_ID

force = None : force = ‘force’ : force release
Return : False Failure
True Success
run_and_check(cmd, expectation=True, force=False)[source]

Run a command check the result. If the caller cares about failure and the command fails we raise a generic exception.

uninstall_program(program_name=None)[source]

This function will uninstall the product from a windows hosts usind WMI tools. Return : True (Successfully installed)

False(Failure)
volumes

return the volumes on the system

wmic_query(query)[source]

This method should be use where possible to execute wmic queries.

Solaris

class otto.initiators.solaris.SolarisSsh(*args, **kwargs)[source]

A paramiko based solaris client.

close()

Close this SSHClient and its underlying L{Transport}.

exec_command(command, bufsize=-1, timeout=None, get_pty=False)

Execute a command on the SSH server. A new L{Channel} is opened and the requested command is executed. The command’s input and output streams are returned as python C{file}-like objects representing stdin, stdout, and stderr.

@param command: the command to execute @type command: str @param bufsize: interpreted the same way as by the built-in C{file()} function in python @type bufsize: int @param timeout: set command’s channel timeout. See L{Channel.settimeout}.settimeout @type timeout: int @return: the stdin, stdout, and stderr of the executing command @rtype: tuple(L{ChannelFile}, L{ChannelFile}, L{ChannelFile})

@raise SSHException: if the server fails to execute the command

get_host_keys()

Get the local L{HostKeys} object. This can be used to examine the local host keys or change them.

@return: the local host keys @rtype: L{HostKeys}

invoke_shell(term='vt100', width=80, height=24, width_pixels=0, height_pixels=0)

Start an interactive shell session on the SSH server. A new L{Channel} is opened and connected to a pseudo-terminal using the requested terminal type and size.

@param term: the terminal type to emulate (for example, C{“vt100”}) @type term: str @param width: the width (in characters) of the terminal window @type width: int @param height: the height (in characters) of the terminal window @type height: int @param width_pixels: the width (in pixels) of the terminal window @type width_pixels: int @param height_pixels: the height (in pixels) of the terminal window @type height_pixels: int @return: a new channel connected to the remote shell @rtype: L{Channel}

@raise SSHException: if the server fails to invoke a shell

load_host_keys(filename)

Load host keys from a local host-key file. Host keys read with this method will be checked I{after} keys loaded via L{load_system_host_keys}, but will be saved back by L{save_host_keys} (so they can be modified). The missing host key policy L{AutoAddPolicy} adds keys to this set and saves them, when connecting to a previously-unknown server.

This method can be called multiple times. Each new set of host keys will be merged with the existing set (new replacing old if there are conflicts). When automatically saving, the last hostname is used.

@param filename: the filename to read @type filename: str

@raise IOError: if the filename could not be read

load_system_host_keys(filename=None)

Load host keys from a system (read-only) file. Host keys read with this method will not be saved back by L{save_host_keys}.

This method can be called multiple times. Each new set of host keys will be merged with the existing set (new replacing old if there are conflicts).

If C{filename} is left as C{None}, an attempt will be made to read keys from the user’s local “known hosts” file, as used by OpenSSH, and no exception will be raised if the file can’t be read. This is probably only useful on posix.

@param filename: the filename to read, or C{None} @type filename: str

@raise IOError: if a filename was provided and the file could not be
read
open_sftp()

Open an SFTP session on the SSH server.

@return: a new SFTP session object @rtype: L{SFTPClient}

save_host_keys(filename)

Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved – not any host keys loaded with L{load_system_host_keys}.

@param filename: the filename to save to @type filename: str

@raise IOError: if the file could not be written

set_log_channel(name)

Set the channel for logging. The default is C{“paramiko.transport”} but it can be set to anything you want.

@param name: new channel name for logging @type name: str

set_missing_host_key_policy(policy)

Set the policy to use when connecting to a server that doesn’t have a host key in either the system or local L{HostKeys} objects. The default policy is to reject all unknown servers (using L{RejectPolicy}). You may substitute L{AutoAddPolicy} or write your own policy class.

@param policy: the policy to use when receiving a host key from a
previously-unknown server

@type policy: L{MissingHostKeyPolicy}

Esx

class otto.initiators.esx.Esx(user, host, password, prompt=None)[source]

A class for interacting with the esx using ssh.

extended parameters:

expectation     (Boolean) if False the library will not raise exceptions for error: or usage:
force           (Boolean) if True the method walks through the acceptance dialog
aoedevices

Get the list of the AOE devices

check_hba_version(release)[source]

Checks if correct HBA version is installed

check_vm_status(vm_list)[source]

Checks if the VM(s) status is green/normal

claim_targets(target_list)[source]

Claim the luns

get_vm_list()[source]

Get the list of the VMs on the ESX

hba_driver_install(path)[source]

Install the specified HBA driver

power_down_vm(vm_list)[source]

Power off the VM(s)

power_on_vm(vm_list)[source]

Power on the VM(s)

reboot()[source]

Reboots the ESX

release

The release command returns a string containing the currently running ESX release.

rescan_hba()[source]

Rescans the AOE HBA

run_and_check(cmd, expectation=True, force=False)[source]

Run a command check the result. If the caller cares about failure and the command fails we raise a generic exception.

shut_down_vm(vm_list)[source]

Shut down/power off the VM(s)