def add_interface(module, connection):
    name = module.params['name']
    mode = module.params['mode']
    status = module.params['status']
    IPandMask = module.params['IPandMask']
    IPv6andMask = module.params['IPv6andMask']
    allowaccess = list_to_str(module.params['allowaccess'])
    intf_type = module.params['intf_type']
    vlanid = module.params['vlanid']
    vdom = module.params['vdom']
    interface = module.params['interface']
    mtu = module.params['mtu']
    aggregate_algorithm = module.params['aggregate_algorithm']
    aggregate_mode = module.params['aggregate_mode']
    default_gw = module.params['default_gw']
    dhcp_gw_override = module.params['dhcp_gw_override']
    dhcp_gw_distance = module.params['dhcp_gw_distance']
    disc_retry_timeout = module.params['disc_retry_timeout']
    pppoe_username = module.params['pppoe_username']
    pppoe_passwd = module.params['pppoe_passwd']
    floating = module.params['floating']
    floating_ip = module.params['floating_ip']
    redundant_member = list_to_str(module.params['redundant_member'])
    traffic_group = module.params['traffic_group']

    payload = {'mkey': name,
               'mode': mode,
               'mtu' : mtu,
               'ip'  : IPandMask,
               'ip6' : IPv6andMask,
               'interface' : interface,
               'allowaccess' : allowaccess,
               'type' : intf_type,
               'vdom' : vdom,
               'vlanid' : vlanid,
               'status' : status,
               'aggregate-algorithm': aggregate_algorithm,
               'aggregate-mode' : aggregate_mode,
               'dedicate-to-management' : 'disable',
               'default-gw' : default_gw,
               'dhcp_gw_distance' : dhcp_gw_distance,
               'dhcp_gw_override' : dhcp_gw_override,
               'dhcp_ip_overlap' : '1',
               'disc-retry-timeout' : disc_retry_timeout,
               'dns-server-override' : 'enable',
               'floating' : floating,
               'floating-ip' : floating_ip,
               'redundant-member' : redundant_member,
               'secondary-ip' : 'disable',
               'traffic-group' : traffic_group,
               'username' : pppoe_username,
               }

    url = '/api/system_interface'
    if is_vdom_enable(connection) and not is_global_admin(connection):
        url += '?vdom=' + vdom

    code, response = connection.send_request(url, payload)

    return code, response
def needs_update(module, data):
    res = False

    if module.params['mode'] and module.params['mode'] != data['mode']:
        data['mode'] = module.params['mode']
        res = True
    if module.params['status'] and module.params['status'] != data['status']:
        data['status'] = module.params['status']
        res = True
    if module.params['IPandMask'] and module.params['IPandMask'] != data['ip']:
        data['ip'] = module.params['IPandMask']
        res = True
    if module.params['IPv6andMask'] and module.params['IPv6andMask'] != data['ipv6']:
        data['ipv6'] = module.params['IPv6andMask']
        res = True
    if module.params['mtu'] and module.params['mtu'] != data['mtu']:
        data['mtu'] = module.params['mtu']
        res = True
    if module.params['intf_type'] and module.params['intf_type'] != data['type']:
        data['type'] = module.params['intf_type']
        res = True
    if list_need_update(module.params['allowaccess'], data['allowaccess']):
        data['allowaccess'] = list_to_str(module.params['allowaccess'])
        res = True
    if list_need_update(module.params['redundant_member'], data['redundant-member']):
        data['redundant-member'] = list_to_str(module.params['redundant_member'])
        res = True

    return res, data
示例#3
0
def add_rs_pool(module, connection):
    name = module.params['name']
    iptype = module.params['iptype']
    healthcheck = module.params['healthcheck']
    health_check_relationship = module.params['health_check_relationship']
    health_check_list = list_to_str(module.params['health_check_list'])
    rs_profile = module.params['rs_profile']
    vdom = module.params['vdom']

    payload = {
        'mkey': name,
        'pool_type': iptype,
        'health_check': healthcheck,
        'health_check_relationship': health_check_relationship,
        'health_check_list': health_check_list,
        'rs_profile': rs_profile
    }

    url = '/api/load_balance_pool'
    if is_vdom_enable(connection):
        url += '?vdom=' + vdom

    code, response = connection.send_request(url, payload)

    return code, response
