def main():
    jrpc_urls = [
        '/dvmdb/adom/{adom}/script',
        '/dvmdb/global/script',
        '/dvmdb/script'
    ]

    url_schema = [
        {
            'name': 'adom',
            'type': 'string'
        }
    ]

    body_schema = {
        'schema_objects': {
            'object0': [
                {
                    'name': 'data',
                    'api_tag': 0,
                    'type': 'array',
                    'items': {
                        'content': {
                            'type': 'string'
                        },
                        'desc': {
                            'type': 'string'
                        },
                        'filter_build': {
                            'type': 'integer'
                        },
                        'filter_device': {
                            'type': 'integer'
                        },
                        'filter_hostname': {
                            'type': 'string'
                        },
                        'filter_ostype': {
                            'type': 'string',
                            'enum': [
                                'unknown',
                                'fos'
                            ]
                        },
                        'filter_osver': {
                            'type': 'string',
                            'enum': [
                                'unknown',
                                '4.00',
                                '5.00'
                            ]
                        },
                        'filter_platform': {
                            'type': 'string'
                        },
                        'filter_serial': {
                            'type': 'string'
                        },
                        'modification_time': {
                            'type': 'string'
                        },
                        'name': {
                            'type': 'string'
                        },
                        'script_schedule': {
                            'type': 'array',
                            'items': {
                                'datetime': {
                                    'type': 'string'
                                },
                                'day_of_week': {
                                    'type': 'string',
                                    'enum': [
                                        'unknown',
                                        'sun',
                                        'mon',
                                        'tue',
                                        'wed',
                                        'thu',
                                        'fri',
                                        'sat'
                                    ]
                                },
                                'device': {
                                    'type': 'integer'
                                },
                                'name': {
                                    'type': 'string'
                                },
                                'run_on_db': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'type': {
                                    'type': 'string',
                                    'enum': [
                                        'auto',
                                        'onetime',
                                        'daily',
                                        'weekly',
                                        'monthly'
                                    ]
                                }
                            }
                        },
                        'target': {
                            'type': 'string',
                            'enum': [
                                'device_database',
                                'remote_device',
                                'adom_database'
                            ]
                        },
                        'type': {
                            'type': 'string',
                            'enum': [
                                'cli',
                                'tcl',
                                'cligrp'
                            ]
                        }
                    }
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ],
            'object1': [
                {
                    'type': 'string',
                    'name': 'expand member',
                    'api_tag': 0
                },
                {
                    'name': 'fields',
                    'api_tag': 0,
                    'type': 'array',
                    'items': {
                        'type': 'array',
                        'items': {
                            'type': 'string',
                            'enum': [
                                'content',
                                'desc',
                                'filter_build',
                                'filter_device',
                                'filter_hostname',
                                'filter_ostype',
                                'filter_osver',
                                'filter_platform',
                                'filter_serial',
                                'modification_time',
                                'name',
                                'target',
                                'type'
                            ]
                        }
                    }
                },
                {
                    'name': 'filter',
                    'type': 'dict',
                    'dict': {
                        'type': 'array',
                        'items': {
                            'type': 'string',
                            'example': [
                                '<attr>',
                                '==',
                                'test'
                            ]
                        }
                    },
                    'api_tag': 0
                },
                {
                    'type': 'integer',
                    'name': 'loadsub',
                    'api_tag': 0
                },
                {
                    'name': 'option',
                    'type': 'dict',
                    'dict': {
                        'type': 'string',
                        'enum': [
                            'count',
                            'object member',
                            'syntax'
                        ]
                    },
                    'api_tag': 0
                },
                {
                    'name': 'range',
                    'type': 'dict',
                    'dict': {
                        'type': 'array',
                        'items': {
                            'type': 'integer',
                            'example': [
                                2,
                                5
                            ]
                        }
                    },
                    'api_tag': 0
                },
                {
                    'name': 'sortings',
                    'type': 'dict',
                    'dict': {
                        'type': 'array',
                        'items': {
                            '{attr_name}': {
                                'type': 'integer',
                                'enum': [
                                    1,
                                    -1
                                ]
                            }
                        }
                    },
                    'api_tag': 0
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': [
                'add',
                'get',
                'set',
                'update'
            ]
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module, results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #2
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/devprof/{devprof}/system/snmp/community/{community}'
    ]

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'devprof',
        'type': 'string'
    }, {
        'name': 'community',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'events': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'cpu-high', 'mem-low', 'log-full', 'intf-ip',
                                'vpn-tun-up', 'vpn-tun-down', 'ha-switch',
                                'ha-hb-failure', 'ips-signature',
                                'ips-anomaly', 'av-virus', 'av-oversize',
                                'av-pattern', 'av-fragmented', 'fm-if-change',
                                'fm-conf-change', 'temperature-high',
                                'voltage-alert', 'ha-member-up',
                                'ha-member-down', 'ent-conf-change',
                                'av-conserve', 'av-bypass',
                                'av-oversize-passed', 'av-oversize-blocked',
                                'ips-pkg-update', 'power-supply-failure',
                                'amc-bypass', 'faz-disconnect', 'fan-failure',
                                'bgp-established', 'bgp-backward-transition',
                                'wc-ap-up', 'wc-ap-down', 'fswctl-session-up',
                                'fswctl-session-down', 'ips-fail-open',
                                'load-balance-real-server-down', 'device-new',
                                'enter-intf-bypass', 'exit-intf-bypass',
                                'per-cpu-high', 'power-blade-down',
                                'confsync_failure'
                            ]
                        }
                    },
                    'hosts': {
                        'type': 'array',
                        'items': {
                            'ha-direct': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'host-type': {
                                'type': 'string',
                                'enum': ['any', 'query', 'trap']
                            },
                            'id': {
                                'type': 'integer'
                            },
                            'ip': {
                                'type': 'string'
                            },
                            'source-ip': {
                                'type': 'string'
                            }
                        }
                    },
                    'hosts6': {
                        'type': 'array',
                        'items': {
                            'ha-direct': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'host-type': {
                                'type': 'string',
                                'enum': ['any', 'query', 'trap']
                            },
                            'id': {
                                'type': 'integer'
                            },
                            'ipv6': {
                                'type': 'string'
                            },
                            'source-ipv6': {
                                'type': 'string'
                            }
                        }
                    },
                    'id': {
                        'type': 'integer'
                    },
                    'name': {
                        'type': 'string'
                    },
                    'query-v1-port': {
                        'type': 'integer'
                    },
                    'query-v1-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'query-v2c-port': {
                        'type': 'integer'
                    },
                    'query-v2c-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'trap-v1-lport': {
                        'type': 'integer'
                    },
                    'trap-v1-rport': {
                        'type': 'integer'
                    },
                    'trap-v1-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'trap-v2c-lport': {
                        'type': 'integer'
                    },
                    'trap-v2c-rport': {
                        'type': 'integer'
                    },
                    'trap-v2c-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object2': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'clone': 'object0',
            'delete': 'object1',
            'get': 'object2',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['clone', 'delete', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = ['/pm/config/adom/{adom}/devprof/{devprof}/system/dns']

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'devprof',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'cache-notfound-responses': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'dns-cache-limit': {
                        'type': 'integer'
                    },
                    'dns-cache-ttl': {
                        'type': 'integer'
                    },
                    'domain': {
                        'type': 'string'
                    },
                    'ip6-primary': {
                        'type': 'string'
                    },
                    'ip6-secondary': {
                        'type': 'string'
                    },
                    'primary': {
                        'type': 'string'
                    },
                    'secondary': {
                        'type': 'string'
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #4
0
def main():
    jrpc_urls = ['/dvm/cmd/add/device', '/dvm/cmd/add/device']

    url_schema = []

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'adom': {
                        'type': 'string'
                    },
                    'device': {
                        'adm_pass': {
                            'type': 'array',
                            'items': {
                                'type': 'string'
                            }
                        },
                        'adm_usr': {
                            'type': 'string'
                        },
                        'desc': {
                            'type': 'string'
                        },
                        'device action': {
                            'type': 'string'
                        },
                        'faz.quota': {
                            'type': 'integer'
                        },
                        'ip': {
                            'type': 'string'
                        },
                        'meta fields': {
                            'type': 'string'
                        },
                        'mgmt_mode': {
                            'type': 'string',
                            'enum': ['unreg', 'fmg', 'faz', 'fmgfaz']
                        },
                        'mr': {
                            'type': 'integer'
                        },
                        'name': {
                            'type': 'string'
                        },
                        'os_type': {
                            'type':
                            'string',
                            'enum': [
                                'unknown', 'fos', 'fsw', 'foc', 'fml', 'faz',
                                'fwb', 'fch', 'fct', 'log', 'fmg', 'fsa',
                                'fdd', 'fac'
                            ]
                        },
                        'os_ver': {
                            'type':
                            'string',
                            'enum': [
                                'unknown', '0.0', '1.0', '2.0', '3.0', '4.0',
                                '5.0'
                            ]
                        },
                        'patch': {
                            'type': 'integer'
                        },
                        'platform_str': {
                            'type': 'string'
                        },
                        'sn': {
                            'type': 'string'
                        }
                    },
                    'flags': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum':
                            ['none', 'create_task', 'nonblocking', 'log_dev']
                        }
                    },
                    'groups': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'vdom': {
                                'type': 'string'
                            }
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'exec': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['exec']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #5
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/dnsfilter/profile',
        '/pm/config/global/obj/dnsfilter/profile'
    ]

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'block-action': {
                        'type': 'string',
                        'enum': ['block', 'redirect']
                    },
                    'block-botnet': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'external-ip-blocklist': {
                        'type': 'string'
                    },
                    'log-all-domain': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'name': {
                        'type': 'string'
                    },
                    'redirect-portal': {
                        'type': 'string'
                    },
                    'safe-search': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'sdns-domain-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'sdns-ftgd-err-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'youtube-restrict': {
                        'type': 'string',
                        'enum': ['strict', 'moderate']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'attr',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'block-action', 'block-botnet', 'comment',
                            'external-ip-blocklist', 'log-all-domain', 'name',
                            'redirect-portal', 'safe-search',
                            'sdns-domain-log', 'sdns-ftgd-err-log',
                            'youtube-restrict'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'get used',
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type':
                    'string',
                    'enum': [
                        'count', 'object member', 'datasrc', 'get reserved',
                        'syntax'
                    ]
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['add', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/firewall/addrgrp/{addrgrp}',
        '/pm/config/global/obj/firewall/addrgrp/{addrgrp}'
    ]

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'addrgrp',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'allow-routing': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'color': {
                        'type': 'integer'
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'dynamic_mapping': {
                        'type': 'array',
                        'items': {
                            '_scope': {
                                'type': 'array',
                                'items': {
                                    'name': {
                                        'type': 'string'
                                    },
                                    'vdom': {
                                        'type': 'string'
                                    }
                                }
                            },
                            'allow-routing': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'color': {
                                'type': 'integer'
                            },
                            'comment': {
                                'type': 'string'
                            },
                            'exclude': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'exclude-member': {
                                'type': 'string'
                            },
                            'member': {
                                'type': 'string'
                            },
                            'tags': {
                                'type': 'string'
                            },
                            'uuid': {
                                'type': 'string'
                            },
                            'visibility': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            }
                        }
                    },
                    'member': {
                        'type': 'string'
                    },
                    'name': {
                        'type': 'string'
                    },
                    'tagging': {
                        'type': 'array',
                        'items': {
                            'category': {
                                'type': 'string'
                            },
                            'name': {
                                'type': 'string'
                            },
                            'tags': {
                                'type': 'array',
                                'items': {
                                    'type': 'string'
                                }
                            }
                        }
                    },
                    'uuid': {
                        'type': 'string'
                    },
                    'visibility': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object2': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'clone': 'object0',
            'delete': 'object1',
            'get': 'object2',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['clone', 'delete', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #7
0
def main():
    jrpc_urls = ['/cli/global/system/ha']

    url_schema = []

    body_schema = {
        'schema_objects': {
            'object0': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'clusterid': {
                        'type': 'integer',
                        'default': 1,
                        'example': 1
                    },
                    'file-quota': {
                        'type': 'integer',
                        'default': 4096,
                        'example': 4096
                    },
                    'hb-interval': {
                        'type': 'integer',
                        'default': 5,
                        'example': 5
                    },
                    'hb-lost-threshold': {
                        'type': 'integer',
                        'default': 3,
                        'example': 3
                    },
                    'mode': {
                        'type': 'string',
                        'enum': ['standalone', 'master', 'slave']
                    },
                    'password': {
                        'type': 'array',
                        'items': {
                            'type': 'string'
                        }
                    },
                    'peer': {
                        'type': 'array',
                        'items': {
                            'id': {
                                'type': 'integer',
                                'default': 0,
                                'example': 0
                            },
                            'ip': {
                                'type': 'string'
                            },
                            'ip6': {
                                'type': 'string'
                            },
                            'serial-number': {
                                'type': 'string'
                            },
                            'status': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            }
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #8
0
def main():
    jrpc_urls = ['/dvmdb/adom/{adom}/device', '/dvmdb/device']

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'type': 'string',
                'name': 'expand member',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'adm_pass', 'adm_usr', 'app_ver', 'av_ver', 'beta',
                            'branch_pt', 'build', 'checksum', 'conf_status',
                            'conn_mode', 'conn_status', 'db_status', 'desc',
                            'dev_status', 'fap_cnt', 'faz.full_act',
                            'faz.perm', 'faz.quota', 'faz.used', 'fex_cnt',
                            'flags', 'foslic_cpu', 'foslic_dr_site',
                            'foslic_inst_time', 'foslic_last_sync',
                            'foslic_ram', 'foslic_type', 'foslic_utm',
                            'fsw_cnt', 'ha_group_id', 'ha_group_name',
                            'ha_mode', 'hdisk_size', 'hostname',
                            'hw_rev_major', 'hw_rev_minor', 'ip', 'ips_ext',
                            'ips_ver', 'last_checked', 'last_resync',
                            'latitude', 'lic_flags', 'lic_region',
                            'location_from', 'logdisk_size', 'longitude',
                            'maxvdom', 'mgmt_id', 'mgmt_if', 'mgmt_mode',
                            'mgt_vdom', 'mr', 'name', 'os_type', 'os_ver',
                            'patch', 'platform_str', 'psk', 'sn', 'version',
                            'vm_cpu', 'vm_cpu_limit', 'vm_lic_expire',
                            'vm_mem', 'vm_mem_limit', 'vm_status'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'meta fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'string'
                }
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['count', 'object member', 'syntax']
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'adm_pass': {
                        'type': 'array',
                        'items': {
                            'type': 'string'
                        }
                    },
                    'adm_usr': {
                        'type': 'string'
                    },
                    'app_ver': {
                        'type': 'string'
                    },
                    'av_ver': {
                        'type': 'string'
                    },
                    'beta': {
                        'type': 'integer'
                    },
                    'branch_pt': {
                        'type': 'integer'
                    },
                    'build': {
                        'type': 'integer'
                    },
                    'checksum': {
                        'type': 'string'
                    },
                    'conf_status': {
                        'type': 'string',
                        'enum': ['unknown', 'insync', 'outofsync']
                    },
                    'conn_mode': {
                        'type': 'string',
                        'enum': ['active', 'passive']
                    },
                    'conn_status': {
                        'type': 'string',
                        'enum': ['UNKNOWN', 'up', 'down']
                    },
                    'db_status': {
                        'type': 'string',
                        'enum': ['unknown', 'nomod', 'mod']
                    },
                    'desc': {
                        'type': 'string'
                    },
                    'dev_status': {
                        'type':
                        'string',
                        'enum': [
                            'none', 'unknown', 'checkedin', 'inprogress',
                            'installed', 'aborted', 'sched', 'retry',
                            'canceled', 'pending', 'retrieved', 'changed_conf',
                            'sync_fail', 'timeout', 'rev_revert',
                            'auto_updated'
                        ]
                    },
                    'fap_cnt': {
                        'type': 'integer'
                    },
                    'faz.full_act': {
                        'type': 'integer'
                    },
                    'faz.perm': {
                        'type': 'integer'
                    },
                    'faz.quota': {
                        'type': 'integer'
                    },
                    'faz.used': {
                        'type': 'integer'
                    },
                    'fex_cnt': {
                        'type': 'integer'
                    },
                    'flags': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'has_hdd', 'vdom_enabled', 'discover',
                                'reload', 'interim_build', 'offline_mode',
                                'is_model', 'fips_mode', 'linked_to_model',
                                'ip-conflict', 'faz-autosync'
                            ]
                        }
                    },
                    'foslic_cpu': {
                        'type': 'integer'
                    },
                    'foslic_dr_site': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'foslic_inst_time': {
                        'type': 'integer'
                    },
                    'foslic_last_sync': {
                        'type': 'integer'
                    },
                    'foslic_ram': {
                        'type': 'integer'
                    },
                    'foslic_type': {
                        'type': 'string',
                        'enum':
                        ['temporary', 'trial', 'regular', 'trial_expired']
                    },
                    'foslic_utm': {
                        'type': 'array',
                        'items': {
                            'type': 'string',
                            'enum':
                            ['fw', 'av', 'ips', 'app', 'url', 'utm', 'fwb']
                        }
                    },
                    'fsw_cnt': {
                        'type': 'integer'
                    },
                    'ha_group_id': {
                        'type': 'integer'
                    },
                    'ha_group_name': {
                        'type': 'string'
                    },
                    'ha_mode': {
                        'type':
                        'string',
                        'enum': [
                            'standalone', 'AP', 'AA', 'ELBC', 'DUAL',
                            'enabled', 'unknown'
                        ]
                    },
                    'hdisk_size': {
                        'type': 'integer'
                    },
                    'hostname': {
                        'type': 'string'
                    },
                    'hw_rev_major': {
                        'type': 'integer'
                    },
                    'hw_rev_minor': {
                        'type': 'integer'
                    },
                    'ip': {
                        'type': 'string'
                    },
                    'ips_ext': {
                        'type': 'integer'
                    },
                    'ips_ver': {
                        'type': 'string'
                    },
                    'last_checked': {
                        'type': 'integer'
                    },
                    'last_resync': {
                        'type': 'integer'
                    },
                    'latitude': {
                        'type': 'string'
                    },
                    'lic_flags': {
                        'type': 'integer'
                    },
                    'lic_region': {
                        'type': 'string'
                    },
                    'location_from': {
                        'type': 'string'
                    },
                    'logdisk_size': {
                        'type': 'integer'
                    },
                    'longitude': {
                        'type': 'string'
                    },
                    'maxvdom': {
                        'type': 'integer',
                        'default': 10,
                        'example': 10
                    },
                    'meta fields': {
                        'type': 'string'
                    },
                    'mgmt_id': {
                        'type': 'integer'
                    },
                    'mgmt_if': {
                        'type': 'string'
                    },
                    'mgmt_mode': {
                        'type': 'string',
                        'enum': ['unreg', 'fmg', 'faz', 'fmgfaz']
                    },
                    'mgt_vdom': {
                        'type': 'string'
                    },
                    'mr': {
                        'type': 'integer',
                        'default': -1,
                        'example': -1
                    },
                    'name': {
                        'type': 'string'
                    },
                    'os_type': {
                        'type':
                        'string',
                        'enum': [
                            'unknown', 'fos', 'fsw', 'foc', 'fml', 'faz',
                            'fwb', 'fch', 'fct', 'log', 'fmg', 'fsa', 'fdd',
                            'fac', 'fpx'
                        ]
                    },
                    'os_ver': {
                        'type':
                        'string',
                        'enum': [
                            'unknown', '0.0', '1.0', '2.0', '3.0', '4.0',
                            '5.0', '6.0'
                        ]
                    },
                    'patch': {
                        'type': 'integer'
                    },
                    'platform_str': {
                        'type': 'string'
                    },
                    'psk': {
                        'type': 'string'
                    },
                    'sn': {
                        'type': 'string'
                    },
                    'vdom': {
                        'type': 'array',
                        'items': {
                            'comments': {
                                'type': 'string'
                            },
                            'name': {
                                'type': 'string'
                            },
                            'opmode': {
                                'type': 'string',
                                'enum': ['nat', 'transparent']
                            },
                            'rtm_prof_id': {
                                'type': 'integer'
                            },
                            'status': {
                                'type': 'string'
                            }
                        }
                    },
                    'version': {
                        'type': 'integer'
                    },
                    'vm_cpu': {
                        'type': 'integer'
                    },
                    'vm_cpu_limit': {
                        'type': 'integer'
                    },
                    'vm_lic_expire': {
                        'type': 'integer'
                    },
                    'vm_mem': {
                        'type': 'integer'
                    },
                    'vm_mem_limit': {
                        'type': 'integer'
                    },
                    'vm_status': {
                        'type': 'integer'
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = ['/cli/global/system/global']

    url_schema = []

    body_schema = {
        'schema_objects': {
            'object0': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'admin-lockout-duration': {
                        'type': 'integer',
                        'default': 60,
                        'example': 60
                    },
                    'admin-lockout-threshold': {
                        'type': 'integer',
                        'default': 3,
                        'example': 3
                    },
                    'adom-mode': {
                        'type': 'string',
                        'enum': ['normal', 'advanced']
                    },
                    'adom-rev-auto-delete': {
                        'type': 'string',
                        'enum': ['disable', 'by-revisions', 'by-days']
                    },
                    'adom-rev-max-backup-revisions': {
                        'type': 'integer',
                        'default': 5,
                        'example': 5
                    },
                    'adom-rev-max-days': {
                        'type': 'integer',
                        'default': 30,
                        'example': 30
                    },
                    'adom-rev-max-revisions': {
                        'type': 'integer',
                        'default': 120,
                        'example': 120
                    },
                    'adom-select': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'adom-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'clt-cert-req': {
                        'type': 'string',
                        'enum': ['disable', 'enable', 'optional']
                    },
                    'console-output': {
                        'type': 'string',
                        'enum': ['standard', 'more']
                    },
                    'country-flag': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'create-revision': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'daylightsavetime': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'default-disk-quota': {
                        'type': 'integer',
                        'default': 1000,
                        'example': 1000
                    },
                    'detect-unregistered-log-device': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'device-view-mode': {
                        'type': 'string',
                        'enum': ['regular', 'tree']
                    },
                    'dh-params': {
                        'type':
                        'string',
                        'enum': [
                            '1024', '1536', '2048', '3072', '4096', '6144',
                            '8192'
                        ]
                    },
                    'disable-module': {
                        'type': 'array',
                        'items': {
                            'type': 'string',
                            'enum': ['fortiview-noc']
                        }
                    },
                    'enc-algorithm': {
                        'type': 'string',
                        'enum': ['low', 'medium', 'high']
                    },
                    'faz-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'fgfm-local-cert': {
                        'type': 'string'
                    },
                    'fgfm-ssl-protocol': {
                        'type': 'string',
                        'enum': ['sslv3', 'tlsv1.0', 'tlsv1.1', 'tlsv1.2']
                    },
                    'ha-member-auto-grouping': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'hitcount_concurrent': {
                        'type': 'integer',
                        'default': 100,
                        'example': 100
                    },
                    'hitcount_interval': {
                        'type': 'integer',
                        'default': 300,
                        'example': 300
                    },
                    'hostname': {
                        'type': 'string'
                    },
                    'import-ignore-addr-cmt': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'language': {
                        'type':
                        'string',
                        'enum': [
                            'english', 'simch', 'japanese', 'korean',
                            'spanish', 'trach'
                        ]
                    },
                    'latitude': {
                        'type': 'string'
                    },
                    'ldap-cache-timeout': {
                        'type': 'integer',
                        'default': 86400,
                        'example': 86400
                    },
                    'ldapconntimeout': {
                        'type': 'integer',
                        'default': 60000,
                        'example': 60000
                    },
                    'lock-preempt': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'log-checksum': {
                        'type': 'string',
                        'enum': ['none', 'md5', 'md5-auth']
                    },
                    'log-forward-cache-size': {
                        'type': 'integer',
                        'default': 0,
                        'example': 0
                    },
                    'longitude': {
                        'type': 'string'
                    },
                    'max-log-forward': {
                        'type': 'integer',
                        'default': 5,
                        'example': 5
                    },
                    'max-running-reports': {
                        'type': 'integer',
                        'default': 1,
                        'example': 1
                    },
                    'oftp-ssl-protocol': {
                        'type': 'string',
                        'enum': ['sslv3', 'tlsv1.0', 'tlsv1.1', 'tlsv1.2']
                    },
                    'partial-install': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'partial-install-force': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'partial-install-rev': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'perform-improve-by-ha': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'policy-hit-count': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'policy-object-in-dual-pane': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'pre-login-banner': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'pre-login-banner-message': {
                        'type': 'string'
                    },
                    'remoteauthtimeout': {
                        'type': 'integer',
                        'default': 10,
                        'example': 10
                    },
                    'search-all-adoms': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ssl-low-encryption': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ssl-protocol': {
                        'type': 'array',
                        'items': {
                            'type': 'string',
                            'enum': ['tlsv1.2', 'tlsv1.1', 'tlsv1.0', 'sslv3']
                        }
                    },
                    'ssl-static-key-ciphers': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'task-list-size': {
                        'type': 'integer',
                        'default': 2000,
                        'example': 2000
                    },
                    'tftp': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'timezone': {
                        'type':
                        'string',
                        'enum': [
                            '00', '01', '02', '03', '04', '05', '06', '07',
                            '08', '09', '10', '11', '12', '13', '14', '15',
                            '16', '17', '18', '19', '20', '21', '22', '23',
                            '24', '25', '26', '27', '28', '29', '30', '31',
                            '32', '33', '34', '35', '36', '37', '38', '39',
                            '40', '41', '42', '43', '44', '45', '46', '47',
                            '48', '49', '50', '51', '52', '53', '54', '55',
                            '56', '57', '58', '59', '60', '61', '62', '63',
                            '64', '65', '66', '67', '68', '69', '70', '71',
                            '72', '73', '74', '75', '76', '77', '78', '79',
                            '80', '81', '82', '83', '84', '85', '86', '87',
                            '88', '89'
                        ]
                    },
                    'tunnel-mtu': {
                        'type': 'integer',
                        'default': 1500,
                        'example': 1500
                    },
                    'usg': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'vdom-mirror': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'webservice-proto': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'tlsv1.2', 'tlsv1.1', 'tlsv1.0', 'sslv3',
                                'sslv2'
                            ]
                        }
                    },
                    'workflow-max-sessions': {
                        'type': 'integer',
                        'default': 500,
                        'example': 500
                    },
                    'workspace-mode': {
                        'type': 'string',
                        'enum': ['disabled', 'normal', 'workflow']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/web-proxy/profile/{profile}',
        '/pm/config/global/obj/web-proxy/profile/{profile}'
    ]

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'profile',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'header-client-ip': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'header-front-end-https': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'header-via-request': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'header-via-response': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'header-x-authenticated-groups': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'header-x-authenticated-user': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'header-x-forwarded-for': {
                        'type': 'string',
                        'enum': ['pass', 'add', 'remove']
                    },
                    'headers': {
                        'type': 'array',
                        'items': {
                            'action': {
                                'type':
                                'string',
                                'enum': [
                                    'add-to-request', 'add-to-response',
                                    'remove-from-request',
                                    'remove-from-response'
                                ]
                            },
                            'content': {
                                'type': 'string'
                            },
                            'id': {
                                'type': 'integer'
                            },
                            'name': {
                                'type': 'string'
                            }
                        }
                    },
                    'log-header-change': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'name': {
                        'type': 'string'
                    },
                    'strip-encoding': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object2': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'clone': 'object0',
            'delete': 'object1',
            'get': 'object2',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['clone', 'delete', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #11
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/webfilter/profile',
        '/pm/config/global/obj/webfilter/profile'
    ]

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'comment': {
                        'type': 'string'
                    },
                    'extended-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'https-replacemsg': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'inspection-mode': {
                        'type': 'string',
                        'enum': ['proxy', 'flow-based', 'dns']
                    },
                    'log-all-url': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'name': {
                        'type': 'string'
                    },
                    'options': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'block-invalid-url', 'jscript', 'js', 'vbs',
                                'unknown', 'wf-referer', 'https-scan',
                                'intrinsic', 'wf-cookie', 'per-user-bwl',
                                'activexfilter', 'cookiefilter',
                                'https-url-scan', 'javafilter', 'rangeblock',
                                'contenttype-check'
                            ]
                        }
                    },
                    'ovrd-perm': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'bannedword-override', 'urlfilter-override',
                                'fortiguard-wf-override',
                                'contenttype-check-override'
                            ]
                        }
                    },
                    'post-action': {
                        'type': 'string',
                        'enum': ['normal', 'comfort', 'block']
                    },
                    'replacemsg-group': {
                        'type': 'string'
                    },
                    'web-content-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-extended-all-action-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-activex-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-applet-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-command-block-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-cookie-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-cookie-removal-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-js-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-jscript-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-referer-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-unknown-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-filter-vbs-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-ftgd-err-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-ftgd-quota-usage': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-invalid-domain-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'web-url-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'wisp': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'wisp-algorithm': {
                        'type':
                        'string',
                        'enum':
                        ['auto-learning', 'primary-secondary', 'round-robin']
                    },
                    'wisp-servers': {
                        'type': 'string'
                    },
                    'youtube-channel-filter': {
                        'type': 'array',
                        'items': {
                            'channel-id': {
                                'type': 'string'
                            },
                            'comment': {
                                'type': 'string'
                            },
                            'id': {
                                'type': 'integer'
                            }
                        }
                    },
                    'youtube-channel-status': {
                        'type': 'string',
                        'enum': ['disable', 'blacklist', 'whitelist']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'attr',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'comment', 'extended-log', 'https-replacemsg',
                            'inspection-mode', 'log-all-url', 'name',
                            'options', 'ovrd-perm', 'post-action',
                            'replacemsg-group', 'web-content-log',
                            'web-extended-all-action-log',
                            'web-filter-activex-log', 'web-filter-applet-log',
                            'web-filter-command-block-log',
                            'web-filter-cookie-log',
                            'web-filter-cookie-removal-log',
                            'web-filter-js-log', 'web-filter-jscript-log',
                            'web-filter-referer-log', 'web-filter-unknown-log',
                            'web-filter-vbs-log', 'web-ftgd-err-log',
                            'web-ftgd-quota-usage', 'web-invalid-domain-log',
                            'web-url-log', 'wisp', 'wisp-algorithm',
                            'wisp-servers', 'youtube-channel-status'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'get used',
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type':
                    'string',
                    'enum': [
                        'count', 'object member', 'datasrc', 'get reserved',
                        'syntax'
                    ]
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['add', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #12
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/antivirus/profile/{profile}',
        '/pm/config/global/obj/antivirus/profile/{profile}'
    ]

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'profile',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'analytics-bl-filetype': {
                        'type': 'string'
                    },
                    'analytics-db': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'analytics-max-upload': {
                        'type': 'integer'
                    },
                    'analytics-wl-filetype': {
                        'type': 'string'
                    },
                    'av-block-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'av-virus-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'extended-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ftgd-analytics': {
                        'type': 'string',
                        'enum': ['disable', 'suspicious', 'everything']
                    },
                    'inspection-mode': {
                        'type': 'string',
                        'enum': ['proxy', 'flow-based']
                    },
                    'mobile-malware-db': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'name': {
                        'type': 'string'
                    },
                    'replacemsg-group': {
                        'type': 'string'
                    },
                    'scan-mode': {
                        'type': 'string',
                        'enum': ['quick', 'full']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object2': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'clone': 'object0',
            'delete': 'object1',
            'get': 'object2',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['clone', 'delete', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #13
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/devprof/{devprof}/log/syslogd/setting'
    ]

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'devprof',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'certificate': {
                        'type': 'string'
                    },
                    'enc-algorithm': {
                        'type': 'string',
                        'enum': ['high', 'low', 'disable', 'high-medium']
                    },
                    'facility': {
                        'type':
                        'string',
                        'enum': [
                            'kernel', 'user', 'mail', 'daemon', 'auth',
                            'syslog', 'lpr', 'news', 'uucp', 'cron',
                            'authpriv', 'ftp', 'ntp', 'audit', 'alert',
                            'clock', 'local0', 'local1', 'local2', 'local3',
                            'local4', 'local5', 'local6', 'local7'
                        ]
                    },
                    'mode': {
                        'type': 'string',
                        'enum': ['udp', 'legacy-reliable', 'reliable']
                    },
                    'port': {
                        'type': 'integer'
                    },
                    'server': {
                        'type': 'string'
                    },
                    'ssl-min-proto-version': {
                        'type': 'string',
                        'enum':
                        ['default', 'TLSv1-1', 'TLSv1-2', 'SSLv3', 'TLSv1']
                    },
                    'status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = [
        '/dvmdb/adom/{adom}/script/execute', '/dvmdb/global/script/execute',
        '/dvmdb/script/execute'
    ]

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }, {
                'name': 'workflow',
                'type': 'dict',
                'dict': {
                    'adom': {
                        'type': 'string'
                    },
                    'package': {
                        'type': 'string'
                    },
                    'scope': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'vdom': {
                                'type': 'string'
                            }
                        }
                    },
                    'script': {
                        'type': 'string'
                    }
                },
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'exec': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['exec']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #15
0
def main():
    jrpc_urls = [
        '/dvmdb/adom/{adom}/group/{group}',
        '/dvmdb/group/{group}'
    ]

    url_schema = [
        {
            'name': 'adom',
            'type': 'string'
        },
        {
            'name': 'group',
            'type': 'string'
        }
    ]

    body_schema = {
        'schema_objects': {
            'object0': [
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                },
                {
                    'name': 'data',
                    'type': 'dict',
                    'dict': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'vdom': {
                                'type': 'string'
                            }
                        }
                    },
                    'api_tag': 1
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 1
                }
            ],
            'object1': [
                {
                    'name': 'option',
                    'type': 'dict',
                    'dict': {
                        'type': 'string',
                        'enum': [
                            'object member',
                            'chksum'
                        ]
                    },
                    'api_tag': 0
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ],
            'object2': [
                {
                    'name': 'data',
                    'type': 'dict',
                    'dict': {
                        'desc': {
                            'type': 'string'
                        },
                        'meta fields': {
                            'type': 'string'
                        },
                        'name': {
                            'type': 'string'
                        },
                        'os_type': {
                            'type': 'string',
                            'enum': [
                                'unknown',
                                'fos',
                                'fsw',
                                'foc',
                                'fml',
                                'faz',
                                'fwb',
                                'fch',
                                'fct',
                                'log',
                                'fmg',
                                'fsa',
                                'fdd',
                                'fac',
                                'fpx'
                            ]
                        },
                        'type': {
                            'type': 'string',
                            'enum': [
                                'normal',
                                'default',
                                'auto'
                            ]
                        }
                    },
                    'api_tag': 0
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                },
                {
                    'name': 'data',
                    'type': 'dict',
                    'dict': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'vdom': {
                                'type': 'string'
                            }
                        }
                    },
                    'api_tag': 1
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 1
                }
            ],
            'object3': [
                {
                    'name': 'data',
                    'type': 'dict',
                    'dict': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'vdom': {
                                'type': 'string'
                            }
                        }
                    },
                    'api_tag': 0
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ]
        },
        'method_mapping': {
            'delete': 'object0',
            'get': 'object1',
            'set': 'object2',
            'update': 'object2',
            'add': 'object3'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': [
                'delete',
                'get',
                'set',
                'update',
                'add'
            ]
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module, results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/firewall/service/custom/{custom}',
        '/pm/config/global/obj/firewall/service/custom/{custom}'
    ]

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'custom',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'app-category': {
                        'type': 'array',
                        'items': {
                            'type': 'integer'
                        }
                    },
                    'app-service-type': {
                        'type': 'string',
                        'enum': ['disable', 'app-id', 'app-category']
                    },
                    'application': {
                        'type': 'array',
                        'items': {
                            'type': 'integer'
                        }
                    },
                    'category': {
                        'type': 'string'
                    },
                    'check-reset-range': {
                        'type': 'string',
                        'enum': ['disable', 'default', 'strict']
                    },
                    'color': {
                        'type': 'integer'
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'fqdn': {
                        'type': 'string'
                    },
                    'helper': {
                        'type':
                        'string',
                        'enum': [
                            'disable', 'auto', 'ftp', 'tftp', 'ras', 'h323',
                            'tns', 'mms', 'sip', 'pptp', 'rtsp', 'dns-udp',
                            'dns-tcp', 'pmap', 'rsh', 'dcerpc', 'mgcp',
                            'gtp-c', 'gtp-u', 'gtp-b'
                        ]
                    },
                    'icmpcode': {
                        'type': 'integer'
                    },
                    'icmptype': {
                        'type': 'integer'
                    },
                    'iprange': {
                        'type': 'string'
                    },
                    'name': {
                        'type': 'string'
                    },
                    'protocol': {
                        'type':
                        'string',
                        'enum': [
                            'ICMP', 'IP', 'TCP/UDP/SCTP', 'ICMP6', 'HTTP',
                            'FTP', 'CONNECT', 'SOCKS', 'ALL', 'SOCKS-TCP',
                            'SOCKS-UDP'
                        ]
                    },
                    'protocol-number': {
                        'type': 'integer'
                    },
                    'proxy': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'sctp-portrange': {
                        'type': 'string'
                    },
                    'session-ttl': {
                        'type': 'integer'
                    },
                    'tcp-halfclose-timer': {
                        'type': 'integer'
                    },
                    'tcp-halfopen-timer': {
                        'type': 'integer'
                    },
                    'tcp-portrange': {
                        'type': 'string'
                    },
                    'tcp-timewait-timer': {
                        'type': 'integer'
                    },
                    'udp-idle-timer': {
                        'type': 'integer'
                    },
                    'udp-portrange': {
                        'type': 'string'
                    },
                    'visibility': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object2': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object3': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['before', 'after']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'target',
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'clone': 'object0',
            'delete': 'object1',
            'get': 'object2',
            'move': 'object3',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['clone', 'delete', 'get', 'move', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #17
0
def main():
    jrpc_urls = ['/task/task']

    url_schema = []

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'adom', 'end_tm', 'flags', 'id', 'num_done',
                            'num_err', 'num_lines', 'num_warn', 'percent',
                            'pid', 'src', 'start_tm', 'state', 'title',
                            'tot_percent', 'user'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['count', 'syntax']
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #18
0
def main():
    jrpc_urls = ['/pm/pkg/adom/{adom}/{pkg_path}', '/pm/pkg/global/{pkg_path}']

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'pkg_path',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'enum':
                        ['name', 'obj ver', 'oid', 'scope member', 'type']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object2': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'name': {
                        'type': 'string'
                    },
                    'obj ver': {
                        'type': 'integer'
                    },
                    'oid': {
                        'type': 'integer'
                    },
                    'package setting': {
                        'central-nat': {
                            'type': 'string',
                            'enum': ['disable', 'enable']
                        },
                        'consolidated-firewall-mode': {
                            'type': 'string',
                            'enum': ['disable', 'enable']
                        },
                        'fwpolicy-implicit-log': {
                            'type': 'string',
                            'enum': ['disable', 'enable']
                        },
                        'fwpolicy6-implicit-log': {
                            'type': 'string',
                            'enum': ['disable', 'enable']
                        },
                        'inspection-mode': {
                            'type': 'string',
                            'enum': ['proxy', 'flow']
                        },
                        'ngfw-mode': {
                            'type': 'string',
                            'enum': ['profile-based', 'policy-based']
                        },
                        'ssl-ssh-profile': {
                            'type': 'string'
                        }
                    },
                    'scope member': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'vdom': {
                                'type': 'string'
                            }
                        }
                    },
                    'type': {
                        'type': 'string',
                        'enum': ['pkg', 'folder']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'delete': 'object0',
            'get': 'object1',
            'set': 'object2',
            'update': 'object2'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['delete', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = ['/cli/global/system/interface/{interface}']

    url_schema = [{'name': 'interface', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'alias': {
                        'type': 'string'
                    },
                    'allowaccess': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'ping', 'https', 'ssh', 'snmp', 'http',
                                'webservice', 'https-logging'
                            ]
                        }
                    },
                    'description': {
                        'type': 'string'
                    },
                    'ip': {
                        'type': 'string'
                    },
                    'ipv6': {
                        'ip6-address': {
                            'type': 'string'
                        },
                        'ip6-allowaccess': {
                            'type': 'array',
                            'items': {
                                'type':
                                'string',
                                'enum': [
                                    'ping', 'https', 'ssh', 'snmp', 'http',
                                    'webservice', 'https-logging'
                                ]
                            }
                        },
                        'ip6-autoconf': {
                            'type': 'string',
                            'enum': ['disable', 'enable']
                        }
                    },
                    'mtu': {
                        'type': 'integer',
                        'default': 1500,
                        'example': 1500
                    },
                    'name': {
                        'type': 'string'
                    },
                    'serviceaccess': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum':
                            ['fgtupdates', 'fclupdates', 'webfilter-antispam']
                        }
                    },
                    'speed': {
                        'type':
                        'string',
                        'enum': [
                            'auto', '10full', '10half', '100full', '100half',
                            '1000full', '10000full'
                        ]
                    },
                    'status': {
                        'type': 'string',
                        'enum': ['down', 'up']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'delete': 'object0',
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['delete', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/firewall/address6',
        '/pm/config/global/obj/firewall/address6'
    ]

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'cache-ttl': {
                        'type': 'integer'
                    },
                    'color': {
                        'type': 'integer'
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'dynamic_mapping': {
                        'type': 'array',
                        'items': {
                            '_scope': {
                                'type': 'array',
                                'items': {
                                    'name': {
                                        'type': 'string'
                                    },
                                    'vdom': {
                                        'type': 'string'
                                    }
                                }
                            },
                            'cache-ttl': {
                                'type': 'integer'
                            },
                            'color': {
                                'type': 'integer'
                            },
                            'comment': {
                                'type': 'string'
                            },
                            'end-ip': {
                                'type': 'string'
                            },
                            'fqdn': {
                                'type': 'string'
                            },
                            'host': {
                                'type': 'string'
                            },
                            'host-type': {
                                'type': 'string',
                                'enum': ['any', 'specific']
                            },
                            'ip6': {
                                'type': 'string'
                            },
                            'obj-id': {
                                'type': 'string'
                            },
                            'sdn': {
                                'type': 'string',
                                'enum': ['nsx']
                            },
                            'start-ip': {
                                'type': 'string'
                            },
                            'tags': {
                                'type': 'string'
                            },
                            'template': {
                                'type': 'string'
                            },
                            'type': {
                                'type':
                                'string',
                                'enum': [
                                    'ipprefix', 'iprange', 'nsx', 'dynamic',
                                    'fqdn', 'template'
                                ]
                            },
                            'uuid': {
                                'type': 'string'
                            },
                            'visibility': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            }
                        }
                    },
                    'end-ip': {
                        'type': 'string'
                    },
                    'fqdn': {
                        'type': 'string'
                    },
                    'host': {
                        'type': 'string'
                    },
                    'host-type': {
                        'type': 'string',
                        'enum': ['any', 'specific']
                    },
                    'ip6': {
                        'type': 'string'
                    },
                    'list': {
                        'type': 'array',
                        'items': {
                            'ip': {
                                'type': 'string'
                            }
                        }
                    },
                    'name': {
                        'type': 'string'
                    },
                    'obj-id': {
                        'type': 'string'
                    },
                    'sdn': {
                        'type': 'string',
                        'enum': ['nsx']
                    },
                    'start-ip': {
                        'type': 'string'
                    },
                    'subnet-segment': {
                        'type': 'array',
                        'items': {
                            'name': {
                                'type': 'string'
                            },
                            'type': {
                                'type': 'string',
                                'enum': ['any', 'specific']
                            },
                            'value': {
                                'type': 'string'
                            }
                        }
                    },
                    'tagging': {
                        'type': 'array',
                        'items': {
                            'category': {
                                'type': 'string'
                            },
                            'name': {
                                'type': 'string'
                            },
                            'tags': {
                                'type': 'array',
                                'items': {
                                    'type': 'string'
                                }
                            }
                        }
                    },
                    'template': {
                        'type': 'string'
                    },
                    'type': {
                        'type':
                        'string',
                        'enum': [
                            'ipprefix', 'iprange', 'nsx', 'dynamic', 'fqdn',
                            'template'
                        ]
                    },
                    'uuid': {
                        'type': 'string'
                    },
                    'visibility': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'attr',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'cache-ttl', 'color', 'comment', 'end-ip', 'fqdn',
                            'host', 'host-type', 'ip6', 'name', 'obj-id',
                            'sdn', 'start-ip', 'template', 'type', 'uuid',
                            'visibility'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'get used',
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type':
                    'string',
                    'enum': [
                        'count', 'object member', 'datasrc', 'get reserved',
                        'syntax'
                    ]
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['add', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
def main():
    jrpc_urls = ['/pm/config/adom/{adom}/pkg/{pkg}/firewall/policy']

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'pkg',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'action': {
                        'type': 'string',
                        'enum': ['deny', 'accept', 'ipsec', 'ssl-vpn']
                    },
                    'app-category': {
                        'type': 'string'
                    },
                    'application': {
                        'type': 'array',
                        'items': {
                            'type': 'integer'
                        }
                    },
                    'application-list': {
                        'type': 'string'
                    },
                    'auth-cert': {
                        'type': 'string'
                    },
                    'auth-path': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'auth-redirect-addr': {
                        'type': 'string'
                    },
                    'auto-asic-offload': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'av-profile': {
                        'type': 'string'
                    },
                    'block-notification': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'captive-portal-exempt': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'capture-packet': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'comments': {
                        'type': 'string'
                    },
                    'custom-log-fields': {
                        'type': 'string'
                    },
                    'delay-tcp-npu-session': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'devices': {
                        'type': 'string'
                    },
                    'diffserv-forward': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'diffserv-reverse': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'diffservcode-forward': {
                        'type': 'string'
                    },
                    'diffservcode-rev': {
                        'type': 'string'
                    },
                    'disclaimer': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'dlp-sensor': {
                        'type': 'string'
                    },
                    'dnsfilter-profile': {
                        'type': 'string'
                    },
                    'dscp-match': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'dscp-negate': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'dscp-value': {
                        'type': 'string'
                    },
                    'dsri': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'dstaddr': {
                        'type': 'string'
                    },
                    'dstaddr-negate': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'dstintf': {
                        'type': 'string'
                    },
                    'firewall-session-dirty': {
                        'type': 'string',
                        'enum': ['check-all', 'check-new']
                    },
                    'fixedport': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'fsso': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'fsso-agent-for-ntlm': {
                        'type': 'string'
                    },
                    'global-label': {
                        'type': 'string'
                    },
                    'groups': {
                        'type': 'string'
                    },
                    'gtp-profile': {
                        'type': 'string'
                    },
                    'icap-profile': {
                        'type': 'string'
                    },
                    'identity-based-route': {
                        'type': 'string'
                    },
                    'inbound': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'internet-service': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'internet-service-custom': {
                        'type': 'string'
                    },
                    'internet-service-id': {
                        'type': 'string'
                    },
                    'internet-service-negate': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ippool': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ips-sensor': {
                        'type': 'string'
                    },
                    'label': {
                        'type': 'string'
                    },
                    'learning-mode': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'logtraffic': {
                        'type': 'string',
                        'enum': ['disable', 'enable', 'all', 'utm']
                    },
                    'logtraffic-start': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'match-vip': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'mms-profile': {
                        'type': 'string'
                    },
                    'name': {
                        'type': 'string'
                    },
                    'nat': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'natinbound': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'natip': {
                        'type': 'string'
                    },
                    'natoutbound': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ntlm': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ntlm-enabled-browsers': {
                        'type': 'array',
                        'items': {
                            'type': 'string'
                        }
                    },
                    'ntlm-guest': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'outbound': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'per-ip-shaper': {
                        'type': 'string'
                    },
                    'permit-any-host': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'permit-stun-host': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'policyid': {
                        'type': 'integer'
                    },
                    'poolname': {
                        'type': 'string'
                    },
                    'profile-group': {
                        'type': 'string'
                    },
                    'profile-protocol-options': {
                        'type': 'string'
                    },
                    'profile-type': {
                        'type': 'string',
                        'enum': ['single', 'group']
                    },
                    'radius-mac-auth-bypass': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'redirect-url': {
                        'type': 'string'
                    },
                    'replacemsg-override-group': {
                        'type': 'string'
                    },
                    'rsso': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'rtp-addr': {
                        'type': 'string'
                    },
                    'rtp-nat': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'scan-botnet-connections': {
                        'type': 'string',
                        'enum': ['disable', 'block', 'monitor']
                    },
                    'schedule': {
                        'type': 'string'
                    },
                    'schedule-timeout': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'send-deny-packet': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'service': {
                        'type': 'string'
                    },
                    'service-negate': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'session-ttl': {
                        'type': 'integer'
                    },
                    'spamfilter-profile': {
                        'type': 'string'
                    },
                    'srcaddr': {
                        'type': 'string'
                    },
                    'srcaddr-negate': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'srcintf': {
                        'type': 'string'
                    },
                    'ssl-mirror': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ssl-mirror-intf': {
                        'type': 'string'
                    },
                    'ssl-ssh-profile': {
                        'type': 'string'
                    },
                    'status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'tags': {
                        'type': 'string'
                    },
                    'tcp-mss-receiver': {
                        'type': 'integer'
                    },
                    'tcp-mss-sender': {
                        'type': 'integer'
                    },
                    'tcp-session-without-syn': {
                        'type': 'string',
                        'enum': ['all', 'data-only', 'disable']
                    },
                    'timeout-send-rst': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'traffic-shaper': {
                        'type': 'string'
                    },
                    'traffic-shaper-reverse': {
                        'type': 'string'
                    },
                    'url-category': {
                        'type': 'string'
                    },
                    'users': {
                        'type': 'string'
                    },
                    'utm-status': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'uuid': {
                        'type': 'string'
                    },
                    'vlan-cos-fwd': {
                        'type': 'integer'
                    },
                    'vlan-cos-rev': {
                        'type': 'integer'
                    },
                    'voip-profile': {
                        'type': 'string'
                    },
                    'vpn_dst_node': {
                        'type': 'array',
                        'items': {
                            'host': {
                                'type': 'string'
                            },
                            'seq': {
                                'type': 'integer'
                            },
                            'subnet': {
                                'type': 'string'
                            }
                        }
                    },
                    'vpn_src_node': {
                        'type': 'array',
                        'items': {
                            'host': {
                                'type': 'string'
                            },
                            'seq': {
                                'type': 'integer'
                            },
                            'subnet': {
                                'type': 'string'
                            }
                        }
                    },
                    'vpntunnel': {
                        'type': 'string'
                    },
                    'waf-profile': {
                        'type': 'string'
                    },
                    'wanopt': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'wanopt-detection': {
                        'type': 'string',
                        'enum': ['active', 'passive', 'off']
                    },
                    'wanopt-passive-opt': {
                        'type': 'string',
                        'enum': ['default', 'transparent', 'non-transparent']
                    },
                    'wanopt-peer': {
                        'type': 'string'
                    },
                    'wanopt-profile': {
                        'type': 'string'
                    },
                    'wccp': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'webcache': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'webcache-https': {
                        'type': 'string',
                        'enum': ['disable', 'ssl-server', 'any', 'enable']
                    },
                    'webfilter-profile': {
                        'type': 'string'
                    },
                    'wsso': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'attr',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'action', 'app-category', 'application',
                            'application-list', 'auth-cert', 'auth-path',
                            'auth-redirect-addr', 'auto-asic-offload',
                            'av-profile', 'block-notification',
                            'captive-portal-exempt', 'capture-packet',
                            'custom-log-fields', 'delay-tcp-npu-session',
                            'devices', 'diffserv-forward', 'diffserv-reverse',
                            'diffservcode-forward', 'diffservcode-rev',
                            'disclaimer', 'dlp-sensor', 'dnsfilter-profile',
                            'dscp-match', 'dscp-negate', 'dscp-value', 'dsri',
                            'dstaddr', 'dstaddr-negate', 'dstintf',
                            'firewall-session-dirty', 'fixedport', 'fsso',
                            'fsso-agent-for-ntlm', 'global-label', 'groups',
                            'gtp-profile', 'icap-profile',
                            'identity-based-route', 'inbound',
                            'internet-service', 'internet-service-custom',
                            'internet-service-id', 'internet-service-negate',
                            'ippool', 'ips-sensor', 'label', 'learning-mode',
                            'logtraffic', 'logtraffic-start', 'match-vip',
                            'mms-profile', 'name', 'nat', 'natinbound',
                            'natip', 'natoutbound', 'ntlm',
                            'ntlm-enabled-browsers', 'ntlm-guest', 'outbound',
                            'per-ip-shaper', 'permit-any-host',
                            'permit-stun-host', 'policyid', 'poolname',
                            'profile-group', 'profile-protocol-options',
                            'profile-type', 'radius-mac-auth-bypass',
                            'redirect-url', 'replacemsg-override-group',
                            'rsso', 'rtp-addr', 'rtp-nat',
                            'scan-botnet-connections', 'schedule',
                            'schedule-timeout', 'send-deny-packet', 'service',
                            'service-negate', 'session-ttl',
                            'spamfilter-profile', 'srcaddr', 'srcaddr-negate',
                            'srcintf', 'ssl-mirror', 'ssl-mirror-intf',
                            'ssl-ssh-profile', 'status', 'tags',
                            'tcp-mss-receiver', 'tcp-mss-sender',
                            'tcp-session-without-syn', 'timeout-send-rst',
                            'traffic-shaper', 'traffic-shaper-reverse',
                            'url-category', 'users', 'utm-status', 'uuid',
                            'vlan-cos-fwd', 'vlan-cos-rev', 'voip-profile',
                            'vpntunnel', 'waf-profile', 'wanopt',
                            'wanopt-detection', 'wanopt-passive-opt',
                            'wanopt-peer', 'wanopt-profile', 'wccp',
                            'webcache', 'webcache-https', 'webfilter-profile',
                            'wsso'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'get used',
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type':
                    'string',
                    'enum': [
                        'count', 'object member', 'datasrc', 'get reserved',
                        'syntax'
                    ]
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['add', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #22
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/firewall/ssl-ssh-profile',
        '/pm/config/global/obj/firewall/ssl-ssh-profile'
    ]

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'caname': {
                        'type': 'string'
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'mapi-over-https': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'name': {
                        'type': 'string'
                    },
                    'rpc-over-https': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'server-cert': {
                        'type': 'string'
                    },
                    'server-cert-mode': {
                        'type': 'string',
                        'enum': ['re-sign', 'replace']
                    },
                    'ssl-anomalies-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ssl-exempt': {
                        'type': 'array',
                        'items': {
                            'address': {
                                'type': 'string'
                            },
                            'address6': {
                                'type': 'string'
                            },
                            'fortiguard-category': {
                                'type': 'string'
                            },
                            'id': {
                                'type': 'integer'
                            },
                            'regex': {
                                'type': 'string'
                            },
                            'type': {
                                'type':
                                'string',
                                'enum': [
                                    'fortiguard-category', 'address',
                                    'address6', 'wildcard-fqdn', 'regex'
                                ]
                            },
                            'wildcard-fqdn': {
                                'type': 'string'
                            }
                        }
                    },
                    'ssl-exemptions-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'ssl-server': {
                        'type': 'array',
                        'items': {
                            'ftps-client-cert-request': {
                                'type': 'string',
                                'enum': ['bypass', 'inspect', 'block']
                            },
                            'https-client-cert-request': {
                                'type': 'string',
                                'enum': ['bypass', 'inspect', 'block']
                            },
                            'id': {
                                'type': 'integer'
                            },
                            'imaps-client-cert-request': {
                                'type': 'string',
                                'enum': ['bypass', 'inspect', 'block']
                            },
                            'ip': {
                                'type': 'string'
                            },
                            'pop3s-client-cert-request': {
                                'type': 'string',
                                'enum': ['bypass', 'inspect', 'block']
                            },
                            'smtps-client-cert-request': {
                                'type': 'string',
                                'enum': ['bypass', 'inspect', 'block']
                            },
                            'ssl-other-client-cert-request': {
                                'type': 'string',
                                'enum': ['bypass', 'inspect', 'block']
                            }
                        }
                    },
                    'untrusted-caname': {
                        'type': 'string'
                    },
                    'use-ssl-server': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'whitelist': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'attr',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'caname', 'comment', 'mapi-over-https', 'name',
                            'rpc-over-https', 'server-cert',
                            'server-cert-mode', 'ssl-anomalies-log',
                            'ssl-exemptions-log', 'untrusted-caname',
                            'use-ssl-server', 'whitelist'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'get used',
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type':
                    'string',
                    'enum': [
                        'count', 'object member', 'datasrc', 'get reserved',
                        'syntax'
                    ]
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['add', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #23
0
def main():
    jrpc_urls = ['/pm/config/adom/{adom}/devprof/{devprof}/system/global']

    url_schema = [{
        'name': 'adom',
        'type': 'string'
    }, {
        'name': 'devprof',
        'type': 'string'
    }]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type': 'string',
                    'enum': ['object member', 'chksum', 'datasrc']
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'name': 'data',
                'type': 'dict',
                'dict': {
                    'admin-https-redirect': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'admin-port': {
                        'type': 'integer'
                    },
                    'admin-scp': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'admin-sport': {
                        'type': 'integer'
                    },
                    'admin-ssh-port': {
                        'type': 'integer'
                    },
                    'admin-ssh-v1': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'admin-telnet-port': {
                        'type': 'integer'
                    },
                    'admintimeout': {
                        'type': 'integer'
                    },
                    'gui-ipv6': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'gui-lines-per-page': {
                        'type': 'integer'
                    },
                    'gui-theme': {
                        'type': 'string',
                        'enum':
                        ['blue', 'green', 'melongene', 'red', 'mariner']
                    },
                    'language': {
                        'type':
                        'string',
                        'enum': [
                            'english', 'simch', 'japanese', 'korean',
                            'spanish', 'trach', 'french', 'portuguese'
                        ]
                    },
                    'switch-controller': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'get': 'object0',
            'set': 'object1',
            'update': 'object1'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #24
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/application/list',
        '/pm/config/global/obj/application/list'
    ]

    url_schema = [{'name': 'adom', 'type': 'string'}]

    body_schema = {
        'schema_objects': {
            'object0': [{
                'name': 'data',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'app-replacemsg': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'comment': {
                        'type': 'string'
                    },
                    'deep-app-inspection': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'entries': {
                        'type': 'array',
                        'items': {
                            'action': {
                                'type': 'string',
                                'enum': ['pass', 'block', 'reset']
                            },
                            'application': {
                                'type': 'array',
                                'items': {
                                    'type': 'integer'
                                }
                            },
                            'behavior': {
                                'type': 'array',
                                'items': {
                                    'type': 'string'
                                }
                            },
                            'category': {
                                'type': 'string'
                            },
                            'id': {
                                'type': 'integer'
                            },
                            'log': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'log-packet': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'parameters': {
                                'type': 'array',
                                'items': {
                                    'id': {
                                        'type': 'integer'
                                    },
                                    'value': {
                                        'type': 'string'
                                    }
                                }
                            },
                            'per-ip-shaper': {
                                'type': 'string'
                            },
                            'popularity': {
                                'type': 'array',
                                'items': {
                                    'type': 'string',
                                    'enum': ['1', '2', '3', '4', '5']
                                }
                            },
                            'protocols': {
                                'type': 'array',
                                'items': {
                                    'type': 'string'
                                }
                            },
                            'quarantine': {
                                'type': 'string',
                                'enum': ['none', 'attacker']
                            },
                            'quarantine-expiry': {
                                'type': 'string'
                            },
                            'quarantine-log': {
                                'type': 'string',
                                'enum': ['disable', 'enable']
                            },
                            'rate-count': {
                                'type': 'integer'
                            },
                            'rate-duration': {
                                'type': 'integer'
                            },
                            'rate-mode': {
                                'type': 'string',
                                'enum': ['periodical', 'continuous']
                            },
                            'rate-track': {
                                'type':
                                'string',
                                'enum': [
                                    'none', 'src-ip', 'dest-ip',
                                    'dhcp-client-mac', 'dns-domain'
                                ]
                            },
                            'risk': {
                                'type': 'array',
                                'items': {
                                    'type': 'integer'
                                }
                            },
                            'session-ttl': {
                                'type': 'integer'
                            },
                            'shaper': {
                                'type': 'string'
                            },
                            'shaper-reverse': {
                                'type': 'string'
                            },
                            'sub-category': {
                                'type': 'array',
                                'items': {
                                    'type': 'integer'
                                }
                            },
                            'technology': {
                                'type': 'array',
                                'items': {
                                    'type': 'string'
                                }
                            },
                            'vendor': {
                                'type': 'array',
                                'items': {
                                    'type': 'string'
                                }
                            }
                        }
                    },
                    'extended-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'name': {
                        'type': 'string'
                    },
                    'options': {
                        'type': 'array',
                        'items': {
                            'type':
                            'string',
                            'enum': [
                                'allow-dns', 'allow-icmp', 'allow-http',
                                'allow-ssl', 'allow-quic'
                            ]
                        }
                    },
                    'other-application-action': {
                        'type': 'string',
                        'enum': ['pass', 'block']
                    },
                    'other-application-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    },
                    'p2p-black-list': {
                        'type': 'array',
                        'items': {
                            'type': 'string',
                            'enum': ['skype', 'edonkey', 'bittorrent']
                        }
                    },
                    'replacemsg-group': {
                        'type': 'string'
                    },
                    'unknown-application-action': {
                        'type': 'string',
                        'enum': ['pass', 'block']
                    },
                    'unknown-application-log': {
                        'type': 'string',
                        'enum': ['disable', 'enable']
                    }
                }
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }],
            'object1': [{
                'type': 'string',
                'name': 'attr',
                'api_tag': 0
            }, {
                'name': 'fields',
                'api_tag': 0,
                'type': 'array',
                'items': {
                    'type': 'array',
                    'items': {
                        'type':
                        'string',
                        'enum': [
                            'app-replacemsg', 'comment', 'deep-app-inspection',
                            'extended-log', 'name', 'options',
                            'other-application-action',
                            'other-application-log', 'p2p-black-list',
                            'replacemsg-group', 'unknown-application-action',
                            'unknown-application-log'
                        ]
                    }
                }
            }, {
                'name': 'filter',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'string',
                        'example': ['<attr>', '==', 'test']
                    }
                },
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'get used',
                'api_tag': 0
            }, {
                'type': 'integer',
                'name': 'loadsub',
                'api_tag': 0
            }, {
                'name': 'option',
                'type': 'dict',
                'dict': {
                    'type':
                    'string',
                    'enum': [
                        'count', 'object member', 'datasrc', 'get reserved',
                        'syntax'
                    ]
                },
                'api_tag': 0
            }, {
                'name': 'range',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        'type': 'integer',
                        'example': [2, 5]
                    }
                },
                'api_tag': 0
            }, {
                'name': 'sortings',
                'type': 'dict',
                'dict': {
                    'type': 'array',
                    'items': {
                        '{attr_name}': {
                            'type': 'integer',
                            'enum': [1, -1]
                        }
                    }
                },
                'api_tag': 0
            }, {
                'type': 'string',
                'name': 'url',
                'api_tag': 0
            }]
        },
        'method_mapping': {
            'add': 'object0',
            'get': 'object1',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': ['add', 'get', 'set', 'update']
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module,
                             results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(
                                 response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])
