Split out OpenStackCloud and OperatorCloud classes
Change-Id: If8a09f52313c07d12c7fe0da66f6599de3120979
This commit is contained in:
parent
5ce5c003e8
commit
0f6203f303
@ -13,5 +13,8 @@ To use shade in a project::
|
|||||||
compatibility, but attribute access is deprecated. New code should
|
compatibility, but attribute access is deprecated. New code should
|
||||||
assume a normal dictionary and access values via key.
|
assume a normal dictionary and access values via key.
|
||||||
|
|
||||||
.. automodule:: shade
|
.. autoclass:: shade.OpenStackCloud
|
||||||
|
:members:
|
||||||
|
|
||||||
|
.. autoclass:: shade.OperatorCloud
|
||||||
:members:
|
:members:
|
||||||
|
5696
shade/__init__.py
5696
shade/__init__.py
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,9 @@ from shade import exc
|
|||||||
log = _log.setup_logging(__name__)
|
log = _log.setup_logging(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
_decorated_methods = []
|
||||||
|
|
||||||
|
|
||||||
def _iterate_timeout(timeout, message, wait=2):
|
def _iterate_timeout(timeout, message, wait=2):
|
||||||
"""Iterate and raise an exception on timeout.
|
"""Iterate and raise an exception on timeout.
|
||||||
|
|
||||||
@ -319,3 +322,23 @@ def valid_kwargs(*valid_args):
|
|||||||
"'{arg}'".format(f=inspect.stack()[1][3], arg=k))
|
"'{arg}'".format(f=inspect.stack()[1][3], arg=k))
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
return func_wrapper
|
return func_wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def cache_on_arguments(*cache_on_args, **cache_on_kwargs):
|
||||||
|
def _inner_cache_on_arguments(func):
|
||||||
|
def _cache_decorator(obj, *args, **kwargs):
|
||||||
|
the_method = obj._cache.cache_on_arguments(
|
||||||
|
*cache_on_args, **cache_on_kwargs)(
|
||||||
|
func.__get__(obj, type(obj)))
|
||||||
|
return the_method(*args, **kwargs)
|
||||||
|
|
||||||
|
def invalidate(obj, *args, **kwargs):
|
||||||
|
return obj._cache.cache_on_arguments()(func).invalidate(
|
||||||
|
*args, **kwargs)
|
||||||
|
|
||||||
|
_cache_decorator.invalidate = invalidate
|
||||||
|
_cache_decorator.func = func
|
||||||
|
_decorated_methods.append(func.__name__)
|
||||||
|
|
||||||
|
return _cache_decorator
|
||||||
|
return _inner_cache_on_arguments
|
||||||
|
4274
shade/openstackcloud.py
Normal file
4274
shade/openstackcloud.py
Normal file
File diff suppressed because it is too large
Load Diff
1438
shade/operatorcloud.py
Normal file
1438
shade/operatorcloud.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@ import testtools
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import shade
|
import shade
|
||||||
|
import shade.openstackcloud
|
||||||
from shade import exc
|
from shade import exc
|
||||||
from shade import meta
|
from shade import meta
|
||||||
from shade.tests import fakes
|
from shade.tests import fakes
|
||||||
@ -386,8 +387,8 @@ class TestMemoryCache(base.TestCase):
|
|||||||
fake_image.update({
|
fake_image.update({
|
||||||
'id': '99',
|
'id': '99',
|
||||||
'name': '99 name',
|
'name': '99 name',
|
||||||
shade.IMAGE_MD5_KEY: fake_md5,
|
shade.openstackcloud.IMAGE_MD5_KEY: fake_md5,
|
||||||
shade.IMAGE_SHA256_KEY: fake_sha256,
|
shade.openstackcloud.IMAGE_SHA256_KEY: fake_sha256,
|
||||||
})
|
})
|
||||||
glance_mock.images.list.return_value = [fake_image]
|
glance_mock.images.list.return_value = [fake_image]
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from swiftclient import service as swift_service
|
|||||||
from swiftclient import exceptions as swift_exc
|
from swiftclient import exceptions as swift_exc
|
||||||
|
|
||||||
import shade
|
import shade
|
||||||
|
import shade.openstackcloud
|
||||||
from shade import exc
|
from shade import exc
|
||||||
from shade import OpenStackCloud
|
from shade import OpenStackCloud
|
||||||
from shade.tests.unit import base
|
from shade.tests.unit import base
|
||||||
@ -93,5 +94,5 @@ class TestObject(base.TestCase):
|
|||||||
def test_get_object_segment_size_http_412(self, swift_mock):
|
def test_get_object_segment_size_http_412(self, swift_mock):
|
||||||
swift_mock.get_capabilities.side_effect = swift_exc.ClientException(
|
swift_mock.get_capabilities.side_effect = swift_exc.ClientException(
|
||||||
"Precondition failed", http_status=412)
|
"Precondition failed", http_status=412)
|
||||||
self.assertEqual(shade.DEFAULT_OBJECT_SEGMENT_SIZE,
|
self.assertEqual(shade.openstackcloud.DEFAULT_OBJECT_SEGMENT_SIZE,
|
||||||
self.cloud.get_object_segment_size(None))
|
self.cloud.get_object_segment_size(None))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user