示例#4
0
def needs_update(module, data):
    res = False

    if module.params['iptype'] and module.params['iptype'] != data['pool_type']:
        data['pool_type'] = module.params['iptype']
        res = True
    if module.params['healthcheck'] and module.params['healthcheck'] != data[
            'health_check']:
        data['health_check'] = module.params['healthcheck']
        res = True
    if module.params['health_check_relationship'] and module.params[
            'health_check_relationship'] != data['health_check_relationship']:
        data['health_check_relationship'] = module.params[
            'health_check_relationship']
        res = True
    if list_need_update(module.params['health_check_list'],
                        data['health_check_list']):
        data['health_check_list'] = list_to_str(
            module.params['health_check_list'])
        res = True
    if module.params['rs_profile'] and module.params['rs_profile'] != data[
            'rs_profile']:
        data['rs_profile'] = module.params['rs_profile']
        res = True
    return res, data
def needs_update(module, data):
    res = False

    if module.params['iptype'] and module.params['iptype'] != data['pool_type']:
        data['pool_type'] = module.params['iptype']
        res = True
    if module.params['healthcheck'] and module.params['healthcheck'] != data[
            'health_check']:
        data['health_check'] = module.params['healthcheck']
        res = True
    if module.params['health_check_relationship'] and module.params[
            'health_check_relationship'] != data['health_check_relationship']:
        data['health_check_relationship'] = module.params[
            'health_check_relationship']
        res = True
    logger.debug(module.params['health_check_list'])
    if list_need_update(module.params['health_check_list'],
                        data['health_check_list']):
        logger.debug("needs update")
        data['health_check_list'] = list_to_str(
            module.params['health_check_list']).decode('utf-8')
        logger.debug(data['health_check_list'])
        res = True
    if module.params['rs_profile'] and module.params['rs_profile'] != data[
            'rs_profile']:
        data['rs_profile'] = module.params['rs_profile']
        res = True
    return res, data
def add_rs_pool_member(module, connection):
    pkey = module.params['pool_name']
    member_id = module.params['member_id']
    port = module.params['port']
    rs = module.params['rs']
    status = module.params['status']
    recover = module.params['recover']
    rs_profile_inherit = module.params['rs_profile_inherit']
    rs_profile = module.params['rs_profile']
    warmrate = module.params['warmrate']
    weight = module.params['weight']
    warmup = module.params['warmup']
    backup = module.params['backup']
    connlimit = module.params['connlimit']
    connection_ratelimit = module.params['connection_ratelimit']
    cookie = module.params['cookie']
    health_check_inherit = module.params['health_check_inherit']
    health_check = module.params['health_check']
    health_check_list = list_to_str(module.params['health_check_list'])
    health_check_relationship = module.params['health_check_relationship']
    mysql_group_id = module.params['mysql_group_id']
    mysql_read_only = module.params['mysql_read_only']
    vdom = module.params['vdom']

    payload = {
        'mkey': member_id,
        'status': status,
        'real_server_id': rs,
        'port': port,
        'recover': recover,
        'rs_profile_inherit': rs_profile_inherit,
        'weight': weight,
        'warmup': warmup,
        'warmrate': warmrate,
        'connlimit': connlimit,
        'connection-rate-limit': connection_ratelimit,
        'cookie': cookie,
        'health_check_inherit': health_check_inherit,
        'm_health_check': health_check,
        'm_health_check_list': health_check_list,
        'm_health_check_relationship': health_check_relationship,
        'mysql_group_id': mysql_group_id,
        'mysql_read_only': mysql_read_only,
        'backup': backup,
        'rs_profile': rs_profile,
    }

    url = '/api/load_balance_pool_child_pool_member?pkey=' + pkey

    if is_vdom_enable(connection):
        url += '&vdom=' + vdom
    code, response = connection.send_request(url, payload)

    return code, response
