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

Narrow down with pool searching existing volume while creating instance from template/flavour

This commit is contained in:
catborise 2018-12-18 10:46:23 +03:00
parent a63e9036fe
commit a519980610
3 changed files with 7 additions and 4 deletions

View file

@ -441,7 +441,7 @@
<label class="col-sm-3 control-label">{% trans "HDD" %}</label> <label class="col-sm-3 control-label">{% trans "HDD" %}</label>
<input id="images" name="images" type="hidden" value=""/> <input id="images" name="images" type="hidden" value=""/>
<div class="col-sm-3"> <div class="col-sm-3">
<select id="temp-storage-control" name="temp-storage-control" class="form-control" onchange="get_template_vols({{ compute_id }}, value);"> <select id="storage" name="storage" class="form-control" onchange="get_template_vols({{ compute_id }}, value);">
{% if storages %} {% if storages %}
<option value disabled selected>{% trans "Select pool" %}...</option> <option value disabled selected>{% trans "Select pool" %}...</option>
{% for storage in storages %} {% for storage in storages %}

View file

@ -130,7 +130,7 @@ def create_instance(request, compute_id):
error_messages.append(lib_err.message) error_messages.append(lib_err.message)
elif data['template']: elif data['template']:
templ_path = conn.get_volume_path(data['template']) templ_path = conn.get_volume_path(data['template'])
dest_vol = conn.get_volume_path(data["name"] + ".img") dest_vol = conn.get_volume_path(data["name"] + ".img", data['storage'])
if dest_vol: if dest_vol:
error_msg = _("Image has already exist. Please check volumes or change instance name") error_msg = _("Image has already exist. Please check volumes or change instance name")
error_messages.append(error_msg) error_messages.append(error_msg)

View file

@ -100,8 +100,11 @@ class wvmCreate(wvmConnect):
else: else:
return 'raw' return 'raw'
def get_volume_path(self, volume): def get_volume_path(self, volume, pool=None):
storages = self.get_storages(only_actives=True) if not pool:
storages = self.get_storages(only_actives=True)
else:
storages = [pool,]
for storage in storages: for storage in storages:
stg = self.get_storage(storage) stg = self.get_storage(storage)
if stg.info()[0] != 0: if stg.info()[0] != 0: