Example #1
0
 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_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_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_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_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_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_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_iqn(self):
     self.flags(iscsi_iqn_prefix='iqn.2012-12.a.b', group='baremetal')
     iqn = volume_driver._get_iqn('instname', '/dev/vdx')
     self.assertEquals('iqn.2012-12.a.b:instname-dev-vdx', iqn)
Example #11
0
 def test_get_iqn(self):
     self.flags(iscsi_iqn_prefix="iqn.2012-12.a.b", group="baremetal")
     iqn = volume_driver._get_iqn("instname", "/dev/vdx")
     self.assertEquals("iqn.2012-12.a.b:instname-dev-vdx", iqn)
Example #12
0
 def test_get_iqn(self):
     self.flags(iscsi_iqn_prefix='iqn.2012-12.a.b', group='baremetal')
     iqn = volume_driver._get_iqn('instname', '/dev/vdx')
     self.assertEqual('iqn.2012-12.a.b:instname-dev-vdx', iqn)