def cinder_context(self, infinisdk, pool, provisioning="thick", volume_backend_name=None): with config.get_config_parser(write_on_exit=True) as config_parser: key = config.apply( config_parser, self.infinisdk.get_name(), pool.get_name(), "admin", "123456", thick_provisioning=provisioning.lower() == "thick", prefer_fc=self.prefer_fc, infinidat_allow_pool_not_found=True, infinidat_purge_volume_on_deletion=True, volume_backend_name=volume_backend_name, ) config.enable(config_parser, key) config.update_volume_type(self.get_cinder_client(), key, self.infinisdk.get_name(), pool.get_name()) restart_cinder() self.wait_for_type_creation(pool) with cinder_logs_context(), iscsi_manager_logs_context(), var_log_messages_logs_context(): yield with config.get_config_parser(write_on_exit=True) as config_parser: config.delete_volume_type(self.get_cinder_client(), key) config.disable(config_parser, key) config.remove(config_parser, key) restart_cinder()
def test_adding_pool_that_was_renamed(self, filepath="tests/conf/adding_after_pool_rename.conf"): kwargs = {'address': '1.2.3.4', 'password': '******', 'pool_name': 'pool', 'username': '******'} box = {'address': '1.2.3.4', 'password': '******', 'pool_id': 1, 'username': '******', 'key': 'infinibox-1-pool-1'} self.prepare_conf(filepath) with config.get_config_parser(filepath, True) as config_parser: self.assertEquals(config.get_enabled_backends(config_parser), list()) with patch("infinisdk.InfiniBox") as InfiniBox, \ patch("infinidat_openstack.versioncheck.get_system_version") as system_version: InfiniBox().get_serial.return_value = 1 system_version.return_value = '1.5' pool = Mock() pool.get_id.return_value = 1 InfiniBox().pools.safe_get.return_value = pool key = config.apply(config_parser, **kwargs) config.enable(config_parser, key) with patch("infinisdk.InfiniBox") as InfiniBox, \ patch("infinidat_openstack.versioncheck.get_system_version") as system_version: InfiniBox().get_serial.return_value = 1 system_version.return_value = '1.5' pool = Mock() pool.get_id.return_value = 1 InfiniBox().pools.safe_get.return_value = pool kwargs['pool_name'] = 'pool2' key = config.apply(config_parser, **kwargs) config.enable(config_parser, key) with config.get_config_parser(filepath) as config_parser: self.assertEquals(len(config.get_volume_backends(config_parser)), 1) self.assertEquals(len(config.get_enabled_backends(config_parser)), 1)