Update apiclient.base and reuse new functional
Module apiclient.base has several updates in oslo, so we need to sync latest code to have ability to reuse new functional. Updates in oslo which related to usage of apiclient.base in heatclient: - I491f9b54c7074546cf738c6150666bfcc3966a78 - I1db6c12a1f798de7f7fafd0c34fb0ef523610153 Related to bp common-client-library-2 Change-Id: I509d6efb0c8eef87ba2e4aa02ebb44ba149a9860
This commit is contained in:
@@ -24,6 +24,7 @@ Base utilities to build API operation managers and objects on top of.
|
||||
# pylint: disable=E1102
|
||||
|
||||
import abc
|
||||
import copy
|
||||
|
||||
import six
|
||||
|
||||
@@ -456,17 +457,17 @@ class Resource(object):
|
||||
def __getattr__(self, k):
|
||||
if k not in self.__dict__:
|
||||
#NOTE(bcwaldon): disallow lazy-loading if already loaded once
|
||||
if not self.is_loaded():
|
||||
self.get()
|
||||
if not self.is_loaded:
|
||||
self._get()
|
||||
return self.__getattr__(k)
|
||||
|
||||
raise AttributeError(k)
|
||||
else:
|
||||
return self.__dict__[k]
|
||||
|
||||
def get(self):
|
||||
# set_loaded() first ... so if we have to bail, we know we tried.
|
||||
self.set_loaded(True)
|
||||
def _get(self):
|
||||
# set _loaded first ... so if we have to bail, we know we tried.
|
||||
self._loaded = True
|
||||
if not hasattr(self.manager, 'get'):
|
||||
return
|
||||
|
||||
@@ -484,8 +485,9 @@ class Resource(object):
|
||||
return self.id == other.id
|
||||
return self._info == other._info
|
||||
|
||||
@property
|
||||
def is_loaded(self):
|
||||
return self._loaded
|
||||
|
||||
def set_loaded(self, val):
|
||||
self._loaded = val
|
||||
def to_dict(self):
|
||||
return copy.deepcopy(self._info)
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import copy
|
||||
|
||||
from heatclient.openstack.common.apiclient import base
|
||||
from heatclient.openstack.common.py3kcompat import urlutils
|
||||
@@ -35,9 +34,6 @@ class Event(base.Resource):
|
||||
def data(self, **kwargs):
|
||||
return self.manager.data(self, **kwargs)
|
||||
|
||||
def to_dict(self):
|
||||
return copy.deepcopy(self._info)
|
||||
|
||||
|
||||
class EventManager(stacks.StackChildManager):
|
||||
resource_class = Event
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from heatclient.openstack.common.apiclient import base
|
||||
from heatclient.openstack.common.py3kcompat import urlutils
|
||||
from heatclient.openstack.common import strutils
|
||||
@@ -36,9 +34,6 @@ class Resource(base.Resource):
|
||||
def data(self, **kwargs):
|
||||
return self.manager.data(self, **kwargs)
|
||||
|
||||
def to_dict(self):
|
||||
return copy.deepcopy(self._info)
|
||||
|
||||
|
||||
class ResourceManager(stacks.StackChildManager):
|
||||
resource_class = Resource
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import copy
|
||||
|
||||
from heatclient.openstack.common.apiclient import base
|
||||
|
||||
@@ -24,9 +23,6 @@ class SoftwareConfig(base.Resource):
|
||||
def data(self, **kwargs):
|
||||
return self.manager.data(self, **kwargs)
|
||||
|
||||
def to_dict(self):
|
||||
return copy.deepcopy(self._info)
|
||||
|
||||
|
||||
class SoftwareConfigManager(base.BaseManager):
|
||||
resource_class = SoftwareConfig
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import copy
|
||||
|
||||
from heatclient.openstack.common.apiclient import base
|
||||
from heatclient.openstack.common.py3kcompat import urlutils
|
||||
@@ -25,9 +24,6 @@ class SoftwareDeployment(base.Resource):
|
||||
def delete(self):
|
||||
return self.manager.delete(deployment_id=self.id)
|
||||
|
||||
def to_dict(self):
|
||||
return copy.deepcopy(self._info)
|
||||
|
||||
|
||||
class SoftwareDeploymentManager(base.BaseManager):
|
||||
resource_class = SoftwareDeployment
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import copy
|
||||
|
||||
import six
|
||||
|
||||
from heatclient.openstack.common.apiclient import base
|
||||
@@ -37,7 +37,7 @@ class Stack(base.Resource):
|
||||
|
||||
def get(self):
|
||||
# set_loaded() first ... so if we have to bail, we know we tried.
|
||||
self.set_loaded(True)
|
||||
self._loaded = True
|
||||
if not hasattr(self.manager, 'get'):
|
||||
return
|
||||
|
||||
@@ -61,9 +61,6 @@ class Stack(base.Resource):
|
||||
def identifier(self):
|
||||
return '%s/%s' % (self.stack_name, self.id)
|
||||
|
||||
def to_dict(self):
|
||||
return copy.deepcopy(self._info)
|
||||
|
||||
|
||||
class StackManager(base.BaseManager):
|
||||
resource_class = Stack
|
||||
|
||||
Reference in New Issue
Block a user