Use username for opennebula related tasks
This commit is contained in:
parent
45af92e049
commit
e2c86116b2
5 changed files with 18 additions and 17 deletions
|
@ -1013,7 +1013,7 @@ class OrderConfirmationView(DetailView, FormView):
|
||||||
|
|
||||||
owner = new_user
|
owner = new_user
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email,
|
email=owner.username,
|
||||||
password=owner.password
|
password=owner.password
|
||||||
)
|
)
|
||||||
keys_to_save = get_all_public_keys(new_user)
|
keys_to_save = get_all_public_keys(new_user)
|
||||||
|
|
|
@ -478,7 +478,7 @@ class SSHKeyDeleteView(LoginRequiredMixin, DeleteView):
|
||||||
def delete(self, request, *args, **kwargs):
|
def delete(self, request, *args, **kwargs):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email,
|
email=owner.username,
|
||||||
password=owner.password
|
password=owner.password
|
||||||
)
|
)
|
||||||
pk = self.kwargs.get('pk')
|
pk = self.kwargs.get('pk')
|
||||||
|
@ -532,7 +532,7 @@ class SSHKeyChoiceView(LoginRequiredMixin, View):
|
||||||
ssh_key.private_key.save(filename, content)
|
ssh_key.private_key.save(filename, content)
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email,
|
email=owner.username,
|
||||||
password=owner.password
|
password=owner.password
|
||||||
)
|
)
|
||||||
keys = get_all_public_keys(request.user)
|
keys = get_all_public_keys(request.user)
|
||||||
|
@ -952,7 +952,7 @@ class OrdersHostingDetailView(LoginRequiredMixin, DetailView, FormView):
|
||||||
except VMDetail.DoesNotExist:
|
except VMDetail.DoesNotExist:
|
||||||
try:
|
try:
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email, password=owner.password
|
email=owner.username, password=owner.password
|
||||||
)
|
)
|
||||||
vm = manager.get_vm(obj.vm_id)
|
vm = manager.get_vm(obj.vm_id)
|
||||||
context['vm'] = VirtualMachineSerializer(vm).data
|
context['vm'] = VirtualMachineSerializer(vm).data
|
||||||
|
@ -1482,7 +1482,7 @@ class VirtualMachinesPlanListView(LoginRequiredMixin, ListView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
try:
|
try:
|
||||||
queryset = manager.get_vms()
|
queryset = manager.get_vms()
|
||||||
|
@ -1643,7 +1643,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
vm = None
|
vm = None
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email,
|
email=owner.username,
|
||||||
password=owner.password
|
password=owner.password
|
||||||
)
|
)
|
||||||
vm_id = self.kwargs.get('pk')
|
vm_id = self.kwargs.get('pk')
|
||||||
|
@ -1727,7 +1727,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
vm = self.get_object()
|
vm = self.get_object()
|
||||||
|
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email,
|
email=owner.username,
|
||||||
password=owner.password
|
password=owner.password
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
@ -1755,7 +1755,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
error_msg = result.get('error')
|
error_msg = result.get('error')
|
||||||
logger.error(
|
logger.error(
|
||||||
'Error canceling subscription for {user} and vm id '
|
'Error canceling subscription for {user} and vm id '
|
||||||
'{vm_id}'.format(user=owner.email, vm_id=vm.id)
|
'{vm_id}'.format(user=owner.username, vm_id=vm.id)
|
||||||
)
|
)
|
||||||
logger.error(error_msg)
|
logger.error(error_msg)
|
||||||
admin_email_body['stripe_error_msg'] = error_msg
|
admin_email_body['stripe_error_msg'] = error_msg
|
||||||
|
@ -1827,6 +1827,7 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
email.send()
|
email.send()
|
||||||
admin_email_body.update(response)
|
admin_email_body.update(response)
|
||||||
admin_email_body["customer_email"] = owner.email
|
admin_email_body["customer_email"] = owner.email
|
||||||
|
admin_email_body["customer_username"] = owner.username
|
||||||
admin_email_body["VM_ID"] = vm.id
|
admin_email_body["VM_ID"] = vm.id
|
||||||
admin_email_body["VM_created_at"] = (str(hosting_order.created_at) if
|
admin_email_body["VM_created_at"] = (str(hosting_order.created_at) if
|
||||||
hosting_order is not None
|
hosting_order is not None
|
||||||
|
@ -1844,9 +1845,9 @@ class VirtualMachineView(LoginRequiredMixin, View):
|
||||||
)
|
)
|
||||||
admin_email_body["subscription_amount"] = total_amount/100
|
admin_email_body["subscription_amount"] = total_amount/100
|
||||||
admin_email_body["subscription_detail"] = content
|
admin_email_body["subscription_detail"] = content
|
||||||
admin_msg_sub = "VM and Subscription for VM {} and user: {}".format(
|
admin_msg_sub = "VM and Subscription for VM {} and user: {}, {}".format(
|
||||||
vm.id,
|
vm.id,
|
||||||
owner.email
|
owner.email, owner.username
|
||||||
)
|
)
|
||||||
email_to_admin_data = {
|
email_to_admin_data = {
|
||||||
'subject': ("Deleted " if response['status']
|
'subject': ("Deleted " if response['status']
|
||||||
|
@ -1892,7 +1893,7 @@ class HostingBillDetailView(PermissionRequiredMixin, LoginRequiredMixin,
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super(DetailView, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
# Get vms
|
# Get vms
|
||||||
queryset = manager.get_vms()
|
queryset = manager.get_vms()
|
||||||
|
|
|
@ -86,7 +86,7 @@ class VirtualMachineSerializer(serializers.Serializer):
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password,
|
password=owner.password,
|
||||||
)
|
)
|
||||||
opennebula_id = manager.create_vm(template_id=template_id,
|
opennebula_id = manager.create_vm(template_id=template_id,
|
||||||
|
|
|
@ -19,7 +19,7 @@ class VmCreateView(generics.ListCreateAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
# We may have ConnectionRefusedError if we don't have a
|
# We may have ConnectionRefusedError if we don't have a
|
||||||
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
||||||
|
@ -42,7 +42,7 @@ class VmDetailsView(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
# We may have ConnectionRefusedError if we don't have a
|
# We may have ConnectionRefusedError if we don't have a
|
||||||
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
||||||
|
@ -54,7 +54,7 @@ class VmDetailsView(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
# We may have ConnectionRefusedError if we don't have a
|
# We may have ConnectionRefusedError if we don't have a
|
||||||
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
||||||
|
@ -66,7 +66,7 @@ class VmDetailsView(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
|
||||||
def perform_destroy(self, instance):
|
def perform_destroy(self, instance):
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(email=owner.email,
|
manager = OpenNebulaManager(email=owner.username,
|
||||||
password=owner.password)
|
password=owner.password)
|
||||||
# We may have ConnectionRefusedError if we don't have a
|
# We may have ConnectionRefusedError if we don't have a
|
||||||
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
# connection to OpenNebula. For now, we raise ServiceUnavailable
|
||||||
|
|
|
@ -228,7 +228,7 @@ class SSHKeyCreateView(FormView):
|
||||||
if self.request.user.is_authenticated():
|
if self.request.user.is_authenticated():
|
||||||
owner = self.request.user
|
owner = self.request.user
|
||||||
manager = OpenNebulaManager(
|
manager = OpenNebulaManager(
|
||||||
email=owner.email,
|
email=owner.username,
|
||||||
password=owner.password
|
password=owner.password
|
||||||
)
|
)
|
||||||
keys_to_save = get_all_public_keys(self.request.user)
|
keys_to_save = get_all_public_keys(self.request.user)
|
||||||
|
|
Loading…
Reference in a new issue