Commit 067a35d9 by Őry Máté

vm: use Node.schedule_enabled in Node states

parent bf7cb98d
......@@ -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 }}
......@@ -130,20 +130,26 @@ class Node(OperatedMixin, TimeStampedModel):
warn('Use["core_num"]', DeprecationWarning)
STATES = {False: {False: ('OFFLINE', _('offline')),
True: ('DISABLED', _('disabled'))},
True: {False: ('MISSING', _('missing')),
True: ('ONLINE', _('online'))}}
STATES = {None: ('MISSING', _('missing')),
False: {False: ('DISABLED', _('disabled'))},
True: {False: ('PASSIVE', _('passive')),
True: ('ACTIVE', _('active'))}}
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][][0]
state = property(get_state)
return self.STATES[self.enabled][self.schedule_enabled]
return self.STATES[None]
def get_status_display(self):
return self.STATES[self.enabled][][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(),
def get_status_label(self):
......@@ -208,8 +208,10 @@ class NodeTestCase(TestCase):
node = Mock(spec=Node) = True
node.enabled = True
node.schedule_enabled = True
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__)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment