checking in some XSD work
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
||||
##
|
||||
from lxml import etree
|
||||
|
||||
#https://stackoverflow.com/questions/30232031/how-can-i-strip-namespaces-out-of-an-lxml-tree/30233635#30233635 ?
|
||||
# https://stackoverflow.com/questions/30232031/how-can-i-strip-namespaces-out-of-an-lxml-tree/30233635#30233635 ?
|
||||
|
||||
class Config(object):
|
||||
def __init__(self):
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
import os
|
||||
import re
|
||||
##
|
||||
import parted
|
||||
|
||||
|
||||
PARTED_FSTYPES = list(dict(vars(parted.filesystem))['fileSystemType'].keys())
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ _units = {'B': 0,
|
||||
_pos_re = re.compile((r'^(?P<pos_or_neg>-|\+)?\s*'
|
||||
r'(?P<size>[0-9]+)\s*'
|
||||
# empty means size in sectors
|
||||
r'(?P<pct_unit_or_sct>%|[{0}]|)\s*$'.format(''.join(list(_units.keys())))),
|
||||
re.IGNORECASE)
|
||||
r'(?P<pct_unit_or_sct>%|{0}|)\s*$'.format('|'.join(list(_units.keys())))
|
||||
))
|
||||
|
||||
|
||||
def convertSizeUnit(pos):
|
||||
@@ -69,6 +69,7 @@ class Partition(object):
|
||||
raise ValueError(('You must specify if this is a '
|
||||
'primary, extended, or logical partition for msdos partition tables'))
|
||||
self.xml = part_xml
|
||||
self.id = part_xml.attrib['id']
|
||||
self.partnum = partnum
|
||||
if tbltype == 'msdos':
|
||||
if partnum > 4:
|
||||
|
||||
@@ -24,7 +24,7 @@ with open('/proc/filesystems', 'r') as fh:
|
||||
_mod_dir = os.path.join('/lib/modules',
|
||||
os.uname().release,
|
||||
'kernel/fs')
|
||||
_strip_mod_suffix = re.compile(r'(?P<fsname>)\.ko(\.(x|g)?z))?$', re.IGNORECASE)
|
||||
_strip_mod_suffix = re.compile(r'(?P<fsname>)\.ko(\.(x|g)?z)?$', re.IGNORECASE)
|
||||
for i in os.listdir(_mod_dir):
|
||||
path = os.path.join(_mod_dir, i)
|
||||
fs_name = None
|
||||
|
||||
@@ -1,11 +1,59 @@
|
||||
import copy
|
||||
import subprocess
|
||||
##
|
||||
import mdstat
|
||||
##
|
||||
from aif.disk.block import Disk
|
||||
from aif.disk.block import Partition
|
||||
|
||||
|
||||
SUPPORTED_LEVELS = (0, 1, 4, 5, 6)
|
||||
|
||||
class Member(object):
|
||||
def __init__(self, member_xml, partobj):
|
||||
self.xml = member_xml
|
||||
self.device = partobj
|
||||
if not isinstance(self.device, (Partition, Disk, Array)):
|
||||
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
|
||||
pass
|
||||
|
||||
def prepare(self):
|
||||
# TODO: logging
|
||||
subprocess.run(['mdadm', '--misc', '--zero-superblock', self.devpath])
|
||||
return()
|
||||
|
||||
class Array(object):
|
||||
def __init__(self, array_xml):
|
||||
self.devpath = None
|
||||
pass
|
||||
self.xml = array_xml
|
||||
self.id = array_xml.attrib['id']
|
||||
self.level = int(array_xml.attrib['level'])
|
||||
if self.level not in SUPPORTED_LEVELS:
|
||||
raise ValueError('RAID level must be one of: {0}'.format(', '.join(SUPPORTED_LEVELS)))
|
||||
self.devname = self.xml.attrib['name']
|
||||
self.devpath = '/dev/md/{0}'.format(self.devname)
|
||||
self.updateStatus()
|
||||
self.members = []
|
||||
|
||||
def addMember(self, memberobj):
|
||||
if not isinstance(memberobj, Member):
|
||||
raise ValueError('memberobj must be of type aif.disk.mdadm.Member')
|
||||
|
||||
def assemble(self):
|
||||
cmd = ['mdadm', '--assemble', self.devpath]
|
||||
for m in self.members:
|
||||
cmd.append(m.devpath)
|
||||
subprocess.run(cmd)
|
||||
|
||||
def stop(self):
|
||||
# TODO: logging
|
||||
subprocess.run(['mdadm', '--stop', self.devpath])
|
||||
return()
|
||||
|
||||
def updateStatus(self):
|
||||
_info = mdstat.parse()
|
||||
for k, v in _info['devices'].items():
|
||||
if k != self.devname:
|
||||
del(_info['devices'][k])
|
||||
self.info = copy.deepcopy(_info)
|
||||
return()
|
||||
|
||||
@@ -13,8 +13,8 @@ import tempfile
|
||||
import venv
|
||||
|
||||
# TODO: a more consistent way of managing deps?
|
||||
depmods = ['blkinfo', 'gpg', 'lxml', 'passlib', 'psutil',
|
||||
'pyparted', 'pytz', 'requests', 'validators']
|
||||
depmods = ['blkinfo', 'gpg', 'lxml', 'mdstat', 'passlib', 'psutil',
|
||||
'pyparted', 'pyroute2', 'pytz', 'requests', 'validators']
|
||||
|
||||
class EnvBuilder(object):
|
||||
def __init__(self):
|
||||
|
||||
0
aif/system/__init__.py
Normal file
0
aif/system/__init__.py
Normal file
0
aif/system/locales.py
Normal file
0
aif/system/locales.py
Normal file
Reference in New Issue
Block a user