Exemple #1
0
	def __init__ (self, configurations):
		_Configuration.__init__(self)
		self.api_encoder = environment.settings().api.encoder

		self._configurations = configurations

		self.error  = Error  ()
		self.scope  = Scope  ()

		self.tokeniser = Tokeniser(self.scope,self.error,self.logger)

		generic           = Section          (self.tokeniser,self.scope,self.error,self.logger)
		self.process      = ParseProcess     (self.tokeniser,self.scope,self.error,self.logger)
		self.template     = ParseTemplate    (self.tokeniser,self.scope,self.error,self.logger)
		self.neighbor     = ParseNeighbor    (self.tokeniser,self.scope,self.error,self.logger)
		self.family       = ParseFamily      (self.tokeniser,self.scope,self.error,self.logger)
		self.capability   = ParseCapability  (self.tokeniser,self.scope,self.error,self.logger)
		self.api          = ParseAPI         (self.tokeniser,self.scope,self.error,self.logger)
		self.api_send     = ParseSend        (self.tokeniser,self.scope,self.error,self.logger)
		self.api_receive  = ParseReceive     (self.tokeniser,self.scope,self.error,self.logger)
		self.static       = ParseStatic      (self.tokeniser,self.scope,self.error,self.logger)
		self.static_route = ParseStaticRoute (self.tokeniser,self.scope,self.error,self.logger)
		self.flow         = ParseFlow        (self.tokeniser,self.scope,self.error,self.logger)
		self.flow_route   = ParseFlowRoute   (self.tokeniser,self.scope,self.error,self.logger)
		self.flow_match   = ParseFlowMatch   (self.tokeniser,self.scope,self.error,self.logger)
		self.flow_then    = ParseFlowThen    (self.tokeniser,self.scope,self.error,self.logger)
		self.l2vpn        = ParseL2VPN       (self.tokeniser,self.scope,self.error,self.logger)
		self.vpls         = ParseVPLS        (self.tokeniser,self.scope,self.error,self.logger)
		self.traffic_engineering = ParseTrafficEngineering(self.tokeniser,self.scope,self.error,self.logger)
		self.ls_unicast   = ParseLSUNICAST   (self.tokeniser,self.scope,self.error,self.logger)
		self.operational  = ParseOperational (self.tokeniser,self.scope,self.error,self.logger)

		# We should check if name are unique when running Section.__init__

		self._structure = {
			'root': {
				'class':    generic,
				'commands': [],
				'sections': {
					'process': self.process.name,
					'neighbor': self.neighbor.name,
					'template': self.template.name,
				},
			},
			self.process.name: {
				'class':    self.process,
				'commands': self.process.known.keys(),
				'sections': {},
			},
			self.template.name: {
				'class':    self.template,
				'commands': self.template.known.keys(),
				'sections': {
					'family':      self.family.name,
					'capability':  self.capability.name,
					'api':         self.api.name,
					'static':      self.static.name,
					'flow':        self.flow.name,
					'l2vpn':       self.l2vpn.name,
					'traffic_engineering': self.traffic_engineering.name,
					'operational': self.operational.name,
				},
			},
			self.neighbor.name: {
				'class':    self.neighbor,
				'commands': self.neighbor.known.keys(),
				'sections': {
					'family':      self.family.name,
					'capability':  self.capability.name,
					'api':         self.api.name,
					'static':      self.static.name,
					'flow':        self.flow.name,
					'l2vpn':       self.l2vpn.name,
					'traffic_engineering': self.traffic_engineering.name,
					'operational': self.operational.name,
				},
			},
			self.family.name: {
				'class':    self.family,
				'commands': self.family.known.keys(),
				'sections': {
				},
			},
			self.capability.name: {
				'class':    self.capability,
				'commands': self.capability.known.keys(),
				'sections': {
				},
			},
			self.api.name: {
				'class':    self.api,
				'commands': self.api.known.keys(),
				'sections': {
					'send':    self.api_send.name,
					'receive': self.api_receive.name,
				},
			},
			self.api_send.name: {
				'class':    self.api_send,
				'commands': self.api_send.known.keys(),
				'sections': {
				},
			},
			self.api_receive.name: {
				'class':    self.api_receive,
				'commands': self.api_receive.known.keys(),
				'sections': {
				},
			},
			self.static.name: {
				'class':    self.static,
				'commands': ['route','attributes'],
				'sections': {
					'route': self.static_route.name,
				},
			},
			self.static_route.name: {
				'class':    self.static_route,
				'commands': self.static_route.known.keys(),
				'sections': {
				},
			},
			self.flow.name: {
				'class':    self.flow,
				'commands': self.flow.known.keys(),
				'sections': {
					'route': self.flow_route.name,
				},
			},
			self.flow_route.name: {
				'class':    self.flow_route,
				'commands': self.flow_route.known.keys(),
				'sections': {
					'match': self.flow_match.name,
					'then':  self.flow_then.name,
				},
			},
			self.flow_match.name: {
				'class':    self.flow_match,
				'commands': self.flow_match.known.keys(),
				'sections': {
				},
			},
			self.flow_then.name: {
				'class':    self.flow_then,
				'commands': self.flow_then.known.keys(),
				'sections': {
				},
			},
			self.l2vpn.name: {
				'class':    self.l2vpn,
				'commands': self.l2vpn.known.keys(),
				'sections': {
					'vpls': self.vpls.name,
				},
			},
			self.vpls.name: {
				'class':    self.vpls,
				'commands': self.l2vpn.known.keys(),
				'sections': {
				},
			},
			self.traffic_engineering.name: {
				'class':    self.traffic_engineering,
				'commands': self.traffic_engineering.known.keys(),
				'sections': {
					'ls_unicast': self.ls_unicast.name,
				},
			},
			self.ls_unicast.name: {
				'class':    self.ls_unicast,
				'commands': self.traffic_engineering.known.keys(),
				'sections': {
				},
			},
			self.operational.name: {
				'class':    self.operational,
				'commands': self.operational.known.keys(),
				'sections': {
				}
			},
		}

		self._neighbors = {}
		self._previous_neighbors = {}
