コード例 #1
0
ファイル: lvm.py プロジェクト: kholia/pyrpm
    def display(chroot=None):
        command = "%s pvdisplay --units b 2>/dev/null" % \
                  LVM_PHYSICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to get general physical volume information.")
            return None

        dict = { }
        device = None
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            if line[:7] == "PV Name":
                device = line[7:].strip()
                dict[device] = { }
                d = dict[device]
            if not device:
                continue
            try:
                if line[:7] == "VG Name":
                    d["vgname"] = line[7:].strip()
                elif line[:7] == "PV UUID":
                    d["pvuuid"] = line[7:].strip()
            except:
                log.error("pvdisplay output malformed.")
                return None
        return dict
コード例 #2
0
ファイル: lvm.py プロジェクト: devzero2000/pyrpm
    def display(chroot=None):
        command = "%s pvdisplay --units b 2>/dev/null" % \
                  LVM_PHYSICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to get general physical volume information.")
            return None

        dict = {}
        device = None
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            if line[:7] == "PV Name":
                device = line[7:].strip()
                dict[device] = {}
                d = dict[device]
            if not device:
                continue
            try:
                if line[:7] == "VG Name":
                    d["vgname"] = line[7:].strip()
                elif line[:7] == "PV UUID":
                    d["pvuuid"] = line[7:].strip()
            except:
                log.error("pvdisplay output malformed.")
                return None
        return dict
コード例 #3
0
ファイル: disk.py プロジェクト: devzero2000/pyrpm
 def reload(self):
     if not self.ped_disk:
         try:
             self.ped_disk = parted.PedDisk.new(self.ped_device)
         except Exception, msg:
             log.debug1(msg)
             pass
コード例 #4
0
ファイル: disk.py プロジェクト: kholia/pyrpm
 def reload(self):
     if not self.ped_disk:
         try:
             self.ped_disk = parted.PedDisk.new(self.ped_device)
         except Exception, msg:
             log.debug1(msg)
             pass
コード例 #5
0
ファイル: functions.py プロジェクト: kholia/pyrpm
def mount_nfs(url, dir, options=None):
    if url[:6] != "nfs://":
        raise ValueError, "'%s' is no valid nfs url." % url

    what = url[6:]
    splits = what.split("/", 1)
    if splits[0][-1] != ":":
        what = ":/".join(splits)
    del splits
    if not options:
        options = "ro,rsize=32768,wsize=32768,hard,nolock"
    # mount nfs source
    log.debug1("Mounting '%s' on '%s'", what, dir)
    mount(what, dir, fstype="nfs", options=options)
    return "file://%s" % dir
コード例 #6
0
ファイル: functions.py プロジェクト: devzero2000/pyrpm
def mount_nfs(url, dir, options=None):
    if url[:6] != "nfs://":
        raise ValueError, "'%s' is no valid nfs url." % url

    what = url[6:]
    splits = what.split("/", 1)
    if splits[0][-1] != ":":
        what = ":/".join(splits)
    del splits
    if not options:
        options = "ro,rsize=32768,wsize=32768,hard,nolock"
    # mount nfs source
    log.debug1("Mounting '%s' on '%s'", what, dir)
    mount(what, dir, fstype="nfs", options=options)
    return "file://%s" % dir
コード例 #7
0
ファイル: lvm.py プロジェクト: kholia/pyrpm
    def scan(chroot=None):
        command = "%s pvscan 2>/dev/null" % LVM_PHYSICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to scan for physical volumes.")
            return None

        dict = { }
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            splits = line.split()
            if len(splits) < 4 or splits[0] != "PV" or splits[2] != "VG":
                continue
            # set <volgroup>: <device>, ..
            dict.setdefault(splits[3], [ ]).append(splits[1])
        return dict
コード例 #8
0
ファイル: lvm.py プロジェクト: devzero2000/pyrpm
    def scan(chroot=None):
        command = "%s pvscan 2>/dev/null" % LVM_PHYSICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to scan for physical volumes.")
            return None

        dict = {}
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            splits = line.split()
            if len(splits) < 4 or splits[0] != "PV" or splits[2] != "VG":
                continue
            # set <volgroup>: <device>, ..
            dict.setdefault(splits[3], []).append(splits[1])
        return dict
コード例 #9
0
ファイル: lvm.py プロジェクト: kholia/pyrpm
    def display(chroot=None):
        command = "%s lvdisplay --units b 2>/dev/null" % \
                  LVM_LOGICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to get volume group information.")
            return None

        dict = { }
        volume = None
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            if line[:7] == "LV Name":
                volume = line[7:].strip()
                dict[volume] = { }
                d = dict[volume]
            if not volume:
                continue
            try:
                if line[:6] == "VG Name":
                    d["vgname"] = line[7:].strip()
                elif line[:6] == "LV UUID":
                    d["lvuuid"] = line[7:].strip()
                elif line[:7] == "LV Size":
                    if line[-2:] == " B":
                        d["lvsize"] = long(line[7:-1].strip())
                elif line[:7] == "Block device":
                    d["device"] = line[12:].strip()
            except:
                log.error("lvdisplay output malformed.")
                return None
        return dict
