Пример #1
0
    def get_map(self):
        if not self._MultiPath__map is None:
            return self._MultiPath__map

        table = self.get_table()

        import dm as _dm

        for map in _dm.maps():
            # XXX wtf?  why's it have a space at the end sometimes?
            if str(map.table).strip() == str(table).strip():
                if self.name != map.name:
                    self.name = nameCache.rename(self.name, map.name)

                self._MultiPath__map = map
                self.buildParts()
                self.active = True
                del _dm
                return self._MultiPath__map

        # all else has failed, make a new map...
        self._MultiPath__map = _dm.map(name=self.name, table=table)
        self.buildParts()
        self.active = True
        del _dm
        return self._MultiPath__map
Пример #2
0
    def get_map(self):
        if not self._MultiPath__map is None:
            return self._MultiPath__map

        table = self.get_table()

        import dm as _dm

        for map in _dm.maps():
            if compare_tables(map.table, table):
                if self.name != map.name:
                    self.name = nameCache.rename(self.name, map.name)

                self._MultiPath__map = map
                self.buildParts()
                self.active = True
                del _dm
                return self._MultiPath__map

        # all else has failed, make a new map...
        self._MultiPath__map = _dm.map(name=self.name, table=table)
        self.buildParts()
        self.active = True
        del _dm
        return self._MultiPath__map
Пример #3
0
    def get_map(self):
        if not self._RaidSet__map is None:
            return self._RaidSet__map

        # we get "/dev/hda" from one and "3:0" from the other, so we have to
        # fix up the device name
        def map_dev(path):
            if path[0] != '/':
                return path.strip()

            try:
                newpath = path.split('/')[-1]
                pos = 0
                dev = None
                num = None
                while pos < len(newpath):
                    if newpath[pos].isdigit():
                        dev = newpath[:pos]
                        num = newpath[pos:]
                        break
                    pos += 1
                if dev is None:
                    dev = newpath
                sysnewpath = None
                if num is None:
                    sysnewpath = '/sys/block/%s/dev' % (dev, )
                else:
                    sysnewpath = '/sys/block/%s/%s%s/dev' % (dev, dev, num)
                f = open(sysnewpath, 'r')
                l = f.readline()
                return l.strip()
            except:
                return path.strip()

        parts = str(self.rs.dmTable).split(' ')

        table = []
        for part in parts:
            table += [
                map_dev(part),
            ]
        table = _string.join(table, ' ')

        import dm as _dm

        for map in _dm.maps():
            # XXX wtf?  why's it have a space at the end sometimes?
            if str(map.table).strip() == table:
                self._RaidSet__map = map
                self.active = True
                del _dm
                return self._RaidSet__map

        # all else has failed, make a new map...
        self._RaidSet__map = _dm.map(name=self.name, table=self.rs.dmTable)
        self.active = True
        del _dm
        return self._RaidSet__map
Пример #4
0
    def create(self, name=None):

        import dm as _dm
        for map in _dm.maps():
            # XXX wtf?  why's it have a space at the end sometimes?
            if str(map.table).strip() == str(self.table).strip():
                self.map = map
                self.name = map.name
                break
        else:
            if name is None:
                name = self.name
            if self.name is None:
                raise ValueError, "DeviceMap name is not set"
            self.map = _dm.map(name=self.name, table=self.table)
        del _dm
Пример #5
0
    def create(self, name=None):

        import dm as _dm
        import device as _device
        for map in _dm.maps():
            if _device.compare_tables(map.table, self.table):
                self.map = map
                self.name = map.name
                break
        else:
            if name is None:
                name = self.name
            if self.name is None:
                raise ValueError, "DeviceMap name is not set"
            self.map = _dm.map(name = self.name, table = self.table)
        del _dm
        del _device
Пример #6
0
    def get_map(self):
        if not self._RaidSet__map is None:
            return self._RaidSet__map

        import dm as _dm

        for map in _dm.maps():
            if compare_tables(map.table, self.rs.dmTable):
                self._RaidSet__map = map
                self.active = True
                del _dm
                return self._RaidSet__map

        # all else has failed, make a new map...
        self._RaidSet__map = _dm.map(name=self.name, table=self.rs.dmTable)
        self.active = True
        del _dm
        return self._RaidSet__map