def needs_update(module, data):
    res = False

    if module.params['status'] and module.params['status'] != data['status']:
        data['status'] = module.params['status']
        res = True
    if module.params['rs'] and module.params['rs'] != data['real_server_id']:
        data['real_server_id'] = module.params['rs']
        res = True
    if module.params['port'] and module.params['port'] != data['port']:
        data['port'] = module.params['port']
        res = True
    if module.params['recover'] and module.params['recover'] != data['recover']:
        data['recover'] = module.params['recover']
        res = True
    if module.params['rs_profile_inherit'] and module.params[
            'rs_profile_inherit'] != data['rs_profile_inherit']:
        data['rs_profile_inherit'] = module.params['rs_profile_inherit']
        res = True
    if module.params['weight'] and module.params['weight'] != data['weight']:
        data['weight'] = module.params['weight']
        res = True
    if module.params['warmup'] and module.params['warmup'] != data['warmup']:
        data['warmup'] = module.params['warmup']
        res = True
    if module.params[
            'warmrate'] and module.params['warmrate'] != data['warmrate']:
        data['warmrate'] = module.params['warmrate']
        res = True
    if module.params[
            'connlimit'] and module.params['connlimit'] != data['connlimit']:
        data['connlimit'] = module.params['connlimit']
        res = True
    if module.params['connection_ratelimit'] and module.params[
            'connection_ratelimit'] != data['connection-rate-limit']:
        data['connection-rate-limit'] = module.params['connection_ratelimit']
        res = True
    if module.params['cookie'] and module.params['cookie'] != data['cookie']:
        data['cookie'] = module.params['cookie']
        res = True
    if module.params['health_check_inherit'] and module.params[
            'health_check_inherit'] != data['health_check_inherit']:
        data['health_check_inherit'] = module.params['health_check_inherit']
        res = True
    if module.params['health_check'] and module.params['health_check'] != data[
            'm_health_check']:
        data['m_health_check'] = module.params['health_check']
        res = True
    if list_need_update(module.params['health_check_list'],
                        data['m_health_check_list']):
        data['m_health_check_list'] = list_to_str(
            module.params['health_check_list'])
        res = True
    if module.params['health_check_relationship'] and module.params[
            'health_check_relationship'] != data['m_health_check_relationship']:
        data['m_health_check_relationship'] = module.params[
            'health_check_relationship']
        res = True
    if module.params['mysql_group_id'] and module.params[
            'mysql_group_id'] != data['mysql_group_id']:
        data['mysql_group_id'] = module.params['mysql_group_id']
        res = True
    if module.params['mysql_read_only'] and module.params[
            'mysql_read_only'] != data['mysql_read_only']:
        data['mysql_read_only'] = module.params['mysql_read_only']
        res = True
    if module.params['backup'] and module.params['backup'] != data['backup']:
        data['backup'] = module.params['backup']
        res = True
    if module.params['rs_profile'] and module.params['rs_profile'] != data[
            'rs_profile']:
        data['rs_profile'] = module.params['rs_profile']
        res = True

    return res, data
