Commit 71b3d176 by Őry Máté

dashboard: use inheritance to implement MassMigrationView

parent 8b527a9e
......@@ -1101,36 +1101,8 @@ class MassOperationView(OperationView):
tuple(list(extra_bases) + [cls, vm_op]), kwargs)
class MassMigrationView(MassOperationView):
class MassMigrationView(MassOperationView, VmMigrateView):
template_name = 'dashboard/_vm-mass-migrate.html'
icon = "info"
op = "migrate"
icon = "truck"
effect = "info"
@classmethod
def check_auth(self, user=None):
if user and not user.is_superuser:
raise PermissionDenied
def get_context_data(self, **kwargs):
ctx = super(MassMigrationView, self).get_context_data(**kwargs)
ctx['nodes'] = [n for n in Node.objects.filter(enabled=True)
if n.state == "ONLINE"]
return ctx
def post(self, request, extra=None, *args, **kwargs):
if extra is None:
extra = {}
node = self.request.POST.get("node")
if node:
node = get_object_or_404(Node, pk=node)
else:
node = None
extra["to_node"] = node
return super(MassMigrationView, self).post(request, extra, *args,
**kwargs)
vm_mass_ops = OrderedDict([
('deploy', MassOperationView.factory(vm_ops['deploy'])),
......
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