def __init__(self, configfile=None):
        config = ConfigParser.ConfigParser()
        if configfile is None:
            if os.path.exists(CONF_FILE):
                configfile = CONF_FILE
            else:
                configfile = find_config(os.path.abspath(
                        os.path.dirname(__file__)))
        if configfile is None:
            raise Exception("Configuration file \"%s\" doesn't exist" %
              (configfile))
        LOG.debug("Using configuration file: %s" % configfile)
        config.read(configfile)
        LOG.debug("Config: %s" % config)

        options = {"sql_connection": config.get("DATABASE", "sql_connection")}
        db.configure_db(options)

        self.vmap = VlanMap()
        # Populate the map with anything that is already present in the
        # database
        vlans = ovs_db.get_vlans()
        for x in vlans:
            vlan_id, network_id = x
            # LOG.debug("Adding already populated vlan %s -> %s"
            #                                   % (vlan_id, network_id))
            self.vmap.set_vlan(vlan_id, network_id)
Exemple #2
0
    def __init__(self, configfile=None):
        config = ConfigParser.ConfigParser()
        if configfile is None:
            if os.path.exists(CONF_FILE):
                configfile = CONF_FILE
            else:
                configfile = find_config(
                    os.path.abspath(os.path.dirname(__file__)))
        if configfile is None:
            raise Exception("Configuration file \"%s\" doesn't exist" %
                            (configfile))
        LOG.debug("Using configuration file: %s" % configfile)
        config.read(configfile)
        LOG.debug("Config: %s" % config)

        options = {"sql_connection": config.get("DATABASE", "sql_connection")}
        db.configure_db(options)

        self.vmap = VlanMap()
        # Populate the map with anything that is already present in the
        # database
        vlans = ovs_db.get_vlans()
        for x in vlans:
            vlan_id, network_id = x
            # LOG.debug("Adding already populated vlan %s -> %s"
            #                                   % (vlan_id, network_id))
            self.vmap.set(vlan_id, network_id)
    def __init__(self):
        self.vlanmap = VlanMap()

        # Populate the map with anything that is already present in the
        # database
        vlans = ovs_db.get_vlans()
        for x in vlans:
            vlan_id, network_id = x
            # LOG.debug("Adding already populated vlan %s -> %s"
            #                                   % (vlan_id, network_id))
            self.vlanmap.set_vlan(vlan_id, network_id)