Skip to content

Commit

Permalink
Merge 362856d into 45c4009
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSymsCtx committed May 26, 2020
2 parents 45c4009 + 362856d commit faa69af
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 124 deletions.
2 changes: 1 addition & 1 deletion base_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mock
mock==1.0.1
xenapi
coverage
astroid==1.4.9
Expand Down
4 changes: 2 additions & 2 deletions drivers/BaseISCSI.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def detach(self, sr_uuid, delete=False):
except:
pass
if self.dconf.has_key('SCSIid'):
self.mpathmodule.reset(self.dconf['SCSIid'], True) # explicitly unmap
self.mpathmodule.reset(self.dconf['SCSIid'], explicit_unmap=True)
keys.append("mpath-" + self.dconf['SCSIid'])

# Remove iscsi_sessions and multipathed keys
Expand Down Expand Up @@ -598,7 +598,7 @@ def _detach_LUN_bylunid(self, lunid, SCSIid):
if not self.attached:
raise xs_errors.XenError('SRUnavailable')
if self.mpath == 'true' and len(SCSIid):
self.mpathmodule.reset(SCSIid, True)
self.mpathmodule.reset(SCSIid, explicit_unmap=True)
util.remove_mpathcount_field(self.session, self.host_ref, self.sr_ref, SCSIid)
for val in self.adapter:
if not self.pathdict.has_key(val):
Expand Down
10 changes: 5 additions & 5 deletions drivers/LVHDoHBASR.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def create(self, sr_uuid, size):
LVHDSR.LVHDSR.create(self, sr_uuid, size)
finally:
if self.mpath == "true":
self.mpathmodule.reset(self.SCSIid, True) # explicit unmap
self.mpathmodule.reset(self.SCSIid, explicit_unmap=True)
util.remove_mpathcount_field(self.session, self.host_ref, \
self.sr_ref, self.SCSIid)

Expand Down Expand Up @@ -167,16 +167,16 @@ def probe(self):
self._pathrefresh(LVHDoHBASR)
result = LVHDSR.LVHDSR.probe(self)
if self.mpath == "true":
self.mpathmodule.reset(self.SCSIid,True)
self.mpathmodule.reset(self.SCSIid, explicit_unmap=True)
return result
except:
if self.mpath == "true":
self.mpathmodule.reset(self.SCSIid,True)
self.mpathmodule.reset(self.SCSIid, explicit_unmap=True)
raise

def detach(self, sr_uuid):
LVHDSR.LVHDSR.detach(self, sr_uuid)
self.mpathmodule.reset(self.SCSIid,True,True) # explicit_unmap
self.mpathmodule.reset(self.SCSIid, explicit_unmap=True)
try:
pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
except:
Expand All @@ -192,7 +192,7 @@ def delete(self, sr_uuid):
LVHDSR.LVHDSR.delete(self, sr_uuid)
finally:
if self.mpath == "true":
self.mpathmodule.reset(self.SCSIid, True) # explicit unmap
self.mpathmodule.reset(self.SCSIid, explicit_unmap=True)

def vdi(self, uuid):
return LVHDoHBAVDI(self, uuid)
Expand Down
3 changes: 1 addition & 2 deletions drivers/RawHBASR.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ def detach(self, sr_uuid, vdi_uuid):

# Multipath disable
if self.sr.mpath == "true":
#devices = scsiutil._genReverseSCSIidmap(scsi_id)
self.sr.mpathmodule.reset(scsi_id, True)
self.sr.mpathmodule.reset(scsi_id, explicit_unmap=True)
util.remove_mpathcount_field(self.sr.session, self.sr.host_ref,
self.sr.sr_ref, scsi_id)

Expand Down
10 changes: 2 additions & 8 deletions drivers/iscsilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,7 @@ def is_iscsi_daemon_running():

def stop_daemon():
if is_iscsi_daemon_running():
if os.path.exists("/etc/init.d/open-iscsi"):
cmd = ["/etc/init.d/open-iscsi", "stop"]
else:
cmd = ["service", "iscsid", "stop"]
cmd = ["service", "iscsid", "stop"]
failuremessage = "Failed to stop iscsi daemon"
exn_on_failure(cmd,failuremessage)

Expand All @@ -383,10 +380,7 @@ def restart_daemon():
shutil.rmtree(os.path.join(_ISCSI_DB_PATH, 'send_targets'))
except:
pass
if os.path.exists("/etc/init.d/open-iscsi"):
cmd = ["/etc/init.d/open-iscsi", "start"]
else:
cmd = ["service", "iscsid", "start"]
cmd = ["service", "iscsid", "start"]
failuremessage = "Failed to start iscsi daemon"
exn_on_failure(cmd,failuremessage)

Expand Down
2 changes: 1 addition & 1 deletion drivers/mpath_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def list_maps():
util.SMlog("mpath cmd: %s" % cmd)
(rc,stdout,stderr) = util.doexec(mpathcmd,cmd)
util.SMlog("mpath output: %s" % stdout)
return map(lambda x: x.split(' ')[0], stdout.split('\n')[1:-1])
return map(lambda x: x.split(' ')[0], stdout.split('\n')[2:-1])

def ensure_map_gone(scsi_id):
while True:
Expand Down
101 changes: 3 additions & 98 deletions drivers/mpath_dmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
import wwid_conf
import errno

