From 35f129a4c7666df88a596fae0e3abac38845ba2f Mon Sep 17 00:00:00 2001 From: modulos Date: Thu, 25 May 2017 15:50:10 +0200 Subject: [PATCH] Add user generated public ssh keys as well --- hosting/views.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 5ba88e10..af86b825 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -341,21 +341,20 @@ class GenerateVMSSHKeysView(LoginRequiredMixin, FormView): 'form': UserHostingKeyForm(request=self.request), }) - owner = self.request.user - # Create OpenNebulaManager - manager = OpenNebulaManager(email=owner.email, - password=owner.password) - # Get OpenNebula user id - user_pool = manager._get_user_pool() - opennebula_user = user_pool.get_by_name(owner.email) + owner = self.request.user + # Create OpenNebulaManager + manager = OpenNebulaManager(email=owner.email, + password=owner.password) + # Get OpenNebula user id + user_pool = manager._get_user_pool() + opennebula_user = user_pool.get_by_name(owner.email) - # Get user ssh key - user_key = UserHostingKey.objects.get(user=owner) - # Add ssh key to user - manager.oneadmin_client.call('user.update', opennebula_user.id, - '{ssh_key}'.format(ssh_key=user_key.public_key)) + # Get user ssh key + user_key = UserHostingKey.objects.get(user=owner) + # Add ssh key to user + manager.oneadmin_client.call('user.update', opennebula_user.id, + '{ssh_key}'.format(ssh_key=user_key.public_key)) - # return HttpResponseRedirect(reverse('hosting:key_pair')) return render(self.request, self.template_name, context) def post(self, request, *args, **kwargs):