1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 23:25:24 +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 %} {% endifequal %}
</div> </div>
{% endfor %} {% 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 %} {% ifequal status 5 %}
<button type="submit" class="btn btn-lg btn-success pull-right" name="clone">{% trans "Clone" %}</button> <button type="submit" class="btn btn-lg btn-success pull-right" name="clone">{% trans "Clone" %}</button>
{% else %} {% else %}

View file

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