def select_dst_ip_from_scope_ip(policy, scope_ip):
    global dst_ip
    service_name = policy['protocol']
    multiple.confirm_service_element(service_name)
    service_element_num = multiple.service_element_num
    if policy['src_ip'] == '"Any"' and 'Untrust"' not in policy['src_zone']:
        try:
            dst_ip += [str(scope_ip[1]), str(scope_ip[-2]),
                   str(scope_ip[1]), str(scope_ip[-2])] * service_element_num
        except IndexError:
            dst_ip += [str(scope_ip[0]), str(scope_ip[0]), 'NaN', 'NaN'] * service_element_num
    elif "VIP(" in policy['src_ip'] and policy['protocol'] == '"ANY"':
        for vip_c in absorbdict.vip_dict:
            if policy['src_ip'].strip(')"').split('(')[1] == vip_c['if_name'] and vip_c['global_ip'] == "interface-ip":
                try:
                    dst_ip += [str(scope_ip[1]), str(scope_ip[-2])
                           ] * service_element_num
                except IndexError:
                    dst_ip += [str(scope_ip[0]), 'NaN'] * service_element_num
            elif policy['src_ip'].strip(')"').split('(')[1] == vip_c['global_ip']:
                try:
                    dst_ip += [str(scope_ip[1]), str(scope_ip[-2])
                           ] * service_element_num
                except IndexError:
                    dst_ip += [str(scope_ip[0]), 'NaN'] * service_element_num
    else:
        address_name = policy['src_ip']
        multiple.judge_src_address_name(address_name)
        src_address_element_num = multiple.src_address_element_num
        try:
            dst_ip += [str(scope_ip[1]), str(scope_ip[-2])
                    ] * service_element_num * src_address_element_num
        except IndexError:
            dst_ip += [str(scope_ip[0]), 'NaN'] * service_element_num * src_address_element_num
Esempio n. 2
0
def select_src_ip_from_scope_ip(policy, scope_ip):
    global src_ip
    service_name = policy['protocol']
    multiple.confirm_service_element(service_name)
    service_element_num = multiple.service_element_num
    if policy['dst_ip'] == '"Any"' and policy['dst_zone'] != '"Untrust"':
        src_ip += [
            str(scope_ip[1]),
            str(scope_ip[-2]),
            str(scope_ip[-2]),
            str(scope_ip[1])
        ] * service_element_num
    elif "VIP" in policy['dst_ip'] and policy['protocol'] == '"ANY"':
        for vip_c in absorbdict.vip_dict:
            if policy['dst_ip'].strip(')"').split('(')[1] == vip_c[
                    'if_name'] and vip_c['global_ip'] == "interface-ip":
                src_ip += [str(scope_ip[1]),
                           str(scope_ip[-2])] * service_element_num
            elif policy['dst_ip'].strip(')"').split(
                    '(')[1] == vip_c['global_ip']:
                src_ip += [str(scope_ip[1]),
                           str(scope_ip[-2])] * service_element_num
    else:
        address_name = policy['dst_ip']
        multiple.judge_dst_address_name(address_name)
        dst_address_element_num = multiple.dst_address_element_num
        src_ip += [str(scope_ip[1]), str(scope_ip[-2])] * \
            service_element_num * dst_address_element_num
def handle_dst_ip_list(policy, dst_ip_list):
    global dst_ip
    src_address = policy['src_ip']
    src_element_num = multiple.confirm_src_address_element(policy, src_address)
    service_name = policy['protocol']
    multiple.confirm_service_element(service_name)
    for n in range(src_element_num):
        for data in dst_ip_list:
            dst_ip += [data] * multiple.service_element_num
Esempio n. 4
0
def handle_multiple_element():
    for policy in absorbdict.policy_dict:
        service_name = policy['protocol']
        service_element_num = multiple.confirm_service_element(service_name)
        handle_src_ip(policy, service_element_num)