adding partition flags
This commit is contained in:
parent
3a6e8843fe
commit
4cdd61da7b
1
aif.xsd
1
aif.xsd
@ -224,6 +224,7 @@
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="t_raid_meta">
|
||||
<!-- Warn about 1.x used for non-aware bootloaders in manual... 0.90 should be used in that case. -->
|
||||
<xs:restriction base="xs:token">
|
||||
<xs:enumeration value="0"/><!-- Same as 0.90 -->
|
||||
<xs:enumeration value="0.90"/><!-- Same as 0 -->
|
||||
|
@ -21,7 +21,10 @@ import psutil
|
||||
from aif.aif_util import xmlBool
|
||||
|
||||
|
||||
PARTED_FSTYPES = list(dict(vars(parted.filesystem))['fileSystemType'].keys())
|
||||
PARTED_FSTYPES = sorted(list(dict(vars(parted.filesystem))['fileSystemType'].keys()))
|
||||
PARTED_FLAGS = sorted(list(parted.partition.partitionFlag.values()))
|
||||
IDX_FLAG = dict(parted.partition.partitionFlag)
|
||||
FLAG_IDX = {v: k for k, v in IDX_FLAG.items()}
|
||||
|
||||
# parted lib can do SI or IEC (see table to right at https://en.wikipedia.org/wiki/Binary_prefix)
|
||||
# We bit-shift to do conversions:
|
||||
@ -70,6 +73,11 @@ class Partition(object):
|
||||
'primary, extended, or logical partition for msdos partition tables'))
|
||||
self.xml = part_xml
|
||||
self.id = part_xml.attrib['id']
|
||||
self.flags = set()
|
||||
for f in self.xml.findall('partitionFlag'):
|
||||
if f.text in PARTED_FLAGS:
|
||||
self.flags.add(f.text)
|
||||
self.flags = sorted(list(self.flags))
|
||||
self.partnum = partnum
|
||||
if tbltype == 'msdos':
|
||||
if partnum > 4:
|
||||
@ -126,6 +134,12 @@ class Partition(object):
|
||||
type = self.part_type,
|
||||
geometry = self.geometry,
|
||||
fs = self.filesystem)
|
||||
for f in self.flags[:]:
|
||||
flag_id = FLAG_IDX[f]
|
||||
if self.partition.isFlagAvailable(flag_id):
|
||||
self.partition.setFlag(flag_id)
|
||||
else:
|
||||
self.flags.remove(f)
|
||||
if tbltype == 'gpt' and self.xml.attrib.get('name'):
|
||||
# The name attribute setting is b0rk3n, so we operate on the underlying PedPartition object.
|
||||
# https://github.com/dcantrell/pyparted/issues/49#issuecomment-540096687
|
||||
|
@ -87,8 +87,8 @@ class Array(object):
|
||||
def addMember(self, memberobj):
|
||||
if not isinstance(memberobj, Member):
|
||||
raise ValueError('memberobj must be of type aif.disk.mdadm.Member')
|
||||
|
||||
pass
|
||||
memberobj.prepare()
|
||||
self.members.append(memberobj)
|
||||
return()
|
||||
|
||||
def assemble(self, scan = False):
|
||||
|
@ -60,7 +60,7 @@
|
||||
<mdadm>
|
||||
<!-- level can be 0, 1, 4, 5, 6, or 10. RAID 1+0 (which is different from mdadm RAID10) would be done by
|
||||
creating an array with members of a previously assembled array. -->
|
||||
<array id="mdadm1" name="md0" meta="1.2" level="1">
|
||||
<array id="mdadm1" name="data" meta="1.2" level="1">
|
||||
<member source="raid1_d1"/>
|
||||
<member source="raid1_d2"/>
|
||||
</array>
|
||||
|
Loading…
Reference in New Issue
Block a user