Exemple #2
0
    def __init__(self, configurations):
        _Configuration.__init__(self)
        self.api_encoder = environment.settings().api.encoder

        self._configurations = configurations

        self.error = Error()
        self.scope = Scope()

        self.tokeniser = Tokeniser(self.scope, self.error, self.logger)

        generic = Section(self.tokeniser, self.scope, self.error, self.logger)
        self.process = ParseProcess(self.tokeniser, self.scope, self.error,
                                    self.logger)
        self.template = ParseTemplate(self.tokeniser, self.scope, self.error,
                                      self.logger)
        self.neighbor = ParseNeighbor(self.tokeniser, self.scope, self.error,
                                      self.logger)
        self.family = ParseFamily(self.tokeniser, self.scope, self.error,
                                  self.logger)
        self.capability = ParseCapability(self.tokeniser, self.scope,
                                          self.error, self.logger)
        self.api = ParseAPI(self.tokeniser, self.scope, self.error,
                            self.logger)
        self.api_send = ParseSend(self.tokeniser, self.scope, self.error,
                                  self.logger)
        self.api_receive = ParseReceive(self.tokeniser, self.scope, self.error,
                                        self.logger)
        self.static = ParseStatic(self.tokeniser, self.scope, self.error,
                                  self.logger)
        self.static_route = ParseStaticRoute(self.tokeniser, self.scope,
                                             self.error, self.logger)
        self.flow = ParseFlow(self.tokeniser, self.scope, self.error,
                              self.logger)
        self.flow_route = ParseFlowRoute(self.tokeniser, self.scope,
                                         self.error, self.logger)
        self.flow_match = ParseFlowMatch(self.tokeniser, self.scope,
                                         self.error, self.logger)
        self.flow_then = ParseFlowThen(self.tokeniser, self.scope, self.error,
                                       self.logger)
        self.l2vpn = ParseL2VPN(self.tokeniser, self.scope, self.error,
                                self.logger)
        self.vpls = ParseVPLS(self.tokeniser, self.scope, self.error,
                              self.logger)
        self.traffic_engineering = ParseTrafficEngineering(
            self.tokeniser, self.scope, self.error, self.logger)
        self.ls_unicast = ParseLSUNICAST(self.tokeniser, self.scope,
                                         self.error, self.logger)
        self.operational = ParseOperational(self.tokeniser, self.scope,
                                            self.error, self.logger)

        # We should check if name are unique when running Section.__init__

        self._structure = {
            'root': {
                'class': generic,
                'commands': [],
                'sections': {
                    'process': self.process.name,
                    'neighbor': self.neighbor.name,
                    'template': self.template.name,
                },
            },
            self.process.name: {
                'class': self.process,
                'commands': self.process.known.keys(),
                'sections': {},
            },
            self.template.name: {
                'class': self.template,
                'commands': self.template.known.keys(),
                'sections': {
                    'family': self.family.name,
                    'capability': self.capability.name,
                    'api': self.api.name,
                    'static': self.static.name,
                    'flow': self.flow.name,
                    'l2vpn': self.l2vpn.name,
                    'traffic_engineering': self.traffic_engineering.name,
                    'operational': self.operational.name,
                },
            },
            self.neighbor.name: {
                'class': self.neighbor,
                'commands': self.neighbor.known.keys(),
                'sections': {
                    'family': self.family.name,
                    'capability': self.capability.name,
                    'api': self.api.name,
                    'static': self.static.name,
                    'flow': self.flow.name,
                    'l2vpn': self.l2vpn.name,
                    'traffic_engineering': self.traffic_engineering.name,
                    'operational': self.operational.name,
                },
            },
            self.family.name: {
                'class': self.family,
                'commands': self.family.known.keys(),
                'sections': {},
            },
            self.capability.name: {
                'class': self.capability,
                'commands': self.capability.known.keys(),
                'sections': {},
            },
            self.api.name: {
                'class': self.api,
                'commands': self.api.known.keys(),
                'sections': {
                    'send': self.api_send.name,
                    'receive': self.api_receive.name,
                },
            },
            self.api_send.name: {
                'class': self.api_send,
                'commands': self.api_send.known.keys(),
                'sections': {},
            },
            self.api_receive.name: {
                'class': self.api_receive,
                'commands': self.api_receive.known.keys(),
                'sections': {},
            },
            self.static.name: {
                'class': self.static,
                'commands': ['route', 'attributes'],
                'sections': {
                    'route': self.static_route.name,
                },
            },
            self.static_route.name: {
                'class': self.static_route,
                'commands': self.static_route.known.keys(),
                'sections': {},
            },
            self.flow.name: {
                'class': self.flow,
                'commands': self.flow.known.keys(),
                'sections': {
                    'route': self.flow_route.name,
                },
            },
            self.flow_route.name: {
                'class': self.flow_route,
                'commands': self.flow_route.known.keys(),
                'sections': {
                    'match': self.flow_match.name,
                    'then': self.flow_then.name,
                },
            },
            self.flow_match.name: {
                'class': self.flow_match,
                'commands': self.flow_match.known.keys(),
                'sections': {},
            },
            self.flow_then.name: {
                'class': self.flow_then,
                'commands': self.flow_then.known.keys(),
                'sections': {},
            },
            self.l2vpn.name: {
                'class': self.l2vpn,
                'commands': self.l2vpn.known.keys(),
                'sections': {
                    'vpls': self.vpls.name,
                },
            },
            self.vpls.name: {
                'class': self.vpls,
                'commands': self.l2vpn.known.keys(),
                'sections': {},
            },
            self.traffic_engineering.name: {
                'class': self.traffic_engineering,
                'commands': self.traffic_engineering.known.keys(),
                'sections': {
                    'ls_unicast': self.ls_unicast.name,
                },
            },
            self.ls_unicast.name: {
                'class': self.ls_unicast,
                'commands': self.traffic_engineering.known.keys(),
                'sections': {},
            },
            self.operational.name: {
                'class': self.operational,
                'commands': self.operational.known.keys(),
                'sections': {}
            },
        }

        self._neighbors = {}
        self._previous_neighbors = {}
