def main(): argument_spec = dict(data=dict(required=True, type='dict')) argument_spec.update(nso_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) p = module.params client = connect(p) nso_config = NsoConfig(module.check_mode, client, p['data']) try: verify_version(client, NsoConfig.REQUIRED_VERSIONS) changes, diffs = nso_config.main() client.logout() changed = len(changes) > 0 module.exit_json(changed=changed, changes=changes, diffs=diffs) except NsoException as ex: client.logout() module.fail_json(msg=ex.message) except ModuleFailException as ex: client.logout() module.fail_json(msg=ex.message)
def main(): argument_spec = dict(path=dict(required=True), input=dict(required=False, type='dict', default={}), output_required=dict(required=False, type='dict', default={}), output_invalid=dict(required=False, type='dict', default={}), validate_strict=dict(required=False, type='bool', default=False)) argument_spec.update(nso_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) p = module.params client = connect(p) nso_action = NsoAction(module.check_mode, client, p['path'], p['input'], p['output_required'], p['output_invalid'], p['validate_strict']) try: verify_version(client, NsoAction.REQUIRED_VERSIONS) output = nso_action.main() client.logout() module.exit_json(changed=True, output=output) except NsoException as ex: client.logout() module.fail_json(msg=ex.message) except ModuleFailException as ex: client.logout() module.fail_json(msg=ex.message)
def main(): argument_spec = dict(data=dict(required=True, type='dict')) argument_spec.update(nso_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) p = module.params client = connect(p) nso_verify = NsoVerify(client, p['data']) try: verify_version(client, NsoVerify.REQUIRED_VERSIONS) violations = nso_verify.main() client.logout() num_violations = len(violations) if num_violations > 0: msg = '{0} value{1} differ'.format( num_violations, num_violations > 1 and 's' or '') module.fail_json(msg=msg, violations=violations) else: module.exit_json(changed=False) except NsoException as ex: client.logout() module.fail_json(msg=ex.message) except ModuleFailException as ex: client.logout() module.fail_json(msg=ex.message)
def main(): argument_spec = dict(path=dict(required=True, type='str'), operational=dict(required=False, type='bool', default=False)) argument_spec.update(nso_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) p = module.params client = connect(p) nso_show = NsoShow(module.check_mode, client, p['path'], p['operational']) try: verify_version(client, NsoShow.REQUIRED_VERSIONS) output = nso_show.main() client.logout() module.exit_json(changed=False, output=output) except NsoException as ex: client.logout() module.fail_json(msg=ex.message) except ModuleFailException as ex: client.logout() module.fail_json(msg=ex.message)
def main(): argument_spec = dict(xpath=dict(required=True, type='str'), fields=dict(required=True, type='list', elements='str')) argument_spec.update(nso_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) p = module.params client = connect(p) nso_query = NsoQuery(module.check_mode, client, p['xpath'], p['fields']) try: verify_version(client, NsoQuery.REQUIRED_VERSIONS) output = nso_query.main() client.logout() module.exit_json(changed=False, output=output) except NsoException as ex: client.logout() module.fail_json(msg=ex.message) except ModuleFailException as ex: client.logout() module.fail_json(msg=ex.message)