def get_neighbor_v6_by_ids(obj_ids): """Return NeighborV6 list by ids. Args: obj_ids: List of Ids of NeighborV6's. """ ids = list() for obj_id in obj_ids: try: obj = get_neighbor_v6_by_id(obj_id).id ids.append(obj) except exceptions.NeighborV6DoesNotExistException as e: raise api_rest_exceptions.ObjectDoesNotExistException(str(e)) except Exception as e: raise api_rest_exceptions.NetworkAPIException(str(e)) return NeighborV6.objects.filter(id__in=ids)
def list_environment_by_environment_vip(request, environment_vip_id): try: env_vip = EnvironmentVip.objects.get(id=environment_vip_id) environment_query = Ambiente.objects.filter( Q(vlan__networkipv4__ambient_vip=env_vip) | Q(vlan__networkipv6__ambient_vip=env_vip)).distinct() serializer_environment = EnvironmentOptionsSerializer( environment_query, many=True) return Response(serializer_environment.data) except EnvironmentVip.DoesNotExist, exception: log.error(exception) raise api_exceptions.ObjectDoesNotExistException( 'Environment Vip Does Not Exist')
def post(self, request, *args, **kwargs): """ Http handler to route v3/channel for POST method """ log.info("POST - api_channel") channels = request.DATA # json_validate(SPECS.get('channel_post_v3')).validate(channels) response = [] try: for channel_data in channels.get('channels'): channel = ChannelV3() data = channel.create(channel_data) response.append({'id': data.get('channels')}) except api_exceptions.ObjectDoesNotExistException, e: raise api_exceptions.ObjectDoesNotExistException(e.detail)