Commit 24523323 by Kálmán Viktor

dashboard: reuse mass operation attrs from regular operations

parent 47d5aad7
...@@ -1079,6 +1079,13 @@ class MassOperationView(OperationView): ...@@ -1079,6 +1079,13 @@ class MassOperationView(OperationView):
op.check_precond() op.check_precond()
return op return op
@classmethod
def factory(cls, vm_op, extra_bases=(), **kwargs):
kwargs.update({'op': vm_op.op, 'icon': vm_op.icon,
'effect': vm_op.effect})
return type(str(cls.__name__ + vm_op.op),
tuple(list(extra_bases) + [cls]), kwargs)
class MassMigrationView(MassOperationView): class MassMigrationView(MassOperationView):
template_name = 'dashboard/_vm-mass-migrate.html' template_name = 'dashboard/_vm-mass-migrate.html'
...@@ -1103,21 +1110,14 @@ class MassMigrationView(MassOperationView): ...@@ -1103,21 +1110,14 @@ class MassMigrationView(MassOperationView):
**kwargs) **kwargs)
vm_mass_ops = OrderedDict([ vm_mass_ops = OrderedDict([
('deploy', MassOperationView.factory( ('deploy', MassOperationView.factory(vm_ops['deploy'])),
op='deploy', icon='play', effect='success')), ('wake_up', MassOperationView.factory(vm_ops['wake_up'])),
('wake_up', MassOperationView.factory( ('sleep', MassOperationView.factory(vm_ops['sleep'])),
op='wake_up', icon='sun-o', effect='success')), ('reboot', MassOperationView.factory(vm_ops['reboot'])),
('sleep', MassOperationView.factory( ('reset', MassOperationView.factory(vm_ops['reset'])),
op='sleep', icon='moon-o', effect='info')), ('shut_off', MassOperationView.factory(vm_ops['shut_off'])),
('reboot', MassOperationView.factory(
op='reboot', icon='refresh', effect='warning')),
('reset', MassOperationView.factory(
op='reset', icon='bolt', effect='warning')),
('shut_off', MassOperationView.factory(
op='shut_off', icon='ban', effect='warning')),
('migrate', MassMigrationView), ('migrate', MassMigrationView),
('destroy', MassOperationView.factory( ('destroy', MassOperationView.factory(vm_ops['destroy'])),
op='destroy', icon='times', effect='danger')),
]) ])
......
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