Esempio n. 1
0
    def __init__(self, _config, peerClass=ExaBGPPeerWorker):
        log.debug("Instantiating Manager")

        self.config = _config
        self.peerClass = peerClass

        # RTC is defaults to being enabled
        self.config['enable_rtc'] = getBoolean(
            self.config.get('enable_rtc', True))

        self.routeTableManager = RouteTableManager()
        self.routeTableManager.start()

        if 'local_address' not in self.config:
            raise Exception("config needs a local_address")

        if 'my_as' not in self.config:
            raise Exception("config needs a my_as")
        self.config['my_as'] = int(self.config['my_as'])

        if 'peer_as' in self.config:
            raise Exception("config must omit peer_as, because only iBGP "
                            "is supported yet")
        self.config['peer_as'] = self.config['my_as']

        self.peers = {}
        if self.config['peers']:
            peersAddresses = [
                x.strip() for x in self.config['peers'].strip().split(",")
            ]
            for peerAddress in peersAddresses:
                log.debug("Creating a peer worker for %s", peerAddress)
                peerWorker = self.peerClass(self, None, peerAddress,
                                            self.config)
                self.peers[peerAddress] = peerWorker
                peerWorker.start()

        self.trackedSubs = dict()

        # we need a .name since we'll masquerade as a routeEntry source
        self.name = "BGPManager"
Esempio n. 2
0
    def __init__(self, _config, peerClass=ExaBGPPeerWorker):
        log.debug("Instantiating Manager")

        self.config = _config
        self.peerClass = peerClass

        # RTC is defaults to being enabled
        self.config['enable_rtc'] = getBoolean(self.config.get('enable_rtc',
                                                               True))

        self.routeTableManager = RouteTableManager()
        self.routeTableManager.start()

        if 'local_address' not in self.config:
            raise Exception("config needs a local_address")

        if 'my_as' not in self.config:
            raise Exception("config needs a my_as")
        self.config['my_as'] = int(self.config['my_as'])

        if 'peer_as' in self.config:
            raise Exception("config must omit peer_as, because only iBGP "
                            "is supported yet")
        self.config['peer_as'] = self.config['my_as']

        self.peers = {}
        if self.config['peers']:
            peersAddresses = [x.strip() for x in
                              self.config['peers'].strip().split(",")]
            for peerAddress in peersAddresses:
                log.debug("Creating a peer worker for %s", peerAddress)
                peerWorker = self.peerClass(
                    self, None, peerAddress, self.config)
                self.peers[peerAddress] = peerWorker
                peerWorker.start()

        self.trackedSubs = dict()

        # we need a .name since we'll masquerade as a routeEntry source
        self.name = "BGPManager"
    def __init__(self, config, init=True):
        LookingGlassLocalLogger.__init__(self)
        self.log.info("Initializing MPLSOVSVRFDataplane")

        try:
            (o, _) = self._runCommand("ovs-ofctl -V | head -1 |"
                                      " awk '{print $4}'")
            self.ovsRelease = o[0]
            self.log.info("OVS release: %s", self.ovsRelease)
        except:
            self.log.warning("Could not determine OVS release")
            self.ovsRelease = None

        self.config = config

        self.mpls_interface = config.get("mpls_interface", None)

        try:
            self.useGRE = getBoolean(config["mpls_over_gre"])
        except KeyError:
            self.useGRE = not (self.mpls_interface
                               and self.mpls_interface != "*gre*")

        if not self.mpls_interface:
            if not self.useGRE:
                raise Exception("mpls_over_gre force-disabled, but no "
                                "mpls_interface specified")
            else:
                self.useGRE = True
                self.log.info("Defaulting to use of MPLS-over-GRE (no "
                              "mpls_interface specified)")
        elif self.mpls_interface == "*gre*":
            if not self.useGRE:
                raise Exception("mpls_over_gre force-disabled, but "
                                "mpls_interface set to '*gre', cannot "
                                "use bare MPLS")
            else:
                self.log.info("mpls_interface is '*gre*', will thus use "
                              "MPLS-over-GRE")
                self.useGRE = True
                self.mpls_interface = None
        else:
            if self.useGRE:
                self.log.warning("mpls_over_gre set to True, "
                                 "ignoring mpls_interface parameter")
                self.mpls_interface = None
            else:
                self.log.info("Will use bare MPLS on interface %s",
                              self.mpls_interface)

        self.bridge = DEFAULT_OVS_BRIDGE
        try:
            self.bridge = config["ovs_bridge"]
        except KeyError:
            self.log.warning("No bridge configured, will use default: %s",
                             DEFAULT_OVS_BRIDGE)

        self.ovs_table_incoming = DEFAULT_OVS_TABLE
        try:
            self.ovs_table_incoming = int(config["ovs_table_incoming"])
        except KeyError:
            self.log.debug(
                "No ovs_table_incoming configured, "
                "will use default table %s", DEFAULT_OVS_TABLE)

        self.ovs_table_vrfs = DEFAULT_OVS_TABLE
        try:
            self.ovs_table_vrfs = int(config["ovs_table_vrfs"])
        except KeyError:
            self.log.debug(
                "No ovs_table_vrfs configured, will use default"
                " table %s", DEFAULT_OVS_TABLE)

        self.vxlanEncap = getBoolean(config.get("vxlan_encap", "False"))

        self.proxy_arp = getBoolean(config.get("proxy_arp", "True"))

        # unless useGRE is enabled, check that fping is installed
        if not self.useGRE:
            self._runCommand("fping -v", raiseExceptionOnError=True)

        if (not self.vxlanEncap
                and StrictVersion(self.ovsRelease) < StrictVersion("2.4.0")):
            self.log.warning(
                "%s requires at least OVS 2.4.0 (you are running %s)",
                self.__class__.__name__, self.ovsRelease)

        DataplaneDriver.__init__(self, config, init)
