Coverage for drivers/mpathcount : 60%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/python
# Copyright (C) Citrix Systems Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation; version 2.1 only. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
global cached_DM_maj if not cached_DM_maj: try: line = filter(lambda x: x.endswith('device-mapper\n'), open('/proc/devices').readlines()) cached_DM_maj = int(line[0].split()[0]) except: pass return cached_DM_maj
if session is not None: try: session.xenapi.logout() except: pass sys.exit(code)
regex = re.compile("^INSTALLATION_UUID") return regex.search(s, 0)
filename = '/etc/xensource-inventory' try: f = open(filename, 'r') except: raise xs_errors.XenError('EIO', \ opterr="Unable to open inventory file [%s]" % filename) domid = '' for line in filter(match_host_id, f.readlines()): domid = line.split("'")[1] return domid
return str(l)
# @key: key to update # @SCSIid: SCSI id of multipath map # @entry: string representing previous value # @remove: callback to remove key # @add: callback to add key/value pair
else:
else: if util._isSCSIid(key): SCSIidlist.append(re.sub("^scsi-", "", key))
# Ensure output headers are not in the list # first map will always correspond to the root dev, dm-0 " Host.other-config:mpath-boot " % i) else:
continue util.SMlog("Matched SCSIid, updating entry %s" % str(mpp_entry)) update_config(key, i, mpp_entry, remove, add, mpp_path_update) else: else:
if len(sys.argv) == 3: match_bySCSIid = True SCSIid = sys.argv[1] mpp_path_update = True mpp_entry = sys.argv[2]
cached_DM_maj = None
try: session = util.get_localAPI_session() except: print("Unable to open local XAPI session") sys.exit(-1)
localhost = session.xenapi.host.get_by_uuid(get_localhost_uuid()) # Check whether multipathing is enabled (either for root dev or SRs) try: if get_root_dev_major() != get_dm_major(): hconf = session.xenapi.host.get_other_config(localhost) assert(hconf['multipathing'] == 'true') mpath_enabled = True except: mpath_enabled = False
# Check root disk if multipathed try: def _remove(key): session.xenapi.host.remove_from_other_config(localhost, key)
def _add(key, val): session.xenapi.host.add_to_other_config(localhost, key, val) config = session.xenapi.host.get_other_config(localhost) maps = mpath_cli.list_maps() check_root_disk(config, maps, _remove, _add)
except: util.SMlog("MPATH: Failure updating Host.other-config:mpath-boot db") mpc_exit(session, -1)
try: pbds = session.xenapi.PBD.get_all_records_where("field \"host\" = \"%s\"" % localhost) except: mpc_exit(session, -1)
try: for pbd in pbds: def remove(key): session.xenapi.PBD.remove_from_other_config(pbd, key)
def add(key, val): session.xenapi.PBD.add_to_other_config(pbd, key, val) record = pbds[pbd] config = record['other_config'] SR = record['SR'] srtype = session.xenapi.SR.get_type(SR) if srtype in supported: devconfig = record["device_config"] sm_config = session.xenapi.SR.get_sm_config(SR) check_devconfig(devconfig, sm_config, config, remove, add) except: util.SMlog("MPATH: Failure updating db. %s" % sys.exc_info()) mpc_exit(session, -1)
util.SMlog("MPATH: Update done")
mpc_exit(session, 0) |