Commit 8b39c899 by Őry Máté

vm: add Node.get_status_display

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