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:
Gonéri Le Bouder 2019-05-16 10:22:18 -04:00 committed by Abhijeet Kasurde
parent 4b39748d21
commit a4f08617d4
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- vmware_datastore_maintenancemode - Raise an error if the datastore does not exist.

View file

@ -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: