VMware: vmware_datastore_maintenancemode: check params (#56515)
Check the `datastore` parameter and raise an error if nothing has been found.
This commit is contained in:
parent
4b39748d21
commit
a4f08617d4
2 changed files with 6 additions and 1 deletions
2
changelogs/fragments/vmware_maintenance_mode_params.yaml
Normal file
2
changelogs/fragments/vmware_maintenance_mode_params.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- vmware_datastore_maintenancemode - Raise an error if the datastore does not exist.
|
|
@ -120,7 +120,10 @@ class VmwareDatastoreMaintenanceMgr(PyVmomi):
|
|||
datastore_cluster = self.params.get('datastore_cluster')
|
||||
self.datastore_objs = []
|
||||
if datastore_name:
|
||||
self.datastore_objs = [self.find_datastore_by_name(datastore_name=datastore_name)]
|
||||
ds = self.find_datastore_by_name(datastore_name=datastore_name)
|
||||
if not ds:
|
||||
self.module.fail_json(msg='Failed to find datastore "%(datastore)s".' % self.params)
|
||||
self.datastore_objs = [ds]
|
||||
elif cluster_name:
|
||||
cluster = find_cluster_by_name(self.content, cluster_name)
|
||||
if not cluster:
|
||||
|
|
Loading…
Reference in a new issue