blivet.devicelibs package¶
Submodules¶
blivet.devicelibs.btrfs module¶
blivet.devicelibs.crypto module¶
blivet.devicelibs.edd module¶
-
class
blivet.devicelibs.edd.
EddEntry
(sysfspath, root=None)¶ Bases:
object
This object merely collects what the /sys/firmware/edd/* entries can provide.
-
ata_device
= None¶ The device number from edd/int13_devXX/interface when self.type is ATA or SATA (because Linux treats these the same.)
-
ata_pmp
= None¶ The ATA port multiplier ID from edd/int13_devXX/interface when self.type is SATA.
-
atapi_device
= None¶ The device number of the ATAPI device from edd/int13_devXX/interface when self.type is ATAPI.
-
atapi_lun
= None¶ The LUN of the ATAPI device from edd/int13_devXX/interface when self.type is ATAPI.
-
bios_device_number
= None¶ The device number from the EDD path
-
channel
= None¶ The host bus device’s channel number edd/int13_devXX/host_bus. The spec says:
Channel number. If more than one interface of the same type is accessed through a single Bus, Slot, Function, then the channel number shall identify each interface. If there is only one interface, the content of this field shall be cleared to zero. If there are two interfaces, such as an ATA Primary and Secondary interface, the primary interface shall be zero, and the secondary interface shall be one.
Values 00h through FEh shall represent a valid Channel Number.
Value FFh shall indicate that this field is not used.
If the device is connected to a SATA controller functioning in non-PATA emulation mode, this byte shall be FFh.
-
fibre_lun
= None¶ The FibreChannel LUN from edd/int13_devXX/interface when self.type is FIBRE.
-
fibre_wwid
= None¶ The FibreChannel WWID from edd/int13_devXX/interface when self.type is FIBRE.
-
host_bus
= None¶ The ID string for the host bus type, from edd/int13_devXX/host_bus.
-
i2o_identity
= None¶ The I2O Identity from edd/int13_devXX/interface when self.type is I2O.
-
ieee1394_eui64
= None¶ The Firewire/IEEE-1394 EUI-64 ID from edd/int13_devXX/interface when self.type is 1394.
-
interface
= None¶ interface is the actual contents of the interface file, preserved for logging later.
-
load
()¶
-
mbr_sig
= None¶ The MBR signature data from edd/int13_devXX/mbr_signature
-
pci_dev
= None¶ The host bus bus:device.function, from edd/int13_devXX/host_bus.
-
sas_address
= None¶ The SAS Address from edd/int13_devXX/interface when self.type is SAS.
-
sas_lun
= None¶ The SAS LUN from edd/int13_devXX/interface when self.type is SAS.
-
scsi_id
= None¶ The SCSI device ID from edd/int13_devXX/interface when self.type is SCSI
-
scsi_lun
= None¶ The SCSI device LUN from edd/int13_devXX/interface when self.type is SCSI
-
sectors
= None¶ The number of sectors on the device from edd/int13_devXX/sectors
-
sysfslink
= None¶ The path /sys/block/BLAH is a symlink link to once we’ve resolved that this is a particular device. Used for logging later.
-
sysfspath
= None¶ sysfspath is the path we’re probing
-
type
= None¶ The device type from edd/int13_devXX/interface.
-
usb_serial
= None¶ The USB storage device’s serial number from edd/int13_devXX/interface when self.type is USB.
-
version
= None¶ The edd version this entry claims conformance with, from /sys/firmware/edd/int13_devXX/version
-
-
class
blivet.devicelibs.edd.
EddMatcher
(edd_entry, root=None)¶ Bases:
object
This object tries to match given entry to a disk device name.
Assuming, heuristic analysis and guessing hapens here.
-
devname_from_ata_pci_dev
()¶
-
devname_from_pci_dev
()¶
-
devname_from_scsi_pci_dev
()¶
-
devname_from_virt_pci_dev
()¶
-
devname_from_virtio_scsi_pci_dev
()¶
-
match_via_mbrsigs
(mbr_dict)¶ Try to match the edd entry based on its mbr signature.
This will obviously fail for a fresh drive/image, but in extreme cases can also show false positives for randomly matching data.
-
-
blivet.devicelibs.edd.
collect_edd_data
(root=None)¶
-
blivet.devicelibs.edd.
collect_mbrs
(devices, root=None)¶ Read MBR signatures from devices.
Returns a dict mapping device names to their MBR signatures. It is not guaranteed this will succeed, with a new disk for instance.
-
blivet.devicelibs.edd.
get_edd_dict
(devices, root=None)¶ Generates the ‘device name’ -> ‘edd number’ mapping.
The EDD kernel module that exposes /sys/firmware/edd is thoroughly broken, the information there is incomplete and sometimes downright wrong. So after we mine out all useful information that the files under /sys/firmware/edd/int13_*/ can provide, we resort to heuristics and guessing. Our first attempt is, by looking at the device type int ‘interface’, attempting to map pci device number, channel number etc. to a sysfs path, check that the path really exists, then read the device name (e.g ‘sda’) from there. Should this fail we try to match contents of ‘mbr_signature’ to a real MBR signature found on the existing block devices.
blivet.devicelibs.lvm module¶
-
class
blivet.devicelibs.lvm.
ThPoolProfile
(name, desc)¶ Bases:
tuple
-
desc
¶ Alias for field number 1
-
name
¶ Alias for field number 0
-
-
blivet.devicelibs.lvm.
determine_parent_lv
(vg_name, internal_lv, lvs)¶ Try to determine which of the lvs is the parent of the internal_lv
Parameters: vg_name (str) – name of the VG the internal_lv and lvs belong to
-
blivet.devicelibs.lvm.
lvm_cc_addFilterRejectRegexp
(*args, **kwargs)¶
-
blivet.devicelibs.lvm.
lvm_cc_removeFilterRejectRegexp
(*args, **kwargs)¶
-
blivet.devicelibs.lvm.
lvm_cc_resetFilter
(*args, **kwargs)¶
-
blivet.devicelibs.lvm.
lvmetad_socket_exists
()¶
-
blivet.devicelibs.lvm.
needs_config_refresh
(fn)¶
blivet.devicelibs.mdraid module¶
-
class
blivet.devicelibs.mdraid.
MDRaidLevels
(levels=None)¶ Bases:
blivet.devicelibs.raid.RAIDLevels
Add the specified standard levels to the levels in this object.
Parameters: levels (list of valid RAID level descriptors) – the levels to be added to this object If levels is True, add all standard levels. Else, levels must be a list of valid level descriptors of standard levels. Duplicate descriptors are ignored.
-
classmethod
is_raid_level
(level)¶
-
classmethod
blivet.devicelibs.raid module¶
-
class
blivet.devicelibs.raid.
ErsatzRAID
¶ Bases:
blivet.devicelibs.raid.RAIDLevel
A superclass for a raid level which is not really a raid level at all, just a bunch of block devices of possibly differing sizes thrown together. This concept has different names depending on where it crops up. btrfs’s name is single, lvm’s is linear. Consequently, this abstract class implements all the functionality, but there are distinct subclasses which have different names.
-
get_max_spares
(member_count)¶
-
get_recommended_stride
(member_count)¶
-
get_size
(member_sizes, num_members=None, chunk_size=None, superblock_size_func=None)¶
-
get_space
(size, num_members, chunk_size=None, superblock_size_func=None)¶
-
has_redundancy
()¶
-
is_uniform
¶
-
min_members
= 1¶
-
-
class
blivet.devicelibs.raid.
RAIDLevel
¶ Bases:
object
An abstract class which is the parent of all classes which represent a RAID level.
It ensures that RAIDLevel objects will really be singleton objects by overriding copy methods.
-
has_redundancy
()¶ Whether this RAID level incorporates inherent redundancy.
Note that for some RAID levels, the notion of redundancy is meaningless.
Return type: boolean Returns: True if this RAID level has inherent redundancy
-
is_uniform
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
min_members
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
name
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
names
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
-
class
blivet.devicelibs.raid.
RAIDLevels
(levels=None)¶ Bases:
object
A class which keeps track of registered RAID levels. This class may be extended, overriding the is_raid method to include any additional properties that a client of this package may require for its RAID levels.
Add the specified standard levels to the levels in this object.
Parameters: levels (list of valid RAID level descriptors) – the levels to be added to this object If levels is True, add all standard levels. Else, levels must be a list of valid level descriptors of standard levels. Duplicate descriptors are ignored.
-
add_raid_level
(level)¶ Adds level to levels if it is not already there.
Parameters: level (object) – an object representing a RAID level Raises a RaidError if level is not valid.
Does not allow duplicate level objects.
-
classmethod
is_raid_level
(level)¶ Return False if level does not satisfy minimum requirements for a RAID level, otherwise return True.
Parameters: level (object) – an object representing a RAID level There must be at least one element in the names list, or the level will be impossible to look up by any string.
The name property must be defined; it should be one of the elements in the names list.
All RAID objects that extend RAIDlevel are guaranteed to pass these minimum requirements.
This method should not be overridden in any subclass so that it is so restrictive that a RAIDlevel object does not satisfy it.
-
raid_level
(descriptor)¶ Return RAID object corresponding to descriptor.
Parameters: descriptor (object) – a RAID level descriptor Note that descriptor may be any object that identifies a RAID level, including the RAID object itself.
Raises a RaidError if no RAID object can be found for this descriptor.
-
-
class
blivet.devicelibs.raid.
RAIDn
¶ Bases:
blivet.devicelibs.raid.RAIDLevel
An abstract class which is the parent of classes which represent a numeric RAID level. A better word would be classification, since ‘level’ implies an ordering, but level is the canonical word.
The abstract properties of the class are:
- level: A string containing the number that designates this level
- nick: A single nickname for this level, may be None
All methods in this class fall into these categories:
- May not be overrridden in any subclass.
- Are private abstract methods.
- Are special Python methods, e.g., __str__
Note that each subclass in this file is instantiated immediately after it is defined and using the same name, effectively yielding a singleton object of the class.
-
alt_synth_names
¶ names that can be synthesized from level but are not name
-
get_base_member_size
(size, member_count)¶ The required size for each member of the array for storing only data.
Parameters: Return type: Raises a RaidError if member_count is fewer than the minimum number of members required for this array or if size is less than 0.
-
get_max_spares
(member_count)¶ The maximum number of spares for this level.
Parameters: member_count (int) – the number of members belonging to the array Return type: int Raiess a RaidError if member_count is fewer than the minimum number of members required for this level.
-
get_net_array_size
(member_count, smallest_member_size)¶ Return the space, essentially the number of bits available for storage. This value is generally a function of the smallest member size. If the smallest member size represents the amount of data that can be stored on the smallest member, then the result will represent the amount of data that can be stored on the array. If the smallest member size represents both data and metadata, then the result will represent the available space in the array for both data and metadata.
Parameters: Returns: the array size
Return type: Raises a RaidError if member_count is fewer than the minimum number of members required for this array or if size is less than 0.
-
get_recommended_stride
(member_count)¶ Return a recommended stride size in blocks.
Returns None if there is no recommended size.
Parameters: member_count (int) – the number of members in the array Return type: int or None Raises a RaidError if member_count is fewer than the minimum number of members required for this level
-
get_size
(member_sizes, num_members=None, chunk_size=None, superblock_size_func=None)¶ Estimate the amount of data that can be stored on this array.
Parameters: - member_size (list of
Size
) – a list of the sizes of members of this array - num_members (int) – the number of members in the array
- chunk_size (
Size
) – the smallest unit of size read or written - superblock_size_func (a function from
Size
toSize
) – a function that estimates the superblock size for this array
Returns: an estimate of the amount of data that can be stored on this array
Return type: Note that the number of members in the array may not be the same as the length of member_sizes if the array is still under construction.
- member_size (list of
-
get_space
(size, num_members, chunk_size=None, superblock_size_func=None)¶ Estimate the amount of memory required by this array, including memory allocated for metadata.
Parameters: Returns: an estimate of the memory required, including metadata
Return type:
-
is_uniform
¶
-
level
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
name
¶ The canonical name for this level
-
names
¶ all valid names for this level
-
nick
¶ A decorator indicating abstract properties.
Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract properties are overridden. The abstract properties can be called using any of the normal ‘super’ call mechanisms.
Usage:
- class C(metaclass=ABCMeta):
@abstractproperty def my_abstract_property(self):
...
This defines a read-only property; you can also define a read-write abstract property using the ‘long’ form of property declaration:
- class C(metaclass=ABCMeta):
- def getx(self): ... def setx(self, value): ... x = abstractproperty(getx, setx)
‘abstractproperty’ is deprecated. Use ‘property’ with ‘abstractmethod’ instead.
-
number
¶ A numeric code for this level
-
blivet.devicelibs.raid.
div_up
(a, b)¶ Rounds up integer division. For example, div_up(3, 2) is 2.
Parameters:
-
blivet.devicelibs.raid.
get_raid_level
(descriptor)¶ Convenience function to return a RAID level for the descriptor.
Parameters: descriptor (object) – a RAID level descriptor Return type: RAIDLevel Returns: The RAIDLevel object for this descriptor Note that descriptor may be any object that identifies a RAID level, including the RAID object itself.
Raises a RaidError is there is no RAID object for the descriptor.