def get_vcpe_service(self, o): if not o.provider_service: return None vcpes = VSGService.get_service_objects().filter(id=o.provider_service.id) if not vcpes: return None return vcpes[0]
def get_vcpe_service(self, o): if o.target: # o.target is a CordSubscriberRoot if o.target.volt and o.target.volt.vcpe: vcpes = VSGService.get_service_objects().filter(id=o.target.volt.vcpe.provider_service.id) if not vcpes: return None return vcpes[0] return None
def get_vcpe_service(self, o): if o.target: # o.target is a CordSubscriberRoot if o.target.volt and o.target.volt.vcpe: vcpes = VSGService.get_service_objects().filter( id=o.target.volt.vcpe.provider_service.id) if not vcpes: return None return vcpes[0] return None
class VSGServiceViewSet(XOSViewSet): base_name = "vsgservice" method_name = None # use the api endpoint /api/service/vsg/ method_kind = "viewset" queryset = VSGService.get_service_objects().select_related().all() serializer_class = VSGServiceSerializer @classmethod def get_urlpatterns(self, api_path="^"): patterns = super(VSGServiceViewSet, self).get_urlpatterns(api_path=api_path) return patterns def list(self, request): object_list = self.filter_queryset(self.get_queryset()) serializer = self.get_serializer(object_list, many=True) return Response(serializer.data)
def get_default_vsg_service(): vsg_services = VSGService.get_service_objects().all() if vsg_services: return vsg_services[0].id return None