示例#8
0
def add_vs(module, connection):

    name = module.params['name']
    status = module.params['status']
    iptype = module.params['iptype']
    ip = module.params['ip']
    public_iptype = module.params['public_iptype']
    public_ip = module.params['public_ip']
    interface = module.params['interface']
    vstype = module.params['vstype']
    pool = module.params['pool']
    port = module.params['port']
    profile = module.params['profile']
    method = module.params['method']
    ssl_mirror = module.params['ssl_mirror']
    ssl_mirror_intf = module.params['ssl_mirror_intf']
    traffic_group = module.params['traffic_group']
    traffic_log = module.params['traffic_log']
    trans_rate_limit = module.params['trans_rate_limit']
    warmrate = module.params['warmrate']
    warmup = module.params['warmup']
    alone = module.params['alone']
    av_profile = module.params['av_profile']
    client_ssl_profile = module.params['client_ssl_profile']
    clone_pool = module.params['clone_pool']
    clone_traffic_type = module.params['clone_traffic_type']
    connection_limit = module.params['connection_limit']
    connection_rate_limit = module.params['connection_rate_limit']
    content_rewriting = module.params['content_rewriting']
    content_rewriting_list = list_to_str(
        module.params['content_rewriting_list'])
    content_routing = module.params['content_routing']
    content_routing_list = list_to_str(module.params['content_routing_list'])
    schedule_list = module.params['schedule_list']
    schedule_pool_list = list_to_str(module.params['schedule_pool_list'])
    scripting_flag = module.params['scripting_flag']
    scripting_list = list_to_str(module.params['scripting_list'])
    source_pool_list = list_to_str(module.params['source_pool_list'])
    waf_profile = module.params['waf_profile']
    http2https = module.params['http2https']
    http2https_port = module.params['http2https_port']
    l2_exception_list = module.params['l2_exception_list']
    packet_fwd_method = module.params['packet_fwd_method']
    pagespeed = module.params['pagespeed']
    persistence = module.params['persistence']
    protocol = module.params['protocol']
    adfs_published_service = module.params['adfs_published_service']
    error_msg = module.params['error_msg']
    error_page = module.params['error_msg']
    fortiview = module.params['fortiview']
    wccp = module.params['wccp']
    comments = module.params['comments']
    vdom = module.params['vdom']

    payload = {
        'mkey': name,
        'addr-type': iptype,
        'public-ip-type': public_iptype,
        'interface': interface,
        'status': status,
        'pool': pool,
        'port': port,
        'alone': alone,
        'type': vstype,
        'profile': profile,
        'method': method,
        'ssl-mirror': ssl_mirror,
        'ssl-mirror-intf': ssl_mirror_intf,
        'traffic-group': traffic_group,
        'traffic-log': traffic_log,
        'trans-rate-limit': trans_rate_limit,
        'warmrate': warmrate,
        'warmup': warmup,
        'av-profile': av_profile,
        'client_ssl_profile': client_ssl_profile,
        'clone-pool': clone_pool,
        'clone-traffic-type': clone_traffic_type,
        'connection-limit': connection_limit,
        'connection-rate-limit': connection_rate_limit,
        'content-rewriting': content_rewriting,
        'content-rewriting-list': content_rewriting_list,
        'content-routing': content_routing,
        'content-routing-list': content_routing_list,
        'schedule-list': schedule_list,
        'schedule-pool-list': schedule_pool_list,
        'scripting_flag': scripting_flag,
        'scripting_list': scripting_list,
        'source-pool-list': source_pool_list,
        'waf-profile': waf_profile,
        'http2https': http2https,
        'http2https-port': http2https_port,
        'l2-exception-list': l2_exception_list,
        'packet-fwd-method': packet_fwd_method,
        'pagespeed': pagespeed,
        'persistence': persistence,
        'protocol': protocol,
        'adfs-published-service': adfs_published_service,
        'error-msg': error_msg,
        'error-page': error_page,
        'comments': comments,
        'fortiview': fortiview,
        'wccp': wccp
    }

    if iptype == 'ipv6':
        payload['address6'] = ip
    else:
        payload['address'] = ip

    if public_iptype == 'ipv6' and module.params['public_ip']:
        payload['public-ip6'] = public_ip
    elif module.params['public_ip']:
        payload['public-ip'] = public_ip

    url = '/api/load_balance_virtual_server'
    if is_vdom_enable(connection):
        url += '?vdom=' + vdom

    code, response = connection.send_request(url, payload)

    return code, response
