def _check(volume_id): """Make sure targets aren't duplicated.""" volume_ids.append(volume_id) admin_context = context.get_admin_context() iscsi_target = db.volume_get_iscsi_target_num(admin_context, volume_id) self.assert_(iscsi_target not in targets) targets.append(iscsi_target) LOG.debug(_("Target %s allocated"), iscsi_target)
def _check(volume_id): """Make sure targets aren't duplicated.""" volume_ids.append(volume_id) admin_context = context.get_admin_context() iscsi_target = db.volume_get_iscsi_target_num( admin_context, volume_id) self.assert_(iscsi_target not in targets) targets.append(iscsi_target) LOG.debug(_("Target %s allocated"), iscsi_target)
def test_check_for_export_with_all_volume_exported(self): """No log message when all the processes are running.""" volume_id_list = self._attach_volume() self.mox.StubOutWithMock(self.volume.driver.tgtadm, 'show_target') for i in volume_id_list: tid = db.volume_get_iscsi_target_num(self.context, i) self.volume.driver.tgtadm.show_target(tid) self.stream.truncate(0) self.mox.ReplayAll() self.volume.check_for_export(self.context, self.instance_id) self.assertEqual(self.stream.getvalue(), '') self.mox.UnsetStubs() self._detach_volume(volume_id_list)
def test_check_for_export_with_some_volume_missing(self): """Output a warning message when some volumes are not recognied by ietd.""" volume_id_list = self._attach_volume() tid = db.volume_get_iscsi_target_num(self.context, volume_id_list[0]) self.mox.StubOutWithMock(self.volume.driver.tgtadm, 'show_target') self.volume.driver.tgtadm.show_target(tid).AndRaise( exception.ProcessExecutionError()) self.mox.ReplayAll() self.assertRaises(exception.ProcessExecutionError, self.volume.check_for_export, self.context, self.instance_id) msg = _("Cannot confirm exported volume id:%s.") % volume_id_list[0] self.assertTrue(0 <= self.stream.getvalue().find(msg)) self.mox.UnsetStubs() self._detach_volume(volume_id_list)