Skip to content

Commit cbf65f4

Browse files
author
Deli Zhang
authored
Merge pull request #87 from DeliZhangX/private/deliz/CA-331398
Private/deliz/ca 331398
2 parents 28e7894 + 7fc5b8b commit cbf65f4

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/XenCert/StorageHandler.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from xml.dom import minidom
2626
import StorageHandlerUtil
2727
from XenCertLog import Print, PrintOnSameLine, XenCertPrint
28-
from XenCertCommon import displayOperationStatus, getConfigWithHiddenPassword
28+
from XenCertCommon import displayOperationStatus, getConfigWithHiddenPassword, hidePathInfoPassword
2929
import scsiutil
3030
import iscsilib
3131
import util
@@ -665,7 +665,8 @@ def BlockUnblockPaths(self, blockOrUnblock, script, noOfPaths, passthrough):
665665

666666
(rc, stdout, stderr) = util.doexec(cmd,'')
667667

668-
XenCertPrint("The path block/unblock utility returned rc: %s stdout: '%s', stderr: '%s'" % (rc, stdout, stderr))
668+
stdoutPrint = hidePathInfoPassword(stdout) if self.storage_conf['storage_type'] == 'hba' else stdout
669+
XenCertPrint("The path block/unblock utility returned rc: %s stdout: '%s', stderr: '%s'" % (rc, stdoutPrint, stderr))
669670
if rc != 0:
670671
raise Exception(" - The path block/unblock utility returned an error: %s." % stderr)
671672
return stdout
@@ -2579,7 +2580,7 @@ def RandomlyFailPaths(self):
25792580
XenCertPrint("No of paths which should fail is %s out of total %s" % \
25802581
(self.noOfPaths, self.noOfTotalPaths))
25812582
self.blockedpathinfo = scriptReturn.split('::')[0]
2582-
PrintOnSameLine(" -> Blocking paths (%s)\n" % self.blockedpathinfo)
2583+
PrintOnSameLine(" -> Blocking paths (%s)\n" % hidePathInfoPassword(self.blockedpathinfo))
25832584
return True
25842585
except Exception, e:
25852586
raise e
@@ -3395,6 +3396,9 @@ def __init__(self, base_handler):
33953396
if self.device_config['provider'] == 'iscsi':
33963397
self.device_config['target'] = storage_conf['target']
33973398
self.device_config['targetIQN'] = storage_conf['targetIQN']
3399+
if storage_conf['chapuser'] is not None and storage_conf['chappasswd'] is not None:
3400+
self.device_config['chapuser'] = storage_conf['chapuser']
3401+
self.device_config['chappassword'] = storage_conf['chappasswd']
33983402

33993403
super(StorageHandlerGFS2, self).__init__(storage_conf)
34003404

@@ -3413,15 +3417,19 @@ def Create(self):
34133417

34143418
device_config = copy.deepcopy(self.device_config)
34153419

3420+
if 'targetIQN' in device_config and len(device_config['targetIQN'].split(',')) > 1:
3421+
device_config['targetIQN'] = '*'
3422+
34163423
Print(" Creating the SR.")
34173424
# try to create an SR with one of the LUNs mapped, if all fails
34183425
# throw an exception
34193426
for scsiId in listSCSIId:
34203427
try:
34213428
device_config['SCSIid'] = scsiId
3429+
device_config_tmp = getConfigWithHiddenPassword(device_config, self.storage_conf['storage_type'])
34223430
XenCertPrint("The SR create parameters are {}, {}".format(
34233431
util.get_localhost_uuid(self.session),
3424-
device_config))
3432+
device_config_tmp))
34253433

34263434
sr_ref = self.session.xenapi.SR.create(
34273435
util.get_localhost_uuid(self.session),
@@ -3437,7 +3445,7 @@ def Create(self):
34373445

34383446
XenCertPrint(
34393447
"Created the SR {} using device_config {}".format(
3440-
sr_ref, device_config))
3448+
sr_ref, device_config_tmp))
34413449
displayOperationStatus(True)
34423450
break
34433451

src/XenCert/XenCertCommon.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ def getConfigWithHiddenPassword(config, storage_type):
284284
pass
285285
return config_with_hidden_password
286286

287+
def hidePathInfoPassword(pathInfo, delimiter=':', password_index=2):
288+
infoList = pathInfo.split(delimiter)
289+
if len(infoList) > password_index:
290+
infoList[password_index] = HIDDEN_PASSWORD
291+
return delimiter.join(infoList)
292+
287293
def showReport(msg, result, checkPoints=1, totalCheckPoints=1, time=0):
288294
Print("%-50s: %s, Pass percentage: %d, Completed: %s" %
289295
(msg, TAG_PASS if result else TAG_FAIL, int((checkPoints * 100) / totalCheckPoints), time))

0 commit comments

Comments
 (0)