Merge pull request #1559 from vtsingaras/vsphere_guest_enhance_find_datastore
This enable one to find a datastore with no config_target supplied
This commit is contained in:
commit
1131ea0bb7
1 changed files with 15 additions and 7 deletions
|
@ -417,13 +417,21 @@ def add_nic(module, s, nfmor, config, devices, nic_type="vmxnet3", network_name=
|
||||||
def find_datastore(module, s, datastore, config_target):
|
def find_datastore(module, s, datastore, config_target):
|
||||||
# Verify the datastore exists and put it in brackets if it does.
|
# Verify the datastore exists and put it in brackets if it does.
|
||||||
ds = None
|
ds = None
|
||||||
for d in config_target.Datastore:
|
if config_target:
|
||||||
if (d.Datastore.Accessible and
|
for d in config_target.Datastore:
|
||||||
(datastore and d.Datastore.Name == datastore)
|
if (d.Datastore.Accessible and
|
||||||
or (not datastore)):
|
(datastore and d.Datastore.Name == datastore)
|
||||||
ds = d.Datastore.Datastore
|
or (not datastore)):
|
||||||
datastore = d.Datastore.Name
|
ds = d.Datastore.Datastore
|
||||||
break
|
datastore = d.Datastore.Name
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
for ds_mor, ds_name in server.get_datastores().items():
|
||||||
|
ds_props = VIProperty(s, ds_mor)
|
||||||
|
if (ds_props.summary.accessible and (datastore and ds_name == datastore)
|
||||||
|
or (not datastore)):
|
||||||
|
ds = ds_mor
|
||||||
|
datastore = ds_name
|
||||||
if not ds:
|
if not ds:
|
||||||
s.disconnect()
|
s.disconnect()
|
||||||
module.fail_json(msg="Datastore: %s does not appear to exist" %
|
module.fail_json(msg="Datastore: %s does not appear to exist" %
|
||||||
|
|
Loading…
Reference in a new issue