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:
parent
98f05cb203
commit
10767f0142
@ -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.
|
@ -42,17 +42,17 @@ def has_cluster(cluster_id):
|
|||||||
|
|
||||||
|
|
||||||
class ClusterInstanceManager(object):
|
class ClusterInstanceManager(object):
|
||||||
|
|
||||||
instances = []
|
|
||||||
|
|
||||||
def __init__(self, cluster_id):
|
def __init__(self, cluster_id):
|
||||||
self.cluster_id = cluster_id
|
self.cluster_id = cluster_id
|
||||||
|
self.instances = []
|
||||||
|
|
||||||
def get_instances(self):
|
def get_instances(self):
|
||||||
|
if not hasattr(self, 'instances'):
|
||||||
|
self.instances = []
|
||||||
return self.instances
|
return self.instances
|
||||||
|
|
||||||
def get_instance(self, id):
|
def get_instance(self, id):
|
||||||
for instance in self.instances:
|
for instance in self.get_instances():
|
||||||
if instance.id == id:
|
if instance.id == id:
|
||||||
return instance
|
return instance
|
||||||
return None
|
return None
|
||||||
@ -63,7 +63,7 @@ class ClusterInstanceManager(object):
|
|||||||
volume, type, related_to, nics)
|
volume, type, related_to, nics)
|
||||||
self.instances.append(instance)
|
self.instances.append(instance)
|
||||||
update(self.cluster_id, self)
|
update(self.cluster_id, self)
|
||||||
return self.instances
|
return self.get_instances()
|
||||||
|
|
||||||
def delete_instance(self, id):
|
def delete_instance(self, id):
|
||||||
instance = self.get_instance(id)
|
instance = self.get_instance(id)
|
||||||
@ -72,7 +72,8 @@ class ClusterInstanceManager(object):
|
|||||||
update(self.cluster_id, self)
|
update(self.cluster_id, self)
|
||||||
|
|
||||||
def clear_instances(self):
|
def clear_instances(self):
|
||||||
del self.instances[:]
|
self.instances = []
|
||||||
|
update(self.cluster_id, self)
|
||||||
|
|
||||||
|
|
||||||
class ClusterInstance(object):
|
class ClusterInstance(object):
|
||||||
|
Loading…
Reference in New Issue
Block a user