- def action(self, entity, action, extras):
+ def get_vm_actions(self, entity ,vm_state):
+
+ actions = []
+
+ status_dict = {'ACTIVE' : 'active',
+ 'STOPPED' : 'inactive',
+ 'REBOOT' : 'inactive',
+ 'ERROR' : 'inactive',
+ 'BUILD' : 'inactive',
+ 'DELETED' : 'inactive',
+ 'UNKNOWN' : 'inactive'
+ }
+
+ if vm_state in status_dict:
+
+ entity.attributes['occi.compute.state'] = status_dict[vm_state]
+ if vm_state == 'ACTIVE':
+ actions.append(infrastructure.STOP)
+ actions.append(infrastructure.RESTART)
+ elif vm_state in ('STOPPED'):
+ actions.append(infrastructure.START)
+
+ return actions
+ else:
+ raise HTTPError(500, 'Undefined status of the VM')
+
+ def action(self, entity, action, attributes, extras):