Active instance count to Node
Note: Add the OVERLCOUD_AUTH_URL, OVERLCOUD_USERNAME, OVERLCOUD_PASSWORD constants to your local_settings.py Change-Id: Ib24620a7549e7c08ff3c8cf46c915565781f1925
This commit is contained in:
committed by
Tomas Sedovic
parent
3833c8de38
commit
396d76856b
@@ -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
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user