From bd362cb6191fd2a2449d42b58823b547984669b1 Mon Sep 17 00:00:00 2001 From: Modulos Date: Sat, 6 May 2017 15:28:18 +0200 Subject: [PATCH] Change to user_email add TODOs --- hosting/views.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index b5a18597..923a6f29 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1,4 +1,5 @@ import oca +import socket from django.shortcuts import render 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 from django.http import HttpResponseRedirect from django.contrib.auth import authenticate, login +from django.contrib import messages from django.conf import settings from guardian.mixins import PermissionRequiredMixin @@ -24,6 +26,9 @@ from .models import VirtualMachineType, VirtualMachinePlan, HostingOrder, Hostin from .forms import HostingUserSignupForm, HostingUserLoginForm from .mixins import ProcessVMSelectionMixin +from oca.exceptions import OpenNebulaException +from oca.pool import WrongNameError + class DjangoHostingView(ProcessVMSelectionMixin, View): template_name = "hosting/django.html" @@ -436,6 +441,7 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV context['vms'] = [] # Connect to open nebula server + # TODO: handle potential connection error client = oca.Client("{0}:{1}".format(settings.OPENNEBULA_USERNAME, settings.OPENNEBULA_PASSWORD), "{protocol}://{domain}:{port}{endpoint}".format( @@ -447,11 +453,13 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin, DetailV # Get open nebula user id for given email user_pool = oca.UserPool(client) 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 vm_pool = oca.VirtualMachinePool(client) vm_pool.info(filter=user_id) + # Reset total price context['bill'].total_price = 0 # Add vm in vm_pool to context