| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/system-config-network/netconfpkg/ |
Upload File : |
"Host Module"
import socket
from netconfpkg.NCAliasList import AliasList
from netconfpkg.NC_functions import testHostname
from netconfpkg.gdt import (Gdtstruct, gdtstruct_properties, Gdtstr)
class Host_base(Gdtstruct):
gdtstruct_properties([
('IP', Gdtstr, "Test doc string"),
('Hostname', Gdtstr, "Test doc string"),
('AliasList', AliasList, "Test doc string"),
])
def __init__(self):
super(Host_base, self).__init__()
self.IP = None
self.Hostname = None
self.AliasList = AliasList()
def createAliasList(self):
if not self.AliasList:
self.AliasList = AliasList()
return self.AliasList
class Host(Host_base):
HostID = None
def __init__(self):
super(Host, self).__init__()
# special store for the original comment
self.Comment = None
# special store for the original line
self.origLine = None
def testIP(self):
try:
socket.inet_pton(socket.AF_INET, self.IP)
except socket.error:
try:
socket.inet_pton(socket.AF_INET6, self.IP)
except socket.error:
return False
return True
def testHostname(self):
return testHostname(self.Hostname)
def test(self):
if not self.testIP():
raise ValueError("IP")
if not self.testHostname():
raise ValueError("Hostname")
if self.AliasList and not self.AliasList.test():
raise ValueError("Alias")