From 817f800fbd4e126e90b10b40a24f70c2dfadad21 Mon Sep 17 00:00:00 2001 From: Levi Date: Sun, 11 Jun 2017 11:44:14 -0500 Subject: [PATCH] fixed #3350 --- hosting/views.py | 2 +- opennebula_api/models.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index d99342e2..fc7796e1 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -369,7 +369,7 @@ class SSHKeyCreateView(LoginRequiredMixin, FormView): manager = OpenNebulaManager() # Get user ssh key - public_key = form.cleaned_data.get('public_key') + public_key = form.cleaned_data.get('public_key', '').decode('utf-8') # Add ssh key to user try: manager.add_public_key(user=owner, public_key=public_key, merge=True) diff --git a/opennebula_api/models.py b/opennebula_api/models.py index 4165e344..77c95db4 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -449,6 +449,7 @@ class OpenNebulaManager(): """ # TODO: Check if we can remove this first try because we basically just # raise the possible Errors + try: open_user = self._get_user(user) try: @@ -492,7 +493,8 @@ class OpenNebulaManager(): try: old_key = open_user.template.ssh_public_key if public_key not in old_key: - raise KeyDoesNotExistsError() + return False + # raise KeyDoesNotExistsError() if '\n{}'.format(public_key) in old_key: public_key = old_key.replace('\n{}'.format(public_key), '') else: