def __init__(self, *args, **kwargs): """ Create a Filesystem instance. Keyword Args: device -- path to the device containing the filesystem mountpoint -- the filesystem's mountpoint label -- the filesystem label uuid -- the filesystem UUID mountopts -- mount options for the filesystem size -- the filesystem's size in MiB exists -- indicates whether this is an existing filesystem """ if self.__class__ is Filesystem: raise TypeError("Filesystem is an abstract class.") Format.__init__(self, *args, **kwargs) self.mountpoint = kwargs.get("mountpoint") self.mountopts = kwargs.get("mountopts") self.label = kwargs.get("label") self.fsprofile = kwargs.get("fsprofile") # filesystem size does not necessarily equal device size self._size = kwargs.get("size", 0) self._minInstanceSize = None # min size of this FS instance self._mountpoint = None # the current mountpoint when mounted if self.exists and self.supported: self._size = self._getExistingSize() foo = self.minSize # force calculation of minimum size self._targetSize = self._size if self.supported: self.loadModule()
def create(self, *args, **kwargs): if self.exists: raise FilesystemError("filesystem already exists") Format.create(self, *args, **kwargs) return self.doFormat(*args, **kwargs)
def setup(self, *args, **kwargs): """ Open, or set up, a device. """ if not self.exists: raise DiskLabelError("format has not been created", self.device) if self.status: return Format.setup(self, *args, **kwargs)
def setup(self, *args, **kwargs): """ Open, or set up, a device. """ if not self.exists: raise SwapSpaceError("format has not been created", self.device) if self.status: return Format.setup(self, *args, **kwargs) swapon(self.device, priority=self.priority)
def create(self, *args, **kwargs): """ Create the format. """ try: Format.create(self, *args, **kwargs) # Consider use of -Z|--zero # -f|--force or -y|--yes may be required # lvm has issues with persistence of metadata, so here comes the # hammer... Format.destroy(self, *args, **kwargs) lvm.pvcreate(self.device) except Exception, msg: raise PhysicalVolumeError("Create device failed!", self.device)
def create(self, *args, **kwargs): """ Create the device. """ force = kwargs.get("force") if not force and self.exists: raise SwapSpaceError("format already exists", self.device) if force: self.teardown() elif self.status: raise SwapError("device exists and is active", self.device) try: Format.create(self, *args, **kwargs) mkswap(self.device, label=self.label) except Exception, msg: raise SwapSpaceError, msg
def create(self, *args, **kwargs): """ Create the device. """ if self.exists: raise DiskLabelError("format already exists", self.device) if self.status: raise DiskLabelError("device exists and is active", self.device) Format.create(self, *args, **kwargs) # We're relying on someone having called resetPartedDisk -- we # could ensure a fresh disklabel by setting self._partedDisk to # None right before calling self.commit(), but that might hide # other problems. self.commit() self.exists = True
def __str__(self): s = Format.__str__(self) s += (" mountpoint = %(mountpoint)s mountopts = %(mountopts)s\n" " label = %(label)s size = %(size)s\n" % {"mountpoint": self.mountpoint, "mountopts": self.mountopts, "label": self.label, "size": self._size}) return s
def __str__(self): s = Format.__str__(self) s += (" priority = %(priority)s label = %(label)s" % { "priority": self.priority, "label": self.label }) return s
def __init__(self, *args, **kwargs): """ Create a SwapSpace instance. Keyword Arguments: device -- path to the underlying device uuid -- this swap space's uuid label -- this swap space's label priority -- this swap space's priority exists -- indicates whether this is an existing format """ Format.__init__(self, *args, **kwargs) self.priority = kwargs.get("priority") self.label = kwargs.get("label")
def destroy(self, *args, **kwargs): """ Destroy the format. """ if not self.exists: raise PhysicalVolumeError("format has not been created", self.device) if self.status: raise PhysicalVolumeError("device is active", self.device) # FIXME: verify path exists? try: lvm.pvremove(self.device) except lvm.LVMError: Format.destroy(self, *args, **kwargs) self.exists = False self.notifyKernel()
def __str__(self): s = Format.__str__(self) s += (" vgName = %(vgName)s vgUUID = %(vgUUID)s" " peStart = %(peStart)s" % {"vgName": self.vgName, "vgUUID": self.vgUuid, "peStart": self.peStart}) return s
def __init__(self, *args, **kwargs): """ Create a RaidMember instance. Keyword Arguments: device -- path to underlying device uuid -- this member device's uuid mdUuid -- the uuid of the array this device belongs to exists -- indicates whether this is an existing format """ Format.__init__(self, *args, **kwargs) self.mdUuid = kwargs.get("mdUuid") self.raidMinor = None self.biosraid = kwargs.get("biosraid")
def __str__(self): s = Format.__str__(self) s += (" mdUUID = %(mdUUID)s biosraid = %(biosraid)s" % { "mdUUID": self.mdUuid, "biosraid": self.biosraid }) return s
def create(self, intf=None): """ Create the device. """ if self.exists: raise PartitionError("device already exists", self.name) w = None if intf: w = intf.progressWindow( _("General", "Creating device %s") % (self.path, )) try: self.createParents() self.setupParents() self.disk.format.addPartition(self.partedPartition) try: self.disk.format.commit() except DiskLabelCommitError, msg: part = self.disk.format.partedDisk.getPartitionByPath( self.path) self.disk.format.removePartition(part) raise PartitionError, msg if not self.isExtended: # Ensure old metadata which lived in freespace so did not get # explictly destroyed by a destroyformat action gets wiped Format(device=self.path, exists=True).destroy()
def __init__(self, *args, **kwargs): """ Create a Format instance. Keyword Arguments: device -- path to the underlying device uuid -- this format's UUID exists -- indicates whether this is an existing format On initialization this format is like Format """ Format.__init__(self, *args, **kwargs) # Initialize the attribute that will hold the block object. self._raidmem = None
def __init__(self, *args, **kwargs): """ Create an PhysicalVolume instance. Keyword Arguments: device -- path to the underlying device uuid -- this PV's uuid (not the VG uuid) vgName -- the name of the VG this PV belongs to vgUuid -- the UUID of the VG this PV belongs to peStart -- offset of first physical extent exists -- indicates whether this is an existing format """ Format.__init__(self, *args, **kwargs) self.vgName = kwargs.get("vgName") self.vgUuid = kwargs.get("vgUuid") self.peStart = kwargs.get("peStart", 0.1875) # in MB
def __init__(self, *args, **kwargs): """ Create a DiskLabel instance. Keyword Arguments: device -- path to the underlying device exists -- indicates whether this is an existing format """ Format.__init__(self, *args, **kwargs) self._size = None self._partedDevice = None self._partedDisk = None self._origPartedDisk = None self._alignment = None self._endAlignment = None if self.partedDevice: # set up the parted objects and raise exception on failure self._origPartedDisk = self.partedDisk.duplicate()
def __str__(self): s = Format.__str__(self) s += (" type = %(type)s partition count = %(count)s" " sectorSize = %(sectorSize)s\n" " align_offset = %(offset)s align_grain = %(grain)s\n" " partedDisk = %(disk)r\n" " origPartedDisk = %(orig_disk)r\n" " partedDevice = %(dev)r\n" % {"type": self.labelType, "count": len(self.partitions), "sectorSize": self.partedDevice.sectorSize, "offset": self.alignment.offset, "grain": self.alignment.grainSize, "disk": self.partedDisk, "orig_disk": self._origPartedDisk, "dev": self.partedDevice}) return s
def __str__(self): s = Format.__str__(self) s += (" raidmem = %(raidmem)r" % {"raidmem": self.raidmem}) return s
def __str__(self): s = Format.__str__(self) s += (" mdUUID = %(mdUUID)s biosraid = %(biosraid)s" % {"mdUUID": self.mdUuid, "biosraid": self.biosraid}) return s
def __str__(self): s = Format.__str__(self) s += (" priority = %(priority)s label = %(label)s" % {"priority": self.priority, "label": self.label}) return s