Change to user_email add TODOs
This commit is contained in:
parent
6f252def5d
commit
bd362cb619
1 changed files with 9 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import oca
|
import oca
|
||||||
|
import socket
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
|
@ -7,6 +8,7 @@ from django.views.generic import View, CreateView, FormView, ListView, DetailVie
|
||||||
DeleteView, TemplateView, UpdateView
|
DeleteView, TemplateView, UpdateView
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.contrib.auth import authenticate, login
|
from django.contrib.auth import authenticate, login
|
||||||
|
from django.contrib import messages
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from guardian.mixins import PermissionRequiredMixin
|
from guardian.mixins import PermissionRequiredMixin
|
||||||
|
@ -24,6 +26,9 @@ from .models import VirtualMachineType, VirtualMachinePlan, HostingOrder, Hostin
|
||||||
from .forms import HostingUserSignupForm, HostingUserLoginForm
|
from .forms import HostingUserSignupForm, HostingUserLoginForm
|
||||||
from .mixins import ProcessVMSelectionMixin
|
from .mixins import ProcessVMSelectionMixin
|
||||||
|
|
||||||
|
from oca.exceptions import OpenNebulaException
|
||||||
|
from oca.pool import WrongNameError
|
||||||
|
|
||||||
|
|
||||||
class DjangoHostingView(ProcessVMSelectionMixin, View):
|
class DjangoHostingView(ProcessVMSelectionMixin, View):
|
||||||
template_name = "hosting/django.html"
|
template_name = "hosting/django.html"
|
||||||
|
@ -436,6 +441,7 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV
|
||||||
context['vms'] = []
|
context['vms'] = []
|
||||||
|
|
||||||
# Connect to open nebula server
|
# Connect to open nebula server
|
||||||
|
# TODO: handle potential connection error
|
||||||
client = oca.Client("{0}:{1}".format(settings.OPENNEBULA_USERNAME,
|
client = oca.Client("{0}:{1}".format(settings.OPENNEBULA_USERNAME,
|
||||||
settings.OPENNEBULA_PASSWORD),
|
settings.OPENNEBULA_PASSWORD),
|
||||||
"{protocol}://{domain}:{port}{endpoint}".format(
|
"{protocol}://{domain}:{port}{endpoint}".format(
|
||||||
|
@ -447,11 +453,13 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV
|
||||||
# Get open nebula user id for given email
|
# Get open nebula user id for given email
|
||||||
user_pool = oca.UserPool(client)
|
user_pool = oca.UserPool(client)
|
||||||
user_pool.info()
|
user_pool.info()
|
||||||
user_id = user_pool.get_by_name('alain').id
|
# TODO: handle potential name error
|
||||||
|
user_id = user_pool.get_by_name(user_email).id
|
||||||
|
|
||||||
# Get vm_pool for given user_id
|
# Get vm_pool for given user_id
|
||||||
vm_pool = oca.VirtualMachinePool(client)
|
vm_pool = oca.VirtualMachinePool(client)
|
||||||
vm_pool.info(filter=user_id)
|
vm_pool.info(filter=user_id)
|
||||||
|
|
||||||
# Reset total price
|
# Reset total price
|
||||||
context['bill'].total_price = 0
|
context['bill'].total_price = 0
|
||||||
# Add vm in vm_pool to context
|
# Add vm in vm_pool to context
|
||||||
|
|
Loading…
Reference in a new issue