]> git.llucax.com Git - software/pymin.git/commitdiff
Create a package named pymin with all the pymin modules.
authorLeandro Lucarella <llucarella@integratech.com.ar>
Thu, 4 Oct 2007 16:10:14 +0000 (13:10 -0300)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Thu, 4 Oct 2007 16:10:14 +0000 (13:10 -0300)
29 files changed:
config.py
pymin/__init__.py [new file with mode: 0644]
pymin/dispatcher.py [moved from dispatcher.py with 100% similarity]
pymin/eventloop.py [moved from eventloop.py with 100% similarity]
pymin/pymindaemon.py [moved from pymindaemon.py with 96% similarity]
pymin/seqtools.py [moved from seqtools.py with 100% similarity]
pymin/serializer.py [moved from serializer.py with 97% similarity]
pymin/services/__init__.py [new file with mode: 0644]
pymin/services/dhcp/__init__.py [moved from services/dhcp/__init__.py with 96% similarity]
pymin/services/dhcp/templates/dhcpd.conf [moved from services/dhcp/templates/dhcpd.conf with 100% similarity]
pymin/services/dns/__init__.py [moved from services/dns/__init__.py with 94% similarity]
pymin/services/dns/templates/named.conf [moved from services/dns/templates/named.conf with 100% similarity]
pymin/services/dns/templates/zoneX.zone [moved from services/dns/templates/zoneX.zone with 100% similarity]
pymin/services/firewall/__init__.py [moved from services/firewall/__init__.py with 97% similarity]
pymin/services/firewall/templates/iptables.sh [moved from services/firewall/templates/iptables.sh with 100% similarity]
pymin/services/ip/__init__.py [moved from services/ip/__init__.py with 95% similarity]
pymin/services/ip/templates/device [moved from services/ip/templates/device with 100% similarity]
pymin/services/ip/templates/ip_add [moved from services/ip/templates/ip_add with 100% similarity]
pymin/services/ip/templates/ip_del [moved from services/ip/templates/ip_del with 100% similarity]
pymin/services/ip/templates/ip_flush [moved from services/ip/templates/ip_flush with 100% similarity]
pymin/services/ip/templates/route_add [moved from services/ip/templates/route_add with 100% similarity]
pymin/services/ip/templates/route_del [moved from services/ip/templates/route_del with 100% similarity]
pymin/services/ip/templates/route_flush [moved from services/ip/templates/route_flush with 100% similarity]
pymin/services/proxy/__init__.py [moved from services/proxy/__init__.py with 77% similarity]
pymin/services/proxy/templates/squid.conf [moved from services/proxy/templates/squid.conf with 100% similarity]
pymin/services/util.py [moved from services/util.py with 99% similarity]
pymin/ucsv.py [moved from ucsv.py with 100% similarity]
pymind
services/__init__.py [deleted file]

index a0f1c45dd1bc855ed69dc7208428da8d0c75532d..059faaeea54762900ef6162904c8888a767a0b30 100644 (file)
--- a/config.py
+++ b/config.py
@@ -1,7 +1,7 @@
 # vim: set et sts=4 sw=4 encoding=utf-8 :
 
-from services import *
-from dispatcher import handler
+from pymin.services import *
+from pymin.dispatcher import handler
 
 # XXX for testing only
 @handler
diff --git a/pymin/__init__.py b/pymin/__init__.py
new file mode 100644 (file)
index 0000000..292a66b
--- /dev/null
@@ -0,0 +1,4 @@
+# vim: set encoding=utf-8 et sw=4 sts=4 :
+
+from pymin.pymindaemon import PyminDaemon
+
similarity index 100%
rename from dispatcher.py
rename to pymin/dispatcher.py
similarity index 100%
rename from eventloop.py
rename to pymin/eventloop.py
similarity index 96%
rename from pymindaemon.py
rename to pymin/pymindaemon.py
index b440c5279f9b015a0beb7b5882dfaeb0d5403ce3..be2c9750d29339d7b79d696bdf6218898ed267c8 100644 (file)
@@ -11,9 +11,8 @@ command-line.
 import signal
 import socket
 
