Search in sources :

Example 21 with ServiceInstance

use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.

the class AAICreateTasks method createOwningEntity.

/**
 * This method is used for creating OwningEntity A&AI.
 *
 * @param execution
 * @throws @return
 */
public void createOwningEntity(BuildingBlockExecution execution) {
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        OwningEntity owningEntity = serviceInstance.getOwningEntity();
        if (Strings.isNullOrEmpty(owningEntity.getOwningEntityId()) && Strings.isNullOrEmpty(owningEntity.getOwningEntityName())) {
            execution.setVariable("ErrorCreateOEAAI", EXCEPTION_NAME_AND_ID_ARE_NULL);
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "EXCEPTION_NAME_AND_ID_ARE_NULL");
        } else if (Strings.isNullOrEmpty(owningEntity.getOwningEntityId()) && !Strings.isNullOrEmpty(owningEntity.getOwningEntityName())) {
            if (aaiSIResources.existsOwningEntityName(owningEntity.getOwningEntityName())) {
                org.onap.aai.domain.yang.OwningEntity aaiEntity = aaiSIResources.getOwningEntityByName(owningEntity.getOwningEntityName());
                owningEntity.setOwningEntityId(aaiEntity.getOwningEntityId());
                owningEntity.setOwningEntityName(owningEntity.getOwningEntityName());
                aaiSIResources.connectOwningEntityandServiceInstance(owningEntity, serviceInstance);
            } else {
                owningEntity.setOwningEntityId(UUID.randomUUID().toString());
                aaiSIResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance);
            }
        } else {
            if (aaiSIResources.existsOwningEntity(owningEntity)) {
                aaiSIResources.connectOwningEntityandServiceInstance(owningEntity, serviceInstance);
            } else {
                if (Strings.isNullOrEmpty(owningEntity.getOwningEntityName())) {
                    String msg = "Exception in AAICreateOwningEntity. Can't create an owningEntity with no owningEntityName.";
                    logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue(), msg);
                    exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
                } else {
                    if (aaiSIResources.existsOwningEntityName(owningEntity.getOwningEntityName())) {
                        logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), EXCEPTION_NAME_EXISTS_WITH_DIFFERENT_ID, "BPMN", ErrorCode.UnknownError.getValue(), EXCEPTION_NAME_EXISTS_WITH_DIFFERENT_ID);
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, EXCEPTION_NAME_EXISTS_WITH_DIFFERENT_ID);
                    } else {
                        aaiSIResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance);
                    }
                }
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : OwningEntity(org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 22 with ServiceInstance

use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.

the class AAICreateTasks method createServiceSubscription.

/**
 * This method is used for creating and subscribing the service in A&AI.
 *
 * @param execution
 * @throws @return
 */
public void createServiceSubscription(BuildingBlockExecution execution) {
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        Customer customer = execution.getGeneralBuildingBlock().getCustomer();
        if (null == customer) {
            String errorMessage = "Exception in creating ServiceSubscription. Customer not present for ServiceInstanceID: " + serviceInstance.getServiceInstanceId();
            logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorMessage, "BPMN", ErrorCode.UnknownError.getValue(), errorMessage);
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errorMessage);
        }
        aaiSIResources.createServiceSubscription(customer);
    } catch (BpmnError ex) {
        throw ex;
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) BpmnError(org.camunda.bpm.engine.delegate.BpmnError)

Example 23 with ServiceInstance

use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.

the class CnfAdapterUpgradeTasks method upgradeInstance.

/**
 * This method is used for updating the request for an Instance in Multicloud K8s Plugin.
 *
 * @param execution
 * @return
 */
public void upgradeInstance(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        RequestContext requestContext = gBBInput.getRequestContext();
        CloudRegion cloudRegion = gBBInput.getCloudRegion();
        String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
        String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
        Map<String, Object> paramsMap = vfModuleMapper.buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf, vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
        Map<String, String> sdncDirectives = getSdncDirectives(paramsMap);
        UpgradeInstanceRequest upgradeInstanceRequest = upgradeInstanceRequest(vfModule, cloudRegion, sdncDirectives);
        UpgradeInstanceResponse response = cnfAdapterClient.upgradeVfModule(upgradeInstanceRequest);
        execution.setVariable("heatStackId", response.getId());
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : UpgradeInstanceResponse(org.onap.so.client.adapter.cnf.entities.UpgradeInstanceResponse) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) JsonParseException(com.fasterxml.jackson.core.JsonParseException) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) UpgradeInstanceRequest(org.onap.so.client.adapter.cnf.entities.UpgradeInstanceRequest)

Example 24 with ServiceInstance

use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.

the class NetworkAdapterCreateTasks method rollbackCreateNetwork.

// TODO is this even used anywhere?
public void rollbackCreateNetwork(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
        Map<String, String> userInput = gBBInput.getUserInput();
        String cloudRegionPo = execution.getVariable("cloudRegionPo");
        networkAdapterResources.rollbackCreateNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) CreateNetworkResponse(org.onap.so.adapters.nwrest.CreateNetworkResponse) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 25 with ServiceInstance

use of org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance in project so by onap.

the class NetworkAdapterUpdateTasks method updateNetwork.

public void updateNetwork(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        UpdateNetworkRequest updateNetworkRequest = networkAdapterObjectMapper.createNetworkUpdateRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, gBBInput.getUserInput(), gBBInput.getCustomer());
        execution.setVariable("networkAdapterRequest", updateNetworkRequest.toXmlString());
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) UpdateNetworkRequest(org.onap.so.adapters.nwrest.UpdateNetworkRequest)

Aggregations

ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)228 Test (org.junit.Test)118 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)110 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)84 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)70 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)61 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)54 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)53 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)51 HashMap (java.util.HashMap)50 Service (org.onap.so.db.catalog.beans.Service)46 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)40 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)38 ResourceKey (org.onap.so.bpmn.servicedecomposition.entities.ResourceKey)37 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)35 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)33 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)33 File (java.io.File)31 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)25 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)24