From d96d2907bc85b1d93ea369b559195a282a6c6c84 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 9 Sep 2017 20:46:43 +0530 Subject: [PATCH] Passing pass as parameter to celery task --- datacenterlight/tasks.py | 12 ++++++------ hosting/views.py | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index 2864a3a6..10208735 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -54,15 +54,15 @@ def create_vm_task(self, vm_template_id, user, specs, template, id=billing_address_id).first() customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() # Create OpenNebulaManager - if self.request.user is None: + if 'pass' in user: + manager = OpenNebulaManager(email=user.get('email'), + password=user.get('pass')) + logger.debug("Using user {user} to create VM".format( + user=user.get('email'))) + else: manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME, password=settings.OPENNEBULA_PASSWORD) logger.debug("Using OpenNebula admin user to create VM") - else: - manager = OpenNebulaManager(email=self.request.user.email, - password=self.request.user.password) - logger.debug("Using user {user} to create VM".format( - user=self.request.user.email)) vm_id = manager.create_vm( template_id=vm_template_id, diff --git a/hosting/views.py b/hosting/views.py index ea699d26..ef7b1956 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -574,7 +574,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): return self.form_invalid(form) -class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin, +class OrdersHostingDetailView(LoginRequiredMixin, DetailView): template_name = "hosting/order_detail.html" context_object_name = "order" @@ -693,7 +693,8 @@ class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin, reverse('hosting:payment') + '#payment_error') user = { 'name': self.request.user.name, - 'email': self.request.user.email + 'email': self.request.user.email, + 'pass': self.request.user.password } create_vm_task.delay(vm_template_id, user, specs, template, stripe_customer_id, billing_address_data,