def handle_stat(module): system, host = get_sys_host(module) host_name = module.params["name"] if not host: module.fail_json(msg='Host {0} not found'.format(host_name)) field_dict = get_host_fields(host) result = dict(changed=False, msg='Host stat found') result = merge_two_dicts(result, field_dict) module.exit_json(**result)
def handle_stat(module): system, user = get_sys_user(module) user_name = module.params["user_name"] if not user: module.fail_json(msg='User {0} not found'.format(user_name)) field_dict = get_user_fields(user) result = dict(changed=False, msg='User stat found') result = merge_two_dicts(result, field_dict) module.exit_json(**result)
def handle_stat(module): system, export = get_sys_exp(module) if not export: module.fail_json( msg='Export {0} not found'.format(module.params['export'])) client_name = module.params['client'] field_dict = get_export_client_fields(export, client_name) result = dict(changed=False, msg='Export client stat found') result = merge_two_dicts(result, field_dict) module.exit_json(**result)
def handle_stat(module): """ Gather stats on export and return. Changed is always False. """ system, export, filesystem = get_sys_exp_fs(module) if not export: module.fail_json( msg='Export "{}" of file system "{}" not found'.format( module.params['name'], module.params['filesystem'], )) field_dict = get_export_fields(export) result = dict(changed=False, msg='File system stat found') result = merge_two_dicts(result, field_dict) module.exit_json(**result)
def handle_stat(module): """ Handle stat state. Fail if host is None. Return json with status. """ system, host = get_sys_host(module) host_name = module.params['host'] if not host: module.fail_json(msg='Host {0} not found'.format(host_name)) field_dict = get_port_fields(module, system, host) result = dict( changed=False, msg='Host {0} ports found'.format(host_name), ) result = merge_two_dicts(result, field_dict) module.exit_json(**result)
def handle_stat(module): system, volume, host = get_sys_vol_host(module) volume_name = module.params['volume'] host_name = module.params['host'] if not volume: module.fail_json(msg='Volume {0} not found'.format(volume_name)) if not host: module.fail_json(msg='Host {0} not found'.format(host_name)) if not vol_is_mapped_to_host(volume, host): msg = 'Volume {0} is not mapped to host {1}'.format( volume_name, host_name) module.fail_json(msg=msg) found_lun = find_lun(host, volume) field_dict = get_mapping_fields(volume, host) result = dict( changed=False, volume_lun=found_lun, msg='Volume {0} is mapped to host {1}'.format(volume_name, host_name), ) result = merge_two_dicts(result, field_dict) module.exit_json(**result)