def __init__(self, conf): self.volumes = VolumeHelper(conf) self.exports = ExportHelper(conf) self.backups = BackupHelper(conf) self.cgroups = CgroupHelper(conf) self.api_server = conf.string('storage', 'api_server', "http://localhost:8080") self.api_retry = conf.int('storage', 'api_retry', 1) # name of node registration self.name = conf.string('storage', 'name', socket.gethostname()) self.affinity_group = conf.string('storage', 'affinity_group', '') # management interface self.management_host = conf.string('server:main', 'host', '0.0.0.0') if self.management_host == '0.0.0.0': self.management_host = my_ip(self.api_server) self.management_port = conf.int('server:main', 'port', 8081) # storage interface self.storage_host = conf.string('storage', 'host', '127.0.0.1') self.storage_port = conf.int('storage', 'port', 3260) self.volume_type = conf.string('storage', 'volume_type', 'vtype') # cinder self.cinder_args = cinderclient.get_args(conf) self.rax_auth = conf.bool('cinder', 'rax_auth', True) if self.rax_auth: self.client = cinderclient.CinderClient(**self.cinder_args) self.cinder_host = conf.string('storage', 'cinder_host', self.management_host)
def setUp(self): IetTest.setUp(self) self.tempdir = mkdtemp() self.conf = self.config(self.tempdir) self.volume = VolumeHelper(self.conf) self.export = ExportHelper(self.conf)
class TestClone(IetTest): def setUp(self): IetTest.setUp(self) self.tempdir = mkdtemp() self.conf = self.config(self.tempdir) self.volume = VolumeHelper(self.conf) self.export = ExportHelper(self.conf) def tearDown(self): try: # Remove any exports self.export.delete(self.volume2) except NotFound: pass shutil.rmtree(self.tempdir) IetTest.tearDown(self) @classmethod def setUpClass(cls): pass @classmethod def tearDownClass(cls): pass def test_create_clone(self): block_size = 32768 # Create 2 Volumes self.volume1 = str(uuid4()) self.volume2 = str(uuid4()) self.volume.create(self.volume1) self.volume.create(self.volume2) # Write some stuff to volume1 volume = self.volume.get(self.volume1) with directio.open(volume['path']) as file: size = directio.size(volume['path']) for i in xrange(0, size / block_size): # 32768 / 4 = 8192 file.write('ZERG' * (block_size / 4)) # Create an export for volume 2 info = self.export.create(self.volume2) # Now clone Volume 1 to Volume 2 clone = self.volume.create_clone(self.volume1, self.volume2, info['name'], '127.0.0.1', 3260, lock=MockResourceLock()) compare_block = 'ZERG' * (block_size / 4) # Ensure the stuff we wrote to Volume 1 is in Volume 2 volume = self.volume.get(self.volume2) with directio.open(volume['path']) as file: size = directio.size(volume['path']) for i in xrange(0, size / block_size): block = file.read(block_size) self.assertTrue(block == compare_block) # Remove the export self.export.delete(self.volume2) def test_cinder_callback(self): block_size = 32768 # Create 2 Volumes self.volume1 = str(uuid4()) self.volume2 = str(uuid4()) self.volume.create(self.volume1) self.volume.create(self.volume2) # Create an export for volume 2 info = self.export.create(self.volume2) cinder = MockCinder() # Now clone Volume 1 to Volume 2 clone = self.volume.create_clone(self.volume1, self.volume2, info['name'], '127.0.0.1', 3260, lock=MockResourceLock(), cinder=cinder) # Assert cinder was called atleast once self.assertTrue(cinder.called != 0) # Remove the export self.export.delete(self.volume2)