From 0cf5e541cce433dbc8edc300ec65b19ce89c8f00 Mon Sep 17 00:00:00 2001
From: PCoder <purple.coder@yahoo.co.uk>
Date: Tue, 25 Jun 2019 02:24:14 +0200
Subject: [PATCH] Code cleanup: remove VM poweroff/resume methods + styles +
 html code

---
 .../static/hosting/css/virtual-machine.css    |  5 --
 .../hosting/virtual_machine_detail.html       | 15 -----
 opennebula_api/models.py                      | 58 -------------------
 3 files changed, 78 deletions(-)

diff --git a/hosting/static/hosting/css/virtual-machine.css b/hosting/static/hosting/css/virtual-machine.css
index abd459a0..726b0f35 100644
--- a/hosting/static/hosting/css/virtual-machine.css
+++ b/hosting/static/hosting/css/virtual-machine.css
@@ -199,11 +199,6 @@
   /* text-align: center; */
 }
 
-.vm-add-ssh-key {
-  margin: 25px 0 30px;
-  /* text-align: center; */
-}
-
 @media(min-width: 768px) {
   .vm-detail-contain {
     display: flex;
diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html
index bf869f91..ce02036f 100644
--- a/hosting/templates/hosting/virtual_machine_detail.html
+++ b/hosting/templates/hosting/virtual_machine_detail.html
@@ -80,21 +80,6 @@
 				</div>
 			</div>
 		</div>
-			{% if keys|length > 0 %}
-			    {% if not virtual_machine.status == 'canceled' %}
-				<div class="text-center vm-add-ssh-key">
-			        <button data-toggle="modal" data-target="#modal-add-ssh-key" class="btn btn-vm-invoice">{% trans "Add SSH Key" %}</button>
-			        <div class="alert alert-danger hide">
-						{% trans "Sorry, there was an unexpected error. Kindly retry." %}
-					</div>
-				</div>
-			    {% endif %}
-			{% else %}
-		        <div class="text-center">
-			        <a class="btn btn-vm-invoice" href="{% url 'hosting:ssh_keys' %}" class="hosting-dashboard-item">Add SSH Key</a>
-				</div>
-			{% endif %}
-
 		<div class="vm-contact-us">
 			<div>
 				<h2 class="vm-detail-title">{% trans "Support / Contact" %} <img class="un-icon visible-xs" src="{% static 'hosting/img/24-hours-support.svg' %}"></h2>
diff --git a/opennebula_api/models.py b/opennebula_api/models.py
index 761c84b7..478758fc 100644
--- a/opennebula_api/models.py
+++ b/opennebula_api/models.py
@@ -363,64 +363,6 @@ class OpenNebulaManager():
 
         return vm_terminated
 
-    def power_off_vm(self, vm_id):
-        vm = None
-        try:
-            vm = self.get_vm(vm_id)
-            vm.poweroff_hard()
-        except socket.timeout as socket_err:
-            logger.error("Socket timeout error: {0}".format(socket_err))
-        except OpenNebulaException as opennebula_err:
-            logger.error(
-                "OpenNebulaException error: {0}".format(opennebula_err))
-        except OSError as os_err:
-            logger.error("OSError : {0}".format(os_err))
-        except ValueError as value_err:
-            logger.error("ValueError : {0}".format(value_err))
-
-        return vm
-
-    def resume(self, vm_id):
-        vm = None
-        try:
-            vm = self.get_vm(vm_id)
-            vm.resume()
-        except socket.timeout as socket_err:
-            logger.error("Socket timeout error: {0}".format(socket_err))
-        except OpenNebulaException as opennebula_err:
-            logger.error(
-                "OpenNebulaException error: {0}".format(opennebula_err))
-        except OSError as os_err:
-            logger.error("OSError : {0}".format(os_err))
-        except ValueError as value_err:
-            logger.error("ValueError : {0}".format(value_err))
-
-        return vm
-
-    def save_key_in_vm_template(self, vm_id, ssh_key):
-        """
-        Update the template of a given VM and set the ssh key of the user
-        :param vm_id: the identifier of the VM object
-        :param ssh_key: a newline(\n) separated ssh key string that needs to be
-        set in the VM template
-        :return:
-        """
-        UPDATE_TYPE = 1
-        return_value = self.client.call(
-            'vm.updateconf',
-            vm_id,
-            '<CONTEXT><SSH_PUBLIC_KEY>%s</SSH_PUBLIC_KEY></CONTEXT>' % ssh_key,
-            UPDATE_TYPE
-        )
-        if type(return_value) == int:
-            logger.debug(
-                "Saved the key in VM Template success : %s" % return_value)
-        else:
-            logger.error(
-                "Could not save the key in VM Template. %s" % return_value)
-
-        return return_value
-
     def save_key_in_opennebula_user(self, ssh_key, update_type=1):
         """
         Save the given ssh key in OpenNebula user