Esempio n. 1
0
    def __init__(self):
        if not os.path.exists(MDADM_EXEC):
            if disttool.is_redhat_based():
                system2(('/usr/bin/yum', '-d0', '-y', 'install', 'mdadm', '-x',
                         'exim'),
                        raise_exc=False)
            else:
                mgr = dynimp.package_mgr()
                mgr.install('mdadm', mgr.candidates('mdadm')[-1])
        for location in ['/etc ', '/lib']:
            path = os.path.join(location, 'udev/rules.d/85-mdadm.rules')
            if os.path.exists(path):

                rule = None
                with open(path, 'r') as fp:
                    rule = fp.read()

                if rule:
                    rule = re.sub(re.compile('^([^#])', re.M), '#\\1', rule)
                    with open(path, 'w') as fp:
                        fp.write(rule)

        self._raid_devices_re = re.compile(
            'Raid\s+Devices\s+:\s+(?P<count>\d+)')
        self._total_devices_re = re.compile(
            'Total\s+Devices\s+:\s+(?P<count>\d+)')
        self._state_re = re.compile('State\s+:\s+(?P<state>.+)')
        self._rebuild_re = re.compile(
            'Rebuild\s+Status\s+:\s+(?P<percent>\d+)%')
        self._level_re = re.compile('Raid Level : (?P<level>.+)')
Esempio n. 2
0
    def __init__(self):
        if not os.path.exists(MDADM_EXEC):
            if disttool.is_redhat_based():
                system2(('/usr/bin/yum', '-d0', '-y', 'install', 'mdadm', '-x', 'exim'), raise_exc=False)
            else:
                mgr = dynimp.package_mgr()
                mgr.install('mdadm', mgr.candidates('mdadm')[-1])
        for location in ['/etc ', '/lib']:
            path = os.path.join(location, 'udev/rules.d/85-mdadm.rules')
            if os.path.exists(path):

                rule = None
                with open(path, 'r') as fp:
                    rule = fp.read()

                if rule:
                    rule = re.sub(re.compile('^([^#])', re.M), '#\\1', rule)
                    with open(path, 'w') as fp:
                        fp.write(rule)

        self._raid_devices_re   = re.compile('Raid\s+Devices\s+:\s+(?P<count>\d+)')
        self._total_devices_re  = re.compile('Total\s+Devices\s+:\s+(?P<count>\d+)')
        self._state_re          = re.compile('State\s+:\s+(?P<state>.+)')
        self._rebuild_re        = re.compile('Rebuild\s+Status\s+:\s+(?P<percent>\d+)%')
        self._level_re                  = re.compile('Raid Level : (?P<level>.+)')
Esempio n. 3
0
	def __init__(self):
		if not os.path.exists('/sbin/mkfs.%s' % self.name):
			system(('/sbin/modprobe', self.name), error_text="Cannot load '%s' kernel module" % self.name)
			mgr = dynimp.package_mgr()
			if self.os_packages:
				for package in self.os_packages:
					candidates = mgr.candidates(package)
					if candidates:
						mgr.install(package, candidates[-1])
					else:
						raise Exception("No installation candidates for package '%s'", package)
Esempio n. 4
0
 def fix_module(self):
     """
     fixing bug in rpaf 0.6-2
     """
     pm = dynimp.package_mgr()
     if "0.6-2" == pm.installed("libapache2-mod-rpaf"):
         try:
             self._cnf.set('./IfModule[@value="mod_rpaf.c"]', {"value": "mod_rpaf-2.0.c"})
         except NoPathError:
             pass
         else:
             LOG.info("Patched IfModule value in rpaf.conf")
Esempio n. 5
0
 def fix_module(self):
     """
     fixing bug in rpaf 0.6-2
     """
     pm = dynimp.package_mgr()
     if "0.6-2" == pm.installed("libapache2-mod-rpaf"):
         try:
             self._cnf.set('./IfModule[@value="mod_rpaf.c"]',
                           {"value": "mod_rpaf-2.0.c"})
         except NoPathError:
             pass
         else:
             LOG.info("Patched IfModule value in rpaf.conf")
Esempio n. 6
0
    def __init__(self):
        if not os.path.exists('/sbin/mkfs.%s' % self.name):
            try:
                coreutils.modprobe(self.name)
            except:
                e = sys.exc_info()[1]
                error_text="Cannot load '%s' kernel module: %s" % (self.name, e)
                raise Exception(error_text)

            mgr = dynimp.package_mgr()
            if self.os_packages:
                for package in self.os_packages:
                    candidates = mgr.candidates(package)
                    if candidates:
                        mgr.install(package, candidates[-1])
                    else:
                        raise Exception("No installation candidates for package '%s'", package)
Esempio n. 7
0
from scalarizr.util import system2, firstmatched, PopenError
from scalarizr.util.software import whereis
from scalarizr.util import dynimp
from scalarizr.linux import coreutils
from scalarizr.storage import StorageError


logger = logging.getLogger(__name__)


class Lvm2Error(PopenError):
    pass

if not os.path.exists('/sbin/pvs'):
    mgr = dynimp.package_mgr()
    if not mgr.installed('lvm2'):
        mgr.install('lvm2', mgr.candidates('lvm2')[-1])


try:
    PVS = whereis('pvs')[0]
    VGS = whereis('vgs')[0]
    LVS = whereis('lvs')[0]

    PVSCAN = whereis('pvscan')[0]
    PVCREATE = whereis('pvcreate')[0]
    VGCREATE = whereis('vgcreate')[0]
    LVCREATE = whereis('lvcreate')[0]

    LVCHANGE = whereis('lvchange')[0]