From c00978551d5dbc85bd4671202e1de23d73706d7d Mon Sep 17 00:00:00 2001 From: Ryan Brady Date: Thu, 9 Jul 2015 10:18:51 -0400 Subject: 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 --- tuskar_ui/api/heat.py | 1 + tuskar_ui/api/node.py | 4 ++++ tuskar_ui/api/tuskar.py | 2 ++ 3 files changed, 7 insertions(+) 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 -- cgit v1.2.1