Ensure that lun_id is an int for NetApp Drivers
Various NetApp drivers were treating the lun_id as a string rather than an int. This was causing attempts to mount NetApp volumes to Hyper-V nodes to fail as they were checking an integer type against a unicode type which would fail. This change casts result_lun to an integer after the value has gone through the ssh injection attack check. This way Hyper-V is able to verify if the found LUN is the target LUN, enabling mounting of NetApp volumes to Hyper-V. This change also refactors initialize_connection into some helper methods so as to enable simpler unit testing of the patchset. Closes-bug: 1372808 Change-Id: I308b3b2dff315ec33451fb45a30ecd53d5d4c353
This commit is contained in:
@@ -139,6 +139,27 @@ def log_extra_spec_warnings(extra_specs):
|
||||
LOG.warning(msg % args)
|
||||
|
||||
|
||||
def get_iscsi_connection_properties(lun_id, volume, iqn,
|
||||
address, port):
|
||||
|
||||
properties = {}
|
||||
properties['target_discovered'] = False
|
||||
properties['target_portal'] = '%s:%s' % (address, port)
|
||||
properties['target_iqn'] = iqn
|
||||
properties['target_lun'] = int(lun_id)
|
||||
properties['volume_id'] = volume['id']
|
||||
auth = volume['provider_auth']
|
||||
if auth:
|
||||
(auth_method, auth_username, auth_secret) = auth.split()
|
||||
properties['auth_method'] = auth_method
|
||||
properties['auth_username'] = auth_username
|
||||
properties['auth_password'] = auth_secret
|
||||
return {
|
||||
'driver_volume_type': 'iscsi',
|
||||
'data': properties,
|
||||
}
|
||||
|
||||
|
||||
class hashabledict(dict):
|
||||
"""A hashable dictionary that is comparable (i.e. in unit tests, etc.)"""
|
||||
def __hash__(self):
|
||||
|
||||
Reference in New Issue
Block a user