Remove local cached version of Resource class
We used to have a local version of Resource class due to insufficient support in SDK back in the old days. Now I believe all those barriers are removed. So the local cached version doesn't make much senses. This patch proposes to remove them forever. Change-Id: Ie4f09e29f584813bf354002aee0f8680c7688c59
This commit is contained in:
parent
bd41eb4c9d
commit
1c6496caeb
@ -11,14 +11,12 @@
|
||||
# under the License.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from openstack import connection
|
||||
from openstack import exceptions
|
||||
from openstack import profile
|
||||
from openstack import resource as base
|
||||
from openstack import utils
|
||||
import os
|
||||
|
||||
from six.moves.urllib import parse as url_parse
|
||||
|
||||
from senlinclient.common import exc
|
||||
|
||||
@ -74,55 +72,6 @@ class ProfileAction(argparse.Action):
|
||||
self.set_option(option_string, values)
|
||||
|
||||
|
||||
class Resource(base.Resource):
|
||||
"""Senlin version of resource.
|
||||
|
||||
These classes are here because the OpenStack SDK base version is making
|
||||
some assumptions about operations that cannot be satisfied in Senlin.
|
||||
"""
|
||||
|
||||
def create(self, session, extra_attrs=False):
|
||||
"""Create a remote resource from this instance.
|
||||
|
||||
:param extra_attrs: If true, all attributions that
|
||||
included in response will be collected and returned
|
||||
to user after resource creation
|
||||
|
||||
"""
|
||||
resp = self.create_by_id(session, self._attrs, self.id, path_args=self)
|
||||
self._attrs[self.id_attribute] = resp[self.id_attribute]
|
||||
if extra_attrs:
|
||||
for attr in resp:
|
||||
self._attrs[attr] = resp[attr]
|
||||
self._reset_dirty()
|
||||
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def get_data_with_args(cls, session, resource_id, args=None):
|
||||
if not cls.allow_retrieve:
|
||||
raise exceptions.MethodNotSupported('list')
|
||||
|
||||
url = utils.urljoin(cls.base_path, resource_id)
|
||||
if args:
|
||||
args.pop('id')
|
||||
url = '%s?%s' % (url, url_parse.urlencode(args))
|
||||
resp = session.get(url, endpoint_filter=cls.service)
|
||||
body = resp.json()
|
||||
if cls.resource_key:
|
||||
body = body[cls.resource_key]
|
||||
|
||||
return body
|
||||
|
||||
def get_with_args(self, session, args=None):
|
||||
body = self.get_data_with_args(session, self.id, args=args)
|
||||
|
||||
self._attrs.update(body)
|
||||
self._loaded = True
|
||||
|
||||
return self
|
||||
|
||||
|
||||
def create_connection(prof=None, user_agent=None, **kwargs):
|
||||
if not prof:
|
||||
prof = profile.Profile()
|
||||
|
Loading…
x
Reference in New Issue
Block a user