Example #1
0
    def getLookingGlassLocalInfo(self, pathPrefix):

        attributesDict = {}

        for (attributeId, value) in self.attributes.iteritems():

            # skip some attributes that we care less about
            if (attributeId == AttributeID.AS_PATH
                    or attributeId == AttributeID.ORIGIN
                    or attributeId == AttributeID.LOCAL_PREF):
                continue

            attributesDict[str(AttributeID(attributeId)).lower()] = repr(value)

        res = {
            "afi-safi": "%s/%s" % (self.afi, self.safi),
            "attributes": attributesDict
        }

        if self.source:
            res["source"] = {
                "id":
                self.source.name,
                "href":
                LookingGlassReferences.getAbsolutePath("BGP_WORKERS",
                                                       pathPrefix,
                                                       [self.source.name])
            }

        if (self.safi) in [SAFI.mpls_vpn, SAFI.evpn]:
            res["route_targets"] = [repr(rt) for rt in self.routeTargets]

        return {repr(self.nlri): res}
Example #2
0
    def getLookingGlassLocalInfo(self, pathPrefix):

        attributesDict = {}

        for (attributeId, value) in self.attributes.iteritems():

            # skip some attributes that we care less about
            if (attributeId == AttributeID.AS_PATH or
               attributeId == AttributeID.ORIGIN or
               attributeId == AttributeID.LOCAL_PREF):
                continue

            attributesDict[
                str(AttributeID(attributeId)).lower()] = repr(value)

        res = {"afi-safi": "%s/%s" % (self.afi, self.safi),
               "attributes": attributesDict
               }

        if self.source:
            res["source"] = {"id": self.source.name,
                             "href": LookingGlassReferences.getAbsolutePath(
                                 "BGP_WORKERS", pathPrefix, [self.source.name])
                             }

        if (self.safi) in [SAFI.mpls_vpn, SAFI.evpn]:
            res["route_targets"] = [repr(rt) for rt in self.routeTargets]

        return {
            repr(self.nlri): res
        }
Example #3
0
 def getLookingGlassLocalInfo(self, pathPrefix):
     if not self.gwPort:
         return {"gwPort": None}
     else:
         (linuxif, ipvpn) = self.gwPort
         return {"gwPort": {
                 "interface": repr(linuxif),
                 "ipvpn": LookingGlassReferences.getAbsolutePath(
                     "VPN_INSTANCES", pathPrefix,
                     [ipvpn.externalInstanceId]),
                 }}
Example #4
0
    def __init__(self, config, daemon, vpnManager, catchAllLGLogHandler):
        self.config = config
        self.daemon = daemon

        self.vpnManager = vpnManager
        self.catchAllLGLogHandler = catchAllLGLogHandler

        self.bottle = Bottle()

        # Wrapping route callbacks (instead of using decorator) to url
        self.bottle.get("/ping", callback=self.ping)
        self.bottle.post("/attach_localport", callback=self.attach_localport)
        self.bottle.post("/detach_localport", callback=self.detach_localport)

        self.bottle.get("/%s<path:path>" % LOOKING_GLASS_BASE,
                        callback=self.looking_glass)
        self.bottle.get("/%s" % LOOKING_GLASS_BASE,
                        callback=self.looking_glass_root)

        self.bottle.error_handler[500] = self.error500

        self.startTime = time.time()

        LookingGlassReferences.setRoot(LOOKING_GLASS_BASE)
        LookingGlassReferences.setReferencePath("BGP_WORKERS",
                                                ["bgp", "workers"])
        LookingGlassReferences.setReferencePath("VPN_INSTANCES",
                                                ["vpns", "instances"])
Example #5
0
    def __init__(self, config, daemon, vpnManager, catchAllLGLogHandler):
        self.config = config
        self.daemon = daemon

        self.vpnManager = vpnManager
        self.catchAllLGLogHandler = catchAllLGLogHandler

        self.bottle = Bottle()

        # Wrapping route callbacks (instead of using decorator) to url
        self.bottle.get("/ping", callback=self.ping)
        self.bottle.post("/attach_localport", callback=self.attach_localport)
        self.bottle.post("/detach_localport", callback=self.detach_localport)

        self.bottle.get("/%s<path:path>" %
                        LOOKING_GLASS_BASE, callback=self.looking_glass)
        self.bottle.get("/%s" %
                        LOOKING_GLASS_BASE, callback=self.looking_glass_root)

        self.bottle.error_handler[500] = self.error500

        self.startTime = time.time()

        LookingGlassReferences.setRoot(LOOKING_GLASS_BASE)
        LookingGlassReferences.setReferencePath(
            "BGP_WORKERS", ["bgp", "workers"])
        LookingGlassReferences.setReferencePath(
            "VPN_INSTANCES", ["vpns", "instances"])
Example #6
0
 def getLookingGlassLocalInfo(self, pathPrefix):
     if not self.gwPort:
         return {"gateway_port": None}
     else:
         (linuxif, ipvpn) = self.gwPort
         return {
             "gateway_port": {
                 "interface": repr(linuxif),
                 "ipvpn": {
                     "href":
                     LookingGlassReferences.getAbsolutePath(
                         "VPN_INSTANCES", pathPrefix,
                         [ipvpn.externalInstanceId]),
                     "id":
                     ipvpn.name,
                     "external_instance_id":
                     ipvpn.externalInstanceId
                 },
             }
         }