Exemple #3
0
class Configuration (_Configuration):

	def __init__ (self, configurations):
		_Configuration.__init__(self)
		self.api_encoder = environment.settings().api.encoder

		self._configurations = configurations

		self.error  = Error  ()
		self.scope  = Scope  ()

		self.tokeniser = Tokeniser(self.scope,self.error,self.logger)

		generic           = Section          (self.tokeniser,self.scope,self.error,self.logger)
		self.process      = ParseProcess     (self.tokeniser,self.scope,self.error,self.logger)
		self.template     = ParseTemplate    (self.tokeniser,self.scope,self.error,self.logger)
		self.neighbor     = ParseNeighbor    (self.tokeniser,self.scope,self.error,self.logger)
		self.family       = ParseFamily      (self.tokeniser,self.scope,self.error,self.logger)
		self.capability   = ParseCapability  (self.tokeniser,self.scope,self.error,self.logger)
		self.api          = ParseAPI         (self.tokeniser,self.scope,self.error,self.logger)
		self.api_send     = ParseSend        (self.tokeniser,self.scope,self.error,self.logger)
		self.api_receive  = ParseReceive     (self.tokeniser,self.scope,self.error,self.logger)
		self.static       = ParseStatic      (self.tokeniser,self.scope,self.error,self.logger)
		self.static_route = ParseStaticRoute (self.tokeniser,self.scope,self.error,self.logger)
		self.flow         = ParseFlow        (self.tokeniser,self.scope,self.error,self.logger)
		self.flow_route   = ParseFlowRoute   (self.tokeniser,self.scope,self.error,self.logger)
		self.flow_match   = ParseFlowMatch   (self.tokeniser,self.scope,self.error,self.logger)
		self.flow_then    = ParseFlowThen    (self.tokeniser,self.scope,self.error,self.logger)
		self.l2vpn        = ParseL2VPN       (self.tokeniser,self.scope,self.error,self.logger)
		self.vpls         = ParseVPLS        (self.tokeniser,self.scope,self.error,self.logger)
		self.traffic_engineering = ParseTrafficEngineering(self.tokeniser,self.scope,self.error,self.logger)
		self.ls_unicast   = ParseLSUNICAST   (self.tokeniser,self.scope,self.error,self.logger)
		self.operational  = ParseOperational (self.tokeniser,self.scope,self.error,self.logger)

		# We should check if name are unique when running Section.__init__

		self._structure = {
			'root': {
				'class':    generic,
				'commands': [],
				'sections': {
					'process': self.process.name,
					'neighbor': self.neighbor.name,
					'template': self.template.name,
				},
			},
			self.process.name: {
				'class':    self.process,
				'commands': self.process.known.keys(),
				'sections': {},
			},
			self.template.name: {
				'class':    self.template,
				'commands': self.template.known.keys(),
				'sections': {
					'family':      self.family.name,
					'capability':  self.capability.name,
					'api':         self.api.name,
					'static':      self.static.name,
					'flow':        self.flow.name,
					'l2vpn':       self.l2vpn.name,
					'traffic_engineering': self.traffic_engineering.name,
					'operational': self.operational.name,
				},
			},
			self.neighbor.name: {
				'class':    self.neighbor,
				'commands': self.neighbor.known.keys(),
				'sections': {
					'family':      self.family.name,
					'capability':  self.capability.name,
					'api':         self.api.name,
					'static':      self.static.name,
					'flow':        self.flow.name,
					'l2vpn':       self.l2vpn.name,
					'traffic_engineering': self.traffic_engineering.name,
					'operational': self.operational.name,
				},
			},
			self.family.name: {
				'class':    self.family,
				'commands': self.family.known.keys(),
				'sections': {
				},
			},
			self.capability.name: {
				'class':    self.capability,
				'commands': self.capability.known.keys(),
				'sections': {
				},
			},
			self.api.name: {
				'class':    self.api,
				'commands': self.api.known.keys(),
				'sections': {
					'send':    self.api_send.name,
					'receive': self.api_receive.name,
				},
			},
			self.api_send.name: {
				'class':    self.api_send,
				'commands': self.api_send.known.keys(),
				'sections': {
				},
			},
			self.api_receive.name: {
				'class':    self.api_receive,
				'commands': self.api_receive.known.keys(),
				'sections': {
				},
			},
			self.static.name: {
				'class':    self.static,
				'commands': ['route','attributes'],
				'sections': {
					'route': self.static_route.name,
				},
			},
			self.static_route.name: {
				'class':    self.static_route,
				'commands': self.static_route.known.keys(),
				'sections': {
				},
			},
			self.flow.name: {
				'class':    self.flow,
				'commands': self.flow.known.keys(),
				'sections': {
					'route': self.flow_route.name,
				},
			},
			self.flow_route.name: {
				'class':    self.flow_route,
				'commands': self.flow_route.known.keys(),
				'sections': {
					'match': self.flow_match.name,
					'then':  self.flow_then.name,
				},
			},
			self.flow_match.name: {
				'class':    self.flow_match,
				'commands': self.flow_match.known.keys(),
				'sections': {
				},
			},
			self.flow_then.name: {
				'class':    self.flow_then,
				'commands': self.flow_then.known.keys(),
				'sections': {
				},
			},
			self.l2vpn.name: {
				'class':    self.l2vpn,
				'commands': self.l2vpn.known.keys(),
				'sections': {
					'vpls': self.vpls.name,
				},
			},
			self.vpls.name: {
				'class':    self.vpls,
				'commands': self.l2vpn.known.keys(),
				'sections': {
				},
			},
			self.traffic_engineering.name: {
				'class':    self.traffic_engineering,
				'commands': self.traffic_engineering.known.keys(),
				'sections': {
					'ls_unicast': self.ls_unicast.name,
				},
			},
			self.ls_unicast.name: {
				'class':    self.ls_unicast,
				'commands': self.traffic_engineering.known.keys(),
				'sections': {
				},
			},
			self.operational.name: {
				'class':    self.operational,
				'commands': self.operational.known.keys(),
				'sections': {
				}
			},
		}

		self._neighbors = {}
		self._previous_neighbors = {}

	def _clear (self):
		self.processes = {}
		self.neighbors = {}
		self._neighbors = {}
		self._previous_neighbors = {}

	# clear the parser data (ie: free memory)
	def _cleanup (self):
		self.error.clear()
		self.tokeniser.clear()
		self.scope.clear()

		self.process.clear()
		self.template.clear()
		self.neighbor.clear()
		self.family.clear()
		self.capability.clear()
		self.api.clear()
		self.api_send.clear()
		self.api_receive.clear()
		self.static.clear()
		self.static_route.clear()
		self.flow.clear()
		self.flow_route.clear()
		self.flow_match.clear()
		self.flow_then.clear()
		self.l2vpn.clear()
		self.vpls.clear()
		self.traffic_engineering.clear()
		self.ls_unicast.clear()
		self.operational.clear()

	def _rollback_reload (self):
		self.neighbors = self._previous_neighbors
		self._neighbors = {}
		self._previous_neighbors = {}

	def _commit_reload (self):
		self.neighbors = self.neighbor.neighbors
		# XXX: Yes, we do not detect changes in processes and restart anything ..
		# XXX: This is a bug ..
		self.processes = self.process.processes
		self._neighbors = {}

		# installing in the neighbor the API routes
		for neighbor in self.neighbors:
			if neighbor in self._previous_neighbors:
				self.neighbors[neighbor].changes = self._previous_neighbors[neighbor].changes

		self._previous_neighbors = {}
		self._cleanup()

	def reload (self):
		try:
			return self._reload()
		except KeyboardInterrupt:
			return self.error.set('configuration reload aborted by ^C or SIGINT')
		except Error, exc:
			if environment.settings().debug.configuration:
				raise
			return self.error.set(
				'problem parsing configuration file line %d\n'
				'error message: %s' % (self.tokeniser.index_line, exc)
			)
		except StandardError, exc:
			if environment.settings().debug.configuration:
				raise
			return self.error.set(
				'problem parsing configuration file line %d\n'
				'error message: %s' % (self.tokeniser.index_line, exc)
			)