示例#9
0
def needs_update(module, data):
    res = False

    if module.params['status'] and module.params['status'] != data['status']:
        data['status'] = module.params['status']
        res = True
    if module.params['iptype'] and module.params['iptype'] != data['addr-type']:
        data['addr-type'] = module.params['iptype']
        res = True
    if data['addr-type'] == 'ipv4' and module.params[
            'ip'] and module.params['ip'] != data['address']:
        data['address'] = module.params['ip']
        res = True
    if data['addr-type'] == 'ipv6' and module.params[
            'ip'] and module.params['ip'] != data['address6']:
        data['address6'] = module.params['ip']
        res = True
    if module.params['public_iptype'] and module.params[
            'public_iptype'] != data['public-ip-type']:
        data['public-ip-type'] = module.params['public_iptype']
        res = True
    if data['public-ip-type'] == 'ipv4' and module.params[
            'public_ip'] and module.params['public_ip'] != data['public-ip']:
        data['public-ip'] = module.params['public_ip']
        res = True
    if data['public-ip-type'] == 'ipv6' and module.params[
            'public_ip'] and module.params['public_ip'] != data['public-ip6']:
        data['public-ip6'] = module.params['public_ip']
        res = True
    if module.params[
            'interface'] and module.params['interface'] != data['interface']:
        data['interface'] = module.params['interface']
        res = True
    if module.params['status'] and module.params['status'] != data['status']:
        data['status'] = module.params['status']
        res = True
    if module.params['pool'] and module.params['pool'] != data['pool']:
        data['pool'] = module.params['pool']
        res = True
    if module.params['port'] and module.params['port'] != data['port']:
        data['port'] = module.params['port']
        res = True
    if module.params['alone'] and module.params['alone'] != data['alone']:
        data['alone'] = module.params['alone']
        res = True
    if module.params['vstype'] and module.params['vstype'] != data['type']:
        data['type'] = module.params['vstype']
        res = True
    if module.params['profile'] and module.params['profile'] != data['profile']:
        data['profile'] = module.params['profile']
        res = True
    if module.params['method'] and module.params['method'] != data['method']:
        data['method'] = module.params['method']
        res = True
    if module.params['ssl_mirror'] and module.params['ssl_mirror'] != data[
            'ssl-mirror']:
        data['ssl-mirror'] = module.params['ssl_mirror']
        res = True
    if module.params['ssl_mirror_intf'] and module.params[
            'ssl_mirror_intf'] != data['ssl-mirror-intf']:
        data['ssl-mirror-intf'] = module.params['ssl_mirror_intf']
        res = True
    if module.params['traffic_group'] and module.params[
            'traffic_group'] != data['traffic-group']:
        data['traffic-group'] = module.params['traffic_group']
        res = True
    if module.params['traffic_group'] and module.params[
            'traffic_group'] != data['traffic-log']:
        data['traffic-log'] = module.params['traffic_group']
        res = True
    if module.params['traffic_log'] and module.params['traffic_log'] != data[
            'traffic-log']:
        data['traffic-log'] = module.params['traffic_log']
        res = True
    if module.params['trans_rate_limit'] and module.params[
            'trans_rate_limit'] != data['trans-rate-limit']:
        data['trans-rate-limit'] = module.params['trans_rate_limit']
        res = True
    if module.params[
            'warmrate'] and module.params['warmrate'] != data['warmrate']:
        data['warmrate'] = module.params['warmrate']
        res = True
    if module.params['warmup'] and module.params['warmup'] != data['warmup']:
        data['warmup'] = module.params['warmup']
        res = True
    if module.params['av_profile'] and module.params['av_profile'] != data[
            'av-profile']:
        data['av-profile'] = module.params['av_profile']
        res = True
    if module.params['client_ssl_profile'] and module.params[
            'client_ssl_profile'] != data['client_ssl_profile']:
        data['client_ssl_profile'] = module.params['client_ssl_profile']
        res = True
    if module.params['clone_pool'] and module.params['clone_pool,'] != data[
            'clone-pool']:
        data['clone-pool'] = module.params['clone_pool,']
        res = True
    if module.params['clone_traffic_type'] and module.params[
            'clone_traffic_type'] != data['clone-traffic-type']:
        data['clone-traffic-type'] = module.params['clone_traffic_type']
        res = True
    if module.params['connection_limit'] and module.params[
            'connection_limit'] != data['connection-limit']:
        data['connection-limit'] = module.params['connection_limit']
        res = True
    if module.params['connection_rate_limit'] and module.params[
            'connection_rate_limit'] != data['connection-rate-limit']:
        data['connection-rate-limit'] = module.params['connection_rate_limit']
        res = True
    if module.params['content_rewriting'] and module.params[
            'content_rewriting'] != data['content-rewriting']:
        data['content-rewriting'] = module.params['content_rewriting']
        res = True
    if module.params['content_rewriting_list'] and module.params[
            'content_rewriting_list'] != data['content-rewriting-list']:
        data['content-rewriting-list'] = module.params[
            'content_rewriting_list,']
        res = True
    if module.params['content_routing'] and module.params[
            'content_routing'] != data['content-routing']:
        data['content-routing'] = module.params['content_routing']
        res = True
    if list_need_update(module.params['content_routing_list'],
                        data['content-routing-list']):
        data['content-routing-list'] = list_to_str(
            module.params['content_routing_list'])
        res = True
    if module.params['schedule_list'] and module.params[
            'schedule_list'] != data['schedule-list']:
        data['schedule-list'] = module.params['schedule_list']
        res = True
    if list_need_update(module.params['schedule_pool_list'],
                        data['schedule-pool-list']):
        data['schedule-pool-list'] = list_to_str(
            module.params['schedule_pool_list'])
        res = True
    if module.params['scripting_flag'] and module.params[
            'scripting_flag'] != data['scripting_flag']:
        data['scripting_flag'] = module.params['scripting_flag']
        res = True
    if list_need_update(module.params['scripting_list'],
                        data['scripting_list']):
        data['scripting_list'] = list_to_str(module.params['scripting_list'])
        res = True
    if list_need_update(module.params['source_pool_list'],
                        data['schedule-pool-list']):
        data['schedule-pool-list'] = list_to_str(
            module.params['source_pool_list'])
        res = True
    if module.params['waf_profile'] and module.params['waf_profile'] != data[
            'waf-profile']:
        data['waf-profile'] = module.params['waf_profile']
        res = True
    if module.params['http2https'] and module.params['http2https'] != data[
            'http2https']:
        data['http2https'] = module.params['http2https']
        res = True
    if module.params['http2https_port'] and module.params[
            'http2https_port'] != data['http2https-port']:
        data['http2https-port'] = module.params['http2https_port']
        res = True
    if module.params['l2_exception_list'] and module.params[
            'l2_exception_list'] != data['l2-exception-list']:
        data['l2-exception-list'] = module.params['l2_exception_list']
        res = True
    if module.params['packet_fwd_method'] and module.params[
            'packet_fwd_method'] != data['packet-fwd-method']:
        data['packet-fwd-method'] = module.params['packet_fwd_method']
        res = True
    if module.params[
            'pagespeed'] and module.params['pagespeed'] != data['pagespeed']:
        data['pagespeed'] = module.params['pagespeed']
        res = True
    if module.params['persistence'] and module.params['persistence'] != data[
            'persistence']:
        data['persistence'] = module.params['persistence']
        res = True
    if module.params[
            'protocol'] and module.params['protocol'] != data['protocol']:
        data['protocol'] = module.params['protocol']
        res = True
    if module.params['adfs_published_service'] and module.params[
            'adfs_published_service'] != data['adfs-published-service']:
        data['adfs-published-service'] = module.params[
            'adfs_published_service']
        res = True
    if module.params[
            'error_msg'] and module.params['error_msg'] != data['error-msg']:
        data['error-msg'] = module.params['error_msg']
        res = True
    if module.params['error_page'] and module.params['error_page,'] != data[
            'error-page']:
        data['error-page'] = module.params['error_page,']
        res = True
    if module.params[
            'comments'] and module.params['comments'] != data['comments']:
        data['comments'] = module.params['comments']
        res = True
    if module.params[
            'fortiview'] and module.params['fortiview'] != data['fortiview']:
        data['fortiview'] = module.params['fortiview']
        res = True
    if module.params['wccp'] and module.params['wccp'] != data['wccp']:
        data['wccp'] = module.params['wccp']
        res = True

    return res, data