Example #1
0
def get_vnf(request, *args, **kwargs):
    vnf_inst_id = ignore_case_get(kwargs, "vnfInstanceId")
    logger.debug("[%s]vnf_inst_id=%s", fun_name(), vnf_inst_id)
    try:
        vnf_inst = NfInstModel.objects.filter(nfinstid=vnf_inst_id)
        if not vnf_inst:
            return Response(
                data={'error': 'Vnf(%s) does not exist' % vnf_inst_id},
                status=status.HTTP_404_NOT_FOUND)
        resp_data = fill_resp_data(vnf_inst[0])
        return Response(data=resp_data, status=status.HTTP_200_OK)
    except:
        logger.error(traceback.format_exc())
        return Response(data={'error': 'Failed to get Vnf(%s)' % vnf_inst_id},
                        status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #2
0
def get_vnfs(request):
    logger.debug("Query all the vnfs[%s]", fun_name())
    try:
        vnf_insts = NfInstModel.objects.all()
        if not vnf_insts:
            return Response(data={'error': 'Vnfs does not exist'},
                            status=status.HTTP_404_NOT_FOUND)
        arr = []
        for vnf_inst in vnf_insts:
            arr.append(fill_resp_data(vnf_inst))
        return Response(data={'resp_data': arr}, status=status.HTTP_200_OK)
    except:
        logger.error(traceback.format_exc())
        return Response(data={'error': 'Failed to get Vnfs'},
                        status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #3
0
def get_volumes(request, *args, **kwargs):
    logger.debug("Query all the volumes by vnfInstanceId[%s]", fun_name())
    try:
        vnf_inst_id = ignore_case_get(kwargs, "vnfInstanceId")
        volumes = StorageInstModel.objects.filter(instid=vnf_inst_id)
        if not volumes:
            return Response(data={'error': 'Volumes does not exist'},
                            status=status.HTTP_404_NOT_FOUND)
        arr = []
        for v in volumes:
            arr.append(fill_volumes_data(v))
        return Response(data={'resp_data': arr}, status=status.HTTP_200_OK)
    except:
        logger.error(traceback.format_exc())
        return Response(data={'error': 'Failed to get volumes'},
                        status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Example #4
0
def get_cps(request, *args, **kwargs):
    logger.debug("Query all the cps by vnfInstanceId[%s]", fun_name())
    try:
        vnf_inst_id = ignore_case_get(kwargs, "vnfInstanceId")
        cps = CPInstModel.objects.filter(ownerid=vnf_inst_id)
        if not cps:
            return Response(data={'error': 'Cps does not exist'},
                            status=status.HTTP_404_NOT_FOUND)
        arr = []
        for cp in cps:
            arr.append(fill_cps_data(cp))
        return Response(data={'resp_data': arr}, status=status.HTTP_200_OK)
    except:
        logger.error(traceback.format_exc())
        return Response(data={'error': 'Failed to get cps'},
                        status=status.HTTP_500_INTERNAL_SERVER_ERROR)