Пример #1
0
def update_page(form):
    error = None

    # action field is not required for some functions, so will not be hard validated
    action = form.get('action', DATA.MISSING)

    nat_type = form.get('nat_type', None)
    if (nat_type in ['DSTNAT', 'SRCNAT']):

        if (nat_type == 'DSTNAT'):
            error = _dnat_rules(action, form)

        elif (nat_type == 'SRCNAT'):
            error = _snat_rules(action, form)

    else:
        return INVALID_FORM, None, None

    # updating page data then returning. this is because we need to serve the content with the newly added
    # configuration item.
    page_data = {
        'dmz_dnat_rules': System.nat_rules(),
        'local_snat_rules': System.nat_rules(nat_type='SRCNAT')
    }

    # print(f'RETURNING: {page_data}')
    return error, None, page_data
Пример #2
0
def load_page():
    return {
        'dmz_dnat_rules': System.nat_rules(),
        'local_snat_rules': System.nat_rules(nat_type='SRCNAT')
    }