Commit 8b39c899 by Őry Máté

vm: add Node.get_status_display

parent 41f26955
...@@ -77,18 +77,19 @@ class Node(TimeStampedModel): ...@@ -77,18 +77,19 @@ class Node(TimeStampedModel):
num_cores = property(get_num_cores) num_cores = property(get_num_cores)
STATES = {False: {False: ('OFFLINE', _('offline')),
True: ('DISABLED', _('disabled'))},
True: {False: ('MISSING', _('missing')),
True: ('ONLINE', _('online'))}}
@property @property
def state(self): def state(self):
"""The state combined of online and enabled attributes. """The state combined of online and enabled attributes.
""" """
if self.enabled and self.online: return self.STATES[self.enabled][self.online][0]
return 'ONLINE'
elif self.enabled and not self.online: def get_status_display(self):
return 'MISSING' return self.STATES[self.enabled][self.online][1]
elif not self.enabled and self.online:
return 'DISABLED'
else:
return 'OFFLINE'
def disable(self, user=None): def disable(self, user=None):
''' Disable the node.''' ''' Disable the node.'''
......
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