aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2018-03-05 18:15:51 +0000
committerSteve McIntyre <steve.mcintyre@linaro.org>2018-03-05 18:15:51 +0000
commit6c7ca7f24ee434e9b582d1ea3dd0d7eb95e98e9e (patch)
tree95728e7ee7ce44701c2fa703edcb891383e1a918
parent7b1aa398a2ec20a84525a2a36dc0f8e3f2186dfb (diff)
downloadvland-6c7ca7f24ee434e9b582d1ea3dd0d7eb95e98e9e.tar.gz
Re-organise the source treeHEADmaster
Make this look more like a typical python source tree: * Move all the module code under a new Vland directory * Rename vland.py to vland * Remove lots of old hacky path-mangling code Change-Id: I6ec18ab5af69db1c213b1ceaddc6a0c4b52baad8
-rw-r--r--Vland/__init__.py (renamed from db/__init__.py)0
-rw-r--r--Vland/config/__init__.py (renamed from config/__init__.py)0
-rw-r--r--Vland/config/config.py (renamed from config/config.py)7
-rw-r--r--Vland/config/test-clashing-ports.cfg (renamed from config/test-clashing-ports.cfg)0
-rw-r--r--Vland/config/test-invalid-DB.cfg (renamed from config/test-invalid-DB.cfg)0
-rw-r--r--Vland/config/test-invalid-logging-level.cfg (renamed from config/test-invalid-logging-level.cfg)0
-rw-r--r--Vland/config/test-invalid-vland.cfg (renamed from config/test-invalid-vland.cfg)0
-rw-r--r--Vland/config/test-known-good.cfg (renamed from config/test-known-good.cfg)0
-rw-r--r--Vland/config/test-missing-db-username.cfg (renamed from config/test-missing-db-username.cfg)0
-rw-r--r--Vland/config/test-missing-dbname.cfg (renamed from config/test-missing-dbname.cfg)0
-rw-r--r--Vland/config/test-reused-switch-names.cfg (renamed from config/test-reused-switch-names.cfg)0
-rw-r--r--Vland/config/test-unknown-section.cfg (renamed from config/test-unknown-section.cfg)0
-rw-r--r--Vland/config/test.py (renamed from config/test.py)6
-rw-r--r--Vland/db/__init__.py (renamed from drivers/__init__.py)0
-rw-r--r--Vland/db/db.py (renamed from db/db.py)7
-rw-r--r--Vland/db/init.doc (renamed from db/init.doc)0
-rwxr-xr-xVland/db/setup_db.py (renamed from db/setup_db.py)0
-rw-r--r--Vland/drivers/CiscoCatalyst.py (renamed from drivers/CiscoCatalyst.py)0
-rw-r--r--Vland/drivers/CiscoSX300.py (renamed from drivers/CiscoSX300.py)0
-rw-r--r--Vland/drivers/Dummy.py (renamed from drivers/Dummy.py)0
-rw-r--r--Vland/drivers/Mellanox.py (renamed from drivers/Mellanox.py)0
-rw-r--r--Vland/drivers/NetgearXSM.py (renamed from drivers/NetgearXSM.py)0
-rw-r--r--Vland/drivers/TPLinkTLSG2XXX.py (renamed from drivers/TPLinkTLSG2XXX.py)0
-rw-r--r--Vland/drivers/__init__.py (renamed from ipc/__init__.py)0
-rw-r--r--Vland/drivers/common.py (renamed from drivers/common.py)0
-rw-r--r--Vland/errors.py (renamed from errors.py)0
-rw-r--r--Vland/ipc/__init__.py (renamed from visualisation/__init__.py)0
-rw-r--r--Vland/ipc/client-new.py (renamed from ipc/client-new.py)0
-rw-r--r--Vland/ipc/ipc.py (renamed from ipc/ipc.py)4
-rw-r--r--Vland/ipc/server-new.py (renamed from ipc/server-new.py)0
-rw-r--r--Vland/util.py (renamed from util.py)0
-rw-r--r--Vland/visualisation/__init__.py0
-rw-r--r--Vland/visualisation/graphics.py (renamed from visualisation/graphics.py)7
-rw-r--r--Vland/visualisation/visualisation.py (renamed from visualisation/visualisation.py)15
-rwxr-xr-xvland (renamed from vland.py)17
-rwxr-xr-xvland-admin9
-rw-r--r--vland.service2
37 files changed, 23 insertions, 51 deletions
diff --git a/db/__init__.py b/Vland/__init__.py
index e69de29..e69de29 100644
--- a/db/__init__.py
+++ b/Vland/__init__.py
diff --git a/config/__init__.py b/Vland/config/__init__.py
index 89e40d5..89e40d5 100644
--- a/config/__init__.py
+++ b/Vland/config/__init__.py
diff --git a/config/config.py b/Vland/config/config.py
index 67d3bfa..802f881 100644
--- a/config/config.py
+++ b/Vland/config/config.py
@@ -24,12 +24,7 @@
import ConfigParser
import os, sys, re
-if __name__ == '__main__':
- vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
- sys.path.insert(0, vlandpath)
- sys.path.insert(0, "%s/.." % vlandpath)
-
-from errors import ConfigError
+from Vland.errors import ConfigError
def is_positive(text):
valid_true = ('1', 'y', 'yes', 't', 'true')
diff --git a/config/test-clashing-ports.cfg b/Vland/config/test-clashing-ports.cfg
index 46b2f3e..46b2f3e 100644
--- a/config/test-clashing-ports.cfg
+++ b/Vland/config/test-clashing-ports.cfg
diff --git a/config/test-invalid-DB.cfg b/Vland/config/test-invalid-DB.cfg
index a80fcbc..a80fcbc 100644
--- a/config/test-invalid-DB.cfg
+++ b/Vland/config/test-invalid-DB.cfg
diff --git a/config/test-invalid-logging-level.cfg b/Vland/config/test-invalid-logging-level.cfg
index d2de278..d2de278 100644
--- a/config/test-invalid-logging-level.cfg
+++ b/Vland/config/test-invalid-logging-level.cfg
diff --git a/config/test-invalid-vland.cfg b/Vland/config/test-invalid-vland.cfg
index 4478e7a..4478e7a 100644
--- a/config/test-invalid-vland.cfg
+++ b/Vland/config/test-invalid-vland.cfg
diff --git a/config/test-known-good.cfg b/Vland/config/test-known-good.cfg
index bd060db..bd060db 100644
--- a/config/test-known-good.cfg
+++ b/Vland/config/test-known-good.cfg
diff --git a/config/test-missing-db-username.cfg b/Vland/config/test-missing-db-username.cfg
index 160934c..160934c 100644
--- a/config/test-missing-db-username.cfg
+++ b/Vland/config/test-missing-db-username.cfg
diff --git a/config/test-missing-dbname.cfg b/Vland/config/test-missing-dbname.cfg
index ddc7168..ddc7168 100644
--- a/config/test-missing-dbname.cfg
+++ b/Vland/config/test-missing-dbname.cfg
diff --git a/config/test-reused-switch-names.cfg b/Vland/config/test-reused-switch-names.cfg
index 2d8485a..2d8485a 100644
--- a/config/test-reused-switch-names.cfg
+++ b/Vland/config/test-reused-switch-names.cfg
diff --git a/config/test-unknown-section.cfg b/Vland/config/test-unknown-section.cfg
index 446e0a5..446e0a5 100644
--- a/config/test-unknown-section.cfg
+++ b/Vland/config/test-unknown-section.cfg
diff --git a/config/test.py b/Vland/config/test.py
index 0ce11f6..046fbb2 100644
--- a/config/test.py
+++ b/Vland/config/test.py
@@ -1,12 +1,12 @@
import unittest, os, sys
vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
sys.path.insert(0, vlandpath)
-sys.path.insert(0, "%s/.." % vlandpath)
+sys.path.insert(0, "%s/../.." % vlandpath)
os.chdir(vlandpath)
-from config.config import VlanConfig
-from errors import ConfigError
+from Vland.config.config import VlanConfig
+from Vland.errors import ConfigError
class MyTest(unittest.TestCase):
diff --git a/drivers/__init__.py b/Vland/db/__init__.py
index e69de29..e69de29 100644
--- a/drivers/__init__.py
+++ b/Vland/db/__init__.py
diff --git a/db/db.py b/Vland/db/db.py
index 4fc9444..d5b541b 100644
--- a/db/db.py
+++ b/Vland/db/db.py
@@ -37,12 +37,7 @@ TRUNK_ID_NONE = -1
# it
DATABASE_SCHEMA_VERSION = 2
-if __name__ == '__main__':
- vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
- sys.path.insert(0, vlandpath)
- sys.path.insert(0, "%s/.." % vlandpath)
-
-from errors import CriticalError, InputError, NotFoundError
+from Vland.errors import CriticalError, InputError, NotFoundError
class VlanDB:
def __init__(self, db_name="vland", username="vland", readonly=True):
diff --git a/db/init.doc b/Vland/db/init.doc
index 91a3841..91a3841 100644
--- a/db/init.doc
+++ b/Vland/db/init.doc
diff --git a/db/setup_db.py b/Vland/db/setup_db.py
index 99cfaf4..99cfaf4 100755
--- a/db/setup_db.py
+++ b/Vland/db/setup_db.py
diff --git a/drivers/CiscoCatalyst.py b/Vland/drivers/CiscoCatalyst.py
index 16f47db..16f47db 100644
--- a/drivers/CiscoCatalyst.py
+++ b/Vland/drivers/CiscoCatalyst.py
diff --git a/drivers/CiscoSX300.py b/Vland/drivers/CiscoSX300.py
index a6f5446..a6f5446 100644
--- a/drivers/CiscoSX300.py
+++ b/Vland/drivers/CiscoSX300.py
diff --git a/drivers/Dummy.py b/Vland/drivers/Dummy.py
index f630184..f630184 100644
--- a/drivers/Dummy.py
+++ b/Vland/drivers/Dummy.py
diff --git a/drivers/Mellanox.py b/Vland/drivers/Mellanox.py
index ea74bf0..ea74bf0 100644
--- a/drivers/Mellanox.py
+++ b/Vland/drivers/Mellanox.py
diff --git a/drivers/NetgearXSM.py b/Vland/drivers/NetgearXSM.py
index f8ba8a5..f8ba8a5 100644
--- a/drivers/NetgearXSM.py
+++ b/Vland/drivers/NetgearXSM.py
diff --git a/drivers/TPLinkTLSG2XXX.py b/Vland/drivers/TPLinkTLSG2XXX.py
index 5213d10..5213d10 100644
--- a/drivers/TPLinkTLSG2XXX.py
+++ b/Vland/drivers/TPLinkTLSG2XXX.py
diff --git a/ipc/__init__.py b/Vland/drivers/__init__.py
index e69de29..e69de29 100644
--- a/ipc/__init__.py
+++ b/Vland/drivers/__init__.py
diff --git a/drivers/common.py b/Vland/drivers/common.py
index e564c9e..e564c9e 100644
--- a/drivers/common.py
+++ b/Vland/drivers/common.py
diff --git a/errors.py b/Vland/errors.py
index 6759e50..6759e50 100644
--- a/errors.py
+++ b/Vland/errors.py
diff --git a/visualisation/__init__.py b/Vland/ipc/__init__.py
index e69de29..e69de29 100644
--- a/visualisation/__init__.py
+++ b/Vland/ipc/__init__.py
diff --git a/ipc/client-new.py b/Vland/ipc/client-new.py
index 8834f9d..8834f9d 100644
--- a/ipc/client-new.py
+++ b/Vland/ipc/client-new.py
diff --git a/ipc/ipc.py b/Vland/ipc/ipc.py
index 8df1219..5961ed1 100644
--- a/ipc/ipc.py
+++ b/Vland/ipc/ipc.py
@@ -25,9 +25,7 @@ import os
import sys
import logging
-vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
-sys.path.insert(0, vlandpath)
-from errors import CriticalError, InputError, ConfigError, SocketError
+from Vland.errors import CriticalError, InputError, ConfigError, SocketError
class VlanIpc:
"""VLANd IPC class"""
diff --git a/ipc/server-new.py b/Vland/ipc/server-new.py
index e398dcc..e398dcc 100644
--- a/ipc/server-new.py
+++ b/Vland/ipc/server-new.py
diff --git a/util.py b/Vland/util.py
index 738eb00..738eb00 100644
--- a/util.py
+++ b/Vland/util.py
diff --git a/Vland/visualisation/__init__.py b/Vland/visualisation/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Vland/visualisation/__init__.py
diff --git a/visualisation/graphics.py b/Vland/visualisation/graphics.py
index 55067d8..84083d0 100644
--- a/visualisation/graphics.py
+++ b/Vland/visualisation/graphics.py
@@ -25,12 +25,7 @@
import gd, os, sys
-if __name__ == '__main__':
- vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
- sys.path.insert(0, vlandpath)
- sys.path.insert(0, "%s/.." % vlandpath)
-
-from errors import InputError
+from Vland.errors import InputError
class Graphics:
""" Code and config for the visualisation graphics module """
diff --git a/visualisation/visualisation.py b/Vland/visualisation/visualisation.py
index eb1edcd..603835d 100644
--- a/visualisation/visualisation.py
+++ b/Vland/visualisation/visualisation.py
@@ -29,16 +29,11 @@ from BaseHTTPServer import HTTPServer
import urlparse
import cStringIO
-if __name__ == '__main__':
- vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
- sys.path.insert(0, vlandpath)
- sys.path.insert(0, "%s/.." % vlandpath)
-
-from errors import InputError
-from db.db import VlanDB
-from config.config import VlanConfig
-from graphics import Graphics,Switch
-from util import VlanUtil
+from Vland.errors import InputError
+from Vland.db.db import VlanDB
+from Vland.config.config import VlanConfig
+from Vland.visualisation.graphics import Graphics,Switch
+from Vland.util import VlanUtil
class VlandHTTPServer(HTTPServer):
""" Trivial wrapper for HTTPServer so we can include our own state. """
def __init__(self, server_address, handler, state):
diff --git a/vland.py b/vland
index 633e10f..7365a73 100755
--- a/vland.py
+++ b/vland
@@ -17,22 +17,19 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
-# Main VLANd module
+# Top-level VLANd daemon
#
import os, sys
import time
import logging
-vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
-sys.path.insert(0, vlandpath)
-
-from config.config import VlanConfig
-from db.db import VlanDB
-from ipc.ipc import VlanIpc
-from errors import InputError, NotFoundError, SocketError
-from util import VlanUtil
-from visualisation.visualisation import Visualisation
+from Vland.config.config import VlanConfig
+from Vland.db.db import VlanDB
+from Vland.ipc.ipc import VlanIpc
+from Vland.errors import InputError, NotFoundError, SocketError
+from Vland.util import VlanUtil
+from Vland.visualisation.visualisation import Visualisation
class DaemonState:
""" Simple container for stuff to make for nicer syntax """
diff --git a/vland-admin b/vland-admin
index f635699..ced26eb 100755
--- a/vland-admin
+++ b/vland-admin
@@ -24,12 +24,9 @@ import os, sys
import argparse
import datetime, time
-vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
-sys.path.insert(0, vlandpath)
-
-from errors import InputError, SocketError, NotFoundError, Error
-from config.config import VlanConfig
-from ipc.ipc import VlanIpc
+from Vland.errors import InputError, SocketError, NotFoundError, Error
+from Vland.config.config import VlanConfig
+from Vland.ipc.ipc import VlanIpc
prog = "vland-admin"
version = "0.7"
diff --git a/vland.service b/vland.service
index 83397c9..e998dba 100644
--- a/vland.service
+++ b/vland.service
@@ -6,7 +6,7 @@ Requires=postgresql.service
[Service]
Type=simple
-ExecStart=/home/vland/vland/vland.py
+ExecStart=/home/vland/vland/vland
ExecStop=/home/vland/vland/vland-admin shutdown
WorkingDirectory=/home/vland/vland
User=vland