ucampurestorage.lib package

Submodules

ucampurestorage.lib.httpclient module

class ucampurestorage.lib.httpclient.HttpClient(host: any, port: int, user: str, password: any, token: any, verify: bool)[source]

Bases: object

API_VERSION = '2.17'
delete(url, payload=None)[source]

Perform a REST DELETE request.

get(url)[source]

Perform a REST GET request.

patch(url, payload)[source]

Perform a REST PATCH request.

post(url, payload)[source]

Perform a REST POST request.

put(url, payload)[source]

Perform a REST PUT request.

ucampurestorage.lib.options module

class ucampurestorage.lib.options.LoadFromFile(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: Action

class ucampurestorage.lib.options.Options[source]

Bases: object

parse(args=None)[source]

Parse given arguments and execute an action accordingly.

ucampurestorage.lib.options.clone_volume(args)[source]

Clone volume on Pure storage and mount to the local server.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume clone –name TEST113_clone –srcvol TEST113 –target_mp /t2

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume clone –name TEST113_clone –srcvol TEST113 –target_mp /t2

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume clone –name TEST113_clone –srcwwn 624a9370a9da32b3267c47150005fa7a –target_mp /t2

ucampurestorage.lib.options.clone_volumes(args)[source]
ucampurestorage.lib.options.connect_volume(args)[source]

Connect Volume to the host on the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume connect –hostname HOST01 –volname TEST113

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume connect –hostname HOST01 –volname TEST113

[optionally define the LUNID] Example 3: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume connect –hostname HOST01 –volname TEST113 –lunid 77

Example 4: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume connect –hostname HOST01 –volname TEST113 –lunid 77

ucampurestorage.lib.options.create_host(args)[source]

Create host defination on the Purestorage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” host create –name <HOSTNAME> –iqn <IQN number> –personality <aix,esxi,hpux,solaris,vms,oracle-vm-server,none>

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json host create –name <HOSTNAME> –iqn <IQN number> –personality <aix,esxi,hpux,solaris,vms,oracle-vm-server,none>

ucampurestorage.lib.options.create_snapshot(args)[source]

Create snapshot of the volume on the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” snapshot create –srcvol TEST113 –suffix snap01

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json snapshot create –srcvol TEST113 –suffix snap01

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json snapshot create –srcwwn 624a9370a9da32b3267c47150005fa7a –suffix snap01

ucampurestorage.lib.options.create_token(args)[source]

Generate Pure Storage token.

Example: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd>

–client_name=<ClientName> –keyfile=”privatekey.pem” tokengen

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json tokengen

ucampurestorage.lib.options.create_volume(args)[source]

Create Volume on the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume create –name TEST113 –size 1T

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume create –name TEST113 –size 1T

ucampurestorage.lib.options.delete_host(args)[source]

Delete host defination on the Pure Storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” host delete –name <HOSTNAME>

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json host delete –name <HOSTNAME>

ucampurestorage.lib.options.delete_snapshot(args)[source]

Delete snapshot of the volume on the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” snapshot delete –snapname TEST113.snap01

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json snapshot delete –snapname TEST113.snap01

ucampurestorage.lib.options.delete_volume(args)[source]

Delete Volume from the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume delete –name TEST113

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume delete –name TEST113

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume delete –wwn 624a9370a9da32b3267c47150005fa7a

ucampurestorage.lib.options.detail_host(args)[source]

List the detail information of the host connected to the Pure Storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” host list –name cs-dev-db2

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json host list –name cs-dev-db2

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json host list –name cs-dev-db2 –format=json

ucampurestorage.lib.options.detail_volume(args)[source]

List the detail information of the volume from the Pure Storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume list –name TEST113

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume list –name TEST113

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume list –name TEST113 –format=json

Example 4: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume list –wwn 624a9370a9da32b3267c47150005fa7a

Example 5: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume list –wwn 624a9370a9da32b3267c47150005fa7a –format=json

ucampurestorage.lib.options.disconnect_volume(args)[source]

Disconnect Volume from the host on the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume disconnect –hostname HOST01 –volname TEST113

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume disconnect –hostname HOST01 –volname TEST113

ucampurestorage.lib.options.eradicate_volume(args)[source]

eradicate Volume from the Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume eradicate –name TEST113

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume eradicate –name TEST113

ucampurestorage.lib.options.host_operations(args)[source]

Perform Pure Storage host level Operations.

Example: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd>

–client_name=<ClientName> –keyfile=”privatekey.pem” host {list,create,delete}

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json host {list,create,delete}

ucampurestorage.lib.options.list_object(args)[source]

List Pure Storage objects.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd>

–client_name=<ClientName> –keyfile=”privatekey.pem” list –object controllers

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json list –object controllers

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json list –object controllers –format=json

ucampurestorage.lib.options.list_snapshots(args)[source]

List the detail information of the snapshot from the Pure Storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” snapshot list –volname TEST12

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json snapshot list –volname TEST12

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json snapshot list –volname TEST12 –format=json

ucampurestorage.lib.options.map_volume(args)[source]

Map volume to the local server which is provided by Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume map –name TEST113 –mp /t2

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume map –name TEST113 –mp /t2

[NOTE: New volume need to be formated therefore -new flag is required]

Example 3: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume map –name TEST113_new –mp /t2 -new

Example 4: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume map –name TEST113 –mp /t2 -new

ucampurestorage.lib.options.replace_volume(args)[source]

Replace the mounted clone volume with new clone from Pure storage and mount to the local server.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume replace –src_mp /t1 –dst_mp /t2

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume replace –src_mp /t1 –dst_mp /t2

ucampurestorage.lib.options.run_option(subparser, args)[source]

Runs a ucampurestorage subcommand. :param subparser: the subcommand to run. :param args: args to pass to the ucampurestorage subcommand. :return: result of the executed subcommand.

ucampurestorage.lib.options.snap_operations(args)[source]

Perform Pure Storage Snapshot level Operations.

Example: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” snapshot {list,create,delete}

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json snapshot {list,create,delete}

ucampurestorage.lib.options.str2bool(v)[source]
ucampurestorage.lib.options.unmap_volume(args)[source]

Map volume to the local server which is provided by Pure storage.

Example 1: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume unmap –name TEST113

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume unmap –name TEST113

[optionally define the WWN]

Example 3: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume unmap –wwn <WWN number>

Example 4: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume unmap –wwn <WWN number>

[optionally define the mountpoint]

Example 5: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume unmap –mp /t1

Example 6: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume unmap –mp /t1

ucampurestorage.lib.options.volume_operations(args)[source]

Perform Pure Storage volume level Operations.

Example: ucampurestorage –client_id=<clientID> –key_id=<KeyID> –user=<User> –password=<passwd> –client_name=<ClientName> –keyfile=”privatekey.pem” volume {list,create,delete,eradicate,connect, disconnect,map,unmap,replace,clone}

Example 2: ucampurestorage –file=./ucampurestorage/lib/secrets.json volume {list,create,delete,eradicate, connect,disconnect,map,unmap,replace,clone}

ucampurestorage.lib.process module

Utilities for linux filesystems administration

class ucampurestorage.lib.process.Process[source]

Bases: object

add_entry_in_fstab(fs_device, mountpoint, fstype='ext4', opts='_netdev')[source]

Adds fs_device in FSTAB_CONF file.

Parameters:
  • fs_device – fs device to add.

  • mountpoint – mountpoint of fs device.

  • fstype – fs type of fs device.

Returns:

True for success, False for error.

add_multipath_alias(wwn)[source]

Adds a multipath alias to MULTIPATH_CONF file.

Parameters:

wwn – wwn to add to MULTIPATH_CONF.

Returns:

True for success, False for error.

backup_file(file_, backup_dir)[source]

Backups a file.

Copies file_ to backup_dir directory and name the new file file.timestamp.

Parameters:
  • file – the full path and the name of the file to back up.

  • backup_dir – the path of the new file.

Returns:

True if backup task succeeded, False, otherwise.

create_dir(path)[source]

Create a directory if provided.

Returns:

True for success, False for error.

create_partition(dev: str) bool[source]

Create partition on the dev.

Args:

dev (str): multipath dev path

Returns:

bool: TRUE if dev is partitioned

daemon_reload()[source]

Reloads systemd manager configuration

Returns:

True for success, False for error.

delete_raw_devices(raw_device)[source]

Deletes a raw device.

Parameters:

raw_device – raw device to delete.

Returns:

True for success, False for error.

format_partition_with_ext4(part: str) bool[source]

Format the partition with ext4.

Args:

part (str): partition name crated on the local system.

Returns:

bool: TRUE if partition is updated

generate_devicemapper_alias()[source]

Generates a new device mapper alias.

Returns:

alias name, None for error.

get_fsdevice_from_mountpoint(mountpoint)[source]

Gets filesystem device from mountpoint.

Example: mountpoint = /d03 –> fsdevice = /dev/mapper/vold03p1.

Parameters:

mountpoint – the mountpoint to look for its filesystem device.

Returns:

fsdevice or None if fsdevice not found.

get_hostname()[source]

Gets hostname of local server.

Returns:

server’s hostname or None for error.

get_index_in_list(index_list)[source]

Returns the available index in a list of int.

If index_list is empty, return 1. If no index is available, return max index in the list + 1.

Parameters:

index_list – list of int.

Returns:

index.

get_local_mountpoints()[source]

fetch information regarding local filesystem.

Returns:

list: All the mounted partitions or False if command fails

get_mountpoint_from_devicename(device_name)[source]

Gets mountpoint from devicename.

Example: device = /dev/mapper/vold03p1 –> mountpoint = /d03.

Parameters:

device_name – the device_name to look for its mountpoint.

Returns:

mountpoint or None if fsdevice not found.

get_mpath_from_mountpoint(mountpoint)[source]

Gets mpath from mountpoint.

Example: mountpoint = /d03 –> mpath = /dev/mapper/vold03.

Parameters:

mountpoint – the mountpoint to look for its mpath.

Returns:

mpath of mountpoint, or None if no mpath is found.

get_mpath_from_wwn(wwn)[source]

Gets mpath of a wwn by looking in multipath -ll output.

Example: wwn = ‘6000d31000e3940000000000000001fd’ –> mpath = vold03.

Parameters:

mpath – mpath to look for its wwn.

Returns:

mpath or None if mpath is not found.

get_multipath_raw_devices(wwid)[source]

Gets multipath raw devices of a multipath device.

Example: wwid = 360dd0d31000e39600000000000000073e –> [‘sdc’, ‘sdb’].

Parameters:

wwid – wwid of the multipath.

Returns:

list of multipath raw devices, None for error.

get_release()[source]

Returns OS release

get_wwid_from_wwn(wwn)[source]

Obtains wwid from wwn by looking at multipath -ll command output.

Parameters:

wwn – wwn to look for its wwid.

Returns:

wwid for success, None on error.

get_wwn_from_mpath(mpath_device)[source]

Gets wwn of a mpath.

Example: mpath = vold03p1 –> wwn = ‘6000d31000e3940000000000000001fd’.

Parameters:

mpath_device – mpath device to look for its wwn.

Returns:

wwn of mpath device, None otherwise.

is_device_in_fstab(device)[source]

Checks if device is in FSTAB_CONF file.

Parameters:

device – device to check in FSTAB_CONF.

Returns:

True if device in FSTAB_CONF, otherwise, False.

is_device_valid(device)[source]

Checks if device name is valid.

A valid device name should start with ‘/dev/mapper/vold’ and ends with ‘p1’.

Parameters:

device – device name to check.

Returns:

True if device name is valid, otherwise, False.

is_dir_empty(path)[source]

Checks if a directory is empty.

Parameters:

path – path of the directory to check.

Returns:

True if the directory, False otherwise.

is_dir_exist(path)[source]

Checks if a directory is exists.

Parameters:

path – path of the directory to check.

Returns:

True if the directory, False otherwise.

is_string_in_file(string, filename)[source]

Checks if a string is in filename.

Parameters:
  • string – the string to look for in the file.

  • file – the file to search in.

Returns:

True if string in file, False, otherwise.

is_wwn_mounted(wwn)[source]

Checks if a device with wwn is mounted.

Parameters:

wwnwwn of the device to check.

Returns:

mountpoint if the device is mounted, None, otherwise.

is_wwn_serial_valid(wwn)[source]

Checks if wwn is valid.

A valid WWN should have 32 or 33 characters.

Parameters:

wwn – the wwn to check

Returns:

True if wwn is valid, otherwise, False.

is_wwn_valid(wwn)[source]

Checks if wwn is valid.

A valid WWN should have 32 or 33 characters.

Parameters:

wwn – the wwn to check

Returns:

True if wwn is valid, otherwise, False.

mount(fs)[source]

Mounts a filesystem or mountpoint if provided.

Returns:

True for success, False for error.

mountpoint_exists(mountpoint)[source]

Checks if mountpoint exists.

Parameters:

mountpoint – mountpoint to check.

Returns:

True if the mountpoint exists, False otherwise.

read_file(filename)[source]

Reads a file.

Parameters:

filename – the name of file to read.

Returns:

content of the file to read, or None on error.

record_config_details()[source]

Logs df, multipath, and fstab config details.

reload_multipathd()[source]

Reloads the multipathd service.

Returns:

True for success, False for error.

remove_entry_from_fstab(fs_device)[source]

Removes fs_device from FSTAB_CONF file.

Parameters:

fs_device – fs device to remove.

Returns:

True for success, False for error.

remove_multipath_entry(wwn, alias)[source]

Removes a multipath entry from MULTIPATH_CONF file.

Parameters:
  • wwn – wwn of the multipath entry to remove.

  • alias – alias of the multipath entry to remove

Returns:

True for success, False for error.

rescan_scsibus()[source]

Scans SCSI bus on local server.

Returns:

True for success, False on error.

run(command, stdin=-1, stdout=-1)[source]

Runs a Shell command.

Parameters:
  • command – command to run.

  • stdin – stdin of the command execution, default: subprocess.PIPE.

  • stdout – stdout of the command execution, default: subprocess.PIPE.

Returns:

tuple (return_code, stdout_data, stderr_data).

umount(fs)[source]

Unmounts a filesystem, or mountpoint if provided.

Returns:

True for success, False for error.

update_system_partition(part: str) bool[source]

Update about the partition to the local system.

Args:

part (str): partition name crated on the local system.

Returns:

bool: TRUE if partition is updated

ucampurestorage.lib.pureconnect module

class ucampurestorage.lib.pureconnect.PureAdvanceConnection(host: any, port: int, user: str, password: any, token: any, verify: bool)[source]

Bases: SystemTask

clone_volume(cln_name: str, src_wwn: str, src_name: str, mt_pt: str = None) bool[source]

Create clone volume.

Args:

cln_name (str): Name of the clone volume to be create on PureStorage Array src_wwn (str): WWN of the source volume for which clone need to be created on PureStorage Array src_name (str): Name of the source volume for which clone need to be created on PureStorage Array mt_pt (str): Name of the mountpoint on local server to be mounted

Returns:

boolean: True for success, False on error.

connect_volume(hostname: str, volname: str, **kwargs) bool[source]

Connect volume.

Args:

hostname (str): Name of the host specified on PureStorage Array with which volume need to be connect volname (str): Name of the volume specified on PureStorage Array which need to be connect

Returns:

boolean: True for success, False on error.

create_host(iqn: str, name: str, personality: str) bool[source]

Create host.

Args:

name (str): Name of the Host to be create on PureStorage Array iqn (str): iqn of Host Eg: “” personality (str): personality of the host

Returns:

boolean: True for success, False on error.

create_snapshot(name: str, src_wwn: str, suffix: str) bool[source]

Create Snapshot of the volume.

Args:

name (str): Name of the volume for which snapshot to be create on PureStorage Array suffix (str): suffix of the snapshot

Returns:

boolean: True for success, False on error.

create_volume(size: str, name: str) bool[source]

Create volume.

Args:

name (str): Name of the volume to be create on PureStorage Array size (str): Capacity of volume Eg: “1T”, “300G”, “20M”

Returns:

boolean: True for success, False on error.

delete_host(name: str) bool[source]

Delete host.

Args:

name (str): Name of the host to be deleted on PureStorage Array

Returns:

boolean: True for success, False on error.

delete_snapshot(name: str) bool[source]

Delete snapshot.

Args:

name (str): Name of the snapshot to be deleted on PureStorage Array

Returns:

boolean: True for success, False on error.

delete_volume(name: str = None, wwn: str = None) bool[source]

Delete volume.

Args:

name (str): Name of the volume to be deleted on PureStorage Array wwn (str): WWN of the volume to be deleted on PureStorage Array

Returns:

boolean: True for success, False on error.

disconnect_volume(hostname: str, volname: str) bool[source]

Remove the connection of volume from .

Args:

hostname (str): Name of the host specified on PureStorage Array with which volume need to be connect volname (str): Name of the volume specified on PureStorage Array which need to be connect

Returns:

boolean: True for success, False on error.

eradicate_volume(name: str) bool[source]

Eradicate volume.

Args:

name (str): Name of the volume to be eradicate on PureStorage Array

Returns:

boolean: True for success, False on error.

map_volume(name, mountpoint=None, new_vol=False)[source]

Map volume to local server and mount it to mountpoint.

Args:

name (str): Name of the volume to map to local server. mountpoint (str): Name of the mountpoint on local server to be mounted new_vol (bool): Is the volume name newly created in PureStorage Array

Returns:

boolean: True for success, False on error.

replace_volume(src_mountpoint, dst_mountpoint, unmount_src_mp)[source]

Clones the volume mounted on src_mountpoint and mount it on dst_mountpoint, the volume that was mounted on dst_mountpoint will be deleted.

Parameters:
  • src_mountpoint – mountpoint of the volume to be cloned.

  • dst_mountpoint – mountpoint of the clone volume.

  • unmount_src_mp – If True, unmount the source mountpoint, otherwise, not.

Returns:

True for success, False on error.

unmap_volume(name=None, wwn=None, mp=None)[source]

Unmaps a Pure Storage volume with WWN. Unmounting the volume should be performed manually.

Parameters:
  • namename of the volume to unmap.

  • wwnwwn of the volume to unmap.

  • mpmountpoint of the localsever to unmap.

Returns:

True for success, False on error.

class ucampurestorage.lib.pureconnect.PureConnection(host: any, port: int, user: str, password: any, token: any, verify: bool)[source]

Bases: object

Pure Storage API interface.

Handles calls to Pure Storage Management via the REST API interface.

get_arrays()[source]

Gets all arrays and updates self.arrays. :returns: True for success, False on error.

get_controllers()[source]

Gets all controllers and updates self.controllers. :returns: True for success, False on error.

get_hostgroups()[source]

Gets all host-groups and updates self.hostgroups. :returns: True for success, False on error.

get_hosts(name=None)[source]

Gets all hosts and updates self.hosts. :returns: True for success, False on error.

get_networkports()[source]

Gets all networkports and updates self.target-ports. :returns: True for success, False on error.

get_pods()[source]

Gets all pods and updates self.pods. :returns: True for success, False on error.

get_protectiongroups()[source]

Gets all networkports and updates self.target-ports. :returns: True for success, False on error.

get_protectiongroupsnapshots()[source]

Gets all networkports and updates self.target-ports. :returns: True for success, False on error.

get_protectiongroupvolmembers()[source]

Gets all volumes in protection-groups and updates self.protectiongroupvolmembers. :returns: True for success, False on error.

get_remotepods()[source]

Gets all pods and updates self.pods. :returns: True for success, False on error.

get_targetports()[source]

Gets all ports and updates self.target-ports. :returns: True for success, False on error.

get_vol_clones(src_name, src_wwn)[source]
get_vol_destroyed()[source]
get_vol_name_by_devwwn(wwn)[source]
get_volumeconnections(name=None)[source]

Gets all connections and updates self.volumeconnections. :returns: True for success, False on error.

get_volumegroups()[source]

Gets all volume-groups and updates self.volumegroups. :returns: True for success, False on error.

get_volumes(name=None, wwn=None)[source]

Gets all volumes and updates self.volumes. :returns: True for success, False on error.

get_volumesnapshots(name=None)[source]

Gets all volume-snapshots and updates self.volumesnapshots. :returns: True for success, False on error.

run_list_object(object_type)[source]

Returns the result of get object functions and updates the corresponding data structures.

Parameters:

object_type – the object type to list.

Returns:

couple of (result of object get function, object data structure)

class ucampurestorage.lib.pureconnect.SystemTask(host: any, port: int, user: str, password: any, token: any, verify: bool)[source]

Bases: PureConnection

generate_clone_name(volume_name)[source]

Generates a clone name from a volume name.

Parameters:

volume_name – the volume name from which to generate a clone name.

Returns:

clone name, None, otherwise.

get_local_mountpoints()[source]
get_local_server_name_on_array()[source]

Returns local server ID, or None on error.

get_mountpoint_info(mountpoint=None)[source]

Returns details of volume with WWN wwn or mounted on mountpoint.

Parameters:
  • name – volume’s name.

  • mountpointmountpoint where the volume is mounted.

Returns:

str wwn, None, otherwise.

ucampurestorage.lib.pureconnect.converttobytes(value, fromtype, bsize=1024)[source]

Converts megabytes to bytes, etc. sample code:

print(‘mb= ‘ + str(bytesto(314575262000000, ‘m’)))

sample output:

mb= 300002347.946

ucampurestorage.lib.pureconnect.totalbytes(value: str) int[source]

ucampurestorage.lib.tokencreater module

Token Generation module.

class ucampurestorage.lib.tokencreater.TokenCreater[source]

Bases: object

Generate Token for the API CALLs

current_token_modify(**kwarg)[source]

Updating the token of the instance on the new token request.

Returns:

str: provide the new token.

token_create_datetime(**kwarg)[source]

Provide date and time of the token creation.

Returns:

datetime: date and time of token creation

token_generation(client_id: str, key_id: str, client_name: str, key_file_private: str, username: str, fa_fqdn_ip: any, password=None, output_file=None) str[source]

Generation of the Token.

Args:

client_id (str): Client ID created on PureStorage for API calls key_id (str): Key ID generated on PureStorage while creating client ID for API calls client_name (str): Client Name created for the api call key_file_private (str): location of the private key file username (str): username of the purestorage fa_fqdn_ip (any): FQDN of the PureStorage password (_type_, optional): password of the pure storage. Defaults to None. output_file (_type_, optional): Location of file if the file need to be redirected. Defaults to None.

Returns:

str: :Provide the token for API call

token_jsonformat()[source]

format data with token and creation date.

Returns:

dict: dictory information of token and creation date

token_output_file(output_file)[source]

Perform the write operation on a file.

Args:

output_file (str): filename need to be written with information.

token_output_json(output_file)[source]

Perform the write operation on a file in json format.

Args:

output_file (str): filename need to be written with information.

Module contents