Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
067a35d9
authored
Sep 24, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: use Node.schedule_enabled in Node states
parent
bf7cb98d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
18 deletions
+25
-18
circle/dashboard/templates/dashboard/node-detail.html
+3
-4
circle/vm/models/node.py
+19
-13
circle/vm/tests/test_models.py
+3
-1
No files found.
circle/dashboard/templates/dashboard/node-detail.html
View file @
067a35d9
...
...
@@ -55,10 +55,9 @@
<div
class=
"col-md-2"
id=
"node-info-pane"
>
<div
id=
"node-info-data"
class=
"big"
>
<span
id=
"node-details-state"
class=
"label
{% if node.state == 'ONLINE' %}label-success
{% elif node.state == 'MISSING' %}label-danger
{% elif node.state == 'DISABLED' %}label-warning
{% elif node.state == 'OFFLINE' %}label-warning{% endif %}"
>
{% if node.state == 'ACTIVE' %}label-success
{% elif node.state == 'PASSIVE' %}label-danger
{% else %}label-warning{% endif %}"
>
<i
class=
"fa {{ node.get_status_icon }}"
></i>
{{ node.get_status_display|upper }}
</span>
</div>
...
...
circle/vm/models/node.py
View file @
067a35d9
...
...
@@ -130,20 +130,26 @@ class Node(OperatedMixin, TimeStampedModel):
warn
(
'Use Node.info["core_num"]'
,
DeprecationWarning
)
return
self
.
info
[
'core_num'
]
STATES
=
{
False
:
{
False
:
(
'OFFLINE'
,
_
(
'offline
'
)),
Tru
e
:
(
'DISABLED'
,
_
(
'disabled'
))},
True
:
{
False
:
(
'
MISSING'
,
_
(
'missing
'
)),
True
:
(
'
ONLINE'
,
_
(
'onlin
e'
))}}
STATES
=
{
None
:
(
'MISSING'
,
_
(
'missing
'
)),
False
:
{
Fals
e
:
(
'DISABLED'
,
_
(
'disabled'
))},
True
:
{
False
:
(
'
PASSIVE'
,
_
(
'passive
'
)),
True
:
(
'
ACTIVE'
,
_
(
'activ
e'
))}}
def
get_state
(
self
):
"""The state
combined of
online and enabled attributes.
def
_
get_state
(
self
):
"""The state
tuple based on
online and enabled attributes.
"""
return
self
.
STATES
[
self
.
enabled
][
self
.
online
][
0
]
state
=
property
(
get_state
)
if
self
.
online
:
return
self
.
STATES
[
self
.
enabled
][
self
.
schedule_enabled
]
else
:
return
self
.
STATES
[
None
]
def
get_status_display
(
self
):
return
self
.
STATES
[
self
.
enabled
][
self
.
online
][
1
]
return
self
.
_get_state
()[
1
]
def
get_state
(
self
):
return
self
.
_get_state
()[
0
]
state
=
property
(
get_state
)
def
enable
(
self
,
user
=
None
,
base_activity
=
None
):
raise
NotImplementedError
(
"Use activate or passivate instead."
)
...
...
@@ -291,10 +297,10 @@ class Node(OperatedMixin, TimeStampedModel):
def
get_status_icon
(
self
):
return
{
'OFFLINE'
:
'fa-minus-circle'
,
'DISABLED'
:
'fa-moon-o'
,
'DISABLED'
:
'times-circle-o'
,
'MISSING'
:
'fa-warning'
,
'ONLINE'
:
'fa-play-circle'
}
.
get
(
self
.
get_state
(),
'PASSIVE'
:
'fa-play-circle-o'
,
'ACTIVE'
:
'fa-play-circle'
}
.
get
(
self
.
get_state
(),
'fa-question-circle'
)
def
get_status_label
(
self
):
...
...
circle/vm/tests/test_models.py
View file @
067a35d9
...
...
@@ -208,8 +208,10 @@ class NodeTestCase(TestCase):
node
=
Mock
(
spec
=
Node
)
node
.
online
=
True
node
.
enabled
=
True
node
.
schedule_enabled
=
True
node
.
STATES
=
Node
.
STATES
self
.
assertEqual
(
Node
.
get_state
(
node
),
"ONLINE"
)
node
.
_get_state
=
lambda
:
Node
.
_get_state
(
node
)
self
.
assertEqual
(
Node
.
get_state
(
node
),
"ACTIVE"
)
assert
isinstance
(
Node
.
get_status_display
(
node
),
_
(
"x"
)
.
__class__
)
...
...
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