show correct total hosts in clusters view

Change-Id: Ia151fdc5b079b4c5172478a314968c3494f57f3a
Closes-Bug: 1384994
This commit is contained in:
xiaodongwang 2014-12-03 17:26:18 -08:00
parent 3b003c2778
commit a470683c29
2 changed files with 10 additions and 1 deletions

View File

@ -1415,8 +1415,12 @@ def update_cluster_hosts(
_add_clusterhosts(session, cluster, **add_hosts)
if set_hosts is not None:
_set_clusterhosts(session, cluster, **set_hosts)
clusterhosts = utils.list_db_objects(
session, models.ClusterHost, cluster_id=cluster.id
)
logging.info('updated clusterhosts: %s', clusterhosts)
return {
'hosts': cluster.clusterhosts
'hosts': clusterhosts
}

View File

@ -681,6 +681,8 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
self.state.state = 'INITIALIZED'
else:
self.state.state = 'UNINITIALIZED'
self.cluster.update()
self.host.update()
self.state.update()
super(ClusterHost, self).update()
@ -1118,6 +1120,9 @@ class ClusterState(BASE, StateMixin):
default=0
)
def __init__(self, **kwargs):
super(ClusterState, self).__init__(**kwargs)
def __str__(self):
return 'ClusterState[%s state %s percentage %s]' % (
self.id, self.state, self.percentage