From 612e11736e350fa593485ced7dd26d7f2d1493af Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 13 Sep 2017 05:37:26 +0530 Subject: [PATCH] Corrected obtaining values from vm_data dict --- hosting/views.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 012040f4..e6d68a9e 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -984,9 +984,9 @@ class VirtualMachineView(LoginRequiredMixin, View): # Remove all keys belonging to the IP(s) # ssh-keygen -R ip_address - if vm_data.ipv4 is not None: - if ', ' in vm_data.ipv4: - vm_ips = vm_data.ipv4.split(', ') + if vm_data['ipv4'] is not None: + if ', ' in vm_data['ipv4']: + vm_ips = vm_data['ipv4'].split(', ') for ip_address in vm_ips: try: subprocess.check_output( @@ -1000,15 +1000,15 @@ class VirtualMachineView(LoginRequiredMixin, View): else: try: subprocess.check_output( - ['ssh-keygen', '-R', vm_data.ipv4]) + ['ssh-keygen', '-R', vm_data['ipv4']]) except subprocess.CalledProcessError as cpe: logger.debug( """Could not remove key belonging to {ip}. - Error details: {details}""".format(ip=vm_data.ipv4, + Error details: {details}""".format(ip=vm_data['ipv4'], details=str(cpe))) - if vm_data.ipv6 is not None: - if ', ' in vm_data.ipv6: - vm_ips = vm_data.ipv6.split(', ') + if vm_data['ipv6'] is not None: + if ', ' in vm_data['ipv6']: + vm_ips = vm_data['ipv6'].split(', ') for ip_address in vm_ips: try: subprocess.check_output( @@ -1022,11 +1022,11 @@ class VirtualMachineView(LoginRequiredMixin, View): else: try: subprocess.check_output( - ['ssh-keygen', '-R', vm_data.ipv6]) + ['ssh-keygen', '-R', vm_data['ipv6']]) except subprocess.CalledProcessError as cpe: logger.debug( """Could not remove key belonging to {ip}. - Error details: {details}""".format(ip=vm_data.ipv6, + Error details: {details}""".format(ip=vm_data['ipv6'], details=str(cpe))) return HttpResponseRedirect(self.get_success_url())