Esempio n. 1
0
    def get_queryset(self):
        queryset = VOLTTenant.get_tenant_objects().select_related().all()

        service_specific_id = self.request.QUERY_PARAMS.get(
            'service_specific_id', None)
        if service_specific_id is not None:
            queryset = queryset.filter(service_specific_id=service_specific_id)


#        vlan_id = self.request.QUERY_PARAMS.get('vlan_id', None)
#        if vlan_id is not None:
#            ids = [x.id for x in queryset if x.get_attribute("vlan_id", None)==vlan_id]
#            queryset = queryset.filter(id__in=ids)

        c_tag = self.request.QUERY_PARAMS.get('c_tag', None)
        if c_tag is not None:
            ids = [
                x.id for x in queryset
                if x.get_attribute("c_tag", None) == c_tag
            ]
            queryset = queryset.filter(id__in=ids)

        s_tag = self.request.QUERY_PARAMS.get('s_tag', None)
        if s_tag is not None:
            ids = [
                x.id for x in queryset
                if x.get_attribute("s_tag", None) == s_tag
            ]
            queryset = queryset.filter(id__in=ids)

        return queryset
Esempio n. 2
0
    def get_extra_attributes(self, o):
        # This is a place to include extra attributes that aren't part of the
        # object itself. In our case, it's handy to know the VLAN IDs when
        # configuring the VCPE.

        dnsdemux_ip = "none"
        for service in HpcService.objects.all():
            for slice in service.slices.all():
                if "dnsdemux" in slice.name:
                    for sliver in slice.slivers.all():
                        if dnsdemux_ip=="none":
                            try:
                                dnsdemux_ip = socket.gethostbyname(sliver.node.name)
                            except:
                                pass

        cdn_prefixes = []
        for prefix in CDNPrefix.objects.all():
            cdn_prefixes.append(prefix.prefix)

        volts = [x for x in VOLTTenant.get_tenant_objects() if (x.vcpe is not None) and (x.vcpe.id==o.id)]
        vlan_ids = [x.vlan_id for x in volts]
        return {"vlan_ids": vlan_ids,
                "dnsdemux_ip": dnsdemux_ip,
                "cdn_prefixes": cdn_prefixes}
Esempio n. 3
0
    def ssiddetail(self, pk=None, ssid=None):
        object_list = VOLTTenant.get_tenant_objects().all()

        ssidmap = [ {"service_specific_id": x.service_specific_id, "subscriber_id": x.id} for x in object_list if str(x.service_specific_id)==str(ssid) ]

        if len(ssidmap)==0:
            raise XOSNotFound("didn't find ssid %s" % str(ssid))

        return Response( ssidmap[0] )
Esempio n. 4
0
    def ssidlist(self, request):
        object_list = VOLTTenant.get_tenant_objects().all()

        ssidmap = [{
            "service_specific_id": x.service_specific_id,
            "subscriber_id": x.id
        } for x in object_list]

        return Response({"ssidmap": ssidmap})
Esempio n. 5
0
    def ssiddetail(self, pk=None, ssid=None):
        object_list = VOLTTenant.get_tenant_objects().all()

        ssidmap = [{
            "service_specific_id": x.service_specific_id,
            "subscriber_id": x.id
        } for x in object_list if str(x.service_specific_id) == str(ssid)]

        if len(ssidmap) == 0:
            raise XOSNotFound("didn't find ssid %s" % str(ssid))

        return Response(ssidmap[0])
Esempio n. 6
0
    def get_queryset(self):
        queryset = VOLTTenant.get_tenant_objects().select_related().all()

        service_specific_id = self.request.QUERY_PARAMS.get('service_specific_id', None)
        if service_specific_id is not None:
            queryset = queryset.filter(service_specific_id=service_specific_id)

        vlan_id = self.request.QUERY_PARAMS.get('vlan_id', None)
        if vlan_id is not None:
            ids = [x.id for x in queryset if x.get_attribute("vlan_id", None)==vlan_id]
            queryset = queryset.filter(id__in=ids)

        return queryset
Esempio n. 7
0
    def post(self, request, format=None):
        data = request.DATA

        existing_obj = None
        for obj in VOLTTenant.get_tenant_objects().all():
            if (obj.vlan_id == data.get("vlan_id", None)) and (obj.service_specific_id == data.get("service_specific_id",None)):
               existing_obj = obj

        if existing_obj:
            serializer = VOLTTenantIdSerializer(existing_obj)
            headers = self.get_success_headers(serializer.data)
            return Response( serializer.data, status=status.HTTP_200_OK )

        return super(VOLTTenantList, self).post(request, format)
Esempio n. 8
0
    def initdemo(self, request):
        object_list = VOLTTenant.get_tenant_objects().all()

        # reset the parental controls in any existing demo vCPEs
        for o in object_list:
            if str(o.service_specific_id) in ["0", "1"]:
                if o.vcpe is not None:
                    self.setup_demo_vcpe(o)

        demo_subscribers = [o for o in object_list if o.is_demo_user]

        if demo_subscribers:
            return Response({"id": demo_subscribers[0].id})

        voltTenant = VOLTTenant(service_specific_id=1234,
                                vlan_id=1234,
                                is_demo_user=True)
        voltTenant.caller = User.objects.get(email="*****@*****.**")
        voltTenant.save()

        self.setup_demo_vcpe(voltTenant)

        return Response({"id": voltTenant.id})
Esempio n. 9
0
    def post(self, request, format=None):
        data = request.DATA

        existing_obj = None
        for obj in VOLTTenant.get_tenant_objects().all():
            if (obj.vlan_id == data.get(
                    "vlan_id", None)) and (obj.service_specific_id == data.get(
                        "service_specific_id", None)):
                existing_obj = obj

        if existing_obj:
            serializer = VOLTTenantIdSerializer(existing_obj)
            headers = self.get_success_headers(serializer.data)
            return Response(serializer.data, status=status.HTTP_200_OK)

        return super(VOLTTenantList, self).post(request, format)
Esempio n. 10
0
    def initdemo(self, request):
        object_list = VOLTTenant.get_tenant_objects().all()

        # reset the parental controls in any existing demo vCPEs
        for o in object_list:
            if str(o.service_specific_id) in ["0", "1"]:
                if o.vcpe is not None:
                    self.setup_demo_vcpe(o)

        demo_subscribers = [o for o in object_list if o.is_demo_user]

        if demo_subscribers:
            return Response({"id": demo_subscribers[0].id})

        voltTenant = VOLTTenant(service_specific_id=1234,
                                vlan_id=1234,
                                is_demo_user=True)
        voltTenant.caller = User.objects.get(email="*****@*****.**")
        voltTenant.save()

        self.setup_demo_vcpe(voltTenant)

        return Response({"id": voltTenant.id})
Esempio n. 11
0
class VOLTTenantDetail(XOSRetrieveUpdateDestroyAPIView):
    serializer_class = VOLTTenantIdSerializer
    queryset = VOLTTenant.get_tenant_objects().select_related().all()

    method_kind = "detail"
    method_name = "volttenant"
Esempio n. 12
0
    def ssidlist(self, request):
        object_list = VOLTTenant.get_tenant_objects().all()

        ssidmap = [ {"service_specific_id": x.service_specific_id, "subscriber_id": x.id} for x in object_list ]

        return Response({"ssidmap": ssidmap})