a VdGC@s~ddlmZddlmZddlmZmZddlm Z Gddde ee Z Gddde Z Gd d d e Z Gd d d e Zd S))ABCMeta)abstractmethod)LsmError ErrorNumber)with_metaclassc@seZdZdZedddZedddZedddZedd d Zedd d Z edd dZ edddZ edddZ ed ddZ ed!ddZdS)"IPluginzU Plug-in interface that all plug-ins must implement for basic operation. rcCsdS)z Method first called to setup the plug-in (except for plugin_info) This would be the place to make a connection to the array. Returns None on success, else LsmError exception N)selfZuripasswordtimeoutflagsrr2/usr/lib64/python3.9/site-packages/lsm/_iplugin.pyplugin_registers zIPlugin.plugin_registercCsdS)zs Sets any time-outs for the plug-in (ms) Returns None on success, else LsmError exception Nr)r msr rrr time_out_setszIPlugin.time_out_setcCsdS)ze Retrieves the current time-out Returns time-out in ms, else raise LsmError Nrr r rrr time_out_get'szIPlugin.time_out_getcCsdS)aZ Called when the client wants to finish up or the socket goes eof. Plug-in should clean up all resources. Note: In the case where the socket goes EOF and the plugin_unregister runs into errors the exception(s) will not be delivered to the client! Returns None on success, else LsmError exception Nrrrrr plugin_unregister0s zIPlugin.plugin_unregistercCsdS)z Returns the stats of the given job. Returns a tuple ( status (enumeration), percent_complete, completed item). else LsmError exception. Nrr Zjob_idr rrr job_status<s zIPlugin.job_statuscCsdS)zl Frees resources for a given job. Returns None on success, else raises an LsmError Nrrrrr job_freeGszIPlugin.job_freecCsdS)zS Returns the capabilities for the selected system, raises LsmError Nrr systemr rrr capabilitiesPszIPlugin.capabilitiescCsdS)z Returns the description and version for plug-in, raises LsmError Note: Make sure plugin can handle this call before plugin_register is called. Nrrrrr plugin_infoWszIPlugin.plugin_infoNcCsdS)z Returns an array of pool objects. Pools are used in both block and file system interfaces, thus the reason they are in the base class. Raises LsmError on error Nrr Z search_keyZ search_valuer rrr poolsasz IPlugin.poolscCsdS)a  Returns an array of system objects. System information is used to distinguish resources from on storage array to another when the plug=in supports the ability to have more than one array managed by it Raises LsmError on error Nrrrrr systemsks zIPlugin.systems)r)r)r)r)r)r)r)r)NNr)r)__name__ __module__ __qualname____doc___abstractmethodrrrrrrrrrrrrrr r s*         rc@seZdZd/ddZd0ddZd1ddZd2d d Zd3d d Zd4d dZd5ddZ d6ddZ d7ddZ ddZ d8ddZ d9ddZd:ddZd;ddZdd#d$Zd?d%d&Zd@d'd(ZdAd)d*ZdBd+d,ZdCd-d.ZdS)DIStorageAreaNetworkNrcCsttjddS)zV Returns an array of volume objects Raises LsmError on error Not supportedNrrZ NO_SUPPORTrrrr volumesyszIStorageAreaNetwork.volumescCsttjddS)z Creates a volume, given a pool, volume name, size and provisioning Returns a tuple (job_id, new volume) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. r$Nr%)r poolZ volume_name size_bytesZ provisioningr rrr volume_creates z!IStorageAreaNetwork.volume_createcCsttjddS)zq Deletes a volume. Returns Job id or None if completed, else raises LsmError on errors. r$Nr%r volumer rrr volume_deletesz!IStorageAreaNetwork.volume_deletecCsttjddS)z Re-sizes a volume. Returns a tuple (job_id, re-sized_volume) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. r$Nr%)r r+new_size_bytesr rrr volume_resizesz!IStorageAreaNetwork.volume_resizecCsttjddS)aB Replicates a volume from the specified pool. In this library, to replicate means to create a new volume which is a copy of the source. Returns a tuple (job_id, replicated volume) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. r$Nr%)r r'rep_type volume_srcnamer rrr volume_replicates z$IStorageAreaNetwork.volume_replicatecCsttjddS)a@ Returns the number of bytes per block for volume_replicate_range call. Callers of volume_replicate_range need to use this when calculating start and block lengths. Note: bytes per block may not match volume blocksize. Returns bytes per block, Raises LsmError on error r$Nr%rrrr !volume_replicate_range_block_sizes z5IStorageAreaNetwork.volume_replicate_range_block_sizecCsttjddS)a+ Replicates a portion of a volume to itself or another volume. The src, dest and number of blocks values change with vendor, call volume_replicate_range_block_size to get block unit size. Returns Job id or None if completed, else raises LsmError on errors. r$Nr%)r r/r0Z volume_destZrangesr rrr volume_replicate_ranges z*IStorageAreaNetwork.volume_replicate_rangecCsttjddS)zx Makes a volume available to the host Returns None on success, else raises LsmError on errors. r$Nr%r*rrr volume_enablesz!IStorageAreaNetwork.volume_enablecCsttjddS)zz Makes a volume unavailable to the host Returns None on success, else raises LsmError on errors. r$Nr%r*rrr volume_disablesz"IStorageAreaNetwork.volume_disablecCsttjddS)a` Register a user/password for the specified initiator for CHAP authentication. in_user & in_password are for inbound CHAP, out_user & out_password are for outbound CHAP. Note: Setting in_user, in_password or out_user, out_password to None will disable authentication. Raises LsmError on error r$Nr%)r init_idZin_userZ in_passwordZout_userZ out_passwordr rrr iscsi_chap_auths z#IStorageAreaNetwork.iscsi_chap_authcCsttjddS)z~ Allows an access group to access a volume. Returns None on success, else raises LsmError on errors. r$Nr%r access_groupr+r rrr volume_maskszIStorageAreaNetwork.volume_maskcCsttjddS)z Revokes access for an access group for a volume Returns None on success, else raises LsmError on errors. r$Nr%r9rrr volume_unmasksz!IStorageAreaNetwork.volume_unmaskcCsttjddSzM Returns a list of access groups, raises LsmError on errors. r$Nr%rrrr access_groupssz!IStorageAreaNetwork.access_groupscCsttjddSr=r%)r r1r7 init_typerr rrr access_group_createsz'IStorageAreaNetwork.access_group_createcCsttjddS)zC Deletes an access group, Raises LsmError on error r$Nr%r r:r rrr access_group_deletesz'IStorageAreaNetwork.access_group_deletecCsttjddS)zP Adds an initiator to an access group, Raises LsmError on error r$Nr%r r:r7r?r rrr access_group_initiator_addsz.IStorageAreaNetwork.access_group_initiator_addcCsttjddS)zU Deletes an initiator from an access group, Raises LsmError on error r$Nr%rCrrr access_group_initiator_deletesz1IStorageAreaNetwork.access_group_initiator_deletecCsttjddS)zo Returns the list of volumes that access group has access to. Raises LsmError on error r$Nr%rArrr "volumes_accessible_by_access_groupsz6IStorageAreaNetwork.volumes_accessible_by_access_groupcCsttjddS)zw Returns the list of access groups that have access to the specified, Raises LsmError on error r$Nr%r*rrr access_groups_granted_to_volume#sz3IStorageAreaNetwork.access_groups_granted_to_volumecCsttjddS)z Returns True if this volume has other volumes which are dependant on it. Implies that this volume cannot be deleted or possibly modified because it would affect its children. r$Nr%r*rrr volume_child_dependency*sz+IStorageAreaNetwork.volume_child_dependencycCsttjddS)a If this volume has child dependency, this method call will fully replicate the blocks removing the relationship between them. This should return None (success) if volume_child_dependency would return False. Note: This operation could take a very long time depending on the size of the volume and the number of child dependencies. Returns None if complete else job id, raises LsmError on errors. r$Nr%r*rrr volume_child_dependency_rm2s z.IStorageAreaNetwork.volume_child_dependency_rmcCsttjddS)Nr$r%rrrr target_ports@sz IStorageAreaNetwork.target_ports)NNr)r)r)r)r)r)r)r)r)r)r)NNr)r)r)r)r)r)r)r)r)NNr)rrr r&r)r,r.r2r3r4r5r6r8r;r<r>r@rBrDrErFrGrHrIrJrrrr r#ws4               r#c@seZdZdZdddZdddZddd Zd d d Zd!d d Zd"ddZ d#ddZ d$ddZ d%ddZ d&ddZ d'ddZd(ddZdS))INetworkAttachedStoragezT Class the represents Network attached storage (Common NFS/CIFS operations) NrcCsdS)zf Returns a list of file systems on the controller. Raises LsmError on errors. Nrrrrr fsIszINetworkAttachedStorage.fscCsttjddS)z WARNING: Destructive Deletes a file system and everything it contains Returns None on success, else job id r$Nr%r rLr rrr fs_deletePsz!INetworkAttachedStorage.fs_deletecCsttjddS)z Re-size a file system Returns a tuple (job_id, re-sized file system) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. r$Nr%)r rLr-r rrr fs_resizeYsz!INetworkAttachedStorage.fs_resizecCsttjddS)aO Creates a file system given a pool, name and size. Note: size is limited to 2**64 bytes so max size of a single volume at this time is 16 Exabytes Returns a tuple (job_id, file system) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. r$Nr%)r r'r1r(r rrr fs_createcs z!INetworkAttachedStorage.fs_createcCsttjddS)a# Creates a thin, point in time read/writable copy of src to dest. Optionally uses snapshot as backing of src_fs Returns a tuple (job_id, file system) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. r$Nr%)r Zsrc_fsZ dest_fs_namesnapshotr rrr fs_cloneos z INetworkAttachedStorage.fs_clonecCsttjddS)z Creates a thinly provisioned clone of src to dest. Note: Source and Destination are required to be on same filesystem Returns Job id or None if completed, else raises LsmError on errors. r$Nr%)r rLZ src_file_nameZdest_file_namerQr rrr fs_file_clonezs z%INetworkAttachedStorage.fs_file_clonecCsttjddS)zl Returns a list of snapshots for the supplied file system, Raises LsmError on error r$Nr%rMrrr fs_snapshotssz$INetworkAttachedStorage.fs_snapshotscCsttjddS)a{ Snapshot is a point in time read-only copy Create a snapshot on the chosen file system Returns a tuple (job_id, snap shot created) Note: Tuple return values are mutually exclusive, when one is None the other must be valid. Note: Snapshot name may not match what was passed in (depends on array implementation) r$Nr%)r rLZ snapshot_namer rrr fs_snapshot_creates z*INetworkAttachedStorage.fs_snapshot_createcCsttjddS)z Frees the re-sources for the given snapshot on the supplied filesystem. Returns Job id or None if completed, else raises LsmError on errors. r$Nr%)r rLrQr rrr fs_snapshot_deletesz*INetworkAttachedStorage.fs_snapshot_deleteFcCsttjddS)a< WARNING: Destructive! Reverts a file-system or just the specified files from the snapshot. If a list of files is supplied but the array cannot restore just them then the operation will fail with an LsmError raised. If files == None and all_files = True then all files on the file-system are restored. Restore_file if not None must be the same length as files with each index in each list referring to the associated file. Returns None on success, else job id, LsmError exception on error r$Nr%)r rLrQfilesZ restore_filesZ all_filesr rrr fs_snapshot_restoresz+INetworkAttachedStorage.fs_snapshot_restorecCsttjddS)a& Returns True if the specified filesystem or specified file on this file system has child dependencies. This implies that this filesystem or specified file on this file system cannot be deleted or possibly modified because it would affect its children. r$Nr%r rLrWr rrr fs_child_dependencysz+INetworkAttachedStorage.fs_child_dependencycCsttjddS)a If this filesystem or specified file on this filesystem has child dependency this method will fully replicate the blocks removing the relationship between them. This should return None(success) if fs_child_dependency would return False. Note: This operation could take a very long time depending on the size of the filesystem and the number of child dependencies. Returns Job id or None if completed, else raises LsmError on errors. r$Nr%rYrrr fs_child_dependency_rms z.INetworkAttachedStorage.fs_child_dependency_rm)NNr)r)r)r)Nr)Nr)r)r)r)Fr)r)r)rrr r!rLrNrOrPrRrSrTrUrVrXrZr[rrrr rKDs"        rKc@s4eZdZd ddZd ddZd ddZdd d ZdS)INfsrcCsttjddS)zP Returns the types of authentication that are available for NFS r$Nr%rrrr export_authszINfs.export_authNcCsttjddS)zL Get a list of all exported file systems on the controller. r$Nr%rrrr exportssz INfs.exportsc CsttjddS)zA Exports a filesystem as specified in the export r$Nr%) r Zfs_idZ export_pathZ root_listZrw_listZro_listZanon_uidZanon_gidZ auth_typeoptionsr rrr export_fsszINfs.export_fscCsttjddS)z. Removes the specified export r$Nr%)r Zexportr rrr export_removeszINfs.export_remove)r)NNr)r)r)rrr r]r^r`rarrrr r\s    r\N)abcrZ_ABCMetarr"ZlsmrrZsixrobjectrr#rKr\rrrr s   jN