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)
 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)
Exemple #3
0
    def test_check_for_export_with_all_volume_exported(self):
        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.mox.ReplayAll()
        instance_uuid = "12345678-1234-5678-1234-567812345678"
        self.volume.check_for_export(self.context, instance_uuid)
        self.mox.UnsetStubs()

        self._detach_volume(volume_id_list)
Exemple #4
0
    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()
        instance_uuid = "12345678-1234-5678-1234-567812345678"

        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, instance_uuid)
        self.mox.UnsetStubs()

        self._detach_volume(volume_id_list)
Exemple #5
0
    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()
        instance_uuid = '12345678-1234-5678-1234-567812345678'
        self.volume.check_for_export(self.context, instance_uuid)
        self.assertEqual(self.stream.getvalue(), '')
        self.mox.UnsetStubs()

        self._detach_volume(volume_id_list)
Exemple #6
0
    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()
        instance_uuid = '12345678-1234-5678-1234-567812345678'

        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,
                          instance_uuid)
        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)
Exemple #7
0
 def test_volume_get_iscsi_target_num(self):
     target = db.iscsi_target_create_safe(self.ctxt, {
         'volume_id': 42,
         'target_num': 43
     })
     self.assertEqual(43, db.volume_get_iscsi_target_num(self.ctxt, 42))
Exemple #8
0
 def test_volume_get_iscsi_target_num(self):
     target = db.iscsi_target_create_safe(self.ctxt, {'volume_id': 42,
                                                      'target_num': 43})
     self.assertEqual(43, db.volume_get_iscsi_target_num(self.ctxt, 42))
Exemple #9
0
 def test_volume_get_iscsi_target_num(self):
     db.iscsi_target_create_safe(self.ctxt, {"volume_id": 42, "target_num": 43})
     self.assertEqual(43, db.volume_get_iscsi_target_num(self.ctxt, 42))