本文整理汇总了Python中mpp_luncheck.is_RdacLun函数的典型用法代码示例。如果您正苦于以下问题:Python is_RdacLun函数的具体用法?Python is_RdacLun怎么用?Python is_RdacLun使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_RdacLun函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: probe
def probe(self):
if self.mpath == "true" and self.dconf.has_key('SCSIid'):
# When multipathing is enabled, since we don't refcount the multipath maps,
# we should not attempt to do the iscsi.attach/detach when the map is already present,
# as this will remove it (which may well be in use).
maps = []
try:
maps = mpath_cli.list_maps()
except:
pass
if self.dconf['SCSIid'] in maps:
if (mpp_luncheck.is_RdacLun(self.dconf['SCSIid'])):
mpath_cli.remove_map(self.dconf['SCSIid'])
else:
raise xs_errors.XenError('SRInUse')
else:
if (mpp_luncheck.is_RdacLun(self.dconf['SCSIid'])):
link=glob.glob('/dev/disk/mpInuse/%s-*' % self.dconf['SCSIid'])
if (len(link)):
raise xs_errors.XenError('SRInUse')
self.mpathmodule.refresh(self.SCSIid,0)
try:
self._pathrefresh(LVHDoHBASR)
result = LVHDSR.LVHDSR.probe(self)
if self.mpath == "true":
self.mpathmodule.reset(self.SCSIid,True)
return result
except:
if self.mpath == "true":
self.mpathmodule.reset(self.SCSIid,True)
raise
示例2: probe
def probe(self):
self.uuid = util.gen_uuid()
# When multipathing is enabled, since we don't refcount the multipath maps,
# we should not attempt to do the iscsi.attach/detach when the map is already present,
# as this will remove it (which may well be in use).
if self.mpath == 'true' and self.dconf.has_key('SCSIid'):
maps = []
mpp_lun = False
try:
if (mpp_luncheck.is_RdacLun(self.dconf['SCSIid'])):
mpp_lun = True
link=glob.glob('/dev/disk/mpInuse/%s-*' % self.dconf['SCSIid'])
else:
maps = mpath_cli.list_maps()
except:
pass
if (mpp_lun):
if (len(link)):
raise xs_errors.XenError('SRInUse')
else:
if self.dconf['SCSIid'] in maps:
raise xs_errors.XenError('SRInUse')
self.iscsi.attach(self.uuid)
if not self.iscsi._attach_LUN_bySCSIid(self.SCSIid):
util.SMlog("Unable to detect LUN")
raise xs_errors.XenError('InvalidDev')
self._pathrefresh(LVHDoISCSISR)
out = LVHDSR.LVHDSR.probe(self)
self.iscsi.detach(self.uuid)
return out
示例3: deactivate_MPdev
def deactivate_MPdev(sid):
if (mpp_luncheck.is_RdacLun(sid)):
pathlist = glob.glob('/dev/disk/mpInuse/%s-*' % sid)
path = pathlist[0]
else:
path = os.path.join(MP_INUSEDIR, sid)
if os.path.exists(path):
os.unlink(path)
示例4: _LUNprint
def _LUNprint(self, sr_uuid):
if self.iscsi.attached:
# Force a rescan on the bus.
self.iscsi.refresh()
# time.sleep(5)
# Now call attach (handles the refcounting + session activa)
self.iscsi.attach(sr_uuid)
util.SMlog("LUNprint: waiting for path: %s" % self.iscsi.path)
if util.wait_for_path("%s/LUN*" % self.iscsi.path, ISCSISR.MAX_TIMEOUT):
try:
adapter=self.iscsi.adapter[self.iscsi.address]
util.SMlog("adapter=%s" % adapter)
# find a scsi device on which to issue a report luns command:
devs=glob.glob("%s/LUN*" % self.iscsi.path)
sgdevs = []
for i in devs:
sgdevs.append(int(i.split("LUN")[1]))
sgdevs.sort()
sgdev = "%s/LUN%d" % (self.iscsi.path,sgdevs[0])
# issue a report luns:
luns=util.pread2(["/usr/bin/sg_luns","-q",sgdev]).split('\n')
nluns=len(luns)-1 # remove the line relating to the final \n
# check if the LUNs are MPP-RDAC Luns
scsi_id = scsiutil.getSCSIid(sgdev)
mpp_lun = False
if (mpp_luncheck.is_RdacLun(scsi_id)):
mpp_lun = True
link=glob.glob('/dev/disk/by-scsibus/%s-*' % scsi_id)
mpp_adapter = link[0].split('/')[-1].split('-')[-1].split(':')[0]
# make sure we've got that many sg devices present
for i in range(0,30):
luns=scsiutil._dosgscan()
sgdevs=filter(lambda r: r[1]==adapter, luns)
if mpp_lun:
sgdevs.extend(filter(lambda r: r[1]==mpp_adapter, luns))
if len(sgdevs)>=nluns:
util.SMlog("Got all %d sg devices" % nluns)
break
else:
util.SMlog("Got %d sg devices - expecting %d" % (len(sgdevs),nluns))
time.sleep(1)
if os.path.exists("/sbin/udevsettle"):
util.pread2(["/sbin/udevsettle"])
else:
util.pread2(["/sbin/udevadm","settle"])
except:
util.SMlog("Generic exception caught. Pass")
pass # Make sure we don't break the probe...
self.iscsi.print_LUNs()
self.iscsi.detach(sr_uuid)
示例5: activate_MPdev
def activate_MPdev(sid, dst):
if not os.path.exists(MP_INUSEDIR):
os.mkdir(MP_INUSEDIR)
if (mpp_luncheck.is_RdacLun(sid)):
suffix = get_TargetID_LunNUM(sid)
sid_with_suffix = sid + "-" + suffix
path = os.path.join(MP_INUSEDIR, sid_with_suffix)
else:
path = os.path.join(MP_INUSEDIR, sid)
cmd = ['ln', '-sf', dst, path]
util.pread2(cmd)
示例6: get_path_count
def get_path_count(SCSIid, active=True):
count = 0
if mpp_luncheck.is_RdacLun(SCSIid):
(total_count, active_count) = mpp_mpathutil.get_pathinfo(SCSIid)
return (total_count, active_count)
lines = mpath_cli.get_topology(SCSIid)
for line in filter(match_dmpLUN, lines):
if not active:
count += 1
elif match_pathup(line):
count += 1
return count
示例7: path
def path(SCSIid):
if _is_mpath_daemon_running():
if (mpp_luncheck.is_RdacLun(SCSIid)):
pathlist = glob.glob('/dev/disk/mpInuse/%s-*' % SCSIid)
util.SMlog("pathlist is:")
util.SMlog(pathlist)
if len(pathlist):
path = pathlist[0]
else:
path = os.path.join(MP_INUSEDIR, SCSIid)
else:
path = os.path.join(MP_INUSEDIR, SCSIid)
return path
else:
return DEVBYIDPATH + "/scsi-" + SCSIid
示例8: refresh
def refresh(sid,npaths):
# Refresh the multipath status
util.SMlog("Refreshing LUN %s" % sid)
if len(sid):
path = DEVBYIDPATH + "/scsi-" + sid
if not os.path.exists(path):
scsiutil.rescan(scsiutil._genHostList(""))
if not util.wait_for_path(path,60):
raise xs_errors.XenError('Device not appeared yet')
if not (mpp_luncheck.is_RdacLun(sid)):
_refresh_DMP(sid,npaths)
else:
_refresh_MPP(sid,npaths)
else:
raise xs_errors.XenError('MPath not written yet')
示例9: update_config
def update_config(key, SCSIid, entry, remove, add, mpp_path_update=False):
if mpp_path_update:
remove("multipathed")
remove(key)
remove("MPPEnabled")
add("MPPEnabled", "true")
add("multipathed", "true")
add(key, str(entry))
return
rdaclun = False
if mpp_luncheck.is_RdacLun(SCSIid):
rdaclun = True
pathlist = glob.glob("/dev/disk/mpInuse/%s-*" % SCSIid)
path = pathlist[0]
else:
path = MP_INUSEDIR + "/" + SCSIid
util.SMlog("MPATH: Updating entry for [%s], current: %s" % (SCSIid, entry))
if os.path.exists(path):
if rdaclun:
(total, count) = get_path_count(SCSIid)
else:
count = get_path_count(SCSIid)
total = get_path_count(SCSIid, active=False)
max = 0
if len(entry) != 0:
try:
p = entry.strip("[")
p = p.strip("]")
q = p.split(",")
max = int(q[1])
except:
pass
if total > max:
max = total
newentry = [count, max]
if str(newentry) != entry:
remove("multipathed")
remove(key)
if rdaclun:
remove("MPPEnabled")
add("MPPEnabled", "true")
add("multipathed", "true")
add(key, str(newentry))
util.SMlog("MPATH: \tSet val: %s" % str(newentry))
示例10: refresh
def refresh(sid,npaths):
# Fix udev bug (?): make sure it updates /dev/disk/by-id
# Trigger the old way, if possible
if os.path.exists("/sbin/udevtrigger"):
util.pread2(["/sbin/udevtrigger"])
else:
util.pread2(["/sbin/udevadm","trigger"])
# Refresh the multipath status
util.SMlog("Refreshing LUN %s" % sid)
if len(sid):
path = DEVBYIDPATH + "/scsi-" + sid
if not os.path.exists(path):
scsiutil.rescan(scsiutil._genHostList(""))
if not util.wait_for_path(path,60):
raise xs_errors.XenError('Device not appeared yet')
if not (mpp_luncheck.is_RdacLun(sid)):
_refresh_DMP(sid,npaths)
else:
_refresh_MPP(sid,npaths)
else:
raise xs_errors.XenError('MPath not written yet')
示例11: reset
def reset(sid,explicit_unmap=False,delete_nodes=False):
util.SMlog("Resetting LUN %s" % sid)
if (mpp_luncheck.is_RdacLun(sid)):
_resetMPP(sid,explicit_unmap)
else:
_resetDMP(sid,explicit_unmap,delete_nodes)
示例12: UpdatePaths
def UpdatePaths():
while True:
try:
session = None
# Garbage collect any memory allocated in the last run of the loop
DEBUG("The garbage collection routine returned: %d" % gc.collect())
# Sleep for some time before checking the status again
time.sleep(MPP_PATH_STATUS_UPDATE_INTERVAL)
# List the contents of the directory /dev/disk/mpInuse
fileList = glob.glob(MPP_DEVICES_IN_USE_LOCATION + "/" + "*")
if not len(fileList):
continue
# for each SCSI ID get the cached values of the total paths and active paths
# and then compare this with the current path status obtained using mpp_mpathutil.py
for filename in fileList:
# extract the SCSI ID from the file name.
scsiid = filename.rsplit("/")[len(filename.rsplit("/")) - 1].split("-")[0]
if not (mpp_luncheck.is_RdacLun(scsiid)):
continue
# Get the cached value for the total and active paths for this SCSI ID
try:
cacheFile = glob.glob(MPP_PATH_CACHE_LOCATION + "/" + scsiid + "*")
if len(cacheFile) > 1:
DEBUG("More than one cache file found for SCSI ID %s. Please check the cache manually.")
raise Exception
# This will return only one file name of the form SCSIID:TOTALPATHS:ACTIVEPATHS, so parse accordingly
cachedTotalPaths = cacheFile[0].split(":")[1]
cachedActivePaths = cacheFile[0].split(":")[2]
cacheFileFound = True
except:
DEBUG("There was an exception getting the cached path status for SCSI ID %s, assuming 0s." % scsiid)
cachedTotalPaths = 0
cachedActivePaths = 0
cacheFileFound = False
(totalPaths, activePaths) = mpp_mpathutil.get_pathinfo(scsiid)
DEBUG(
"For SCSI ID %s, cached TotalPaths: %s, cached ActivePaths: %s, New Totalpaths: %s New ActivePaths: %s"
% (scsiid, cachedTotalPaths, cachedActivePaths, totalPaths, activePaths)
)
if cachedTotalPaths != str(totalPaths) or cachedActivePaths != str(activePaths):
DEBUG("Some path status has changed for SCSI ID %s, updating PBD." % scsiid)
entry = "[" + str(activePaths) + ", " + str(totalPaths) + "]"
DEBUG(entry)
cmd = ["/opt/xensource/sm/mpathcount.py", scsiid, entry]
util.pread2(cmd)
# Now update the cache with this updated path status
DEBUG("Checking if cache file was found.")
if cacheFileFound == True:
DEBUG("Cache file was found, delete it.")
os.remove(cacheFile[0])
cacheFileName = (
MPP_PATH_CACHE_LOCATION + "/" + scsiid + ":" + str(totalPaths) + ":" + str(activePaths)
)
DEBUG("Generated new cache file name %s" % cacheFileName)
open(cacheFileName, "w").close()
except:
pass
# DEBUG("There was some exception while updating path status for the SCSI ID %s." % scsiid )
# break
if session != None:
session.xenapi.session.logout()
return