Search in sources :

Example 1 with InstanceGroup

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

the class UnassignVnf method deleteInstanceGroups.

/**
 * BPMN access method to deleting instanceGroup in AAI.
 *
 * It will extract the vnf from BBobject ,It will get the instance group from the vnf and add it into a list.
 *
 * Then iterate that list and check the ModelInfoInstanceGroup type.
 *
 * Then it will delete that.
 *
 * @param execution
 */
public void deleteInstanceGroups(BuildingBlockExecution execution) {
    try {
        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        List<InstanceGroup> instanceGroups = vnf.getInstanceGroups();
        for (InstanceGroup instanceGroup : instanceGroups) {
            if (ModelInfoInstanceGroup.TYPE_VNFC.equalsIgnoreCase(instanceGroup.getModelInfoInstanceGroup().getType())) {
                aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
            }
        }
    } catch (Exception ex) {
        logger.error("Exception occurred in UnassignVnf deleteInstanceGroups", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup) ModelInfoInstanceGroup(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)

Example 2 with InstanceGroup

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

the class NamingServiceCreateTasks method createInstanceGroupName.

public void createInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
    InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
    String policyInstanceName = execution.getVariable("policyInstanceName");
    String nfNamingCode = execution.getVariable("nfNamingCode");
    String generatedInstanceGroupName = "";
    try {
        generatedInstanceGroupName = namingServiceResources.generateInstanceGroupName(instanceGroup, policyInstanceName, nfNamingCode);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
    instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 3 with InstanceGroup

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

the class CreateNetworkCollection method buildNetworkCollectionName.

/**
 * BPMN access method to build Network Collection Name
 *
 * @param execution
 * @throws Exception
 */
public void buildNetworkCollectionName(BuildingBlockExecution execution) throws Exception {
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        InstanceGroup instanceGroup = serviceInstance.getCollection().getInstanceGroup();
        if (instanceGroup.getModelInfoInstanceGroup() != null) {
            // Build collection name assembling SI name and IG function
            if (serviceInstance.getServiceInstanceName() != null && instanceGroup.getModelInfoInstanceGroup().getFunction() != null) {
                String networkCollectionName = serviceInstance.getServiceInstanceName().concat(UNDERSCORE).concat(instanceGroup.getModelInfoInstanceGroup().getFunction());
                // set networkCollectionName object on execution to be re-used within current BB
                execution.setVariable(NETWORK_COLLECTION_NAME, networkCollectionName);
            } else {
                throw new IllegalArgumentException("Cannot generate collection name because either one or both fields are null: " + " Service Instance Name: " + serviceInstance.getServiceInstanceName() + ", Instance Group Function: " + instanceGroup.getModelInfoInstanceGroup().getFunction());
            }
        } else {
            throw new IllegalArgumentException("Instance group model info is null");
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 4 with InstanceGroup

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

the class AAICreateTasks method createInstanceGroupVnf.

/**
 * This method is used for creating vnf instance group in A&AI.
 *
 * @param execution @throws
 */
public void createInstanceGroupVnf(BuildingBlockExecution execution) {
    try {
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
        aaiInstanceGroupResources.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Example 5 with InstanceGroup

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

the class AAIDeleteTasks method deleteInstanceGroupVnf.

/**
 * BPMN access method to delete the InstanceGroupVnf from A&AI.
 *
 * It will extract the instanceGroup from the BBObject.
 *
 * Then it will delete from A&AI.
 *
 * @param execution
 */
public void deleteInstanceGroupVnf(BuildingBlockExecution execution) {
    try {
        InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
        aaiInstanceGroupResources.deleteInstanceGroup(instanceGroup);
    } catch (Exception ex) {
        logger.error("Exception occurred in AAIDeleteTasks deleteInstanceGroupVnf process", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : InstanceGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)

Aggregations

InstanceGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup)32 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)14 ModelInfoInstanceGroup (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup)13 Test (org.junit.Test)9 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)9 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)9 Collection (org.onap.so.bpmn.servicedecomposition.bbobjects.Collection)8 BBObjectNotFoundException (org.onap.so.client.exception.BBObjectNotFoundException)7 ArrayList (java.util.ArrayList)6 Service (org.onap.so.db.catalog.beans.Service)4 AAIFluentTypeBuilder (org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder)3 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)3 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)3 ModelInfoCollection (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoCollection)3 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)3 NetworkCollectionResourceCustomization (org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 GenericResourceApiVnfOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation)2 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)2