Esempio n. 1
0
def _parse_dmz_settings(html):
    regex = "//\s+nvram = \{(.+?)\};\n\nvar lipp = '(.+?)';"
    match_object = re.compile(regex, re.DOTALL).search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ settings')

    bad_json_settings, lipp = match_object.groups()
    nvram = _parse_data_structure(bad_json_settings)

    ip = nvram['dmz_ipaddr']
    if '.' not in ip:
        # it's the last part only.. it's shortened
        # and the rest is in lipp
        ip = lipp + ip

    obj = DMZSettings()
    obj.set_supported_status(True)
    obj.set_reboot_requirement_status(False)
    obj.set_enabled_status(nvram['dmz_enable'] == '1')
    obj.set_ip(ip)
    obj.ensure_valid()
    return obj
Esempio n. 2
0
def _parse_dmz_settings(html):
    regex = "//\s+nvram = \{(.+?)\};\n\nvar lipp = '(.+?)';"
    match_object = re.compile(regex, re.DOTALL).search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ settings')

    bad_json_settings, lipp = match_object.groups()
    nvram = _parse_data_structure(bad_json_settings)

    ip = nvram['dmz_ipaddr']
    if '.' not in ip:
        # it's the last part only.. it's shortened
        # and the rest is in lipp
        ip = lipp + ip

    obj = DMZSettings()
    obj.set_supported_status(True)
    obj.set_reboot_requirement_status(False)
    obj.set_enabled_status(nvram['dmz_enable'] == '1')
    obj.set_ip(ip)
    obj.ensure_valid()
    return obj