コード例 #10
0
ファイル: lvm.py プロジェクト: kholia/pyrpm
    def display(chroot=None):
        command = "%s vgdisplay --units b 2>/dev/null" % LVM_VOLGROUP.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to get volume group information.")
            return None

        dict = { }
        group = None
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            if line[:7] == "VG Name":
                group = line[7:].strip()
                dict[group] = { }
                d = dict[group]
            if not group:
                continue
            try:
                if line[:6] == "Format":
                    d["format"] = line[7:].strip()
                elif line[:7] == "VG Size":
                    if line[-2:] == " B":
                        d["vgsize"] = long(line[7:-1].strip())
                elif line[:7] == "PE Size":
                    if line[-2:] == " B":
                        d["pesize"] = long(line[7:-1].strip())
                elif line[:8] == "Total PE":
                    d["pe"] = long(line[8:].strip())
            except:
                log.error("vgdisplay output malformed.")
                return None
        return dict
コード例 #11
0
ファイル: lvm.py プロジェクト: devzero2000/pyrpm
    def display(chroot=None):
        command = "%s lvdisplay --units b 2>/dev/null" % \
                  LVM_LOGICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to get volume group information.")
            return None

        dict = {}
        volume = None
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            if line[:7] == "LV Name":
                volume = line[7:].strip()
                dict[volume] = {}
                d = dict[volume]
            if not volume:
                continue
            try:
                if line[:6] == "VG Name":
                    d["vgname"] = line[7:].strip()
                elif line[:6] == "LV UUID":
                    d["lvuuid"] = line[7:].strip()
                elif line[:7] == "LV Size":
                    if line[-2:] == " B":
                        d["lvsize"] = long(line[7:-1].strip())
                elif line[:7] == "Block device":
                    d["device"] = line[12:].strip()
            except:
                log.error("lvdisplay output malformed.")
                return None
        return dict
コード例 #12
0
ファイル: lvm.py プロジェクト: devzero2000/pyrpm
    def display(chroot=None):
        command = "%s vgdisplay --units b 2>/dev/null" % LVM_VOLGROUP.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to get volume group information.")
            return None

        dict = {}
        group = None
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            if line[:7] == "VG Name":
                group = line[7:].strip()
                dict[group] = {}
                d = dict[group]
            if not group:
                continue
            try:
                if line[:6] == "Format":
                    d["format"] = line[7:].strip()
                elif line[:7] == "VG Size":
                    if line[-2:] == " B":
                        d["vgsize"] = long(line[7:-1].strip())
                elif line[:7] == "PE Size":
                    if line[-2:] == " B":
                        d["pesize"] = long(line[7:-1].strip())
                elif line[:8] == "Total PE":
                    d["pe"] = long(line[8:].strip())
            except:
                log.error("vgdisplay output malformed.")
                return None
        return dict
コード例 #13
0
ファイル: lvm.py プロジェクト: kholia/pyrpm
    def scan(chroot=None):
        command = "%s lvscan 2>/dev/null" % LVM_LOGICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to scan for logical volumes.")
            return None

        dict = { }
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            splits = line.split("'")
            if len(splits) < 3:
                continue
            # set <volgroup>: <device>, ..
            d = splits[1].split("/")
            if len(d) != 3 or d[0] != "dev":
                continue
            dict[splits[1]] = d[1]
        return dict
コード例 #14
0
ファイル: lvm.py プロジェクト: devzero2000/pyrpm
    def scan(chroot=None):
        command = "%s lvscan 2>/dev/null" % LVM_LOGICAL_VOLUME.prog
        log.debug1(command)
        (status, rusage, msg) = runScript(script=command, chroot=chroot)
        if msg and msg != "":
            log.debug1(msg, nofmt=1)
        if status != 0:
            log.error("Failed to scan for logical volumes.")
            return None

        dict = {}
        for line in msg.split("\n"):
            line = line.strip()
            if len(line) < 1 or line[0] == '#':
                continue
            splits = line.split("'")
            if len(splits) < 3:
                continue
            # set <volgroup>: <device>, ..
            d = splits[1].split("/")
            if len(d) != 3 or d[0] != "dev":
                continue
            dict[splits[1]] = d[1]
        return dict
コード例 #15
0
ファイル: functions.py プロジェクト: kholia/pyrpm
def mount_cdrom(dir):
    what = "/dev/cdrom"
    log.debug1("Mounting '%s' on '%s'", what, dir)
    mount(what, dir, fstype="auto", options="ro")
    return "file://%s" % dir
コード例 #16
0
ファイル: functions.py プロジェクト: devzero2000/pyrpm
def mount_cdrom(dir):
    what = "/dev/cdrom"
    log.debug1("Mounting '%s' on '%s'", what, dir)
    mount(what, dir, fstype="auto", options="ro")
    return "file://%s" % dir