def __init__(self, format=None): """ Create a NoDevice instance. Arguments: Keyword Arguments: format -- a DeviceFormat instance """ if format: name = format.type else: name = "none" Device.__init__(self, name, format=format)
def __init__(self, format=None): """ Create a NoDevice instance. Arguments: Keyword Arguments: format -- a DeviceFormat instance """ if format: name = format.type else: name = "none" Device.__init__(self, name, format=format)
def __init__(self, name, format=None, size=None, grow=False, maxsize=None, major=None, minor=None, bootable=None, sysfsPath='', parents=None, exists=None, partType=None, primary=False, weight=0): """ Create a Partition instance. Arguments: name -- the device name (generally a device node's basename) Keyword Arguments: exists -- indicates whether this is an existing device format -- the device's format (DeviceFormat instance) For existing partitions: parents -- the disk that contains this partition major -- the device major minor -- the device minor sysfsPath -- sysfs device path For new partitions: partType -- primary,extended,&c (as parted constant) grow -- whether or not to grow the partition maxsize -- max size for growable partitions (in MB) size -- the device's size (in MB) bootable -- whether the partition is bootable parents -- a list of potential containing disks weight -- an initial sorting weight to assign """ self.req_disks = [] self.req_partType = None self.req_primary = None self.req_grow = None self.req_bootable = None self.req_size = 0 self.req_base_size = 0 self.req_max_size = 0 self.req_base_weight = 0 self._bootable = False Device.__init__(self, name, format=format, size=size, major=major, minor=minor, exists=exists, sysfsPath=sysfsPath, parents=parents) if not exists: # this is a request, not a partition -- it has no parents self.req_disks = self.parents[:] for dev in self.parents: dev.removeChild() self.parents = [] # FIXME: Validate partType, but only if this is a new partition # Otherwise, overwrite it with the partition's type. self._partType = None self.partedFlags = {} self._partedPartition = None self._origPath = None self._currentSize = 0 # FIXME: Validate size, but only if this is a new partition. # For existing partitions we will get the size from # parted. if self.exists: ctx.logger.debug("looking up parted Partition: %s" % self.path) self._partedPartition = self.disk.format.partedDisk.getPartitionByPath(self.path) if not self._partedPartition: raise PartitionError("cannot find parted partition instance", self.name) self._origPath = self.path self.probe() if self.getFlag(parted.PARTITION_PREP): # the only way to identify a PPC PReP Boot partition is to # check the partition type/flags, so do it here. self.format = getFormat("prepboot", device=self.path, exists=True) else: # XXX It might be worthwhile to create a shit-simple # PartitionRequest class and pass one to this constructor # for new partitions. if not self._size: # default size for new partition requests self._size = self.defaultSize self.req_name = name self.req_partType = partType self.req_primary = primary self.req_max_size = numeric_type(maxsize) self.req_grow = grow self.req_bootable = bootable # req_size may be manipulated in the course of partitioning self.req_size = self._size # req_base_size will always remain constant self.req_base_size = self._size self.req_base_weight = weight
def __init__(self, name, format=None, size=None, grow=False, maxsize=None, major=None, minor=None, bootable=None, sysfsPath='', parents=None, exists=None, partType=None, primary=False, weight=0): """ Create a Partition instance. Arguments: name -- the device name (generally a device node's basename) Keyword Arguments: exists -- indicates whether this is an existing device format -- the device's format (DeviceFormat instance) For existing partitions: parents -- the disk that contains this partition major -- the device major minor -- the device minor sysfsPath -- sysfs device path For new partitions: partType -- primary,extended,&c (as parted constant) grow -- whether or not to grow the partition maxsize -- max size for growable partitions (in MB) size -- the device's size (in MB) bootable -- whether the partition is bootable parents -- a list of potential containing disks weight -- an initial sorting weight to assign """ self.req_disks = [] self.req_partType = None self.req_primary = None self.req_grow = None self.req_bootable = None self.req_size = 0 self.req_base_size = 0 self.req_max_size = 0 self.req_base_weight = 0 self._bootable = False Device.__init__(self, name, format=format, size=size, major=major, minor=minor, exists=exists, sysfsPath=sysfsPath, parents=parents) if not exists: # this is a request, not a partition -- it has no parents self.req_disks = self.parents[:] for dev in self.parents: dev.removeChild() self.parents = [] # FIXME: Validate partType, but only if this is a new partition # Otherwise, overwrite it with the partition's type. self._partType = None self.partedFlags = {} self._partedPartition = None self._origPath = None self._currentSize = 0 # FIXME: Validate size, but only if this is a new partition. # For existing partitions we will get the size from # parted. if self.exists: ctx.logger.debug("looking up parted Partition: %s" % self.path) self._partedPartition = self.disk.format.partedDisk.getPartitionByPath( self.path) if not self._partedPartition: raise PartitionError("cannot find parted partition instance", self.name) self._origPath = self.path self.probe() if self.getFlag(parted.PARTITION_PREP): # the only way to identify a PPC PReP Boot partition is to # check the partition type/flags, so do it here. self.format = getFormat("prepboot", device=self.path, exists=True) else: # XXX It might be worthwhile to create a shit-simple # PartitionRequest class and pass one to this constructor # for new partitions. if not self._size: # default size for new partition requests self._size = self.defaultSize self.req_name = name self.req_partType = partType self.req_primary = primary self.req_max_size = numeric_type(maxsize) self.req_grow = grow self.req_bootable = bootable # req_size may be manipulated in the course of partitioning self.req_size = self._size # req_base_size will always remain constant self.req_base_size = self._size self.req_base_weight = weight
def __init__(self, name, level=None, major=None, minor=None, size=None, memberDevices=None, totalDevices=None, uuid=None, format=None, exists=None, parents=None, sysfsPath=''): """ Create a RaidArray instance. Arguments: name -- the device name (generally a device node's basename) Keyword Arguments: level -- the device's RAID level (a string, eg: '1' or 'raid1') parents -- list of member devices (Device instances) size -- the device's size (units/format TBD) uuid -- the device's UUID minor -- the device minor sysfsPath -- sysfs device path format -- a DeviceFormat instance exists -- indicates whether this is an existing device """ Device.__init__(self, name, format=format, exists=exists, major=major, minor=minor, size=size, parents=parents, sysfsPath=sysfsPath) self.level = level if level == "container": self._type = "mdcontainer" elif level is not None: self.level = raid.raidLevel(level) # For new arrays check if we have enough members if (not exists and parents and len(parents) < raid.get_raid_min_members(self.level)): raise ValueError, _("A RAID%(level)d set requires at least %(min_member)d member") % \ {"level":self.level, "min_member":raid.get_raid_min_members(self.level)} self.uuid = uuid self._totalDevices = numeric_type(totalDevices) self._memberDevices = numeric_type(memberDevices) self.sysfsPath = "/devices/virtual/block/%s" % name self.chunkSize = 512.0 / 1024.0 # chunk size in MB self.superBlockSize = 2.0 # superblock size in MB self.createMetadataVer = "1.1" # bitmaps are not meaningful on raid0 according to mdadm-3.0.3 self.createBitmap = self.level != 0 # For container members probe size now, as we cannot determine it # when teared down. if self.parents and self.parents[0].type == "mdcontainer": self._size = self.currentSize self._type = "mdbiosraidarray" self.formatClass = get_device_format("mdmember") if not self.formatClass: raise RaidArrayError("cannot find class for 'mdmember'", self.name) if self.exists and self.uuid: # this is a hack to work around mdadm's insistence on giving # really high minors to arrays it has no config entry for open("/etc/mdadm.conf", "a").write("ARRAY %s UUID=%s\n" % (self.path, self.uuid))
def __init__(self, name, level=None, major=None, minor=None, size=None, memberDevices=None, totalDevices=None, uuid=None, format=None, exists=None, parents=None, sysfsPath=''): """ Create a RaidArray instance. Arguments: name -- the device name (generally a device node's basename) Keyword Arguments: level -- the device's RAID level (a string, eg: '1' or 'raid1') parents -- list of member devices (Device instances) size -- the device's size (units/format TBD) uuid -- the device's UUID minor -- the device minor sysfsPath -- sysfs device path format -- a DeviceFormat instance exists -- indicates whether this is an existing device """ Device.__init__(self, name, format=format, exists=exists, major=major, minor=minor, size=size, parents=parents, sysfsPath=sysfsPath) self.level = level if level == "container": self._type = "mdcontainer" elif level is not None: self.level = raid.raidLevel(level) # For new arrays check if we have enough members if (not exists and parents and len(parents) < raid.get_raid_min_members(self.level)): raise ValueError, _("A RAID%(level)d set requires at least %(min_member)d member") % \ {"level":self.level, "min_member":raid.get_raid_min_members(self.level)} self.uuid = uuid self._totalDevices = numeric_type(totalDevices) self._memberDevices = numeric_type(memberDevices) self.sysfsPath = "/devices/virtual/block/%s" % name self.chunkSize = 512.0 / 1024.0 # chunk size in MB self.superBlockSize = 2.0 # superblock size in MB self.createMetadataVer = "1.1" # bitmaps are not meaningful on raid0 according to mdadm-3.0.3 self.createBitmap = self.level != 0 # For container members probe size now, as we cannot determine it # when teared down. if self.parents and self.parents[0].type == "mdcontainer": self._size = self.currentSize self._type = "mdbiosraidarray" self.formatClass = get_device_format("mdmember") if not self.formatClass: raise RaidArrayError("cannot find class for 'mdmember'", self.name) if self.exists and self.uuid: # this is a hack to work around mdadm's insistence on giving # really high minors to arrays it has no config entry for open("/etc/mdadm.conf", "a").write("ARRAY %s UUID=%s\n" % (self.path, self.uuid))