VMware: vmware_datastore_maintenancemode: check params (#56515)

Check the `datastore` parameter and raise an error if nothing has been
found.
pull/56518/head
Gonéri Le Bouder 6 years ago committed by Abhijeet Kasurde
parent 4b39748d21
commit a4f08617d4

@ -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') datastore_cluster = self.params.get('datastore_cluster')
self.datastore_objs = [] self.datastore_objs = []
if datastore_name: 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: elif cluster_name:
cluster = find_cluster_by_name(self.content, cluster_name) cluster = find_cluster_by_name(self.content, cluster_name)
if not cluster: if not cluster:

Loading…
Cancel
Save