diff options
author | Ryan Brady <rbrady@redhat.com> | 2015-07-09 10:18:51 -0400 |
---|---|---|
committer | Ryan Brady <rbrady@redhat.com> | 2015-07-09 10:59:50 -0400 |
commit | c00978551d5dbc85bd4671202e1de23d73706d7d (patch) | |
tree | cb470570b6c0218b60b349df029009cf680a0475 | |
parent | 99201028f74851cc14360107c289812e09d06d17 (diff) | |
download | tuskar-ui-c00978551d5dbc85bd4671202e1de23d73706d7d.tar.gz |
Optimizes API Calls
Through additional profiling, I found a few more places where
caching could be enabled to reduce network calls and speed up
page load times slightly. This patch adds caching to frequently
used methods and provides for minor improvements. Tested in both
virt and baremetal environments.
Change-Id: I768d6643c4523d33c440a13f5ddc5212555956a8
-rw-r--r-- | tuskar_ui/api/heat.py | 1 | ||||
-rw-r--r-- | tuskar_ui/api/node.py | 4 | ||||
-rw-r--r-- | tuskar_ui/api/tuskar.py | 2 |
3 files changed, 7 insertions, 0 deletions
diff --git a/tuskar_ui/api/heat.py b/tuskar_ui/api/heat.py index 3054ad0d..9852ca00 100644 --- a/tuskar_ui/api/heat.py +++ b/tuskar_ui/api/heat.py @@ -34,6 +34,7 @@ from tuskar_ui.utils import utils LOG = logging.getLogger(__name__) +@memoized.memoized def overcloud_keystoneclient(request, endpoint, password): """Returns a client connected to the Keystone backend. diff --git a/tuskar_ui/api/node.py b/tuskar_ui/api/node.py index 12b037b4..2f67ae78 100644 --- a/tuskar_ui/api/node.py +++ b/tuskar_ui/api/node.py @@ -56,6 +56,7 @@ IRONIC_DISCOVERD_URL = getattr(settings, 'IRONIC_DISCOVERD_URL', None) LOG = logging.getLogger(__name__) +@memoized.memoized def ironicclient(request): api_version = 1 kwargs = {'os_auth_token': request.user.token.id, @@ -156,6 +157,7 @@ class Node(base.APIResourceWrapper): return cls(node, request) @classmethod + @memoized.memoized @handle_errors(_("Unable to retrieve node")) def get(cls, request, uuid): """Return the Node that matches the ID @@ -199,6 +201,7 @@ class Node(base.APIResourceWrapper): return cls(node, request, server) @classmethod + @memoized.memoized @handle_errors(_("Unable to retrieve nodes"), []) def list(cls, request, associated=None, maintenance=None): """Return a list of Nodes @@ -302,6 +305,7 @@ class Node(base.APIResourceWrapper): return cls(node, request) @classmethod + @memoized.memoized def list_ports(cls, request, uuid): """Return a list of ports associated with this Node diff --git a/tuskar_ui/api/tuskar.py b/tuskar_ui/api/tuskar.py index c97f93e7..85d293eb 100644 --- a/tuskar_ui/api/tuskar.py +++ b/tuskar_ui/api/tuskar.py @@ -352,6 +352,7 @@ class Role(base.APIResourceWrapper): self._request = request @classmethod + @memoized.memoized @handle_errors(_("Unable to retrieve overcloud roles"), []) def list(cls, request): """Return a list of Overcloud Roles in Tuskar @@ -367,6 +368,7 @@ class Role(base.APIResourceWrapper): return [cls(role, request=request) for role in roles] @classmethod + @memoized.memoized @handle_errors(_("Unable to retrieve overcloud role")) def get(cls, request, role_id): """Return the Tuskar Role that matches the ID |