summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorImre Farkas <ifarkas@redhat.com>2013-07-26 19:53:11 +0200
committerTomas Sedovic <tomas@sedovic.cz>2013-08-01 16:18:58 +0200
commit396d76856bee4078935e1a582fcb6a0806144aba (patch)
tree1fc92163494e4c1da7d31e51fd0b1adcdaed9d8c
parent3833c8de38c4d76f6a9f75ed3b3d4c7d14145419 (diff)
downloadtuskar-ui-396d76856bee4078935e1a582fcb6a0806144aba.tar.gz
Active instance count to Node
Note: Add the OVERLCOUD_AUTH_URL, OVERLCOUD_USERNAME, OVERLCOUD_PASSWORD constants to your local_settings.py Change-Id: Ib24620a7549e7c08ff3c8cf46c915565781f1925
-rw-r--r--openstack_dashboard/api/tuskar.py17
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html2
-rw-r--r--openstack_dashboard/local/local_settings.py.example3
-rw-r--r--openstack_dashboard/test/settings.py3
4 files changed, 25 insertions, 0 deletions
diff --git a/openstack_dashboard/api/tuskar.py b/openstack_dashboard/api/tuskar.py
index 8483be83..a0b15ab7 100644
--- a/openstack_dashboard/api/tuskar.py
+++ b/openstack_dashboard/api/tuskar.py
@@ -34,6 +34,9 @@ import openstack_dashboard.dashboards.infrastructure.models as dummymodels
LOG = logging.getLogger(__name__)
TUSKAR_ENDPOINT_URL = getattr(settings, 'TUSKAR_ENDPOINT_URL')
NOVA_BAREMETAL_CREDS = getattr(settings, 'NOVA_BAREMETAL_CREDS')
+OVERCLOUD_AUTH_URL = getattr(settings, 'OVERCLOUD_AUTH_URL')
+OVERCLOUD_USERNAME = getattr(settings, 'OVERCLOUD_USERNAME')
+OVERCLOUD_PASSWORD = getattr(settings, 'OVERCLOUD_PASSWORD')
# FIXME: request isn't used right in the tuskar client right now, but looking
@@ -367,6 +370,20 @@ class Node(StringIdAPIResourceWrapper):
except:
return None
+ @property
+ def running_virtual_machines(self):
+ if not hasattr(self, '_running_virtual_machines'):
+ search_opts = {}
+ search_opts['all_tenants'] = True
+ nova_client = nova.nova_client.Client(OVERCLOUD_USERNAME,
+ OVERCLOUD_PASSWORD,
+ 'admin',
+ auth_url=OVERCLOUD_AUTH_URL)
+ self._running_virtual_machines = [s for s in
+ nova_client.servers.list(True, search_opts)
+ if s.hostId == self.id]
+ return self._running_virtual_machines
+
class Rack(StringIdAPIResourceWrapper):
"""Wrapper for the Rack object returned by the
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html
index 7dc6d457..71b83891 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/nodes/_detail_overview.html
@@ -35,6 +35,8 @@
<dd>{{ node.type|default:_("none") }}</dd>
<dt>{% trans "Provisioned Image" %}</dt>
<dd>{{ node.image|default:_("None") }}</dd>
+ <dt>{% trans "Running Instances" %}</dt>
+ <dd>{{ node.running_virtual_machines|length }}</dd>
</dl>
</div>
<div class="span4">
diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example
index 821304cd..fed29015 100644
--- a/openstack_dashboard/local/local_settings.py.example
+++ b/openstack_dashboard/local/local_settings.py.example
@@ -362,3 +362,6 @@ SECURITY_GROUP_RULES = {
# 'auth_url': 'http://localhost:5001/v2.0/',
# 'bypass_url': 'http://localhost:9774/v2/692567cd99f84f5d8f26ec23ff0ba460'
#}
+#OVERCLOUD_AUTH_URL = 'http://127.0.0.1:5000/v2.0'
+#OVERCLOUD_USERNAME = 'admin'
+#OVERCLOUD_PASSWORD = 'password'
diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py
index 796a5234..a4ee5ea6 100644
--- a/openstack_dashboard/test/settings.py
+++ b/openstack_dashboard/test/settings.py
@@ -133,3 +133,6 @@ NOVA_BAREMETAL_CREDS = {
'auth_url': 'http://localhost:5001/v2.0/',
'bypass_url': 'http://localhost:9774/v2/692567cd99f84f5d8f26ec23ff0ba460'
}
+OVERCLOUD_AUTH_URL = 'http://127.0.0.1:5000/v2.0'
+OVERCLOUD_USERNAME = 'admin'
+OVERCLOUD_PASSWORD = 'password'