Merge "Update apiclient.base and reuse new functional"

This commit is contained in:
Jenkins
2014-03-01 13:11:58 +00:00
committed by Gerrit Code Review
6 changed files with 11 additions and 29 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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