Пример #1
0
    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 = sutils.SwiftParams().params
        store = swift.SingleTenantStore(self.conf)
        store.configure()
        location = store.create_location('image-id')
        self.assertEqual(location.scheme, 'swift+http')
        self.assertEqual(location.swift_url, 'http://example.com')
Пример #2
0
    def setUp(self):
        """Establish a clean test environment"""
        super(TestStoreAuthV1, self).setUp()
        conf = self.getConfig()

        conf_file = 'glance-swift.conf'
        self.swift_config_file = self.copy_data_file(conf_file, self.test_dir)
        conf.update({'swift_store_config_file': self.swift_config_file})

        self.stubs = stubout.StubOutForTesting()
        stub_out_swiftclient(self.stubs, conf['swift_store_auth_version'])
        self.store = Store(self.conf)
        self.config(**conf)
        self.store.configure()
        self.addCleanup(self.stubs.UnsetAll)
        self.register_store_schemes(self.store)
        swift.SWIFT_STORE_REF_PARAMS = sutils.SwiftParams().params
        self.addCleanup(self.conf.reset)
Пример #3
0
 def _get_conf_value_from_account_ref(self, netloc):
     try:
         ref_params = sutils.SwiftParams(self.conf).params
         self.user = ref_params[netloc]['user']
         self.key = ref_params[netloc]['key']
         netloc = ref_params[netloc]['auth_address']
         self.ssl_enabled = True
         if netloc != '':
             if netloc.startswith('http://'):
                 self.ssl_enabled = False
                 netloc = netloc[len('http://'):]
             elif netloc.startswith('https://'):
                 netloc = netloc[len('https://'):]
     except KeyError:
         reason = _("Badly formed Swift URI. Credentials not found for "
                    "account reference")
         LOG.info(reason)
         raise exceptions.BadStoreUri(message=reason)
     return netloc
Пример #4
0
 def __init__(self, conf):
     super(SingleTenantStore, self).__init__(conf)
     self.ref_params = sutils.SwiftParams(self.conf).params
Пример #5
0
                       'multi-tenant mode.')),
    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

SWIFT_STORE_REF_PARAMS = sutils.SwiftParams().params


def swift_retry_iter(resp_iter, length, store, location, context):
    length = length if length else (
        resp_iter.len if hasattr(resp_iter, 'len') else 0)
    retries = 0
    bytes_read = 0

    while retries <= store.conf.glance_store.swift_store_retry_get_count:
        try:
            for chunk in resp_iter:
                yield chunk
                bytes_read += len(chunk)
        except swiftclient.ClientException as e:
            LOG.warn(_(u"Swift exception raised %s") % unicode(e))