Nir Soffer has uploaded a new change for review. Change subject: iscsicred: Use local iscsi credentials database ......................................................................
iscsicred: Use local iscsi credentials database When discovering send targets or logging in to targets, use the local iscsi credentials database. Change-Id: I065619f31fbefeb5b96bc86ed9da81ce17c1c47d Signed-off-by: Nir Soffer <[email protected]> --- M vdsm/storage/hsm.py 1 file changed, 24 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/43258/1 diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py index 1b9de05..a236b23 100644 --- a/vdsm/storage/hsm.py +++ b/vdsm/storage/hsm.py @@ -57,6 +57,7 @@ import image import volume import iscsi +import iscsicred import misc from misc import deprecated import taskManager @@ -234,17 +235,34 @@ conDict.get('initiatorName', None), conDict.get('netIfaceName', None)) - cred = None - username = conDict.get('user', None) - password = conDict.get('password', None) - if username or password: - cred = iscsi.ChapCredentials(username, password) + cred = _iscsi_chap_credentials(conDict) params = storageServer.IscsiConnectionParameters(target, iface, cred) else: raise se.StorageServerActionError() return storageServer.ConnectionInfo(typeName, params) + + +def _iscsi_chap_credentials(con): + """ + Return iscsi.ChapCredentials from local credentials database of from + connection info. + + TODO: prefer more specific credentials over less specific: + iqn > ip:port > host > engine. + """ + try: + credentials = iscsicred.get_credentials('host') + return iscsi.ChapCredentials(credentials['username'], + credentials['password']) + except iscsicred.NotFound: + username = con.get('user') + if username: + password = con.get('password') + return iscsi.ChapCredentials(username, password) + + return None class HSM(object): @@ -3028,16 +3046,10 @@ """ ip = con['connection'] port = int(con['port']) - username = con['user'] - password = con['password'] - if username == "": - username = password = None iface = iscsi.IscsiInterface("default") portal = iscsi.IscsiPortal(ip, port) - cred = None - if username or password: - cred = iscsi.ChapCredentials(username, password) + cred = _iscsi_chap_credentials(con) try: targets = iscsi.discoverSendTargets(iface, portal, cred) -- To view, visit https://gerrit.ovirt.org/43258 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I065619f31fbefeb5b96bc86ed9da81ce17c1c47d Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
