Prv8 Shell
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4
System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64
User : jackjohn ( 502)
PHP Version : 5.3.17
Disable Function : NONE
Directory :  /usr/share/system-config-network/netconfpkg/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/system-config-network/netconfpkg/NCRoute.py
import re
from netconfpkg.gdt import (Gdtstruct, gdtstruct_properties, Gdtstr)


class Route_base(Gdtstruct):
    gdtstruct_properties([
                          ('Address', Gdtstr, "Test doc string"),
                          ('Netmask', Gdtstr, "Test doc string"),
                          ('Gateway', Gdtstr, "Test doc string"),
                          ('GatewayDevice', Gdtstr, "Test doc string"),
                          ])
    def __init__(self):
        super(Route_base, self).__init__()
        self.Address = None
        self.Netmask = None
        self.Gateway = None
        self.GatewayDevice = None

_ip_pattern = re.compile(
    r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}"
    r"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
    )

_mac_pattern = re.compile(
    r"^([0-9a-fA-F]{2}[-:]){5}[0-9a-fA-F]{2}$"
    )

def testIP(value):
    # FIXME: split, then check for range
    if _ip_pattern.match(value):
        return True
    else:
        return False

def testMAC(value):
    if _mac_pattern.match(value):
        return True
    else:
        return False

class Route(Route_base):                   
    def test(self):        
        all_ok = super(Route, self).test()
        if not(all_ok):
            raise ValueError
        return True

    def testAddress(self):
        return testIP(self.Address)

    def testGateway(self):
        "check for consistency"
        if not self.Gateway:
            return True
        else: 
            return testIP(self.Gateway)

#    def testGatewayDevice(self, value):
#        "check for consistency"
#        return True

    def testNetmask(self):
        "check for consistency"
        if not self.Netmask:
            return True
        else: 
            return testIP(self.Netmask)

haha - 2025