mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 15:15:22 +00:00
Add destination storage option for instance creation from a template.
This commit is contained in:
parent
1aea7baada
commit
fc6761aabc
3 changed files with 25 additions and 4 deletions
|
@ -441,7 +441,7 @@
|
|||
<label class="col-sm-3 control-label">{% trans "HDD" %}</label>
|
||||
<input id="images" name="images" type="hidden" value=""/>
|
||||
<div class="col-sm-3">
|
||||
<select id="storage" name="storage" class="form-control" onchange="get_template_vols({{ compute_id }}, value);">
|
||||
<select class="form-control" onchange="get_template_vols({{ compute_id }}, value);">
|
||||
{% if storages %}
|
||||
<option value disabled selected>{% trans "Select pool" %}...</option>
|
||||
{% for storage in storages %}
|
||||
|
@ -458,6 +458,20 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">{% trans "Storage" %}</label>
|
||||
<div class="col-sm-7">
|
||||
<select id="storage" name="storage" class="form-control" disabled>
|
||||
{% if storages %}
|
||||
{% for storage in storages %}
|
||||
<option value="{{ storage }}" >{{ storage }}</option>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<option value="">{% trans "None" %}</option>
|
||||
{% endif %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group meta-prealloc">
|
||||
<label class="col-sm-3 control-label">{% trans "Metadata" %}</label>
|
||||
<div class="col-sm-7">
|
||||
|
@ -697,6 +711,9 @@
|
|||
});
|
||||
});
|
||||
$("#template").removeAttr("disabled");
|
||||
$("#storage").val(pool).change();
|
||||
$("#storage").removeAttr("disabled");
|
||||
|
||||
}
|
||||
|
||||
function get_disk_bus_choices(compute_id, dev_idx, disk_type){
|
||||
|
|
|
@ -134,7 +134,7 @@ def create_instance(request, compute_id):
|
|||
error_msg = _("Image has already exist. Please check volumes or change instance name")
|
||||
error_messages.append(error_msg)
|
||||
else:
|
||||
clone_path = conn.clone_from_template(data['name'], templ_path, metadata=meta_prealloc)
|
||||
clone_path = conn.clone_from_template(data['name'], templ_path, data['storage'], metadata=meta_prealloc)
|
||||
volume = dict()
|
||||
volume['path'] = clone_path
|
||||
volume['type'] = conn.get_volume_type(clone_path)
|
||||
|
|
|
@ -118,9 +118,13 @@ class wvmCreate(wvmConnect):
|
|||
vol = self.get_volume_by_path(vol_path)
|
||||
return vol.storagePoolLookupByVolume()
|
||||
|
||||
def clone_from_template(self, clone, template, metadata=False, owner=default_owner):
|
||||
def clone_from_template(self, clone, template, storage=None, metadata=False, owner=default_owner):
|
||||
vol = self.get_volume_by_path(template)
|
||||
if not storage:
|
||||
stg = vol.storagePoolLookupByVolume()
|
||||
else:
|
||||
stg = self.get_storage(storage)
|
||||
|
||||
storage_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type")
|
||||
format = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type")
|
||||
if storage_type == 'dir':
|
||||
|
|
Loading…
Reference in a new issue