def test_attach_volume_connection_error(self): instance = self._get_instance() connection_info = db_fakes.get_fake_volume_info_data( self._volume_target_portal, self._volume_id) mount_point = '/dev/sdc' def fake_login_storage_target(self, connection_info): raise vmutils.HyperVException('Fake connection exception') self.stubs.Set(volumeops.ISCSIVolumeDriver, 'login_storage_target', fake_login_storage_target) self.assertRaises(vmutils.HyperVException, self._conn.attach_volume, None, connection_info, instance, mount_point)
def _test_detach_volume(self, other_luns_available=False): instance = self._get_instance() connection_info = db_fakes.get_fake_volume_info_data( self._volume_target_portal, self._volume_id) data = connection_info['data'] target_lun = data['target_lun'] target_iqn = data['target_iqn'] self.assertIn('target_portal', data) mount_point = '/dev/sdc' self._mock_detach_volume(target_iqn, target_lun, other_luns_available) self._mox.ReplayAll() self._conn.detach_volume(connection_info, instance, mount_point) self._mox.VerifyAll()
def test_attach_volume_logout(self): instance = self._get_instance() connection_info = db_fakes.get_fake_volume_info_data( self._volume_target_portal, self._volume_id) data = connection_info['data'] target_lun = data['target_lun'] target_iqn = data['target_iqn'] target_portal = data['target_portal'] mount_point = '/dev/sdc' self._mock_attach_volume_target_logout(instance.name, target_iqn, target_lun, target_portal) self._mox.ReplayAll() self.assertRaises(vmutils.HyperVException, self._conn.attach_volume, None, connection_info, instance, mount_point) self._mox.VerifyAll()
def test_attach_volume(self): instance = self._get_instance() connection_info = db_fakes.get_fake_volume_info_data( self._volume_target_portal, self._volume_id) data = connection_info['data'] target_lun = data['target_lun'] target_iqn = data['target_iqn'] target_portal = data['target_portal'] mount_point = '/dev/sdc' self._mock_attach_volume(instance['name'], target_iqn, target_lun, target_portal) self._mox.ReplayAll() self._conn.attach_volume(None, connection_info, instance, mount_point) self._mox.VerifyAll() self.assertEqual(len(self._instance_volume_disks), 1)