def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects name=dict(type='str', aliases=['unique_name']), file=dict(type='str', aliases=['file_name']), state=dict(type='str', default='present', choices=['absent', 'present', 'query']), validate_certs=dict(type='bool', default=False)) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_if=[ ['state', 'absent', ['name']], ['state', 'present', ['file']], ['state', 'present', ['name']], ]) state = module.params.get('state') nae = NAEModule(module) if state == 'present': nae.upload_file() module.exit_json(**nae.result) elif state == 'absent': nae.delete_file() module.exit_json(**nae.result) elif state == 'query': nae.get_all_files() nae.result['Result'] = nae.files module.exit_json(**nae.result) module.fail_json(msg='Incorrect params passed', **nae.result)
def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) result = dict(changed=False, resp='') argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects validate_certs=dict(type='bool', default=False), name=dict(type='str', default=""), ag_name=dict(type='str', default=""), state=dict(type='str', default="")) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, required_if=[['state', 'absent', ['ag_name', 'name']], ['state', 'query', ['ag_name']], ['state', 'present', ['ag_name', 'name']]]) ag_name = module.params.get('ag_name') name = module.params.get('name') state = module.params.get('state') nae = NAEModule(module) if state == 'present' and 'name': nae.new_delta_analysis() module.exit_json(**nae.result) if state == 'query' and not name: nae.query_delta_analyses() module.exit_json(**nae.result) if state == 'query' and name: nae.result['Result'] = nae.get_delta_result() if not nae.result['Result']: module.exit_json( msg= "Delta analysis failed. The above smart events have been detected for later epoch only.", **nae.result) module.exit_json(**nae.result) if state == 'absent': nae.delete_delta_analysis() module.exit_json(**nae.result) module.fail_json(msg='Incorrect params passed', **nae.result)
def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects validate_certs=dict(type='bool', default=False), file=dict(type='str', default=""), ag_name=dict(type='str', default="")) module = AnsibleModule( argument_spec=argument_spec, supports_check_mode=True, ) file = module.params.get('file') ag_name = module.params.get('ag_name') nae = NAEModule(module) if ag_name and file: nae.tcam_to_csv() module.exit_json(**nae.result) if ag_name: nae.result['tcam'] = nae.get_tcam_stats() module.exit_json(**nae.result) module.fail_json(msg='Incorrect parameters passed', **nae.result)
def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) result = dict(changed=False, resp='') argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects ag_name=dict(type='str', aliases=['fab_name']), name=dict(type='str', aliases=['name']), description=dict(type='str'), changes=dict(type='str'), verify=dict(type='bool', default=False), file=dict(type='str', default=None), validate_certs=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'present', 'query']), ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_if=[['state', 'absent', ['name']], ['state', 'present', ['name']]]) changes = module.params.get('changes') change_file = module.params.get('file') description = module.params.get('description') state = module.params.get('state') ag_name = module.params.get('ag_name') name = module.params.get('name') nae = NAEModule(module) if state == 'present' and change_file: nae.create_pre_change_from_file() nae.result['changed'] = True module.exit_json(**nae.result) elif state == 'present' and changes: nae.create_pre_change_from_manual_changes() nae.result['changed'] = True module.exit_json(**nae.result) elif state == 'query' and name: nae.result['Result'] = nae.get_pre_change_result() if not nae.result['Result']: module.exit_json( msg= "Pre-change analysis failed. The above smart events have been detected for later epoch only.", **nae.result) module.exit_json(**nae.result) elif state == 'query' and not name: nae.show_pre_change_analyses() module.exit_json(**nae.result) elif state == 'absent': nae.delete_pre_change_analysis() module.exit_json(**nae.result) module.fail_json(msg='Incorrect params passed', **nae.result)
def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) result = dict(changed=False, resp='') argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects name=dict(type='str', aliases=['fab_name']), description=dict(type='str'), apic_hostnames=dict(type='str', default=""), apic_username=dict(type='str', default=""), apic_password=dict(type='str', default="", no_log=True), online=dict(type='bool', default=False), validate_certs=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'present', 'query', 'modify']), export_apic_policy=dict(type='bool', default=False)) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_if=[['state', 'absent', ['name']], ['state', 'present', ['name']]]) description = module.params.get('description') state = module.params.get('state') name = module.params.get('name') online = module.params.get('online') apic_hostname = module.params.get('apic_hostname') apic_username = module.params.get('apic_username') apic_password = module.params.get('apic_password') nae = NAEModule(module) if state == 'query' and name: ag = nae.get_assurance_group(name) if ag is None: module.exit_json( msg='Assurance group {0} does not exist'.format(name), **nae.result) nae.result['Result'] = ag module.exit_json(**nae.result) elif state == 'query' and not name: nae.get_all_assurance_groups() nae.result['Result'] = nae.assuranceGroups module.exit_json(**nae.result) elif state == 'absent' and name: nae.deleteAG() nae.result['changed'] = True module.exit_json(**nae.result) elif state == 'present' and online: nae.newOnlineAG() nae.result['changed'] = True module.exit_json(**nae.result) elif state == 'present' and name: nae.newOfflineAG() nae.result['changed'] = True module.exit_json(**nae.result) module.fail_json(msg='Incorrect params passed', **nae.result)
def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) result = dict(changed=False, resp='') argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects name=dict(type='str', aliases=['name']), description=dict(type='str'), selector=dict(type='str',default='object', choices=['object','traffic','requirement','requirement_set']), validate_certs=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'present', 'query', 'modify']), form=dict(type='str',default=""), ag_name=dict(type='str',default="") ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_if=[['state', 'absent', ['name']], ['selector', 'requirement_set', ['ag_name']], ]) selector = module.params.get('selector') ag_name = module.params.get('ag_name') name = module.params.get('name') state = module.params.get('state') form = module.params.get('form') nae = NAEModule(module) if state == 'present' and form and selector == 'object': nae.new_object_selector() result['changed'] = True module.exit_json(**nae.result) elif state == 'present' and form and selector == 'traffic': nae.new_traffic_selector() result['changed'] = True module.exit_json(**nae.result) elif state == 'present' and form and selector == 'requirement': nae.new_compliance_requirement() result['changed'] = True module.exit_json(**nae.result) elif state == 'present' and form and selector == 'requirement_set': nae.new_compliance_requirement_set() result['changed'] = True module.exit_json(**nae.result) elif state == 'query' and selector == 'object': nae.get_all_object_selectors() module.exit_json(**nae.result) elif state == 'query' and selector == 'traffic': nae.get_all_traffic_selectors() module.exit_json(**nae.result) elif state == 'query' and selector == 'requirement': nae.get_all_requirements() module.exit_json(**nae.result) elif state == 'query' and selector == 'requirement_set': nae.get_all_requirement_sets() module.exit_json(**nae.result) elif state == 'absent' and selector == 'object': nae.delete_object_selector() result['changed'] = True module.exit_json(**nae.result) elif state == 'absent' and selector == 'traffic': nae.delete_traffic_selector() result['changed'] = True module.exit_json(**nae.result) elif state == 'absent' and selector == 'requirement': nae.delete_requirement() result['changed'] = True module.exit_json(**nae.result) elif state == 'absent' and selector == 'requirement_set': nae.delete_requirement_set() result['changed'] = True module.exit_json(**nae.result) module.fail_json(msg='Incorrect params passed', **self.result)
def main(): requests.packages.urllib3.disable_warnings(InsecureRequestWarning) result = dict(changed=False, resp='') argument_spec = nae_argument_spec() argument_spec.update( # Not required for querying all objects name=dict(type='str', aliases=['unique_name']), filename=dict(type='str', aliases=['file_name']), ag_name=dict(type='str', aliases=['assurance_group_name']), complete=dict(type='bool', default=False), state=dict(type='str', default='present', choices=['absent', 'present', 'query', 'complete']), validate_certs=dict(type='bool', default=False)) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_if=[ ['state', 'absent', ['name']], ['state', 'present', ['filename']], ['state', 'present', ['name']], ['state', 'present', ['ag_name']], ]) state = module.params.get('state') file_name = module.params.get('file') name = module.params.get('name') ag_name = module.params.get('ag_name') nae = NAEModule(module) if state == 'present': nae.newOfflineAnalysis() module.exit_json(**nae.result) elif state == 'absent': nae.deleteOfflineAnalysis() module.exit_json(**nae.result) elif state == 'query' and name: nae.result['Result'] = nae.get_OfflineAnalysis(name) module.exit_json(**nae.result) elif state == 'query': nae.get_all_OfflineAnalysis() nae.result['Result'] = nae.offlineAnalysis module.exit_json(**nae.result) module.fail_json(msg='Incorrect params passed', **nae.result)