iscsi_mpath_file = "/etc/iscsi/iscsid-mpath.conf"
iscsi_default_file = "/etc/iscsi/iscsid-default.conf"
iscsi_file = "/etc/iscsi/iscsid.conf"

DMPBIN = "/sbin/multipath"
DEVMAPPERPATH = "/dev/mapper"
DEVBYIDPATH = "/dev/disk/by-id"
Expand Down Expand Up @@ -62,20 +58,11 @@ def deactivate_MPdev(sid):
if os.path.exists(path):
os.unlink(path)

def reset(sid,explicit_unmap=False,delete_nodes=False):
def reset(sid,explicit_unmap=False):
util.SMlog("Resetting LUN %s" % sid)
_resetDMP(sid,explicit_unmap,delete_nodes)
_resetDMP(sid,explicit_unmap)

def _delete_node(dev):
try:
path = '/sys/block/' + dev + '/device/delete'
f = os.open(path, os.O_WRONLY)
os.write(f,'1')
os.close(f)
except:
util.SMlog("Failed to delete %s" % dev)

def _resetDMP(sid,explicit_unmap=False,delete_nodes=False):
def _resetDMP(sid, explicit_unmap=False):
# If mpath has been turned on since the sr/vdi was attached, we
# might be trying to unmap it before the daemon has been started
# This is unnecessary (and will fail) so just return.
Expand Down Expand Up @@ -103,68 +90,6 @@ def _resetDMP(sid,explicit_unmap=False,delete_nodes=False):
else:
util.SMlog("MPATH: path disappeared [%s]" % path)

# expecting e.g. ["/dev/sda","/dev/sdb"] or ["/dev/disk/by-scsibus/...whatever" (links to the real devices)]
def __map_explicit(devices):
for device in devices:
realpath = os.path.realpath(device)
base = os.path.basename(realpath)
util.SMlog("Adding mpath path '%s'" % base)
try:
mpath_cli.add_path(base)
except:
util.SMlog("WARNING: exception raised while attempting to add path %s" % base)

def map_by_scsibus(sid,npaths=0):
# Synchronously creates/refreshs the MP map for a single SCSIid.
# Gathers the device vector from /dev/disk/by-scsibus - we expect
# there to be 'npaths' paths

util.SMlog("map_by_scsibus: sid=%s" % sid)

devices = []

# Wait for up to 60 seconds for n devices to appear
for attempt in range(0,60):
devices = scsiutil._genReverseSCSIidmap(sid)

# If we've got the right number of paths, or we don't know
# how many devices there ought to be, tell multipathd about
# the paths, and return.
if(len(devices)>=npaths or npaths==0):
# Enable this device's sid: it could be blacklisted
# We expect devices to be blacklisted according to their
# wwid only. We go through the list of paths until we have
# a definite answer about the device's blacklist status.
# If the path we are checking is down, we cannot tell.
for dev in devices:
try:
if wwid_conf.is_blacklisted(dev):
try:
wwid_conf.edit_wwid(sid)
except:
util.SMlog("WARNING: exception raised while "
"attempting to modify multipath.conf")
try:
mpath_cli.reconfigure()
except:
util.SMlog("WARNING: exception raised while "
"attempting to reconfigure")
time.sleep(5)

break
except wwid_conf.WWIDException as e:
util.SMlog(e.errstr)
else:
util.SMlog("Device 'SCSI_id: {}' is inaccessible; "
"All paths are down.".format(sid))

__map_explicit(devices)
return

time.sleep(1)

__map_explicit(devices)

def refresh(sid,npaths):
# Refresh the multipath status
util.SMlog("Refreshing LUN %s" % sid)
Expand Down Expand Up @@ -252,14 +177,6 @@ def _refresh_DMP(sid, npaths):

def activate():
util.SMlog("MPATH: multipath activate called")
cmd = ['ln', '-sf', iscsi_mpath_file, iscsi_file]
try:
if os.path.exists(iscsi_mpath_file):
# Only do this if using our customized open-iscsi package
util.pread2(cmd)
except util.CommandException, ce:
if not ce.reason.endswith(': File exists'):
raise

# If we've got no active sessions, and the deamon is already running,
# we're ok to restart the daemon
Expand All @@ -283,10 +200,6 @@ def activate():

def deactivate():
util.SMlog("MPATH: multipath deactivate called")
cmd = ['ln', '-sf', iscsi_default_file, iscsi_file]
if os.path.exists(iscsi_default_file):
# Only do this if using our customized open-iscsi package
util.pread2(cmd)

if _is_mpath_daemon_running():
# Flush the multipath nodes
Expand Down Expand Up @@ -315,11 +228,3 @@ def path(SCSIid):
return path
else:
return DEVBYIDPATH + "/scsi-" + SCSIid

def status(SCSIid):
pass

def get_TargetID_LunNUM(SCSIid):
devices = scsiutil._genReverseSCSIidmap(SCSIid)
cmd = [MPPGETAIDLNOBIN, devices[0]]
return util.pread2(cmd).split('\n')[0]
5 changes: 1 addition & 4 deletions drivers/mpath_null.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def refresh(sid,npaths):
return

def reset(sid,explicit_unmap=False,delete_nodes=False):
def reset(sid,explicit_unmap=False):
return

def activate():
Expand All @@ -31,6 +31,3 @@ def deactivate():

def path(SCSIid):
return DEVBYIDPATH + "/scsi-" + SCSIid

def status(SCSIid):
pass
Loading

0 comments on commit faa69af

Please sign in to comment.