Move initialisation of the default VLAN to vland main

Change-Id: Iba1d9d3a6d1d56bfe4d45119e289f8a26d7dc9ee
diff --git a/admin.py b/admin.py
index 8e9902b..c442681 100644
--- a/admin.py
+++ b/admin.py
@@ -24,7 +24,8 @@
 import time
 import logging
 import optparse
-from errors import CriticalError, InputError
+from config.config import VlanConfig
+from errors import CriticalError, InputError, ConfigError, SocketError
 
 vlandpath = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
 sys.path.insert(0, vlandpath)
@@ -54,20 +55,19 @@
 
 #print '%s' % banner
 
+print 'Parsing Config...'
+config = VlanConfig(filenames=('./vland.cfg',))
+print '  Config knows about %d switches' % len(config.switches)
+
 #print 'Connecting to DB...'
 db = VlanDB()
 
-# For sanity, we need to know the vlan_id for the default vlan (tag
-# 1). Make sure we know that before anybody attempts to create things
-# that depend on it.
-default_vlan_tag = 1
-default_vlan_id = db.get_vlan_id_by_tag(default_vlan_tag)
+# We need to know the vlan_id for the default vlan (tag 1). Make sure
+# we know that before anybody attempts to create things that depend on
+# it.
+default_vlan_id = db.get_vlan_id_by_tag(config.vland.default_vlan_tag)
 if default_vlan_id is None:
-    # It doesn't exist - create it and try again
-    default_vlan_id = db.create_vlan("DEFAULT",
-                                     default_vlan_tag,
-                                     True)
-
+    raise ConfigError("No vlan ID found for default VLAN tag %d" % config.vland.default_vlan_tag)
 
 usage = 'Usage: %prog --command [command options]'
 parser = optparse.OptionParser(usage=usage, description=banner)