1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-11-01 03:54:15 +00:00

instance/clone adds title and description input fields

This commit is contained in:
Jan Krcmar 2016-02-24 13:08:43 +01:00
parent 6c4a3a93e3
commit 2aa81ccecb
2 changed files with 30 additions and 9 deletions

View file

@ -729,6 +729,18 @@
{% endifequal %}
</div>
{% endfor %}
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Title" %}</label>
<div class="col-sm-6">
<input type="text" name="clone-title" class="form-control">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">{% trans "Description" %}</label>
<div class="col-sm-6">
<textarea name="clone-description" class="form-control"></textarea>
</div>
</div>
{% ifequal status 5 %}
<button type="submit" class="btn btn-lg btn-success pull-right" name="clone">{% trans "Clone" %}</button>
{% else %}

View file

@ -692,6 +692,12 @@ class wvmInstance(wvmConnect):
storage = self.get_wvmStorage(pool_name)
storage.clone_volume(vol_name, target_file)
options = {
'title': clone_data.get('clone-title', ''),
'description': clone_data.get('clone-description', ''),
}
self._set_options(tree, options)
self._defineXML(ElementTree.tostring(tree))
def change_network(self, network_data):
@ -708,16 +714,10 @@ class wvmInstance(wvmConnect):
new_xml = ElementTree.tostring(tree)
self._defineXML(new_xml)
def set_options(self, options):
"""
Function change description, title
"""
xml = self._XMLDesc(VIR_DOMAIN_XML_SECURE)
tree = ElementTree.fromstring(xml)
def _set_options(self, tree, options):
for o in ['title', 'description']:
option = tree.find(o)
option_value = str(options[o]).strip()
option_value = str(options.get(o, '')).strip()
if not option_value:
if not option is None:
tree.remove(option)
@ -726,6 +726,15 @@ class wvmInstance(wvmConnect):
option = ElementTree.SubElement(tree, o)
option.text = option_value
def set_options(self, options):
"""
Function change description, title
"""
xml = self._XMLDesc(VIR_DOMAIN_XML_SECURE)
tree = ElementTree.fromstring(xml)
self._set_options(tree, options)
new_xml = ElementTree.tostring(tree)
self._defineXML(new_xml)