From 035367170c67c9332c846b68e46668188d92c839 Mon Sep 17 00:00:00 2001 From: alxsey Date: Tue, 30 Aug 2016 10:17:30 -0400 Subject: [PATCH] Implement template storage selection (#2755) --- cloud/misc/proxmox.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cloud/misc/proxmox.py b/cloud/misc/proxmox.py index f02ff2e292b..d0df6b3f42a 100644 --- a/cloud/misc/proxmox.py +++ b/cloud/misc/proxmox.py @@ -214,8 +214,8 @@ VZ_TYPE=None def get_instance(proxmox, vmid): return [ vm for vm in proxmox.cluster.resources.get(type='vm') if vm['vmid'] == int(vmid) ] -def content_check(proxmox, node, ostemplate, storage): - return [ True for cnt in proxmox.nodes(node).storage(storage).content.get() if cnt['volid'] == ostemplate ] +def content_check(proxmox, node, ostemplate, template_store): + return [ True for cnt in proxmox.nodes(node).storage(template_store).content.get() if cnt['volid'] == ostemplate ] def node_check(proxmox, node): return [ True for nd in proxmox.nodes.get() if nd['node'] == node ] @@ -339,6 +339,8 @@ def main(): memory = module.params['memory'] swap = module.params['swap'] storage = module.params['storage'] + if module.params['ostemplate'] is not None: + template_store = module.params['ostemplate'].split(":")[0] timeout = module.params['timeout'] # If password not set get it from PROXMOX_PASSWORD env @@ -364,9 +366,9 @@ def main(): module.fail_json(msg='node, hostname, password and ostemplate are mandatory for creating vm') elif not node_check(proxmox, node): module.fail_json(msg="node '%s' not exists in cluster" % node) - elif not content_check(proxmox, node, module.params['ostemplate'], storage): + elif not content_check(proxmox, node, module.params['ostemplate'], template_store): module.fail_json(msg="ostemplate '%s' not exists on node %s and storage %s" - % (module.params['ostemplate'], node, storage)) + % (module.params['ostemplate'], node, template_store)) create_instance(module, proxmox, vmid, node, disk, storage, cpus, memory, swap, timeout, password = module.params['password'],