Fix grow cluster caching

The current caching initializes the instance list for the grow
cluster manager each time a new process would instantiate the
manager.

Changed to manager to only initialize on creation.

Change-Id: I81a4856464c796a674bd267f6225b85505d4e31b
Closes-Bug: #1648229
This commit is contained in:
Duk Loi 2016-07-11 16:34:20 -04:00
parent 98f05cb203
commit 10767f0142
2 changed files with 12 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- The current caching initializes the instance list for the grow
cluster manager each time a new process would instantiate the
manager. Changed to manager to only initialize on creation.

View File

@ -42,17 +42,17 @@ def has_cluster(cluster_id):
class ClusterInstanceManager(object):
instances = []
def __init__(self, cluster_id):
self.cluster_id = cluster_id
self.instances = []
def get_instances(self):
if not hasattr(self, 'instances'):
self.instances = []
return self.instances
def get_instance(self, id):
for instance in self.instances:
for instance in self.get_instances():
if instance.id == id:
return instance
return None
@ -63,7 +63,7 @@ class ClusterInstanceManager(object):
volume, type, related_to, nics)
self.instances.append(instance)
update(self.cluster_id, self)
return self.instances
return self.get_instances()
def delete_instance(self, id):
instance = self.get_instance(id)
@ -72,7 +72,8 @@ class ClusterInstanceManager(object):
update(self.cluster_id, self)
def clear_instances(self):
del self.instances[:]
self.instances = []
update(self.cluster_id, self)
class ClusterInstance(object):