Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
40175563
authored
Jan 11, 2019
by
Turcsik Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'node_list_error' into 'master'
Node list error See merge request
!399
parents
a001ad0d
0646721b
Pipeline
#688
passed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
+27
-4
circle/dashboard/views/node.py
+11
-0
circle/vm/models/node.py
+16
-4
No files found.
circle/dashboard/views/node.py
View file @
40175563
...
...
@@ -210,9 +210,20 @@ class NodeList(LoginRequiredMixin, GraphMixin, SingleTableView):
return
super
(
NodeList
,
self
)
.
get
(
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
self
.
wrong_nodes_message
()
return
Node
.
objects
.
annotate
(
number_of_VMs
=
Count
(
'instance_set'
))
.
select_related
(
'host'
)
def
wrong_nodes_message
(
self
):
wrong_nodes
=
[]
for
node
in
Node
.
objects
.
all
():
if
node
.
monitor_info
is
None
:
wrong_nodes
.
append
(
node
.
name
)
message
=
', '
.
join
(
wrong_nodes
)
if
wrong_nodes
:
messages
.
error
(
self
.
request
,
"Can't reach "
+
message
+
" monitor info"
)
class
NodeCreate
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
TemplateView
):
...
...
circle/vm/models/node.py
View file @
40175563
...
...
@@ -35,7 +35,7 @@ from django.db.models import (
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
celery.exceptions
import
TimeoutError
from
celery.exceptions
import
TimeoutError
,
TaskRevokedError
from
model_utils.models
import
TimeStampedModel
from
taggit.managers
import
TaggableManager
...
...
@@ -315,7 +315,7 @@ class Node(OperatedMixin, TimeStampedModel):
queue
=
self
.
get_remote_queue_name
(
'vm'
,
priority
),
expires
=
timeout
+
60
)
return
r
.
get
(
timeout
=
timeout
)
except
(
TimeoutError
,
WorkerNotFound
):
except
(
TimeoutError
,
WorkerNotFound
,
TaskRevokedError
):
if
raise_
:
raise
else
:
...
...
@@ -363,15 +363,27 @@ class Node(OperatedMixin, TimeStampedModel):
def
driver_version
(
self
):
return
self
.
info
.
get
(
'driver_version'
)
def
get_monitor_info
(
self
,
metric
):
# return with the metric value if the monitor info not none
# or return 0 if its None or the metric unreachable
if
self
.
monitor_info
is
None
:
logger
.
warning
(
'Monitor info is None'
)
return
0
elif
self
.
monitor_info
.
get
(
metric
)
is
None
:
logger
.
warning
(
'Unreachable monitor info of: '
+
metric
)
return
0
else
:
return
self
.
monitor_info
.
get
(
metric
)
@property
@node_available
def
cpu_usage
(
self
):
return
self
.
monitor_info
.
get
(
'cpu.percent'
)
/
100
return
self
.
get_monitor_info
(
'cpu.percent'
)
/
100
@property
@node_available
def
ram_usage
(
self
):
return
self
.
monitor_info
.
get
(
'memory.usage'
)
/
100
return
self
.
get_monitor_info
(
'memory.usage'
)
/
100
@property
@node_available
...
...
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