Пример #1
0
def getMultiPathDevice(dev_disk_by_path):
    # input: /dev/disk/by-path/ip-10.100.10.3:3260-iscsi-iqn.2000-11.jp.co.valinux:00000006-lun-1
    # output: /dev/mapper/mpath5
    dev_path = ""

    # iSCSI device path --> wwid
    wwid = ""

    command = "scsi_id -g -u /dev/%s" % os.path.realpath(dev_disk_by_path).split("/dev/")[1]

    def condition():
        return os.path.exists(dev_disk_by_path)

    wwid = executecommand_retry(command, condition, SCSI_ID_RETRY_TIMES)

    # wwid --> Multipath device path
    dev_name = ""

    for i in range(0, GETMULTIPATHDEVICE_RETRY_TIMES):
        try:
            executecommand("multipath")
            dev_name = executecommand("dmsetup info --noheadings -c -u mpath-%s -o name" % (wwid))
            return getDmDevPath(dev_name)
        except:
            time.sleep(GETMULTIPATHDEVICE_RETRY_INTERVAL)

    logger.error("getMultiPathDevice: multipath -v3: %s", executecommand("multipath -v3"))
    raise Exception, "retry over"
Пример #2
0
 def undo(self):
     assert len(self.components) == 1
     name = getDextDevName(self.dext_ssvrid, self.lvolid)
     path = getDmDevPath(name)
     if os.path.exists(path):
         dmsetup_remove(name)
     self.path = None
Пример #3
0
 def undo(self):
     assert(len(self.components) > 0)
     name = getSnapshotDevName(self.lvolid)
     path = getDmDevPath(name)
     if os.path.exists(path):
         dmsetup_remove(name)
     self.path = None
Пример #4
0
 def do(self):
     assert(len(self.components) > 0)
     name = getSnapshotOriginDevName(self.lvolid)
     path = getDmDevPath(name)
     if not os.path.exists(path):
         c = self.components[0]
         command = "echo 0 %s snapshot-origin %s | dmsetup create %s" % \
             (gtos(self.capacity), c.path, name)
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
Пример #5
0
 def do(self):
     assert(len(self.components) > 0)
     name = getSnapshotDevName(self.lvolid)
     path = getDmDevPath(name)
     if not os.path.exists(path):
         origin_path = getSnapshotOriginOriginPath( \
             self.snapshot_origin_lvolid)
         origin_size = blockdev_getsize(origin_path)
         c = self.components[0]
         command = \
             "echo 0 %s snapshot %s %s P %u | dmsetup create --readonly %s" \
             % (origin_size, origin_path, c.path, SNAPSHOT_CHUNK_SIZE, name)
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
Пример #6
0
 def do(self):
     assert len(self.components) == 1
     c = self.components[0]
     assert c.iscsi_ref != None
     name = getDextDevName(self.dext_ssvrid, self.lvolid)
     path = getDmDevPath(name)
     if not os.path.exists(path):
         command = "echo 0 %s linear %s %s | dmsetup create %s" % (
             vbtos(self.capacity),
             c.path,
             vbtos(self.dext_offset),
             name,
         )
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
     os.close(c.iscsi_ref)
     c.iscsi_ref = None
Пример #7
0
def dm_resume(lvolid):
    name = getSnapshotOriginDevName(lvolid)
    path = getDmDevPath(name)
    if os.path.exists(path):
        command = "dmsetup resume %s" % name
        executecommand(command)