本文整理汇总了Python中trove.common.remote.create_swift_client函数的典型用法代码示例。如果您正苦于以下问题:Python create_swift_client函数的具体用法?Python create_swift_client怎么用?Python create_swift_client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_swift_client函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_with_catalog_all_opts
def test_create_with_catalog_all_opts(self):
cfg.CONF.set_override('swift_service_type', 'object-storev3')
cfg.CONF.set_override('os_region_name', 'RegionTwo')
client = remote.create_swift_client(
TroveContext(service_catalog=self.service_catalog))
self.assertEqual(self.swiftv3_public_url_region_two,
client.url)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:7,代码来源:test_remote.py
示例2: test_create_swift_client
def test_create_swift_client(self):
mock_resp = mock(dict)
when(swiftclient.client.Connection).get_container("bob").thenReturn(["text", mock_resp])
client = remote.create_swift_client(TroveContext(tenant="123"))
headers, container = client.get_container("bob")
self.assertIs(headers, "text")
self.assertIs(container, mock_resp)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:7,代码来源:test_remote.py
示例3: __init__
def __init__(self, context, **kwargs):
self.process = None
self.pid = None
self.cmd = self.cmd % kwargs
self.container = kwargs.get('container')
self.filename = kwargs.get('filename')
self.original_backup_checksum = kwargs.get('backup_checksum', None)
self.swift_client = create_swift_client(context)
开发者ID:SlickNik,项目名称:trove-guestagent,代码行数:8,代码来源:swift.py
示例4: verify_swift_auth_token
def verify_swift_auth_token(cls, context):
try:
client = create_swift_client(context)
client.get_account()
except ClientException:
raise exception.SwiftAuthError(tenant_id=context.tenant)
except exception.NoServiceEndpoint:
raise exception.SwiftNotFound(tenant_id=context.tenant)
开发者ID:Hopebaytech,项目名称:trove,代码行数:8,代码来源:models.py
示例5: test_create_swift_client
def test_create_swift_client(self):
mock_resp = MagicMock()
swiftclient.client.Connection.get_container = MagicMock(
return_value=["text", mock_resp])
client = remote.create_swift_client(TroveContext(tenant='123'))
headers, container = client.get_container('bob')
self.assertIs(headers, "text")
self.assertIs(container, mock_resp)
开发者ID:Simplit-openapps,项目名称:trove,代码行数:8,代码来源:test_remote.py
示例6: test_create_with_conf_override
def test_create_with_conf_override(self):
swift_url_from_conf = 'http://example.com/AUTH_'
tenant_from_ctx = 'abc'
cfg.CONF.set_override('swift_url', swift_url_from_conf)
client = remote.create_swift_client(
TroveContext(tenant=tenant_from_ctx))
self.assertEqual('%s%s' % (swift_url_from_conf, tenant_from_ctx),
client.url)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:9,代码来源:test_remote.py
示例7: test_create_swift_client
def test_create_swift_client(self):
mock_resp = MagicMock()
swiftclient.client.Connection.get_container = MagicMock(
return_value=["text", mock_resp])
service_catalog = [{'endpoints': [{'publicURL': 'example.com'}],
'type': 'object-store'}]
client = remote.create_swift_client(TroveContext(
tenant='123',
service_catalog=service_catalog))
headers, container = client.get_container('bob')
self.assertIs(headers, "text")
self.assertIs(container, mock_resp)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:12,代码来源:test_remote.py
示例8: check_object_exist
def check_object_exist(cls, context, location):
try:
parts = location.split('/')
obj = parts[-1]
container = parts[-2]
client = create_swift_client(context)
client.head_object(container, obj)
return True
except ClientException as e:
if e.http_status == 404:
return False
else:
raise exception.SwiftAuthError(tenant_id=context.tenant)
开发者ID:dfecker,项目名称:trove,代码行数:13,代码来源:models.py
示例9: test_create_swift_client
def test_create_swift_client(self):
mock_resp = MagicMock()
with patch.object(swiftclient.client.Connection, 'get_container',
MagicMock(return_value=["text", mock_resp])):
service_catalog = [{'endpoints': [{'region': 'RegionOne',
'publicURL': 'example.com'}],
'type': 'object-store'}]
client = remote.create_swift_client(TroveContext(
tenant=uuid.uuid4().hex,
service_catalog=service_catalog))
headers, container = client.get_container('bob')
self.assertIs(headers, "text")
self.assertIs(container, mock_resp)
开发者ID:magictour,项目名称:trove,代码行数:13,代码来源:test_remote.py
示例10: delete_files_from_swift
def delete_files_from_swift(cls, context, filename):
client = remote.create_swift_client(context)
# Delete the manifest
if client.head_object(CONF.backup_swift_container, filename):
client.delete_object(CONF.backup_swift_container, filename)
# Delete the segments
if client.head_container(filename + "_segments"):
for obj in client.get_container(filename + "_segments")[1]:
client.delete_object(filename + "_segments", obj['name'])
# Delete the segments container
client.delete_container(filename + "_segments")
开发者ID:dfecker,项目名称:trove,代码行数:14,代码来源:models.py
示例11: delete_files_from_swift
def delete_files_from_swift(cls, context, filename):
container = CONF.backup_swift_container
client = remote.create_swift_client(context)
obj = client.head_object(container, filename)
manifest = obj.get('x-object-manifest', '')
cont, prefix = cls._parse_manifest(manifest)
if all([cont, prefix]):
# This is a manifest file, first delete all segments.
LOG.info("Deleting files with prefix: %s/%s", cont, prefix)
# list files from container/prefix specified by manifest
headers, segments = client.get_container(cont, prefix=prefix)
LOG.debug(headers)
for segment in segments:
name = segment.get('name')
if name:
LOG.info("Deleting file: %s/%s", cont, name)
client.delete_object(cont, name)
# Delete the manifest file
LOG.info("Deleting file: %s/%s", container, filename)
client.delete_object(container, filename)
开发者ID:citrix-openstack-build,项目名称:trove,代码行数:20,代码来源:models.py
示例12: check_swift_object_exist
def check_swift_object_exist(self, context, verify_checksum=False):
try:
parts = self.location.split("/")
obj = parts[-1]
container = parts[-2]
client = create_swift_client(context)
LOG.info(_("Checking if backup exist in '%s'") % self.location)
resp = client.head_object(container, obj)
if verify_checksum:
LOG.info(_("Checking if backup checksum matches swift."))
# swift returns etag in double quotes
# e.g. '"dc3b0827f276d8d78312992cc60c2c3f"'
swift_checksum = resp["etag"].strip('"')
if self.checksum != swift_checksum:
raise exception.RestoreBackupIntegrityError(backup_id=self.id)
return True
except ClientException as e:
if e.http_status == 404:
return False
else:
raise exception.SwiftAuthError(tenant_id=context.tenant)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:21,代码来源:models.py
示例13: __init__
def __init__(self, *args, **kwargs):
super(SwiftStorage, self).__init__(*args, **kwargs)
self.connection = create_swift_client(self.context)
开发者ID:NeCTAR-RC,项目名称:trove,代码行数:3,代码来源:swift.py
示例14: get_client
def get_client(cls, context):
return remote.create_swift_client(context)
开发者ID:cdelatte,项目名称:tesora-trove,代码行数:2,代码来源:models.py
示例15: swift_client
def swift_client(self):
if not self._cached_swift_client or (
self._cached_context != self.context):
self._cached_swift_client = create_swift_client(self.context)
self._cached_context = self.context
return self._cached_swift_client
开发者ID:Tesora,项目名称:tesora-trove,代码行数:6,代码来源:guest_log.py
示例16: get_client
def get_client(cls, context, region_name):
return remote.create_swift_client(context, region_name)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:2,代码来源:models.py
示例17: test_create_with_catalog_and_default_service_type
def test_create_with_catalog_and_default_service_type(self):
client = remote.create_swift_client(
TroveContext(service_catalog=self.service_catalog))
self.assertEqual(self.swift_public_url,
client.url)
开发者ID:AlexeyDeyneko,项目名称:trove,代码行数:5,代码来源:test_remote.py
注:本文中的trove.common.remote.create_swift_client函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论