Making cluster parameter optional

reviewable/pr18780/r1
Tobias Smolka 9 years ago
parent 3c685d7468
commit 0cacadb670

@ -656,7 +656,7 @@ def deploy_template(vsphere_client, guest, resource_pool, template_src, esxi, mo
elif resource_pool: elif resource_pool:
try: try:
cluster = [k for k, cluster = [k for k,
v in vsphere_client.get_clusters().items() if v == cluster_name][0] v in vsphere_client.get_clusters().items() if v == cluster_name][0] if cluster_name else None
except IndexError, e: except IndexError, e:
vsphere_client.disconnect() vsphere_client.disconnect()
module.fail_json(msg="Cannot find Cluster named: %s" % module.fail_json(msg="Cannot find Cluster named: %s" %
@ -1059,7 +1059,7 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest,
if resource_pool: if resource_pool:
try: try:
cluster = [k for k, cluster = [k for k,
v in vsphere_client.get_clusters().items() if v == cluster_name][0] v in vsphere_client.get_clusters().items() if v == cluster_name][0] if cluster_name else None
except IndexError, e: except IndexError, e:
vsphere_client.disconnect() vsphere_client.disconnect()
module.fail_json(msg="Cannot find Cluster named: %s" % module.fail_json(msg="Cannot find Cluster named: %s" %

Loading…
Cancel
Save