This commit is contained in:
brent s 2019-10-31 23:20:05 -04:00
parent 799ef58667
commit 9e5ff48926
8 changed files with 34 additions and 33 deletions

16
aif.xsd
View File

@ -466,23 +466,23 @@
<xs:attribute name="name" type="aif:t_nonempty" use="required"/>
</xs:complexType>
<xs:unique name="uniq_vg_tags">
<xs:selector xpath="tags"/>
<xs:selector xpath="aif:tags"/>
<xs:field xpath="tag"/>
</xs:unique>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniq_vg_names">
<xs:selector xpath="volumeGroup"/>
<xs:selector xpath="aif:volumeGroup"/>
<xs:field xpath="@name"/>
</xs:unique>
<!-- ??? doesn't seem to work. -->
<xs:unique name="uniq_vg_lv">
<xs:selector xpath="volumeGroup/logicalVolumes/lv"/>
<xs:selector xpath=".//aif:lv"/>
<xs:field xpath="@name"/>
</xs:unique>
<xs:unique name="uniq_vg_pv">
<xs:selector xpath="pv"/>
<xs:selector xpath=".//aif:pv"/>
<xs:field xpath="@source"/>
</xs:unique>
</xs:element>
@ -518,7 +518,7 @@
</xs:sequence>
</xs:complexType>
<xs:unique name="uniq_array_name">
<xs:selector xpath="array"/>
<xs:selector xpath="aif:array"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
@ -586,11 +586,11 @@
</xs:sequence>
</xs:complexType>
<xs:unique name="uniq_ip4">
<xs:selector xpath="ipv4"/>
<xs:selector xpath="aif:ipv4"/>
<xs:field xpath="address"/>
</xs:unique>
<xs:unique name="uniq_ip6">
<xs:selector xpath="ipv6"/>
<xs:selector xpath="aif:ipv6"/>
<xs:field xpath="address"/>
</xs:unique>
</xs:element>
@ -606,7 +606,7 @@
<xs:attribute name="device" type="aif:t_iface" use="required"/>
</xs:complexType>
<xs:unique name="uniq_resolver">
<xs:selector xpath="resolvers"/>
<xs:selector xpath="aif:resolvers"/>
<xs:field xpath="resolver"/>
</xs:unique>
</xs:element>

View File

@ -146,7 +146,7 @@ class LocalFile(Config):
def __init__(self, path, xsd_path = None, *args, **kwargs):
super().__init__(xsd_path = xsd_path, *args, **kwargs)
self.type = 'local'
self.source = _patterns['local'].search(path).group('path')
self.source = path

def fetch(self):
self.source = os.path.realpath(self.source)

View File

@ -4,10 +4,10 @@ import subprocess
##
import psutil
##
from aif.disk.block import Partition
from aif.disk.luks import LUKS
from aif.disk.lvm import LV as LVMVolume
from aif.disk.mdadm import Array as MDArray
import aif.disk.block
import aif.disk.luks
import aif.disk.lvm
import aif.disk.mdadm

# I wish there was a better way of doing this.
# https://unix.stackexchange.com/a/98680
@ -44,7 +44,11 @@ for i in os.listdir(_mod_dir):
class FS(object):
def __init__(self, fs_xml, sourceobj):
self.xml = fs_xml
if not isinstance(sourceobj, (Partition, LUKS, LVMVolume, MDArray)):
if not isinstance(sourceobj, (aif.disk.block.Disk,
aif.disk.block.Partition,
aif.disk.luks.LUKS,
aif.disk.lvm.LV,
aif.disk.mdadm.Array)):
raise ValueError(('sourceobj must be of type '
'aif.disk.block.Partition, '
'aif.disk.luks.LUKS, '

View File

@ -1,6 +1,7 @@
from aif.disk.block import Disk, Partition
from aif.disk.lvm import LV
from aif.disk.mdadm import Array
import aif.disk.block
import aif.disk.lvm
import aif.disk.mdadm


class LUKS(object):
def __init__(self, partobj):

View File

@ -7,9 +7,9 @@ except ImportError:
import subprocess
has_mod = False
##
from aif.disk.block import Disk, Partition
from aif.disk.luks import LUKS
from aif.disk.mdadm import Array
import aif.disk.block
import aif.disk.luks
import aif.disk.mdadm


class PV(object):

View File

@ -7,9 +7,9 @@ import uuid
##
import mdstat
##
from aif.disk.block import Disk, Partition
from aif.disk.luks import LUKS
from aif.disk.lvm import LV
import aif.disk.block
import aif.disk.luks
import aif.disk.lvm


SUPPORTED_LEVELS = (0, 1, 4, 5, 6, 10)
@ -50,7 +50,11 @@ class Member(object):
def __init__(self, member_xml, partobj):
self.xml = member_xml
self.device = partobj
if not isinstance(self.device, (Partition, Disk, Array)):
if not isinstance(self.device, (aif.disk.block.Partition,
aif.disk.block.Disk,
aif.disk.mdadm.Array,
aif.disk.lvm.LV,
aif.disk.luks.LUKS)):
raise ValueError(('partobj must be of type aif.disk.block.Partition, '
'aif.disk.block.Disk, or aif.disk.mdadm.Array'))
self.devpath = self.device.devpath

View File

@ -67,14 +67,6 @@
<lv id="lv1" name="logical1" size="100%"/>
</logicalVolumes>
</volumeGroup>
<volumeGroup id="vg2" name="group2">
<physicalVolumes>
<pv id="pv2" source="lvm_member1"/>
</physicalVolumes>
<logicalVolumes>
<lv id="lv2" name="logical1" size="100%"/>
</logicalVolumes>
</volumeGroup>
</lvm>
<mdadm>
<!-- level can be 0, 1, 4, 5, 6, or 10. RAID 1+0 (which is different from mdadm RAID10) would be done by