def setUp(self): super(ISCSIConnectorTestCase, self).setUp() self.connector = connector.ISCSIConnector(None, execute=self.fake_execute, use_multipath=False) self.connector_with_multipath = connector.ISCSIConnector( None, execute=self.fake_execute, use_multipath=True) self.stubs.Set(self.connector._linuxscsi, 'get_name_from_path', lambda x: "/dev/sdb")
def test_connect_volume_with_multipath(self): location = '10.0.2.15:3260' name = 'volume-00000001' iqn = 'iqn.2010-10.org.openstack:%s' % name vol = {'id': 1, 'name': name} connection_properties = self.iscsi_connection(vol, location, iqn) self.connector_with_multipath =\ connector.ISCSIConnector(None, use_multipath=True) self.stubs.Set(self.connector_with_multipath, '_run_iscsiadm_bare', lambda *args, **kwargs: "%s %s" % (location, iqn)) self.stubs.Set(self.connector_with_multipath, '_get_target_portals_from_iscsiadm_output', lambda x: [[location, iqn]]) self.stubs.Set(self.connector_with_multipath, '_connect_to_iscsi_portal', lambda x: None) self.stubs.Set(self.connector_with_multipath, '_rescan_iscsi', lambda: None) self.stubs.Set(self.connector_with_multipath, '_rescan_multipath', lambda: None) self.stubs.Set(self.connector_with_multipath, '_get_multipath_device_name', lambda x: 'iqn.2010-10.org.openstack:%s' % name) self.stubs.Set(os.path, 'exists', lambda x: True) result = self.connector_with_multipath.connect_volume( connection_properties['data']) expected_result = {'path': 'iqn.2010-10.org.openstack:volume-00000001', 'type': 'block'} self.assertEqual(result, expected_result)
def test_brick_get_connector(self): root_helper = utils.get_root_helper() self.mox.StubOutClassWithMocks(connector, 'ISCSIConnector') connector.ISCSIConnector(execute=putils.execute, driver=None, root_helper=root_helper, use_multipath=False) self.mox.StubOutClassWithMocks(connector, 'FibreChannelConnector') connector.FibreChannelConnector(execute=putils.execute, driver=None, root_helper=root_helper, use_multipath=False) self.mox.StubOutClassWithMocks(connector, 'AoEConnector') connector.AoEConnector(execute=putils.execute, driver=None, root_helper=root_helper) self.mox.ReplayAll() utils.brick_get_connector('iscsi') utils.brick_get_connector('fibre_channel') utils.brick_get_connector('aoe') self.mox.VerifyAll()