Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c2b89065
authored
Nov 02, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: display minion status in node list view
parent
38b6f781
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
4 deletions
+79
-4
circle/dashboard/tables.py
+9
-2
circle/dashboard/templates/dashboard/node-detail/resources.html
+3
-2
circle/vm/models/node.py
+67
-0
No files found.
circle/dashboard/tables.py
View file @
c2b89065
...
...
@@ -19,7 +19,8 @@ from __future__ import absolute_import
from
django.contrib.auth.models
import
Group
,
User
from
django_tables2
import
Table
,
A
from
django_tables2.columns
import
TemplateColumn
,
Column
,
LinkColumn
from
django_tables2.columns
import
(
TemplateColumn
,
Column
,
LinkColumn
,
BooleanColumn
)
from
vm.models
import
Node
,
InstanceTemplate
,
Lease
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -67,12 +68,18 @@ class NodeListTable(Table):
orderable
=
False
,
)
minion_online
=
BooleanColumn
(
verbose_name
=
_
(
"Minion online"
),
attrs
=
{
'th'
:
{
'class'
:
'node-list-table-thin'
}},
orderable
=
False
,
)
class
Meta
:
model
=
Node
attrs
=
{
'class'
:
(
'table table-bordered table-striped table-hover '
'node-list-table'
)}
fields
=
(
'pk'
,
'name'
,
'host'
,
'get_status_display'
,
'priority'
,
'overcommit'
,
'number_of_VMs'
,
)
'
minion_online'
,
'
overcommit'
,
'number_of_VMs'
,
)
class
GroupListTable
(
Table
):
...
...
circle/dashboard/templates/dashboard/node-detail/resources.html
View file @
c2b89065
...
...
@@ -7,8 +7,9 @@
<dt>
{% trans "RAM size" %}:
</dt>
<dd>
{% widthratio node.info.ram_size 1048576 1 %} MiB
</dd>
<dt>
{% trans "Architecture" %}:
</dt><dd>
{{ node.info.architecture }}
</dd>
<dt>
{% trans "Host IP" %}:
</dt><dd>
{{ node.host.ipv4 }}
</dd>
<dt>
{% trans "Enabled" %}:
</dt><dd>
{{ node.enabled }}
</dd>
<dt>
{% trans "Host online" %}:
</dt><dd>
{{ node.online }}
</dd>
<dt>
{% trans "Enabled" %}:
</dt><dd>
{{ node.enabled|yesno }}
</dd>
<dt>
{% trans "Host online" %}:
</dt><dd>
{{ node.online|yesno }}
</dd>
<dt>
{% trans "Minion online" %}:
</dt><dd>
{{ node.minion_online|yesno }}
</dd>
<dt>
{% trans "Priority" %}:
</dt><dd>
{{ node.priority }}
</dd>
<dt>
{% trans "Driver Version:" %}
</dt>
<dd>
...
...
circle/vm/models/node.py
View file @
c2b89065
...
...
@@ -17,9 +17,14 @@
from
__future__
import
absolute_import
,
unicode_literals
from
functools
import
update_wrapper
from
glob
import
glob
from
logging
import
getLogger
import
os.path
from
warnings
import
warn
import
requests
from
salt.client
import
LocalClient
import
salt.utils
from
time
import
time
,
sleep
from
django.conf
import
settings
from
django.db.models
import
(
...
...
@@ -44,6 +49,56 @@ from .common import Trait
logger
=
getLogger
(
__name__
)
class
MyLocalClient
(
LocalClient
):
def
get_returns
(
self
,
jid
,
minions
,
timeout
=
None
):
'''
Get the returns for the command line interface via the event system
'''
minions
=
set
(
minions
)
if
timeout
is
None
:
timeout
=
self
.
opts
[
'timeout'
]
jid_dir
=
salt
.
utils
.
jid_dir
(
jid
,
self
.
opts
[
'cachedir'
],
self
.
opts
[
'hash_type'
])
start
=
time
()
timeout_at
=
start
+
timeout
found
=
set
()
ret
=
{}
wtag
=
os
.
path
.
join
(
jid_dir
,
'wtag*'
)
# Check to see if the jid is real, if not return the empty dict
if
not
os
.
path
.
isdir
(
jid_dir
):
logger
.
warning
(
"jid_dir (
%
s) does not exist"
,
jid_dir
)
return
ret
# Wait for the hosts to check in
while
True
:
time_left
=
timeout_at
-
time
()
raw
=
self
.
event
.
get_event
(
time_left
,
jid
)
if
raw
is
not
None
and
'return'
in
raw
:
found
.
add
(
raw
[
'id'
])
ret
[
raw
[
'id'
]]
=
raw
[
'return'
]
if
len
(
found
.
intersection
(
minions
))
>=
len
(
minions
):
# All minions have returned, break out of the loop
logger
.
debug
(
"jid
%
s found all minions"
,
jid
)
break
continue
# Then event system timeout was reached and nothing was returned
if
len
(
found
.
intersection
(
minions
))
>=
len
(
minions
):
# All minions have returned, break out of the loop
logger
.
debug
(
"jid
%
s found all minions"
,
jid
)
break
if
glob
(
wtag
)
and
time
()
<=
timeout_at
+
1
:
# The timeout +1 has not been reached and there is still a
# write tag for the syndic
continue
if
time
()
>
timeout_at
:
logger
.
info
(
'jid
%
s minions
%
s did not return in time'
,
jid
,
(
minions
-
found
))
break
sleep
(
0.01
)
return
ret
def
node_available
(
function
):
"""Decorate methods to ignore disabled Nodes.
"""
...
...
@@ -111,6 +166,18 @@ class Node(OperatedMixin, TimeStampedModel):
online
=
property
(
get_online
)
@method_cache
(
20
)
def
get_minion_online
(
self
):
name
=
self
.
host
.
hostname
client
=
MyLocalClient
()
client
.
opts
[
'timeout'
]
=
0.2
try
:
return
bool
(
client
.
cmd
(
name
,
'test.ping'
)[
name
])
except
KeyError
:
return
False
minion_online
=
property
(
get_minion_online
)
@node_available
@method_cache
(
300
)
def
get_info
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment