def test_attach_volume(self): self.mox.StubOutWithMock(volume_driver, '_get_fixed_ips') self.mox.StubOutWithMock(self.driver, '_volume_driver_method') self.mox.StubOutWithMock(volume_driver, '_get_iqn') self.mox.StubOutWithMock(volume_driver, '_get_next_tid') self.mox.StubOutWithMock(volume_driver, '_create_iscsi_export_tgtadm') self.mox.StubOutWithMock(volume_driver, '_allow_iscsi_tgtadm') volume_driver._get_fixed_ips(self.instance).AndReturn(self.fixed_ips) self.driver._volume_driver_method('connect_volume', self.connection_info, self.disk_info).\ AndReturn(FakeConf(self.source_path)) volume_driver._get_iqn(self.instance['name'], self.mount_point).\ AndReturn(self.iqn) volume_driver._get_next_tid().AndReturn(self.tid) volume_driver._create_iscsi_export_tgtadm(self.source_path, self.tid, self.iqn) volume_driver._allow_iscsi_tgtadm(self.tid, self.fixed_ips[0]['address']) volume_driver._allow_iscsi_tgtadm(self.tid, self.fixed_ips[1]['address']) self.mox.ReplayAll() self.driver.attach_volume(self.connection_info, self.instance, self.mount_point)
def test_publish_iscsi(self): self.mox.StubOutWithMock(volume_driver, '_get_iqn') self.mox.StubOutWithMock(volume_driver, '_get_next_tid') self.mox.StubOutWithMock(volume_driver, '_create_iscsi_export_tgtadm') self.mox.StubOutWithMock(volume_driver, '_allow_iscsi_tgtadm') volume_driver._get_iqn(self.instance['name'], self.mount_point).\ AndReturn(self.iqn) volume_driver._get_next_tid().AndReturn(self.tid) volume_driver._create_iscsi_export_tgtadm(self.source_path, self.tid, self.iqn) volume_driver._allow_iscsi_tgtadm(self.tid, self.fixed_ips[0]['address']) volume_driver._allow_iscsi_tgtadm(self.tid, self.fixed_ips[1]['address']) self.mox.ReplayAll() self.driver._publish_iscsi(self.instance, self.mount_point, self.fixed_ips, self.source_path)
def test_get_next_tid(self): tid = volume_driver._get_next_tid() self.assertEqual(1000002, tid)