-import dispatcher
-import eventloop
-import serializer
+from pymin import eventloop
+from pymin import serializer
 
 class PyminDaemon(eventloop.EventLoop):
     r"""PyminDaemon(bind_addr, routes) -> PyminDaemon instance
@@ -45,7 +44,7 @@ class PyminDaemon(eventloop.EventLoop):
         # Create EventLoop
         eventloop.EventLoop.__init__(self, sock)
         # Create Dispatcher
-        self.dispatcher = dispatcher.Dispatcher(routes)
+        self.dispatcher = Dispatcher(routes)
         # Signal handling
         def quit(signum, frame):
             print "Shuting down ..."
similarity index 100%
rename from seqtools.py
rename to pymin/seqtools.py
similarity index 97%
rename from serializer.py
rename to pymin/serializer.py
index e76030b6c360021175aa52607210678b1f761f51..c9d3dbba79e15b8a5df11f20201da8b223aa8c2f 100644 (file)
@@ -1,7 +1,7 @@
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
-import ucsv
-import seqtools
+from pymin import ucsv
+from pymin import seqtools
 
 r"UTF-8 encoded CSV serializer."
 
diff --git a/pymin/services/__init__.py b/pymin/services/__init__.py
new file mode 100644 (file)
index 0000000..a9f8d03
--- /dev/null
@@ -0,0 +1,8 @@
+# vim: set encoding=utf-8 et sw=4 sts=4 :
+
+from pymin.services.dhcp import DhcpHandler
+from pymin.services.dns import DnsHandler
+from pymin.services.firewall import FirewallHandler
+from pymin.services.ip import IpHandler
+from pymin.services.proxy import ProxyHandler
+
similarity index 96%
rename from services/dhcp/__init__.py
rename to pymin/services/dhcp/__init__.py
index c9c25b49d7bbd9edd2ffbbae201bebd48e30ab15..8f42e1ac013db09d6739720e8537285505b4023c 100644 (file)
@@ -2,10 +2,10 @@
 
 from os import path
 
-from seqtools import Sequence
-from dispatcher import Handler, handler, HandlerError
-from services.util import Restorable, ConfigWriter
-from services.util import InitdHandler, TransactionalHandler, ParametersHandler
+from pymin.seqtools import Sequence
+from pymin.dispatcher import Handler, handler, HandlerError
+from pymin.services.util import Restorable, ConfigWriter, InitdHandler, \
+                                TransactionalHandler, ParametersHandler
 
 __ALL__ = ('DhcpHandler', 'Error', 'HostError', 'HostAlreadyExistsError',
             'HostNotFoundError')
@@ -134,6 +134,7 @@ class HostHandler(Handler):
         r"show() -> list of Hosts :: List all the complete hosts information."
         return self.hosts.values()
 
+
 class DhcpHandler(Restorable, ConfigWriter, InitdHandler, TransactionalHandler,
                   ParametersHandler):
     r"""DhcpHandler([pickle_dir[, config_dir]]) -> DhcpHandler instance.
