def test_swift_store_config_validates_for_creds_auth_address(self): swift_params = swift_store_utils.SwiftParams().params self.assertEqual('tenant:user1', swift_params['ref1']['user']) self.assertEqual('key1', swift_params['ref1']['key']) self.assertEqual('example.com', swift_params['ref1']['auth_address']) self.assertEqual('user2', swift_params['ref2']['user']) self.assertEqual('key2', swift_params['ref2']['key']) self.assertEqual('http://example.com', swift_params['ref2']['auth_address'])
def test_single_tenant_location_http(self): conf_file = "glance-swift.conf" test_dir = self.useFixture(fixtures.TempDir()).path self.swift_config_file = self._copy_data_file(conf_file, test_dir) self.config(swift_store_container='container', default_swift_reference='ref2', swift_store_config_file=self.swift_config_file) swift.SWIFT_STORE_REF_PARAMS = swift_store_utils.SwiftParams().params store = glance.store.swift.SingleTenantStore() location = store.create_location('image-id') self.assertEqual(location.scheme, 'swift+http') self.assertEqual(location.swift_url, 'http://example.com')
def setUp(self): """Establish a clean test environment""" conf = self.getConfig() self.config(**conf) conf_file = 'glance-swift.conf' self.test_dir = self.useFixture(fixtures.TempDir()).path self.swift_config_file = self._copy_data_file(conf_file, self.test_dir) conf.update({'swift_store_config_file': conf_file}) self.config(swift_store_config_file=self.swift_config_file) super(TestStoreAuthV1, self).setUp() swift.SWIFT_STORE_REF_PARAMS = swift_store_utils.SwiftParams().params self.stubs = stubout.StubOutForTesting() stub_out_swiftclient(self.stubs, conf['swift_store_auth_version']) self.store = Store() self.addCleanup(self.stubs.UnsetAll)
def test_swift_config_uses_default_values_multiple_account_disabled(self): default_user = '******' default_key = 'key_default' default_auth_address = '*****@*****.**' default_account_reference = 'ref_default' confs = { 'swift_store_config_file': None, 'swift_store_user': default_user, 'swift_store_key': default_key, 'swift_store_auth_address': default_auth_address, 'default_swift_reference': default_account_reference } self.config(**confs) swift_params = swift_store_utils.SwiftParams().params self.assertEqual(1, len(swift_params.keys())) self.assertEqual(default_user, swift_params[default_account_reference]['user']) self.assertEqual(default_key, swift_params[default_account_reference]['key']) self.assertEqual( default_auth_address, swift_params[default_account_reference]['auth_address'])
cfg.BoolOpt('swift_store_ssl_compression', default=True, help=_('If set to False, disables SSL layer compression of ' 'https swift requests. Setting to False may improve ' 'performance for images which are already in a ' 'compressed format, eg qcow2.')), cfg.IntOpt('swift_store_retry_get_count', default=0, help=_('The number of times a Swift download will be retried ' 'before the request fails.')) ] CONF = cfg.CONF CONF.register_opts(swift_opts) SWIFT_STORE_REF_PARAMS = swift_store_utils.SwiftParams().params def swift_retry_iter(resp_iter, length, store, location): length = length if length else ( resp_iter.len if hasattr(resp_iter, 'len') else 0) retries = 0 bytes_read = 0 while retries <= CONF.swift_store_retry_get_count: try: for chunk in resp_iter: yield chunk bytes_read += len(chunk) except swiftclient.ClientException as e: LOG.warn(