From a5199806102dc352b9605aebc90d22fed367e90e Mon Sep 17 00:00:00 2001 From: catborise Date: Tue, 18 Dec 2018 10:46:23 +0300 Subject: [PATCH] Narrow down with pool searching existing volume while creating instance from template/flavour --- create/templates/create_instance.html | 2 +- create/views.py | 2 +- vrtManager/create.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/create/templates/create_instance.html b/create/templates/create_instance.html index baaada2..34ee73c 100644 --- a/create/templates/create_instance.html +++ b/create/templates/create_instance.html @@ -441,7 +441,7 @@
- {% if storages %} {% for storage in storages %} diff --git a/create/views.py b/create/views.py index b367e95..1f8cfe3 100644 --- a/create/views.py +++ b/create/views.py @@ -130,7 +130,7 @@ def create_instance(request, compute_id): error_messages.append(lib_err.message) elif 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: error_msg = _("Image has already exist. Please check volumes or change instance name") error_messages.append(error_msg) diff --git a/vrtManager/create.py b/vrtManager/create.py index 29d2e68..5a41a6a 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -100,8 +100,11 @@ class wvmCreate(wvmConnect): else: return 'raw' - def get_volume_path(self, volume): - storages = self.get_storages(only_actives=True) + def get_volume_path(self, volume, pool=None): + if not pool: + storages = self.get_storages(only_actives=True) + else: + storages = [pool,] for storage in storages: stg = self.get_storage(storage) if stg.info()[0] != 0: