From ae173f41b3d81e69fb22369c5a7bf046ce8e029f Mon Sep 17 00:00:00 2001 From: Midun Kumar Date: Fri, 14 Nov 2014 21:26:13 +0530 Subject: [PATCH] CiscoFCSanLookupService passing command as string The command to fetch the fcns database was passed as a string in the class CiscoFCSanLookupService (FCSanLookupService). I has to be passed as list. Updated the test_cisco_fc_san_lookup_service.py file with the unit test for this change. Closes-Bug: 1385980 Change-Id: Ia35662190047450d054b1831aa1c530ca4656101 --- .../test_cisco_fc_san_lookup_service.py | 16 ++++++++++++++++ .../drivers/cisco/cisco_fc_san_lookup_service.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cinder/tests/zonemanager/test_cisco_fc_san_lookup_service.py b/cinder/tests/zonemanager/test_cisco_fc_san_lookup_service.py index acf8146fd..fca1cdf3f 100644 --- a/cinder/tests/zonemanager/test_cisco_fc_san_lookup_service.py +++ b/cinder/tests/zonemanager/test_cisco_fc_san_lookup_service.py @@ -25,6 +25,7 @@ from cinder import test from cinder.volume import configuration as conf import cinder.zonemanager.drivers.cisco.cisco_fc_san_lookup_service \ as cisco_lookup +import cinder.zonemanager.drivers.cisco.fc_zone_constants as ZoneConstant from cinder.zonemanager.utils import get_formatted_wwn nsshow = '20:1a:00:05:1e:e8:e3:29' @@ -54,6 +55,7 @@ class TestCiscoFCSanLookupService(cisco_lookup.CiscoFCSanLookupService, 'fc-zone-manager') self.configuration.fc_fabric_names = 'CISCO_FAB_2' self.create_configuration() + self.fabric_vsan = '304' # override some of the functions def __init__(self, *args, **kwargs): @@ -112,6 +114,17 @@ class TestCiscoFCSanLookupService(cisco_lookup.CiscoFCSanLookupService, return_wwn_list.append(get_formatted_wwn(wwn_list[0])) self.assertEqual(return_wwn_list, expected_wwn_list) + @mock.patch.object(cisco_lookup.CiscoFCSanLookupService, + '_run_ssh') + def test__get_switch_info(self, run_ssh_mock): + cmd_list = [ZoneConstant.FCNS_SHOW, self.fabric_vsan, + ' | no-more'] + nsshow_list = [nsshow] + run_ssh_mock.return_value = (Stream(nsshow), Stream()) + switch_data = self._get_switch_info(cmd_list) + self.assertEqual(switch_data, nsshow_list) + run_ssh_mock.assert_called_once_with(cmd_list, True, 1) + class Channel(object): def recv_exit_status(self): @@ -126,6 +139,9 @@ class Stream(object): def readlines(self): return self.buffer + def splitlines(self): + return self.buffer.splitlines() + def close(self): pass diff --git a/cinder/zonemanager/drivers/cisco/cisco_fc_san_lookup_service.py b/cinder/zonemanager/drivers/cisco/cisco_fc_san_lookup_service.py index a72bc9f9f..d181e0f54 100644 --- a/cinder/zonemanager/drivers/cisco/cisco_fc_san_lookup_service.py +++ b/cinder/zonemanager/drivers/cisco/cisco_fc_san_lookup_service.py @@ -177,7 +177,7 @@ class CiscoFCSanLookupService(FCSanLookupService): cli_output = None nsinfo_list = [] try: - cmd = ZoneConstant.FCNS_SHOW + fabric_vsan + ' | no-more' + cmd = ([ZoneConstant.FCNS_SHOW, fabric_vsan, ' | no-more']) cli_output = self._get_switch_info(cmd) except exception.FCSanLookupServiceException: with excutils.save_and_reraise_exception(): -- 2.45.2