1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +00:00

Add capability to remove UEFI instances: Add option for NVRAM delete

This commit is contained in:
catborise 2019-12-13 16:40:59 +03:00
parent 3a925af3c2
commit 28b001e7cb
2 changed files with 21 additions and 4 deletions

View file

@ -1524,9 +1524,17 @@
<div class="checkbox" style="margin-left: 8px;">
<label>
<input type="checkbox" name="delete_disk" value="true" checked>
<strong>{% trans "Remove Instance's data" %}</strong>
<strong>{% trans "Remove Instance's disks" %}</strong>
</label>
</div>
{% if nvram %}
<div class="checkbox" style="margin-left: 8px;">
<label>
<input type="checkbox" name="delete_nvram" value="true" checked>
<strong>{% trans "Remove Instance's NVRAM" %}</strong>
</label>
</div>
{% endif %}
<button type="submit" class="btn btn-lg btn-success pull-right" name="delete">{% trans "Destroy" %}</button>
</form>
{% endifequal %}

View file

@ -2,7 +2,7 @@ import time
import os.path
try:
from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_MIGRATE_LIVE, VIR_MIGRATE_UNSAFE, VIR_DOMAIN_RUNNING, \
VIR_DOMAIN_AFFECT_LIVE, VIR_DOMAIN_AFFECT_CONFIG
VIR_DOMAIN_AFFECT_LIVE, VIR_DOMAIN_AFFECT_CONFIG, VIR_DOMAIN_UNDEFINE_NVRAM, VIR_DOMAIN_UNDEFINE_KEEP_NVRAM
except:
from libvirt import libvirtError, VIR_DOMAIN_XML_SECURE, VIR_MIGRATE_LIVE
@ -150,8 +150,8 @@ class wvmInstance(wvmConnect):
def resume(self):
self.instance.resume()
def delete(self):
self.instance.undefine()
def delete(self, flags=0):
self.instance.undefineFlags(flags)
def _XMLDesc(self, flag):
return self.instance.XMLDesc(flag)
@ -186,6 +186,15 @@ class wvmInstance(wvmConnect):
if cur_vcpu:
return int(cur_vcpu)
def get_arch(self):
return util.get_xml_path(self._XMLDesc(0), "/domain/os/type/@arch")
def get_machine_type(self):
return util.get_xml_path(self._XMLDesc(0), "/domain/os/type/@machine")
def get_nvram(self):
return util.get_xml_path(self._XMLDesc(0), "/domain/os/nvram")
def get_vcpus(self):
vcpus = OrderedDict()
tree = etree.fromstring(self._XMLDesc(0))