import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
+import com.google.common.base.Strings;
@Component
public class AAICreateTasks {
private static final Logger logger = LoggerFactory.getLogger(AAICreateTasks.class);
private static final String networkTypeProvider = "PROVIDER";
- private static final String A_LA_CARTE = "aLaCarte";
private static String NETWORK_COLLECTION_NAME = "networkCollectionName";
private static String CONTRAIL_NETWORK_POLICY_FQDN_LIST = "contrailNetworkPolicyFqdnList";
private static String HEAT_STACK_ID = "heatStackId";
@Autowired
private Environment env;
+ /**
+ * This method is used for creating the service instance in A&AI.
+ *
+ * It will check the alaCarte and create the service instance in A&AI.
+ *
+ * @param execution
+ * @throws @return
+ */
public void createServiceInstance(BuildingBlockExecution execution) {
try {
ServiceInstance serviceInstance =
}
}
+ /**
+ * 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 =
}
}
+ /**
+ * This method is used for creation of the project A&AI.
+ *
+ * @param execution
+ * @throws @return
+ */
public void createProject(BuildingBlockExecution execution) {
try {
ServiceInstance serviceInstance =
}
}
+ /**
+ * 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();
- String owningEntityId = owningEntity.getOwningEntityId();
- String owningEntityName = owningEntity.getOwningEntityName();
- if (owningEntityId == null || "".equals(owningEntityId)) {
- String msg = "Exception in AAICreateOwningEntity. OwningEntityId is null.";
+ if (Strings.isNullOrEmpty(owningEntity.getOwningEntityId())
+ && Strings.isNullOrEmpty(owningEntity.getOwningEntityName())) {
+ String msg = "Exception in AAICreateOwningEntity. OwningEntityId and Name are null.";
execution.setVariable("ErrorCreateOEAAI", msg);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
+ } 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 (owningEntityName == null || "".equals(owningEntityName)) {
+ 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(owningEntityName)) {
+ if (aaiSIResources.existsOwningEntityName(owningEntity.getOwningEntityName())) {
String msg =
"Exception in AAICreateOwningEntity. Can't create OwningEntity as name already exists in AAI associated with a different owning-entity-id (name must be unique)";
logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg,
}
}
+ /**
+ * This method is used for creating Vnf in A&AI.
+ *
+ * It will check if the Vnf Name is exits in A&AI then it will throw the duplicate name exception.
+ *
+ * Otherwise it will create the vnf amd connect to the serviceinstance.
+ *
+ * @param execution
+ * @throws @return
+ */
public void createVnf(BuildingBlockExecution execution) {
try {
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- if (Boolean.TRUE.equals(alaCarte) && aaiVnfResources.checkNameInUse(vnf.getVnfName())) {
- throw new DuplicateNameException("generic-vnf", vnf.getVnfName());
- }
ServiceInstance serviceInstance =
extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
execution.setVariable("homing", Boolean.TRUE.equals(vnf.isCallHoming()));
}
}
+ /**
+ * This method is used for separating (,) from the string.
+ *
+ * @param str
+ * @throws @return
+ */
public void createPlatform(BuildingBlockExecution execution) {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
}
+ /**
+ * This method is used for separating (,) from the string.
+ *
+ * @param str
+ * @throws @return
+ */
public List<String> splitCDL(String str) {
return Stream.of(str.split(",")).map(String::trim).map(elem -> new String(elem)).collect(Collectors.toList());
}
+ /**
+ * This method is used for creating the type of business in A&AI.
+ *
+ * @param execution
+ * @throws @return
+ */
public void createLineOfBusiness(BuildingBlockExecution execution) {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
}
}
+ /**
+ * This method is used for creating the volume group in A&AI.
+ *
+ * @param execution
+ * @throws @return
+ */
public void createVolumeGroup(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
CloudRegion cloudRegion = gBBInput.getCloudRegion();
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
- if (Boolean.TRUE.equals(alaCarte) && aaiVolumeGroupResources.checkNameInUse(volumeGroup)) {
- throw new DuplicateNameException("volume-group", volumeGroup.getVolumeGroupName());
- }
aaiVolumeGroupResources.createVolumeGroup(volumeGroup, cloudRegion);
aaiVolumeGroupResources.connectVolumeGroupToVnf(genericVnf, volumeGroup, cloudRegion);
aaiVolumeGroupResources.connectVolumeGroupToTenant(volumeGroup, cloudRegion);
}
}
+ /**
+ * This method is used for creating the vfModule in A&AI.
+ *
+ * @param execution
+ * @throws @return
+ */
public void createVfModule(BuildingBlockExecution execution) {
try {
GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- Boolean alaCarte = execution.getVariable(A_LA_CARTE);
- if (Boolean.TRUE.equals(alaCarte) && aaiVfModuleResources.checkNameInUse(vfModule)) {
- throw new DuplicateNameException("vf-module", vfModule.getVfModuleName());
- }
int moduleIndex = 0;
if (vfModule.getModelInfoVfModule() != null
&& !Boolean.TRUE.equals(vfModule.getModelInfoVfModule().getIsBaseBoolean())) {
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
logger.info("VolumeGroup not found. Skipping Connect between VfModule and VolumeGroup");
}
if (volumeGroup != null) {
+ logger.debug("Connecting VfModule to VolumGroup");
aaiVfModuleResources.connectVfModuleToVolumeGroup(vnf, vfModule, volumeGroup,
execution.getGeneralBuildingBlock().getCloudRegion());
}
/**
* BPMN access method to execute Create L3Network operation (PUT )in AAI
- *
+ *
* @param execution
* @throws Exception
*/
}
}
+ /**
+ * This method is used for creating the customer in A&AI.
+ *
+ * @param execution
+ * @throws Exception
+ */
public void createCustomer(BuildingBlockExecution execution) throws Exception {
try {
Customer customer = execution.getGeneralBuildingBlock().getCustomer();
/**
* BPMN access method to execute NetworkCollection operation (PUT) in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to execute NetworkCollectionInstanceGroup operation (PUT) in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
/**
* BPMN access method to establish relationships in AAI
- *
+ *
* @param execution
* @throws Exception
*/
}
}
+ /**
+ * This method is used for configuring the service in A&AI.
+ *
+ * @param execution @throws
+ */
public void createConfiguration(BuildingBlockExecution execution) {
try {
Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
}
}
+ /**
+ * This method is used for creating vnf instance group in A&AI.
+ *
+ * @param execution @throws
+ */
public void createInstanceGroupVnf(BuildingBlockExecution execution) {
try {
ServiceInstance serviceInstance =
}
}
+ /**
+ * This method is used to put the network policy in A&AI.
+ *
+ * @param execution @throws
+ */
public void createNetworkPolicies(BuildingBlockExecution execution) {
try {
String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
/**
* Groups existing vf modules by the model uuid of our new vf module and returns the lowest unused index
- *
+ *
* if we have a module type A, and there are 3 instances of those, and then module type B has 2 instances, if we are
* adding a new module type A, the vf-module-index should be 3 assuming contiguous indices (not 5, or 2)
- *
+ *
*/
protected int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf, VfModule newVfModule) {