Beispiel #1
0
def send_nf_scaling_request(vnfm_inst_id, vnf_inst_id, req_param):
    vnfm = get_vnfm_by_id(vnfm_inst_id)
    uri = '/openoapi/%s/v1/%s/vnfs/%s/scale' % (vnfm["type"], vnfm_inst_id, vnf_inst_id)
    ret = req_by_msb(uri, "POST", req_param)
    if ret[0] > 0:
        logger.error("Failed to send nf scale req:%s,%s", ret[2], ret[1])
        raise NSLCMException('Failed to send nf scale request to VNFM(%s)' % vnfm_inst_id)
    return json.JSONDecoder().decode(ret[1])
Beispiel #2
0
 def prepare_lccn_subscription_request_data(self):
     vnfm_info = get_vnfm_by_id(self.vnfm_id)
     call_back = "%s/api/gvnfmdriver/v1/vnfs/lifecyclechangesnotification" % pub_config.MSB_BASE_URL
     self.subscription_request_data = {
         "filter": {
             "notificationTypes": ["VnfLcmOperationOccurrenceNotification"],
             "operationTypes": [
                 "INSTANTIATE",
                 "SCALE",
                 "SCALE_TO_LEVEL",
                 "CHANGE_FLAVOUR",
                 "TERMINATE",
                 "HEAL",
                 "OPERATE",
                 "CHANGE_EXT_CONN",
                 "MODIFY_INFO"
             ],
             "operationStates": [
                 "STARTING",
                 "PROCESSING",
                 "COMPLETED",
                 "FAILED_TEMP",
                 "FAILED",
                 "ROLLING_BACK",
                 "ROLLED_BACK"
             ],
             "vnfInstanceSubscriptionFilter": {
                 # "vnfdIds": [],
                 "vnfInstanceIds": [self.vnf_instance_id],
                 # "vnfInstanceNames": [],
                 # "vnfProductsFromProviders": {}
             }
         },
         "callbackUri": call_back,  # TODO: need reconfirming
         "authentication": {
             "authType": ["BASIC"],
             "paramsBasic": {
                 # "userName": vnfm_info['userName'],
                 # "password": vnfm_info['password']
             }
         }
     }
     if vnfm_info['userName']:
         self.subscription_request_data["authentication"]["paramsBasic"]["userName"] = vnfm_info['userName']
     if vnfm_info['password']:
         self.subscription_request_data["authentication"]["paramsBasic"]["password"] = vnfm_info['password']
Beispiel #3
0
    def get(self, request, vnfmid):
        logger.debug("NfVnfmInfoView--get::> %s" % vnfmid)
        try:
            vnfm_info = get_vnfm_by_id(vnfmid)

            resp_serializer = VnfmInfoRespSerializer(data=vnfm_info)
            if not resp_serializer.is_valid():
                raise Exception(resp_serializer.errors)

        except NSLCMException as e:
            logger.error(e.args[0])
            return Response(data={'error': '%s' % e.args[0]}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
        except Exception as e:
            logger.error(e.args[0])
            logger.error(traceback.format_exc())
            return Response(data={'error': 'Failed to get vnfm info.'},
                            status=status.HTTP_500_INTERNAL_SERVER_ERROR)
        return Response(data=vnfm_info, status=status.HTTP_200_OK)
Beispiel #4
0
def query_vnfm_job(vnfm_inst_id, job_id, response_id=0):
    vnfm = get_vnfm_by_id(vnfm_inst_id)
    retry_time = 3
    uri = '/openoapi/%s/v1/%s/jobs/%s?responseId=%s' % (vnfm["type"], 
        vnfm_inst_id, job_id, response_id)
    while retry_time > 0:
        rsp = req_by_msb(uri, "GET")
        if str(rsp[2]) == '404':
            return False, ''
        if rsp[0] != 0:
            logger.warning('retry_time=%s, detail message:%s' % (retry_time, rsp[1]))
            retry_time -= 1
        else:
            break
    if retry_time <= 0:
        logger.error(rsp[1])
        raise NSLCMException('Failed to query job from VNFM!')
    return True, json.JSONDecoder().decode(rsp[1])
Beispiel #5
0
 def send_get_vnfm_request_to_extsys(self):
     resp_body = get_vnfm_by_id(self.vnfm_inst_id)
     self.vnfm_inst_name = ignore_case_get(resp_body, 'name')