From 861e93a671f4ca4a7d8b08b05055bab9b9e141f8 Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Thu, 1 May 2014 17:13:25 -0500 Subject: [PATCH] Ensure that lun_id is an int The map_vol_to_host function was treating the lun number as a string rather than an int. This was causing attempts to mount storwize_svc 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 mount of storwize_svc volumes to Hyper-V. Change-Id: I96d179f2a58e5948c8ba6c9ae618daad7b8d4c86 Closes-bug: 1269915 --- cinder/tests/test_storwize_svc.py | 6 +++--- cinder/volume/drivers/ibm/storwize_svc/helpers.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py index 39a06dfab..ea602d455 100644 --- a/cinder/tests/test_storwize_svc.py +++ b/cinder/tests/test_storwize_svc.py @@ -1931,7 +1931,7 @@ class StorwizeSVCDriverTestCase(test.TestCase): types[protocol] = volume_types.create(ctxt, protocol, opts) expected = {'FC': {'driver_volume_type': 'fibre_channel', - 'data': {'target_lun': '0', + 'data': {'target_lun': 0, 'target_wwn': 'AABBCCDDEEFF0011', 'target_discovered': False}}, 'iSCSI': {'driver_volume_type': 'iscsi', @@ -1939,7 +1939,7 @@ class StorwizeSVCDriverTestCase(test.TestCase): 'target_iqn': 'iqn.1982-01.com.ibm:1234.sim.node1', 'target_portal': '1.234.56.78:3260', - 'target_lun': '0', + 'target_lun': 0, 'auth_method': 'CHAP'}}} for protocol in ['FC', 'iSCSI']: @@ -2547,7 +2547,7 @@ class StorwizeSVCDriverTestCase(test.TestCase): {'ff00000000000000': ['AABBCCDDEEFF0011'], 'ff00000000000001': ['AABBCCDDEEFF0011']}, 'target_discovered': False, - 'target_lun': '0', + 'target_lun': 0, 'target_wwn': 'AABBCCDDEEFF0011', 'volume_id': volume['id'] } diff --git a/cinder/volume/drivers/ibm/storwize_svc/helpers.py b/cinder/volume/drivers/ibm/storwize_svc/helpers.py index 558117526..d2f6ee97f 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/helpers.py +++ b/cinder/volume/drivers/ibm/storwize_svc/helpers.py @@ -308,7 +308,7 @@ class StorwizeHelpers(object): {'result_lun': result_lun, 'volume_name': volume_name, 'host_name': host_name}) - return result_lun + return int(result_lun) def unmap_vol_from_host(self, volume_name, host_name): """Unmap the volume and delete the host if it has no more mappings.""" -- 2.45.2