]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
CiscoFCSanLookupService passing command as string
authorMidun Kumar <mneelame@cisco.com>
Fri, 14 Nov 2014 15:56:13 +0000 (21:26 +0530)
committerMidun Kumar <mneelame@cisco.com>
Sun, 16 Nov 2014 18:37:32 +0000 (00:07 +0530)
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

cinder/tests/zonemanager/test_cisco_fc_san_lookup_service.py
cinder/zonemanager/drivers/cisco/cisco_fc_san_lookup_service.py

index acf8146fd18ca14542e395c8c46f178b7727ee82..fca1cdf3f1263a779eeb1dd726953ee7c1b2e356 100644 (file)
@@ -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
 
index a72bc9f9f95d5bc416106b3118db10911d108327..d181e0f548582884bc8193c7da20404f921ce18d 100644 (file)
@@ -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():