def __init__(self): self.argument_spec = netapp_utils.na_um_host_argument_spec() self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = UMRestAPI(self.module)
class NetAppUMVolume(object): ''' volumes initialize and class methods ''' def __init__(self): self.argument_spec = netapp_utils.na_um_host_argument_spec() self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=True) self.na_helper = NetAppModule() self.parameters = self.na_helper.set_parameters(self.module.params) self.rest_api = UMRestAPI(self.module) def get_volumes(self): """ Fetch details of volumes. :return: Dictionary of current details if volumes found None if volumes is not found """ data = {} api = "datacenter/storage/volumes" message, error = self.rest_api.get(api, data) if error: self.module.fail_json(msg=error) if message['total_records'] != 0: return message['records'] return [] def apply(self): """ Apply action to the volumes listing :return: None """ current = self.get_volumes() if current is not None: self.na_helper.changed = True self.module.exit_json(changed=self.na_helper.changed, msg=current)