Example #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"
Example #2
0
 def undo(self):
     path = getMirrorDevPath(self.lvolid)
     assert(len(self.components) > 0)
     if os.path.exists(path):
         executecommand("mdadm -S %s" % path)
         executecommand("rm -f %s" % path)
     self.path = None
Example #3
0
def executemdadm(mdcommand):
    mdadm_lock.acquire()
    try:
        executecommand(mdcommand)
    except:
        mdadm_lock.release()
        raise
    mdadm_lock.release()
Example #4
0
 def do(self):
     try:
         executecommand("mdadm --manage --%s %s %s" % \
             (self.md_op, self.md_mirrordev, \
             self.md_component))
     except:
         if self.md_op == "fail" or self.md_op == "remove":
             # pass through dext remove.
             # if fail/remove fail by already removed, it is OK and dext remove should be OK.
             # otherwise dext remove will fail and return error to the caller
             return
         else:
             raise
Example #5
0
    def __do_shred(self, eventid, path, offset_mb, len_mb, dextid, pdskid):
        # zero clear disk extent
        command = '%s if=/dev/zero of=%s bs=1024k seek=%d count=%d %s' \
            % (DD_CMD, path, offset_mb, len_mb, DD_OPTIONS)
        try:
            executecommand(command)
        except Exception, e:
            logger.error("do_shred: %s" % (e))
            self.event_record.del_event(eventid, needlock = True)
# bug 3082606
#           notify_sm("notifyFailure", \
#               {'ver': XMLRPC_VERSION, 'target': TARGET['LVOL'], \
#               'targetid': dextid})
            notify_sm("notifyFailure", \
                {'ver': XMLRPC_VERSION, 'target': TARGET['PDSK'], \
                'targetid': pdskid})
            return
Example #6
0
def executeiscsiadm(command):
    iscsiadm_lock.acquire()
    try:
        ret = executecommand(command)
    except:
        iscsiadm_lock.release()
        raise
    iscsiadm_lock.release()
    return ret
Example #7
0
    def getTidTable(self):
        tid_re = re.compile("^Target")
        t = {}

        output = vas_subr.executecommand("tgtadm --lld iscsi --op show --mode=target")
        lines = output.splitlines()
        for line in lines:
            words = line.split(' ')
            if tid_re.match(words[0]):
                t[int(words[1].split(':')[0], 10)] = int(words[-1].split(':')[-1], 16)
        return t
Example #8
0
 def do(self):
     assert(len(self.components) > 0)
     s = ""
     offset = 0
     total_sectors = gtos(self.capacity)
     for c in self.components:
         assert c.path
         real_size = executecommand("blockdev --getsize %s" % c.path)
         c_sectors = min([int(real_size), total_sectors - offset])
         s += "%d %d linear %s 0\\n" % (offset, c_sectors, c.path)
         offset += c_sectors
     name = getLinearDevName(self.lvolid)
     path = getLinearDevPath(self.lvolid)
     if not os.path.exists(path):
         command = "echo -e \"%s\" | dmsetup create %s" % (s, name)
         execute_retry_not_path_exist(command, path, DMSETUP_RETRY_TIMES)
     self.path = path
Example #9
0
def cleanupMultiPathDevice(path):
    pdskid_str = extract_pdskid_from_iscsi_path(path)
    dev_name = getMultiPathDevice(path).split(DM_DEVICE_DIR + "/")[1]
    # NOTE: the multipath command returns 1. (bug?)
    executecommand("/sbin/multipath -f %s" % dev_name, status_ignore=True)
Example #10
0
def dm_resume(lvolid):
    name = getSnapshotOriginDevName(lvolid)
    path = getDmDevPath(name)
    if os.path.exists(path):
        command = "dmsetup resume %s" % name
        executecommand(command)
Example #11
0
 def delTarget(self, tid):
     vas_subr.executecommand("igtadm --lld iscsi --op delete --mode=target --tid=%d" % (tid))
Example #12
0
 def newLogicalUnit(self, pdskid, tid, path):
     vas_subr.executecommand("tgtadm --lld iscsi --op new --mode=logicalunit --tid=%d --lun=1 --backing-store %s %s " % (tid, path, TGTADM_PARAMS_LUN))
     vas_subr.executecommand("tgtadm --lld iscsi --op update --mode=logicalunit --tid=%d --lun=1 --params scsi_id=%08x,scsi_sn=%08x" % (tid, pdskid, pdskid))
Example #13
0
 def newTarget(self, tid, iqn, pdskid):
     vas_subr.executecommand("tgtadm --lld iscsi --op new --mode=target --tid=%d --targetname %s:%08x" % (tid, iqn, pdskid))
     vas_subr.executecommand("tgtadm --lld iscsi --op bind --mode=target --tid=%d --initiator-address=ALL" % (tid))
Example #14
0
 def delTarget(self, tid):
     vas_subr.executecommand("ietadm --op delete --tid=%d" % (tid))
Example #15
0
 def newLogicalUnit(self, pdskid, tid, path):
     vas_subr.executecommand("ietadm --op new --tid=%d --lun=1 --params Path=%s,ScsiId=%08x,ScsiSN=%08x,%s" % (tid, path, pdskid, pdskid, IETADM_PARAMS_LUN))
Example #16
0
 def newTarget(self, tid, iqn, pdskid):
     vas_subr.executecommand("ietadm --op new --tid=%d --params Name=%s:%08x" % (tid, iqn, pdskid))
     vas_subr.executecommand("ietadm --op update --tid=%d --params=%s" % (tid, IETADM_PARAMS_TID))