Esempio n. 4
0
    def __init__(self, config, init=True):
        LookingGlassLocalLogger.__init__(self)
        self.log.info("Initializing MPLSOVSVRFDataplane")

        try:
            (o, _) = self._runCommand("ovs-ofctl -V | head -1 |"
                                      " awk '{print $4}'")
            self.ovsRelease = o[0]
            self.log.info("OVS kernel module %s", self.ovsRelease)
        except:
            self.log.warning("Could not determine OVS release")
            self.ovsRelease = None

        self.config = config

        self.mpls_interface = config.get("mpls_interface", None)

        try:
            self.useGRE = getBoolean(config["mpls_over_gre"])
        except KeyError:
            self.useGRE = not (self.mpls_interface and
                               self.mpls_interface != "*gre*")

        if not self.mpls_interface:
            if not self.useGRE:
                raise Exception("mpls_over_gre force-disabled, but no "
                                "mpls_interface specified")
            else:
                self.useGRE = True
                self.log.info("Defaulting to use of MPLS-over-GRE (no "
                              "mpls_interface specified)")
        elif self.mpls_interface == "*gre*":
            if not self.useGRE:
                raise Exception("mpls_over_gre force-disabled, but "
                                "mpls_interface set to '*gre', cannot "
                                "use bare MPLS")
            else:
                self.log.info("mpls_interface is '*gre*', will thus use "
                              "MPLS-over-GRE")
                self.useGRE = True
                self.mpls_interface = None
        else:
            if self.useGRE:
                self.log.warning("mpls_over_gre set to True, "
                                 "ignoring mpls_interface parameter")
                self.mpls_interface = None
            else:
                self.log.info("Will use bare MPLS on interface %s",
                              self.mpls_interface)

        self.bridge = DEFAULT_OVS_BRIDGE
        try:
            self.bridge = config["ovs_bridge"]
        except KeyError:
            self.log.warning("No bridge configured, will use default: %s",
                             DEFAULT_OVS_BRIDGE)

        self.ovs_table_incoming = DEFAULT_OVS_TABLE
        try:
            self.ovs_table_incoming = int(config["ovs_table_incoming"])
        except KeyError:
            self.log.debug("No ovs_table_incoming configured, "
                           "will use default table %s", DEFAULT_OVS_TABLE)

        self.ovs_table_vrfs = DEFAULT_OVS_TABLE
        try:
            self.ovs_table_vrfs = int(config["ovs_table_vrfs"])
        except KeyError:
            self.log.debug("No ovs_table_vrfs configured, will use default"
                           " table %s", DEFAULT_OVS_TABLE)

        self.vxlanEncap = getBoolean(config.get("vxlan_encap", "False"))

        # check that fping is installed
        if not self.useGRE:
            self._runCommand("fping -v", raiseExceptionOnError=True)

        if (not self.vxlanEncap and
                StrictVersion(self.ovsRelease) < StrictVersion("2.4.0")):
            self.log.warning(
                "%s requires at least OVS 2.4.0 (you are running %s)",
                self.__class__.__name__, self.ovsRelease)

        DataplaneDriver.__init__(self, config, init)