Exemple #4
0
class Configuration(_Configuration):
    def __init__(self, configurations):
        _Configuration.__init__(self)
        self.api_encoder = environment.settings().api.encoder

        self._configurations = configurations

        self.error = Error()
        self.scope = Scope()

        self.tokeniser = Tokeniser(self.scope, self.error, self.logger)

        generic = Section(self.tokeniser, self.scope, self.error, self.logger)
        self.process = ParseProcess(self.tokeniser, self.scope, self.error,
                                    self.logger)
        self.template = ParseTemplate(self.tokeniser, self.scope, self.error,
                                      self.logger)
        self.neighbor = ParseNeighbor(self.tokeniser, self.scope, self.error,
                                      self.logger)
        self.family = ParseFamily(self.tokeniser, self.scope, self.error,
                                  self.logger)
        self.capability = ParseCapability(self.tokeniser, self.scope,
                                          self.error, self.logger)
        self.api = ParseAPI(self.tokeniser, self.scope, self.error,
                            self.logger)
        self.api_send = ParseSend(self.tokeniser, self.scope, self.error,
                                  self.logger)
        self.api_receive = ParseReceive(self.tokeniser, self.scope, self.error,
                                        self.logger)
        self.static = ParseStatic(self.tokeniser, self.scope, self.error,
                                  self.logger)
        self.static_route = ParseStaticRoute(self.tokeniser, self.scope,
                                             self.error, self.logger)
        self.flow = ParseFlow(self.tokeniser, self.scope, self.error,
                              self.logger)
        self.flow_route = ParseFlowRoute(self.tokeniser, self.scope,
                                         self.error, self.logger)
        self.flow_match = ParseFlowMatch(self.tokeniser, self.scope,
                                         self.error, self.logger)
        self.flow_then = ParseFlowThen(self.tokeniser, self.scope, self.error,
                                       self.logger)
        self.l2vpn = ParseL2VPN(self.tokeniser, self.scope, self.error,
                                self.logger)
        self.vpls = ParseVPLS(self.tokeniser, self.scope, self.error,
                              self.logger)
        self.traffic_engineering = ParseTrafficEngineering(
            self.tokeniser, self.scope, self.error, self.logger)
        self.ls_unicast = ParseLSUNICAST(self.tokeniser, self.scope,
                                         self.error, self.logger)
        self.operational = ParseOperational(self.tokeniser, self.scope,
                                            self.error, self.logger)

        # We should check if name are unique when running Section.__init__

        self._structure = {
            'root': {
                'class': generic,
                'commands': [],
                'sections': {
                    'process': self.process.name,
                    'neighbor': self.neighbor.name,
                    'template': self.template.name,
                },
            },
            self.process.name: {
                'class': self.process,
                'commands': self.process.known.keys(),
                'sections': {},
            },
            self.template.name: {
                'class': self.template,
                'commands': self.template.known.keys(),
                'sections': {
                    'family': self.family.name,
                    'capability': self.capability.name,
                    'api': self.api.name,
                    'static': self.static.name,
                    'flow': self.flow.name,
                    'l2vpn': self.l2vpn.name,
                    'traffic_engineering': self.traffic_engineering.name,
                    'operational': self.operational.name,
                },
            },
            self.neighbor.name: {
                'class': self.neighbor,
                'commands': self.neighbor.known.keys(),
                'sections': {
                    'family': self.family.name,
                    'capability': self.capability.name,
                    'api': self.api.name,
                    'static': self.static.name,
                    'flow': self.flow.name,
                    'l2vpn': self.l2vpn.name,
                    'traffic_engineering': self.traffic_engineering.name,
                    'operational': self.operational.name,
                },
            },
            self.family.name: {
                'class': self.family,
                'commands': self.family.known.keys(),
                'sections': {},
            },
            self.capability.name: {
                'class': self.capability,
                'commands': self.capability.known.keys(),
                'sections': {},
            },
            self.api.name: {
                'class': self.api,
                'commands': self.api.known.keys(),
                'sections': {
                    'send': self.api_send.name,
                    'receive': self.api_receive.name,
                },
            },
            self.api_send.name: {
                'class': self.api_send,
                'commands': self.api_send.known.keys(),
                'sections': {},
            },
            self.api_receive.name: {
                'class': self.api_receive,
                'commands': self.api_receive.known.keys(),
                'sections': {},
            },
            self.static.name: {
                'class': self.static,
                'commands': ['route', 'attributes'],
                'sections': {
                    'route': self.static_route.name,
                },
            },
            self.static_route.name: {
                'class': self.static_route,
                'commands': self.static_route.known.keys(),
                'sections': {},
            },
            self.flow.name: {
                'class': self.flow,
                'commands': self.flow.known.keys(),
                'sections': {
                    'route': self.flow_route.name,
                },
            },
            self.flow_route.name: {
                'class': self.flow_route,
                'commands': self.flow_route.known.keys(),
                'sections': {
                    'match': self.flow_match.name,
                    'then': self.flow_then.name,
                },
            },
            self.flow_match.name: {
                'class': self.flow_match,
                'commands': self.flow_match.known.keys(),
                'sections': {},
            },
            self.flow_then.name: {
                'class': self.flow_then,
                'commands': self.flow_then.known.keys(),
                'sections': {},
            },
            self.l2vpn.name: {
                'class': self.l2vpn,
                'commands': self.l2vpn.known.keys(),
                'sections': {
                    'vpls': self.vpls.name,
                },
            },
            self.vpls.name: {
                'class': self.vpls,
                'commands': self.l2vpn.known.keys(),
                'sections': {},
            },
            self.traffic_engineering.name: {
                'class': self.traffic_engineering,
                'commands': self.traffic_engineering.known.keys(),
                'sections': {
                    'ls_unicast': self.ls_unicast.name,
                },
            },
            self.ls_unicast.name: {
                'class': self.ls_unicast,
                'commands': self.traffic_engineering.known.keys(),
                'sections': {},
            },
            self.operational.name: {
                'class': self.operational,
                'commands': self.operational.known.keys(),
                'sections': {}
            },
        }

        self._neighbors = {}
        self._previous_neighbors = {}

    def _clear(self):
        self.processes = {}
        self.neighbors = {}
        self._neighbors = {}
        self._previous_neighbors = {}

    # clear the parser data (ie: free memory)
    def _cleanup(self):
        self.error.clear()
        self.tokeniser.clear()
        self.scope.clear()

        self.process.clear()
        self.template.clear()
        self.neighbor.clear()
        self.family.clear()
        self.capability.clear()
        self.api.clear()
        self.api_send.clear()
        self.api_receive.clear()
        self.static.clear()
        self.static_route.clear()
        self.flow.clear()
        self.flow_route.clear()
        self.flow_match.clear()
        self.flow_then.clear()
        self.l2vpn.clear()
        self.vpls.clear()
        self.traffic_engineering.clear()
        self.ls_unicast.clear()
        self.operational.clear()

    def _rollback_reload(self):
        self.neighbors = self._previous_neighbors
        self._neighbors = {}
        self._previous_neighbors = {}

    def _commit_reload(self):
        self.neighbors = self.neighbor.neighbors
        # XXX: Yes, we do not detect changes in processes and restart anything ..
        # XXX: This is a bug ..
        self.processes = self.process.processes
        self._neighbors = {}

        # installing in the neighbor the API routes
        for neighbor in self.neighbors:
            if neighbor in self._previous_neighbors:
                self.neighbors[neighbor].changes = self._previous_neighbors[
                    neighbor].changes

        self._previous_neighbors = {}
        self._cleanup()

    def reload(self):
        try:
            return self._reload()
        except KeyboardInterrupt:
            return self.error.set(
                'configuration reload aborted by ^C or SIGINT')
        except Error, exc:
            if environment.settings().debug.configuration:
                raise
            return self.error.set(
                'problem parsing configuration file line %d\n'
                'error message: %s' % (self.tokeniser.index_line, exc))
        except StandardError, exc:
            if environment.settings().debug.configuration:
                raise
            return self.error.set(
                'problem parsing configuration file line %d\n'
                'error message: %s' % (self.tokeniser.index_line, exc))