wasp_general.os.linux package

Submodules

wasp_general.os.linux.lvm module

class wasp_general.os.linux.lvm.WLVMInfo(command, fields_count, lvm_entity, sudo=False)[source]

Bases: object

Basic class for actual LVM information. This class creates WLVMInfoCommand object which may be called on an object creation (it depends on constructor parameters)

lvm_command()[source]

Return LVM-command object

Returns:WLVMInfoCommand
lvm_entity()[source]

Return object fields

Returns:tuple of str (fields)
class wasp_general.os.linux.lvm.WLVMInfoCommand(command, fields_count, cmd_timeout=None, sudo=False)[source]

Bases: object

This is a helper, with which it is easier to call for pvdisplay, vgdisplay or lvdisplay program.

This class uses subprocess.check_output method for a program calling. And when non-zero code is returned by the program, an subprocess.CalledProcessError exception is raised. There is a timeout for a program to be complete. If a program wasn’t completed for that period of time, subprocess.TimeoutExpired exception is raised

cmd_timeout()[source]

Timeout for a program to complete

Returns:int, float
command()[source]

Return target program

Returns:str
fields_count()[source]

Return number of fields in a program output

Returns:int
lvm_info(name=None)[source]

Call a program

Parameters:name – if specified - program will return information for that lvm-entity only. otherwise -

all available entries are returned

Returns:tuple of str (fields)
sudo()[source]

Return ‘sudo’ flag (whether to run this program with sudo or not)

Returns:bool
class wasp_general.os.linux.lvm.WLogicalVolume(logical_volume, sudo=False)[source]

Bases: wasp_general.os.linux.lvm.WLVMInfo

Class represent a logical volume

all()[source]

Return every logical volume in the system

Returns:tuple of WLogicalVolume
create_snapshot(snapshot_size, snapshot_suffix)[source]

Create snapshot for this logical volume.

Parameters:
  • snapshot_size – size of newly created snapshot volume. This size is a fraction of the source logical volume space (of this logical volume)
  • snapshot_suffix – suffix for logical volume name (base part is the same as the original volume name)
Returns:

WLogicalVolume

device_number()[source]

Return tuple of major and minor device number of logical volume

Returns:tuple of int
extents_count()[source]

Return current logical extents associated to logical volume

Returns:int
classmethod logical_volume(file_path, sudo=False)[source]

Return logical volume that stores the given path

Parameters:
  • file_path – target path to search
  • sudo – same as ‘sudo’ in WLogicalVolume.__init__()
Returns:

WLogicalVolume or None (if file path is outside current mount points)

remove_volume()[source]

Remove this volume

Returns:None
sectors_count()[source]

Return logical volume size in sectors

Returns:int
snapshot_allocation()[source]

Return allocated size (fraction of total snapshot volume space). If this is not a snapshot volume, than RuntimeError exception is raised.

Returns:float
snapshot_corrupted()[source]

Check if this snapshot volume is corrupted or not

Returns:bool (True if corrupted, False - otherwise)
uuid()[source]

Return UUID of logical volume

Returns:str
volume_group()[source]

Return volume group

Returns:WVolumeGroup
volume_group_name()[source]

Return volume group name

Returns:str
volume_name()[source]

Return logical volume name

Returns:str
volume_path()[source]

Return logical volume path

Returns:str
class wasp_general.os.linux.lvm.WPhysicalVolume(physical_volume, sudo=False)[source]

Bases: wasp_general.os.linux.lvm.WLVMInfo

Class represent a physical volume

all()[source]

Return every physical volume in the system

Returns:tuple of WPhysicalVolume
allocated_extents()[source]

Return allocated number of physical extents (may have 0 value if this volume is not allocated to any)

Returns:int
device_name()[source]

Return physical volume device name

Returns:str
extent_size()[source]

Return physical extent size in kilobytes (may have 0 value if this volume is not allocated to any)

Returns:int
free_extents()[source]

Return free number of physical extents (may have 0 value if this volume is not allocated to any)

Returns:int
sectors_count()[source]

Return physical volume size in sectors

Returns:int
total_extents()[source]

Return total number of physical extents (may have 0 value if this volume is not allocated to any)

Returns:int
uuid()[source]

Return physical volume UUID

Returns:str
volume_group()[source]

Return related volume group name (may be empty string if this volume is not allocated to any)

Returns:str
class wasp_general.os.linux.lvm.WVolumeGroup(volume_group, sudo=False)[source]

Bases: wasp_general.os.linux.lvm.WLVMInfo

Class represent a volume group

actual_volumes()[source]

Return actual number of physical volumes

Returns:int
all()[source]

Return every volume group in the system

Returns:tuple of WVolumeGroup
allocated_extents()[source]

Return allocated number of physical extents for this volume group

Returns:int
extent_size()[source]

Return physical extent size in kilobytes

Returns:int
free_extents()[source]

Return free number of physical extents for this volume group

Returns:int
group_access()[source]

Return volume group access

Returns:str
group_name()[source]

Return volume group name

Returns:str
logical_volumes()[source]

Return current number of logical volumes

Returns:int
maximum_logical_volumes()[source]

Return maximum number of logical volumes (0 - for unlimited)

Returns:int
maximum_physical_volumes()[source]

Return maximum number of physical volumes (0 - for unlimited)

Returns:int
opened_logical_volumes()[source]

Return open count of all logical volumes in this volume group

Returns:int
physical_volumes()[source]

Return current number of physical volumes

Returns:int
size()[source]

Return size of volume group in kilobytes

Returns:int
total_extents()[source]

Return total number of physical extents for this volume group

Returns:int
uuid()[source]

Return UUID of volume group

Returns:str

wasp_general.os.linux.mounts module

class wasp_general.os.linux.mounts.WMountPoint(mount_record)[source]

Bases: object

This class supply information about system mount points. It allows to find mount point by a custom file path.

device()[source]

Return a mount point device path

Returns:str
device_name()[source]

Return a mount point device name (a base name of a device path)

Returns:str
dump_flag()[source]

Return dump flag for this mount point

Returns:bool
fs()[source]

Return a mount point filesystem name

Returns:str
fsck_order()[source]

Return fsck (filesystem check) order for this mount point

Returns:int
classmethod mount(device, mount_directory, fs=None, options=None, cmd_timeout=None, sudo=False)[source]

Mount a device to mount directory

Parameters:
  • device – device to mount
  • mount_directory – target directory where the given device will be mounted to
  • fs – optional, filesystem on the specified device. If specifies - overrides OS filesystem detection with this value.
  • options – specifies mount options (OS/filesystem dependent)
  • cmd_timeout – if specified - timeout with which this mount command should be evaluated (if command isn’t complete within the given timeout - an exception will be raised)
  • sudo – whether to use sudo to run mount command
Returns:

None

classmethod mount_point(file_path)[source]

Return mount point that, where the given path is reside on

Parameters:file_path – target path to search
Returns:WMountPoint or None (if file path is outside current mount points)
classmethod mounts()[source]

Return tuple of current mount points

Returns:tuple of WMountPoint
options()[source]

Return a mount point options (options with which this point was mounted)

Returns:tuple of str
path()[source]

Return a mount point path (path where this mount point is mounted to)

Returns:str
classmethod umount(device_or_directory, cmd_timeout=None, sudo=False)[source]

Unmount device (or mount directory)

Parameters:
  • device_or_directory – device name or mount directory to unmount
  • cmd_timeout – if specified - timeout with which this unmount command should be evaluated (if command isn’t complete within the given timeout - an exception will be raised)
  • sudo – whether to use sudo to run mount command
Returns:

None

Module contents