Passing pass as parameter to celery task

This commit is contained in:
PCoder 2017-09-09 20:46:43 +05:30
parent 085786907c
commit d96d2907bc
2 changed files with 9 additions and 8 deletions

View file

@ -54,15 +54,15 @@ def create_vm_task(self, vm_template_id, user, specs, template,
id=billing_address_id).first() id=billing_address_id).first()
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first() customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
# Create OpenNebulaManager # 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, manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME,
password=settings.OPENNEBULA_PASSWORD) password=settings.OPENNEBULA_PASSWORD)
logger.debug("Using OpenNebula admin user to create VM") 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( vm_id = manager.create_vm(
template_id=vm_template_id, template_id=vm_template_id,

View file

@ -574,7 +574,7 @@ class PaymentVMView(LoginRequiredMixin, FormView):
return self.form_invalid(form) return self.form_invalid(form)
class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin, class OrdersHostingDetailView(LoginRequiredMixin,
DetailView): DetailView):
template_name = "hosting/order_detail.html" template_name = "hosting/order_detail.html"
context_object_name = "order" context_object_name = "order"
@ -693,7 +693,8 @@ class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin,
reverse('hosting:payment') + '#payment_error') reverse('hosting:payment') + '#payment_error')
user = { user = {
'name': self.request.user.name, '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, create_vm_task.delay(vm_template_id, user, specs, template,
stripe_customer_id, billing_address_data, stripe_customer_id, billing_address_data,