Beispiel #1
0
def main():
    argument_spec = dict(
        action=dict(type='str', required=True),
        name=dict(type='str', required=True),
    )
    argument_spec.update(fadcos_argument_spec)

    required_if = [('name')]
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)
    connection = Connection(module._socket_path)
    action = module.params['action']
    result = {}
    if not is_vdom_enable(connection):
        result['err_msg'] = 'vdom is disable in system setting, please check'
        result['failed'] = True
    elif action == 'add':
        code, response = add_vdom(module, connection)
        result['res'] = response
        result['changed'] = True
    elif action == 'get':
        code, response = get_vdom(module, connection)
        result['res'] = response
    elif action == 'delete':
        code, data = get_vdom(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            code, response = delete_vdom(module, connection)
            result['res'] = response
            result['changed'] = True
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
    else:
        result['err_msg'] = 'error action: ' + action
        result['failed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result['changed'] = False
        result['failed'] = True

    module.exit_json(**result)
def main():
    argument_spec = dict(
        name=dict(type='str', required=True),
        application=dict(type='str', required=True),
        address=dict(type='str', required=True),
        interface=dict(type='str', required=True),
        pool=dict(type='str', required=True),
        port=dict(type='str', required=True),
        ssl=dict(type='str', default='disable'),
        ssl_profile=dict(type='str'),
        vdom=dict(type='str'),
    )
    argument_spec.update(fadcos_argument_spec)
    result = {}
    required_if = [('name')]
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)
    connection = Connection(module._socket_path)
    if is_vdom_enable(connection) and not module.params['vdom']:
        result['err_msg'] = 'The vdom is enable, please set vdom'
        result['failed'] = True
    elif is_vdom_enable(
            connection) and module.params['vdom'] and not is_user_in_vdom(
                connection, module.params['vdom']):
        result[
            'err_msg'] = 'The user can not accsee the vdom ' + module.params[
                'vdom']
        result['failed'] = True
    else:
        code, response = add_basic_vs(module, connection)
        result = {'code': code}
        result['res'] = response
        result['changed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result['changed'] = False
        result['failed'] = True

    module.exit_json(**result)
Beispiel #3
0
def main():
    argument_spec = dict(
        action=dict(type='str', required=True),
        name=dict(type='str'),
        iptype=dict(type='str'),
        healthcheck=dict(type='str', default='disable'),
        health_check_relationship=dict(type='str', default='AND'),
        health_check_list=dict(type='list'),
        rs_profile=dict(type='str', default='NONE'),
        vdom=dict(type='str'),
    )
    argument_spec.update(fadcos_argument_spec)
    required_if = [('name')]
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)
    connection = Connection(module._socket_path)

    action = module.params['action']
    result = {}
    param_pass, param_err = param_check(module, connection)
    if not param_pass:
        result['err_msg'] = param_err
        result['failed'] = True
    elif action == 'add':
        code, response = add_rs_pool(module, connection)
        result['res'] = response
        result['changed'] = True
    elif action == 'get':
        code, response = get_rs_pool(module, connection)
        result['res'] = response
    elif action == 'edit':
        code, data = get_rs_pool(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
        if res:
            code, response = edit_rs_pool(module, new_data, connection)
            result['changed'] = True
            result['res'] = response
    elif action == 'delete':
        code, data = get_rs_pool(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
            code, response = delete_rs_pool(module, connection)
            result['res'] = response
            result['changed'] = True
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
    else:
        result['err_msg'] = 'error action: ' + action
        result['failed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result['changed'] = False
        result['failed'] = True

    module.exit_json(**result)
def main():
    argument_spec = dict(
        action=dict(type='str', required=True),
        pool_name=dict(type='str', required=True),
        member_id=dict(type='str'),
        rs=dict(type='str'),
        status=dict(type='str', default='enable'),
        port=dict(type='str', default='80'),
        recover=dict(type='str', default='0'),
        rs_profile_inherit=dict(type='str', default='enable'),
        rs_profile=dict(type='str', default='NONE'),
        weight=dict(type='str', default='1'),
        warmup=dict(type='str', default='0'),
        warmrate=dict(type='str', default='100'),
        backup=dict(type='str', default='disable'),
        connlimit=dict(type='str', default='0'),
        connection_ratelimit=dict(type='str', default='0'),
        cookie=dict(type='str', default=''),
        health_check_inherit=dict(type='str', default='enable'),
        health_check=dict(type='str', default='disable'),
        health_check_list=dict(type='list'),
        health_check_relationship=dict(type='str', default='AND'),
        mysql_group_id=dict(type='str', default='0'),
        mysql_read_only=dict(type='str', default='disable'),
        vdom=dict(type='str'),
    )
    argument_spec.update(fadcos_argument_spec)
    required_if = []
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)
    connection = Connection(module._socket_path)

    action = module.params['action']
    result = {}
    param_pass, param_err = param_check(module, connection)
    if not param_pass:
        result['err_msg'] = param_err
        result['failed'] = True
    elif action == 'add':
        code, response = add_rs_pool_member(module, connection)

        result['res'] = response
        result['changed'] = True
    elif action == 'get':
        code, response = get_rs_pool_member(module, connection)
        result['res'] = response
    elif action == 'edit':
        code, data = get_rs_pool_member(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
        if res:
            code, response = edit_rs_pool_member(module, new_data, connection)
            result['res'] = response
            result['changed'] = True
    elif action == 'delete':
        code, data = get_rs_pool_member(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
            code, response = delete_rs_pool_member(module, connection)
            result['res'] = response
            result['changed'] = True
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
    else:
        result['err_msg'] = 'error action: ' + action
        result['failed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result['changed'] = False
        result['failed'] = True

    module.exit_json(**result)
def main():
    argument_spec = dict(
        action=dict(type='str', required=True),
        name=dict(type='str'),
        status=dict(type='str', default='up'),
        mode=dict(type='str'),
        IPandMask=dict(type='str'),
        IPv6andMask=dict(type='str'),
        allowaccess=dict(type='list'),
        mtu=dict(type='str', default='1500'),
        intf_type=dict(type='str'),
        vlanid=dict(type='str'),
        vdom=dict(type='str'),
        interface = dict(type='str'),
        aggregate_algorithm = dict(type='str'),
        aggregate_mode = dict(type='str'),
        default_gw = dict(type='str', default='enable'),
        dhcp_gw_override = dict(type='str', default='disable'),
        dhcp_gw_distance = dict(type='str', default='10'),
        disc_retry_timeout = dict(type='str'),
        pppoe_username = dict(type='str'),
        pppoe_passwd = dict(type='str'),
        floating = dict(type='str', default='disable'),
        floating_ip = dict(type='str'),
        redundant_member = dict(type='list'),
        traffic_group = dict(type='str', default='default'),
    )

    argument_spec.update(fadcos_argument_spec)

    required_if = [('name')]
    module = AnsibleModule(argument_spec=argument_spec, required_if=required_if)
    connection = Connection(module._socket_path)

    action = module.params['action']
    result = {}
    param_pass, param_err = param_check(module, connection)
    if not param_pass:
        result['err_msg'] = param_err
        result['failed'] = True
    elif action == 'add':
        code, response = add_interface(module, connection)
        result['res'] = response
        result ['changed'] = True
    elif action == 'get':
        code, response = get_interface(module, connection)
        result['res'] = response
    elif action == 'edit':
        code, data = get_interface(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
        if res:
            code, response = edit_interface(module, new_data, connection)
            result['res'] = response
            result ['changed'] = True
    elif action == 'delete':
        code, data = get_interface(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(data['payload']) is not int:
            code, response = delete_interface(module, connection)
            result['res'] = response
            result ['changed'] = True
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
    else:
        result['err_msg'] = 'error action: ' + action
        result['failed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result ['changed'] = False
        result['failed'] = True

    module.exit_json(**result)
Beispiel #6
0
def main():
    argument_spec = dict(
        action=dict(type='str', required=True),
        name=dict(type='str'),
        status=dict(type='str'),
        iptype=dict(type='str'),
        ip=dict(type='str'),
        public_ip=dict(type='str'),
        public_iptype=dict(type='str', default='ipv4'),
        interface=dict(type='str'),
        vstype=dict(type='str'),
        pool=dict(type='str'),
        port=dict(type='str', default='80'),
        profile=dict(type='str'),
        method=dict(type='str', default='LB_METHOD_ROUND_ROBIN'),
        ssl_mirror=dict(type='str', default='disable'),
        ssl_mirror_intf=dict(type='str', default=''),
        traffic_group=dict(type='str', default='default'),
        traffic_log=dict(type='str', default='disable'),
        trans_rate_limit=dict(type='str', default='0'),
        warmrate=dict(type='str', default='100'),
        warmup=dict(type='str', default='0'),
        alone=dict(type='str', default='enable'),
        av_profile=dict(type='str', default=''),
        client_ssl_profile=dict(type='str', default=''),
        clone_pool=dict(type='str', default=''),
        clone_traffic_type=dict(type='str', default=''),
        connection_limit=dict(type='str', default='0'),
        connection_rate_limit=dict(type='str', default=''),
        content_rewriting=dict(type='str', default='disable'),
        content_rewriting_list=dict(type='list'),
        content_routing=dict(type='str', default='disable'),
        content_routing_list=dict(type='list'),
        schedule_list=dict(type='str', default='disable'),
        schedule_pool_list=dict(type='list'),
        scripting_flag=dict(type='str', default='disable'),
        scripting_list=dict(type='list'),
        source_pool_list=dict(type='list'),
        waf_profile=dict(type='str', default=''),
        http2https=dict(type='str', default=''),
        http2https_port=dict(type='str', default=''),
        l2_exception_list=dict(type='str', default=''),
        packet_fwd_method=dict(type='str', default=''),
        pagespeed=dict(type='str', default=''),
        persistence=dict(type='str', default=''),
        protocol=dict(type='str', default='0'),
        adfs_published_service=dict(type='str', default=''),
        error_msg=dict(type='str', default='Server-unavailable!'),
        error_page=dict(type='str', default=''),
        fortiview=dict(type='str', default='disable'),
        wccp=dict(type='str', default='disable'),
        comments=dict(type='str'),
        vdom=dict(type='str'),
    )
    argument_spec.update(fadcos_argument_spec)

    required_if = [('name')]
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)
    connection = Connection(module._socket_path)

    action = module.params['action']
    result = {}
    param_pass, param_err = param_check(module, connection)
    if not param_pass:
        result['err_msg'] = param_err
        result['failed'] = True
    elif action == 'add':
        code, response = add_vs(module, connection)
        result['res'] = response
        result['changed'] = True
    elif action == 'get':
        code, response = get_vs(module, connection)
        result['res'] = response
    elif action == 'edit':
        code, data = get_vs(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
        if res:
            code, response = edit_vs(module, new_data, connection)
            result['res'] = response
            result['changed'] = True
    elif action == 'delete':
        code, data = get_vs(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            code, response = delete_vs(module, connection)
            result['res'] = response
            result['changed'] = True
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
    else:
        result['err_msg'] = 'error action: ' + action
        result['failed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result['changed'] = False
        result['failed'] = True

    module.exit_json(**result)
def main():
    argument_spec = dict(action=dict(type='str', required=True),
                         route_id=dict(type='str'),
                         desination=dict(type='str'),
                         gateway=dict(type='str'),
                         distance=dict(type='str'),
                         vdom=dict(type='str'))
    argument_spec.update(fadcos_argument_spec)

    required_if = []
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)
    connection = Connection(module._socket_path)

    action = module.params['action']
    result = {}
    param_pass, param_err = param_check(module, connection)
    if not param_pass:
        result['err_msg'] = param_err
        result['failed'] = True
    elif action == 'add':
        code, response = add_route_static(module, connection)
        result['res'] = response
        result['changed'] = True
    elif action == 'get':
        code, response = get_route_static(module, connection)
        result['res'] = response
    elif action == 'edit':
        code, data = get_route_static(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
        if res:
            code, response = edit_route_static(module, new_data, connection)
            result['changed'] = True
            result['res'] = response
    elif action == 'delete':
        code, data = get_route_static(module, connection)
        if 'payload' in data.keys() and data['payload'] and type(
                data['payload']) is not int:
            res, new_data = needs_update(module, data['payload'])
            code, response = delete_route_static(module, connection)
            result['res'] = response
            result['changed'] = True
        else:
            result['failed'] = True
            res = False
            result['err_msg'] = 'Entry not found'
    else:
        result['err_msg'] = 'error action: ' + action
        result['failed'] = True

    if 'res' in result.keys() and type(result['res']) is dict\
            and type(result['res']['payload'])  is int and result['res']['payload'] < 0:
        result['err_msg'] = get_err_msg(connection, result['res']['payload'])
        result['changed'] = False
        result['failed'] = True

    module.exit_json(**result)