Code cleanup: remove VM poweroff/resume methods + styles + html code

This commit is contained in:
PCoder 2019-06-25 02:24:14 +02:00
parent 08608c726f
commit 0cf5e541cc
3 changed files with 0 additions and 78 deletions

View file

@ -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;

View file

@ -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>

View file

@ -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