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
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
Hide 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 @@
...
@@ -55,10 +55,9 @@
<div
class=
"col-md-2"
id=
"node-info-pane"
>
<div
class=
"col-md-2"
id=
"node-info-pane"
>
<div
id=
"node-info-data"
class=
"big"
>
<div
id=
"node-info-data"
class=
"big"
>
<span
id=
"node-details-state"
class=
"label
<span
id=
"node-details-state"
class=
"label
{% if node.state == 'ONLINE' %}label-success
{% if node.state == 'ACTIVE' %}label-success
{% elif node.state == 'MISSING' %}label-danger
{% elif node.state == 'PASSIVE' %}label-danger
{% elif node.state == 'DISABLED' %}label-warning
{% else %}label-warning{% endif %}"
>
{% elif node.state == 'OFFLINE' %}label-warning{% endif %}"
>
<i
class=
"fa {{ node.get_status_icon }}"
></i>
{{ node.get_status_display|upper }}
<i
class=
"fa {{ node.get_status_icon }}"
></i>
{{ node.get_status_display|upper }}
</span>
</span>
</div>
</div>
...
...
circle/vm/models/node.py
View file @
067a35d9
...
@@ -130,20 +130,26 @@ class Node(OperatedMixin, TimeStampedModel):
...
@@ -130,20 +130,26 @@ class Node(OperatedMixin, TimeStampedModel):
warn
(
'Use Node.info["core_num"]'
,
DeprecationWarning
)
warn
(
'Use Node.info["core_num"]'
,
DeprecationWarning
)
return
self
.
info
[
'core_num'
]
return
self
.
info
[
'core_num'
]
STATES
=
{
False
:
{
False
:
(
'OFFLINE'
,
_
(
'offline
'
)),
STATES
=
{
None
:
(
'MISSING'
,
_
(
'missing
'
)),
Tru
e
:
(
'DISABLED'
,
_
(
'disabled'
))},
False
:
{
Fals
e
:
(
'DISABLED'
,
_
(
'disabled'
))},
True
:
{
False
:
(
'
MISSING'
,
_
(
'missing
'
)),
True
:
{
False
:
(
'
PASSIVE'
,
_
(
'passive
'
)),
True
:
(
'
ONLINE'
,
_
(
'onlin
e'
))}}
True
:
(
'
ACTIVE'
,
_
(
'activ
e'
))}}
def
get_state
(
self
):
def
_
get_state
(
self
):
"""The state
combined of
online and enabled attributes.
"""The state
tuple based on
online and enabled attributes.
"""
"""
return
self
.
STATES
[
self
.
enabled
][
self
.
online
][
0
]
if
self
.
online
:
return
self
.
STATES
[
self
.
enabled
][
self
.
schedule_enabled
]
state
=
property
(
get_state
)
else
:
return
self
.
STATES
[
None
]
def
get_status_display
(
self
):
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
):
def
enable
(
self
,
user
=
None
,
base_activity
=
None
):
raise
NotImplementedError
(
"Use activate or passivate instead."
)
raise
NotImplementedError
(
"Use activate or passivate instead."
)
...
@@ -291,10 +297,10 @@ class Node(OperatedMixin, TimeStampedModel):
...
@@ -291,10 +297,10 @@ class Node(OperatedMixin, TimeStampedModel):
def
get_status_icon
(
self
):
def
get_status_icon
(
self
):
return
{
return
{
'OFFLINE'
:
'fa-minus-circle'
,
'DISABLED'
:
'times-circle-o'
,
'DISABLED'
:
'fa-moon-o'
,
'MISSING'
:
'fa-warning'
,
'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'
)
'fa-question-circle'
)
def
get_status_label
(
self
):
def
get_status_label
(
self
):
...
...
circle/vm/tests/test_models.py
View file @
067a35d9
...
@@ -208,8 +208,10 @@ class NodeTestCase(TestCase):
...
@@ -208,8 +208,10 @@ class NodeTestCase(TestCase):
node
=
Mock
(
spec
=
Node
)
node
=
Mock
(
spec
=
Node
)
node
.
online
=
True
node
.
online
=
True
node
.
enabled
=
True
node
.
enabled
=
True
node
.
schedule_enabled
=
True
node
.
STATES
=
Node
.
STATES
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__
)
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