def test_depublish_iscsi_do_nothing_if_tid_is_not_found(self): self.mox.StubOutWithMock(volume_driver, '_get_iqn') self.mox.StubOutWithMock(volume_driver, '_find_tid') volume_driver._get_iqn(self.instance['name'], self.mount_point).\ AndReturn(self.iqn) volume_driver._find_tid(self.iqn).AndReturn(None) self.mox.ReplayAll() self.driver._depublish_iscsi(self.instance, self.mount_point)
def test_depublish_iscsi_ok(self): self.mox.StubOutWithMock(volume_driver, '_get_iqn') self.mox.StubOutWithMock(volume_driver, '_find_tid') self.mox.StubOutWithMock(volume_driver, '_delete_iscsi_export_tgtadm') volume_driver._get_iqn(self.instance['name'], self.mount_point).\ AndReturn(self.iqn) volume_driver._find_tid(self.iqn).AndReturn(self.tid) volume_driver._delete_iscsi_export_tgtadm(self.tid) self.mox.ReplayAll() self.driver._depublish_iscsi(self.instance, self.mount_point)
def test_detach_volume(self): self.mox.StubOutWithMock(volume_driver, '_get_iqn') self.mox.StubOutWithMock(volume_driver, '_find_tid') self.mox.StubOutWithMock(volume_driver, '_delete_iscsi_export_tgtadm') self.mox.StubOutWithMock(self.driver, '_disconnect_volume') volume_driver._get_iqn(self.instance['name'], self.mount_point).\ AndReturn(self.iqn) volume_driver._find_tid(self.iqn).AndReturn(self.tid) volume_driver._delete_iscsi_export_tgtadm(self.tid) self.driver._disconnect_volume(self.connection_info, self.mount_device) self.mox.ReplayAll() self.driver.detach_volume(self.connection_info, self.instance, self.mount_point)
def test_find_tid_not_found(self): tid = volume_driver._find_tid( 'iqn.2010-10.org.openstack.baremetal:1000002-dev.vdc') self.assertTrue(tid is None)
def test_find_tid_found(self): tid = volume_driver._find_tid( 'iqn.2010-10.org.openstack.baremetal:1000001-dev.vdc') self.assertEqual(1000001, tid)
def test_find_tid_not_found(self): tid = volume_driver._find_tid("iqn.2010-10.org.openstack.baremetal:1000002-dev.vdc") self.assertTrue(tid is None)
def test_find_tid_found(self): tid = volume_driver._find_tid("iqn.2010-10.org.openstack.baremetal:1000001-dev.vdc") self.assertEqual(1000001, tid)