diff options
author | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-15 15:00:12 +0000 |
---|---|---|
committer | Steve McIntyre <steve.mcintyre@linaro.org> | 2014-12-15 15:00:12 +0000 |
commit | c12f631675916d07018be3a2f99bae50511d345c (patch) | |
tree | 1f9faa72c74967ea42f22f1ebdfa4a1723ea490a /admin.py | |
parent | 31f3528df2946710ad2d504843fd1e7f7da91000 (diff) |
Move initialisation of the default VLAN to vland main
Change-Id: Iba1d9d3a6d1d56bfe4d45119e289f8a26d7dc9ee
Diffstat (limited to 'admin.py')
-rw-r--r-- | admin.py | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -24,7 +24,8 @@ import os, sys, types 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 @@ def dump_vlan(vlan): #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) |