Exemplo n.º 1
0
    def fetch_pending(self, deleted):
        if (not deleted):
            objs = VCPETenant.get_tenant_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
        else:
            objs = VCPETenant.get_deleted_tenant_objects()

        return objs
Exemplo n.º 2
0
    def fetch_pending(self, deleted):
        if (not deleted):
            objs = VCPETenant.get_tenant_objects().filter(Q(enacted__lt=F('updated')) | Q(enacted=None),Q(lazy_blocked=False))
        else:
            objs = VCPETenant.get_deleted_tenant_objects()

        return objs
Exemplo n.º 3
0
    def get_private_interface(self, o):
        vcpes = VCPETenant.get_tenant_objects().all()
        vcpes = [
            x for x in vcpes if (x.vbng is not None) and (x.vbng.id == o.id)
        ]
        if not vcpes:
            raise Exception("No vCPE tenant is associated with vBNG %s" %
                            str(o.id))
        if len(vcpes) > 1:
            raise Exception(
                "More than one vCPE tenant is associated with vBNG %s" %
                str(o.id))

        vcpe = vcpes[0]
        sliver = vcpe.sliver

        if not sliver:
            raise Exception("No sliver associated with vBNG %s" % str(o.id))

        if not vcpe.wan_ip:
            self.defer_sync(o, "does not have a WAN IP yet")

        if not vcpe.wan_mac:
            # this should never happen; WAN MAC is computed from WAN IP
            self.defer_sync(o, "does not have a WAN MAC yet")

        return (vcpe.wan_ip, vcpe.wan_mac, vcpe.sliver.node.name)
Exemplo n.º 4
0
    def get_private_interface(self, o):
        vcpes = VCPETenant.get_tenant_objects().all()
        vcpes = [x for x in vcpes if (x.vbng is not None) and (x.vbng.id == o.id)]
        if not vcpes:
            raise Exception("No vCPE tenant is associated with vBNG %s" % str(o.id))
        if len(vcpes)>1:
            raise Exception("More than one vCPE tenant is associated with vBNG %s" % str(o.id))

        vcpe = vcpes[0]
        sliver = vcpe.sliver

        if not sliver:
            raise Exception("No sliver associated with vBNG %s" % str(o.id))

        if not vcpe.wan_ip:
            self.defer_sync(o, "does not have a WAN IP yet")

        if not vcpe.wan_mac:
            # this should never happen; WAN MAC is computed from WAN IP
            self.defer_sync(o, "does not have a WAN MAC yet")

        return (vcpe.wan_ip, vcpe.wan_mac, vcpe.sliver.node.name)
Exemplo n.º 5
0
    def sync_record(self, o):
        logger.info("sync'ing VBNGTenant %s" % str(o))

        vcpes = VCPETenant.get_tenant_objects().all()
        vcpes = [x for x in vcpes if (x.vbng is not None) and (x.vbng.id == o.id)]
        if not vcpes:
            raise Exception("No vCPE tenant is associated with vBNG %s" % str(o.id))
        if len(vcpes)>1:
            raise Exception("More than one vCPE tenant is associated with vBNG %s" % str(o.id))

        vcpe = vcpes[0]
        sliver = vcpe.sliver

        if not sliver:
            raise Exception("No sliver associated with vBNG %s" % str(o.id))

        external_ns = None
        for ns in sliver.networkslivers.all():
            if (ns.ip) and (ns.network.template.visibility=="private") and (ns.network.template.translation=="none"):
                # need some logic here to find the right network
                external_ns = ns

        if not external_ns:
            self.defer_sync(o, "private network is not filled in yet")
            return

        private_ip = external_ns.ip

        if not o.routeable_subnet:
            print "This is where we would call Pingping's API"
            o.routeable_subnet = "placeholder-from-observer"

            # r = requests.post(VBNG_API + "%s" % private_ip, )
            # public_ip = r.json()
            # o.routeable_subnet = public_ip

        o.save()
Exemplo n.º 6
0
    def get_private_ip(self, o):
        vcpes = VCPETenant.get_tenant_objects().all()
        vcpes = [x for x in vcpes if (x.vbng is not None) and (x.vbng.id == o.id)]
        if not vcpes:
            raise Exception("No vCPE tenant is associated with vBNG %s" % str(o.id))
        if len(vcpes)>1:
            raise Exception("More than one vCPE tenant is associated with vBNG %s" % str(o.id))

        vcpe = vcpes[0]
        sliver = vcpe.sliver

        if not sliver:
            raise Exception("No sliver associated with vBNG %s" % str(o.id))

        external_ns = None
        for ns in sliver.networkslivers.all():
            if (ns.ip) and ("WAN" in ns.network.template.name):
                external_ns = ns

        if not external_ns:
            self.defer_sync(o, "WAN network is not filled in yet")
            return

        return external_ns.ip