@@ -179,6 +180,7 @@ class DhcpHandler(Restorable, ConfigWriter, InitdHandler, TransactionalHandler,
     def _get_config_vars(self, config_file):
         return dict(hosts=self.hosts.values(), **self.params)
 
+
 if __name__ == '__main__':
 
     import os
similarity index 94%
rename from services/dns/__init__.py
rename to pymin/services/dns/__init__.py
index 2ff6f60b07296db83ee72d3e2138df7a91d94211..624dfc44c14e67690a1a59d3572df6d089fdba1f 100644 (file)
@@ -5,10 +5,10 @@ from os import path
 from os import unlink
 from new import instancemethod
 
-from seqtools import Sequence
-from dispatcher import handler, HandlerError, Handler
-from services.util import Restorable, ConfigWriter, call
-from services.util import InitdHandler, TransactionalHandler, ParametersHandler
+from pymin.seqtools import Sequence
+from pymin.dispatcher import handler, HandlerError, Handler
+from pymin.services.util import Restorable, ConfigWriter, InitdHandler, \
+                                TransactionalHandler, ParametersHandler, call
 
 __ALL__ = ('DnsHandler', 'Error',
             'ZoneError', 'ZoneNotFoundError', 'ZoneAlreadyExistsError',
@@ -48,7 +48,6 @@ class ZoneError(Error, KeyError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Zone error: "%s"' % zonename
 
-
 class ZoneNotFoundError(ZoneError):
     r"""
     ZoneNotFoundError(hostname) -> ZoneNotFoundError instance
@@ -61,7 +60,6 @@ class ZoneNotFoundError(ZoneError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'zone not found: "%s"' % zonename
 
-
 class ZoneAlreadyExistsError(ZoneError):
     r"""
     ZoneAlreadyExistsError(hostname) -> ZoneAlreadyExistsError instance
@@ -73,7 +71,6 @@ class ZoneAlreadyExistsError(ZoneError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Zone already exists: "%s"' % zonename
 
-
 class HostError(Error, KeyError):
     r"""
     HostError(hostname) -> HostError instance
@@ -108,7 +105,6 @@ class HostNotFoundError(HostError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Host not found: "%s"' % hostname
 
-
 class MailExchangeError(Error, KeyError):
     r"""
     MailExchangeError(hostname) -> MailExchangeError instance
@@ -120,7 +116,6 @@ class MailExchangeError(Error, KeyError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Mail Exchange error: "%s"' % mx
 
-
 class MailExchangeAlreadyExistsError(MailExchangeError):
     r"""
     MailExchangeAlreadyExistsError(hostname) -> MailExchangeAlreadyExistsError instance
@@ -132,7 +127,6 @@ class MailExchangeAlreadyExistsError(MailExchangeError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Mail Exchange already exists: "%s"' % mx
 
-
 class MailExchangeNotFoundError(MailExchangeError):
     r"""
     MailExchangeNotFoundError(hostname) -> MailExchangeNotFoundError instance
@@ -145,8 +139,6 @@ class MailExchangeNotFoundError(MailExchangeError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Mail Exchange not found: "%s"' % mx
 
-
-
 class NameServerError(Error, KeyError):
     r"""
     NameServerError(ns) -> NameServerError instance
@@ -182,29 +174,6 @@ class NameServerNotFoundError(NameServerError):
         self.message = 'Mail Exchange not found: "%s"' % ns
 
 
-class ParameterError(Error, KeyError):
-    r"""
-    ParameterError(paramname) -> ParameterError instance
-
-    This is the base exception for all DhcpHandler parameters related errors.
-    """
-
-    def __init__(self, paramname):
-        r"Initialize the object. See class documentation for more info."
-        self.message = 'Parameter error: "%s"' % paramname
-
-class ParameterNotFoundError(ParameterError):
-    r"""
-    ParameterNotFoundError(hostname) -> ParameterNotFoundError instance
-
-    This exception is raised when trying to operate on a parameter that doesn't
-    exists.
-    """
-
-    def __init__(self, paramname):
-        r"Initialize the object. See class documentation for more info."
-        self.message = 'Parameter not found: "%s"' % paramname
-
 class Host(Sequence):
     def __init__(self, name, ip):
         self.name = name
@@ -395,6 +364,7 @@ class ZoneHandler(Handler):
     def show(self):
         return self.zones.values()
 
+
 class DnsHandler(Restorable, ConfigWriter, InitdHandler, TransactionalHandler,
                  ParametersHandler):
     r"""DnsHandler([pickle_dir[, config_dir]]) -> DnsHandler instance.
@@ -485,6 +455,7 @@ class DnsHandler(Restorable, ConfigWriter, InitdHandler, TransactionalHandler,
             self.mod = False
             self.reload()
 
+
 if __name__ == '__main__':
 
     dns = DnsHandler();
similarity index 97%
rename from services/firewall/__init__.py
rename to pymin/services/firewall/__init__.py
index ca9bd5d866a6d958491efe8a3360de3cdf423f2f..dbf9b155015e4053cc32cc83e96c2537d18dec09 100644 (file)
@@ -5,10 +5,10 @@
 
 from os import path
 
-from seqtools import Sequence
-from dispatcher import Handler, handler, HandlerError
-from services.util import Restorable, ConfigWriter
-from services.util import ServiceHandler, TransactionalHandler
+from pymin.seqtools import Sequence
+from pymin.dispatcher import Handler, handler, HandlerError
+from pymin.services.util import Restorable, ConfigWriter, ServiceHandler, \
+                                TransactionalHandler
 
 __ALL__ = ('FirewallHandler', 'Error', 'RuleError', 'RuleAlreadyExistsError',
            'RuleNotFoundError')
@@ -64,6 +64,7 @@ class RuleNotFoundError(RuleError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Rule not found: "%s"' % rule
 
+
 class Rule(Sequence):
     r"""Rule(chain, target[, src[, dst[, ...]]]) -> Rule instance.
 
@@ -173,6 +174,7 @@ class RuleHandler(Handler):
         r"show() -> list of Rules :: List all the complete rules information."
         return self.rules
 
+
 class FirewallHandler(Restorable, ConfigWriter, ServiceHandler,
                       TransactionalHandler):
     r"""FirewallHandler([pickle_dir[, config_dir]]) -> FirewallHandler instance.
@@ -209,6 +211,7 @@ class FirewallHandler(Restorable, ConfigWriter, ServiceHandler,
     def _get_config_vars(self, config_file):
         return dict(rules=self.rules)
 
+
 if __name__ == '__main__':
 
     import os
similarity index 95%
rename from services/ip/__init__.py
rename to pymin/services/ip/__init__.py
index a27e0d805028ef01494d424c01dbcb046e684ea3..4330eeb359b8cdb8a31d49295505c07a69d9d911 100644 (file)
@@ -3,13 +3,14 @@
 from subprocess import Popen, PIPE
 from os import path
 
-from seqtools import Sequence
-from dispatcher import handler, HandlerError, Handler
-from services.util import Restorable, ConfigWriter
-from services.util import InitdHandler, TransactionalHandler
+from pymin.seqtools import Sequence
+from pymin.dispatcher import handler, HandlerError, Handler
+from pymin.services.util import Restorable, ConfigWriter, InitdHandler, \
+                                TransactionalHandler
 
-__ALL__ = ('IpHandler','Error','DeviceError','DeviceNotFoundError','RouteError','RouteNotFoundError',
-            'RouteAlreadyExistsError','AddressError','AddressNotFoundError','AddressAlreadyExistsError')
+__ALL__ = ('IpHandler', 'Error','DeviceError', 'DeviceNotFoundError',
+           'RouteError', 'RouteNotFoundError', 'RouteAlreadyExistsError',
+           'AddressError', 'AddressNotFoundError', 'AddressAlreadyExistsError')
 
 class Error(HandlerError):
     r"""
@@ -68,6 +69,7 @@ class RouteAlreadyExistsError(RouteError):
     def __init__(self, route):
         self.message = 'Route already exists : "%s"' % route
 
+
 class Route(Sequence):
 
     def __init__(self, net_addr, prefix, gateway):
@@ -134,6 +136,7 @@ class RouteHandler(Handler):
             k = list()
         return k
 
+
 class Address(Sequence):
 
     def __init__(self, ip, prefix, broadcast):
@@ -187,6 +190,7 @@ class AddressHandler(Handler):
             k = list()
         return k
 
+
 class Device(Sequence):
 
     def __init__(self, name, mac):
@@ -230,6 +234,7 @@ class DeviceHandler(Handler):
     def show(self):
         return self.devices.items()
 
+
 def get_devices():
     p = Popen(('ip', 'link', 'list'), stdout=PIPE, close_fds=True)
     string = p.stdout.read()
similarity index 77%
rename from services/proxy/__init__.py
rename to pymin/services/proxy/__init__.py
index 6aff5cda686e48c7ed68da5275b5b861bfe9f7f7..b3b1172bc74474752890f5ccd48fd8f2fd32ec6a 100644 (file)
@@ -2,13 +2,13 @@
 
 from os import path
 
-from seqtools import Sequence
-from dispatcher import Handler, handler, HandlerError
-from services.util import Restorable, ConfigWriter
-from services.util import InitdHandler, TransactionalHandler, ParametersHandler
+from pymin.seqtools import Sequence
+from pymin.dispatcher import Handler, handler, HandlerError
+from pymin.services.util import Restorable, ConfigWriter, InitdHandler, \
+                                TransactionalHandler, ParametersHandler
 
 __ALL__ = ('ProxyHandler', 'Error', 'HostError', 'HostAlreadyExistsError',
-            'HostNotFoundError', 'ParameterError', 'ParameterNotFoundError')
+            'HostNotFoundError')
 
 class Error(HandlerError):
     r"""
@@ -61,28 +61,6 @@ class HostNotFoundError(HostError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Host not found: "%s"' % hostname
 
-class ParameterError(Error, KeyError):
-    r"""
-    ParameterError(paramname) -> ParameterError instance
-
-    This is the base exception for all DhcpHandler parameters related errors.
-    """
-
-    def __init__(self, paramname):
-        r"Initialize the object. See class documentation for more info."
-        self.message = 'Parameter error: "%s"' % paramname
-
-class ParameterNotFoundError(ParameterError):
-    r"""
-    ParameterNotFoundError(hostname) -> ParameterNotFoundError instance
-
-    This exception is raised when trying to operate on a parameter that doesn't
-    exists.
-    """
-
-    def __init__(self, paramname):
-        r"Initialize the object. See class documentation for more info."
-        self.message = 'Parameter not found: "%s"' % paramname
 
 class Host(Sequence):
 
similarity index 99%
rename from services/util.py
rename to pymin/services/util.py
index 7239867f34e1f8e1dbb12ad1ed7d43aa594b56cc..81b2767e4107ad99f73e364cc76b39996367874f 100644 (file)
@@ -9,7 +9,7 @@ try:
 except ImportError:
     import pickle
 
-from dispatcher import Handler, handler, HandlerError
+from pymin.dispatcher import Handler, handler, HandlerError
 
 #DEBUG = False
 DEBUG = True
@@ -95,6 +95,7 @@ class ParameterNotFoundError(ParameterError):
         r"Initialize the object. See class documentation for more info."
         self.message = 'Parameter not found: "%s"' % paramname
 
+
 def call(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
             stderr=subprocess.PIPE, close_fds=True, universal_newlines=True,
             **kw):
@@ -340,6 +341,7 @@ class ConfigWriter:
         for t in self._config_writer_files:
             self._write_single_config(t)
 
+
 class ServiceHandler(Handler):
     r"""ServiceHandler([start[, stop[, restart[, reload]]]]) -> ServiceHandler.
 
similarity index 100%
rename from ucsv.py
rename to pymin/ucsv.py
diff --git a/pymind b/pymind
index 37feab9243c9b201251f6add59aa7227c214dc68..27a972269c7597f73a4fe40926cc592a90bf0e9b 100755 (executable)
--- a/pymind
+++ b/pymind
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim: set encoding=utf-8 et sw=4 sts=4 :
 
-from pymindaemon import PyminDaemon
+from pymin.pymindaemon import PyminDaemon
 import config
 
 PyminDaemon(config.routes, config.bind_addr).run()
diff --git a/services/__init__.py b/services/__init__.py
deleted file mode 100644 (file)
index 4d4dfb6..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# vim: set encoding=utf-8 et sw=4 sts=4 :
-
-from services.dhcp import DhcpHandler
-from services.dns import DnsHandler
-from services.firewall import FirewallHandler
-from services.ip import IpHandler
-from services.proxy import ProxyHandler
-