Example #25
0
def main():
    jrpc_urls = [
        '/pm/config/adom/{adom}/obj/ips/sensor/{sensor}',
        '/pm/config/global/obj/ips/sensor/{sensor}'
    ]

    url_schema = [
        {
            'name': 'adom',
            'type': 'string'
        },
        {
            'name': 'sensor',
            'type': 'string'
        }
    ]

    body_schema = {
        'schema_objects': {
            'object0': [
                {
                    'name': 'data',
                    'type': 'dict',
                    'dict': {
                        'block-malicious-url': {
                            'type': 'string',
                            'enum': [
                                'disable',
                                'enable'
                            ]
                        },
                        'comment': {
                            'type': 'string'
                        },
                        'entries': {
                            'type': 'array',
                            'items': {
                                'action': {
                                    'type': 'string',
                                    'enum': [
                                        'pass',
                                        'block',
                                        'reset',
                                        'default'
                                    ]
                                },
                                'application': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'exempt-ip': {
                                    'type': 'array',
                                    'items': {
                                        'dst-ip': {
                                            'type': 'string'
                                        },
                                        'id': {
                                            'type': 'integer'
                                        },
                                        'src-ip': {
                                            'type': 'string'
                                        }
                                    }
                                },
                                'id': {
                                    'type': 'integer'
                                },
                                'location': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'log': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'log-attack-context': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'log-packet': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'os': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'protocol': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'quarantine': {
                                    'type': 'string',
                                    'enum': [
                                        'none',
                                        'attacker',
                                        'both',
                                        'interface'
                                    ]
                                },
                                'quarantine-expiry': {
                                    'type': 'string'
                                },
                                'quarantine-log': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'rate-count': {
                                    'type': 'integer'
                                },
                                'rate-duration': {
                                    'type': 'integer'
                                },
                                'rate-mode': {
                                    'type': 'string',
                                    'enum': [
                                        'periodical',
                                        'continuous'
                                    ]
                                },
                                'rate-track': {
                                    'type': 'string',
                                    'enum': [
                                        'none',
                                        'src-ip',
                                        'dest-ip',
                                        'dhcp-client-mac',
                                        'dns-domain'
                                    ]
                                },
                                'rule': {
                                    'type': 'string'
                                },
                                'severity': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'status': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable',
                                        'default'
                                    ]
                                }
                            }
                        },
                        'extended-log': {
                            'type': 'string',
                            'enum': [
                                'disable',
                                'enable'
                            ]
                        },
                        'filter': {
                            'type': 'array',
                            'items': {
                                'action': {
                                    'type': 'string',
                                    'enum': [
                                        'pass',
                                        'block',
                                        'default',
                                        'reset'
                                    ]
                                },
                                'application': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'location': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'log': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable',
                                        'default'
                                    ]
                                },
                                'log-packet': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable',
                                        'default'
                                    ]
                                },
                                'name': {
                                    'type': 'string'
                                },
                                'os': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'protocol': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'quarantine': {
                                    'type': 'string',
                                    'enum': [
                                        'none',
                                        'attacker',
                                        'both',
                                        'interface'
                                    ]
                                },
                                'quarantine-expiry': {
                                    'type': 'integer'
                                },
                                'quarantine-log': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'severity': {
                                    'type': 'array',
                                    'items': {
                                        'type': 'string'
                                    }
                                },
                                'status': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable',
                                        'default'
                                    ]
                                }
                            }
                        },
                        'name': {
                            'type': 'string'
                        },
                        'override': {
                            'type': 'array',
                            'items': {
                                'action': {
                                    'type': 'string',
                                    'enum': [
                                        'pass',
                                        'block',
                                        'reset'
                                    ]
                                },
                                'exempt-ip': {
                                    'type': 'array',
                                    'items': {
                                        'dst-ip': {
                                            'type': 'string'
                                        },
                                        'id': {
                                            'type': 'integer'
                                        },
                                        'src-ip': {
                                            'type': 'string'
                                        }
                                    }
                                },
                                'log': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'log-packet': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'quarantine': {
                                    'type': 'string',
                                    'enum': [
                                        'none',
                                        'attacker',
                                        'both',
                                        'interface'
                                    ]
                                },
                                'quarantine-expiry': {
                                    'type': 'integer'
                                },
                                'quarantine-log': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                },
                                'rule-id': {
                                    'type': 'integer'
                                },
                                'status': {
                                    'type': 'string',
                                    'enum': [
                                        'disable',
                                        'enable'
                                    ]
                                }
                            }
                        },
                        'replacemsg-group': {
                            'type': 'string'
                        }
                    },
                    'api_tag': 0
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ],
            'object1': [
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ],
            'object2': [
                {
                    'name': 'option',
                    'type': 'dict',
                    'dict': {
                        'type': 'string',
                        'enum': [
                            'object member',
                            'chksum',
                            'datasrc'
                        ]
                    },
                    'api_tag': 0
                },
                {
                    'type': 'string',
                    'name': 'url',
                    'api_tag': 0
                }
            ]
        },
        'method_mapping': {
            'clone': 'object0',
            'delete': 'object1',
            'get': 'object2',
            'set': 'object0',
            'update': 'object0'
        }
    }

    module_arg_spec = {
        'loose_validation': {
            'type': 'bool',
            'required': False,
            'default': False
        },
        'workspace_locking_adom': {
            'type': 'str',
            'required': False
        },
        'workspace_locking_timeout': {
            'type': 'int',
            'required': False,
            'default': 300
        },
        'params': {
            'type': 'list',
            'required': False
        },
        'method': {
            'type': 'str',
            'required': True,
            'choices': [
                'clone',
                'delete',
                'get',
                'set',
                'update'
            ]
        },
        'url_params': {
            'type': 'dict',
            'required': False
        }
    }
    module = AnsibleModule(argument_spec=module_arg_spec,
                           supports_check_mode=False)
    method = module.params['method']
    loose_validation = module.params['loose_validation']

    fmgr = None
    payload = None
    response = DEFAULT_RESULT_OBJ

    if module._socket_path:
        connection = Connection(module._socket_path)
        tools = FMGRCommon()
        if loose_validation is False:
            tools.validate_module_params(module, body_schema)
        tools.validate_module_url_params(module, jrpc_urls, url_schema)
        full_url = tools.get_full_url_path(module, jrpc_urls)
        payload = tools.get_full_payload(module, full_url)
        fmgr = FortiManagerHandler(connection, module)
        fmgr.tools = tools
    else:
        module.fail_json(**FAIL_SOCKET_MSG)

    try:
        response = fmgr._conn.send_request(method, payload)
        fmgr.govern_response(module=module, results=response,
                             msg='Operation Finished',
                             ansible_facts=fmgr.construct_ansible_facts(response, module.params, module.params))
    except Exception as e:
        raise FMGBaseException(e)

    module.exit_json(meta=response[1])