use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.
the class BBInputSetup method populateVfModule.
protected void populateVfModule(BBInputSetupParameter parameter) throws Exception {
String vnfModelCustomizationUUID = null;
String replaceVnfModelCustomizationUUID = null;
if (parameter.getRelatedInstanceList() != null) {
for (RelatedInstanceList relatedInstList : parameter.getRelatedInstanceList()) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
if (parameter.getIsReplace()) {
replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
} else {
vnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId();
}
}
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) {
parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, relatedInstance.getInstanceId());
}
}
}
GenericVnf vnf = null;
for (GenericVnf tempVnf : parameter.getServiceInstance().getVnfs()) {
if (tempVnf.getVnfId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID))) {
vnf = tempVnf;
vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
ModelInfo vnfModelInfo = new ModelInfo();
if (parameter.getIsReplace()) {
vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID);
this.mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getNewService());
} else {
vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
this.mapCatalogVnf(tempVnf, vnfModelInfo, parameter.getServiceModel().getCurrentService());
}
Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, parameter.getModelInfo(), parameter.getCloudConfiguration().getCloudOwner(), parameter.getCloudConfiguration().getLcpCloudRegionId(), parameter.getLookupKeyMap());
if (volumeGroupIdOp.isPresent()) {
parameter.getLookupKeyMap().put(ResourceKey.VOLUME_GROUP_ID, volumeGroupIdOp.get());
}
break;
}
}
if (vnf != null) {
VfModule vfModule = null;
for (VfModule vfModuleTemp : vnf.getVfModules()) {
if (parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID))) {
vfModule = vfModuleTemp;
}
String vfModuleCustId = bbInputSetupUtils.getAAIVfModule(vnf.getVnfId(), vfModuleTemp.getVfModuleId()).getModelCustomizationId();
ModelInfo modelInfoVfModule = new ModelInfo();
modelInfoVfModule.setModelCustomizationId(vfModuleCustId);
if (parameter.getIsReplace() && parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID) != null && vfModuleTemp.getVfModuleId().equalsIgnoreCase(parameter.getLookupKeyMap().get(ResourceKey.VF_MODULE_ID))) {
mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID);
} else {
mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID);
}
}
if (vfModule == null && parameter.getBbName().equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) {
vfModule = createVfModule(parameter.getLookupKeyMap(), parameter.getResourceId(), parameter.getInstanceName(), parameter.getInstanceParams());
vnf.getVfModules().add(vfModule);
if (parameter.getIsReplace()) {
mapCatalogVfModule(vfModule, parameter.getModelInfo(), parameter.getServiceModel().getNewService(), replaceVnfModelCustomizationUUID);
} else {
mapCatalogVfModule(vfModule, parameter.getModelInfo(), parameter.getServiceModel().getCurrentService(), vnfModelCustomizationUUID);
}
}
if (vfModule != null && vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null && vfModule.getModelInfoVfModule().getModelName().contains("helm")) {
parameter.setIsHelm(true);
}
} else {
logger.debug("Related VNF instance Id not found: {}", parameter.getLookupKeyMap().get(ResourceKey.GENERIC_VNF_ID));
throw new Exception("Could not find relevant information for related VNF");
}
}
use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.
the class BBInputSetup method getGBBCM.
protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, String resourceId) throws Exception {
ServiceInstance serviceInstance = new ServiceInstance();
String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
serviceInstance.setServiceInstanceId(serviceInstanceId);
Customer customer = new Customer();
List<GenericVnf> genericVnfs = serviceInstance.getVnfs();
String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
if (vnfId != null) {
org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
genericVnfs.add(genericVnf);
}
String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID);
if (instanceGroupId != null && !instanceGroupId.isEmpty()) {
org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup);
instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
if (serviceInstanceId == null) {
Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
if (aaiServiceInstanceOpt.isPresent()) {
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get();
serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance);
WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId());
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId());
} else {
throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI.");
}
}
RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
if (relatedInstanceList != null) {
for (RelatedInstanceList relatedInstList : relatedInstanceList) {
RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId());
GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf);
instanceGroup.getVnfs().add(vnf);
}
}
}
serviceInstance.getInstanceGroups().add(instanceGroup);
customer.setServiceSubscription(new ServiceSubscription());
}
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestDetails(requestDetails).setServiceInstance(serviceInstance).setExecuteBB(executeBB).setRequestAction(requestAction).setCustomer(customer).build();
return this.populateGBBWithSIAndAdditionalInfo(parameter);
}
use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.
the class MsoRequest method getVnfType.
public String getVnfType(ServiceInstancesRequest sir, String requestScope) {
String vnfType = null;
RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList();
String serviceModelName = null;
String vnfModelName = null;
String volumeGroupId = null;
if (instanceList == null) {
return null;
}
for (RelatedInstanceList relatedInstanceList : instanceList) {
RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo();
if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
serviceModelName = relatedInstanceModelInfo.getModelName();
} else if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) {
vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
} else if (relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
volumeGroupId = relatedInstance.getInstanceId();
}
}
if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) {
vnfType = serviceModelName + "/" + vnfModelName;
} else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) {
vnfType = serviceModelName + "/" + vnfModelName;
sir.setVolumeGroupInstanceId(volumeGroupId);
} else if (requestScope.equalsIgnoreCase(ModelType.vnf.name()))
vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName();
return vnfType;
}
use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.
the class BBInputSetupTest method testGBBMacroNoUserParamsVrfConfiguration.
@Test
public void testGBBMacroNoUserParamsVrfConfiguration() throws Exception {
String resourceId = "123";
String vnfType = "vnfType";
String requestAction = "createInstance";
Service service = Mockito.mock(Service.class);
GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), GeneralBuildingBlock.class);
ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class);
RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacroVrf.json"), RequestDetails.class);
Map<ResourceKey, String> lookupKeyMap = prepareLookupKeyMap();
ConfigurationResourceKeys configResourceKeys = prepareConfigurationResourceKeys();
executeBB.setConfigurationResourceKeys(configResourceKeys).setRequestDetails(requestDetails);
BuildingBlock buildingBlock = executeBB.getBuildingBlock();
buildingBlock.setBpmnFlowName("AssignVrfConfigurationBB");
buildingBlock.setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap, requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
RelatedInstance relatedVpnBinding = new RelatedInstance();
relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
RelatedInstance relatedLocalNetwork = new RelatedInstance();
relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
aaiVpnBinding.setVpnId("vpnBindingId");
org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
aaiLocalNetwork.setNetworkId("localNetworkId");
Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = Optional.of(new org.onap.aai.domain.yang.VpnBinding());
aaiAICVpnBindingOp.get().setVpnId("AICVpnBindingId");
ServiceProxy proxy = new ServiceProxy();
proxy.setType("transport");
proxy.setServiceInstance(new ServiceInstance());
proxy.getServiceInstance().setModelInfoServiceInstance(new ModelInfoServiceInstance());
proxy.getServiceInstance().getModelInfoServiceInstance().setModelUuid("sourceServiceModelUUID");
doReturn(relatedVpnBinding).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, ModelType.vpnBinding);
doReturn(relatedLocalNetwork).when(SPY_bbInputSetupUtils).getRelatedInstanceByType(requestDetails, ModelType.network);
doReturn(aaiVpnBinding).when(SPY_bbInputSetupUtils).getAAIVpnBinding(relatedVpnBinding.getInstanceId());
doReturn(aaiLocalNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(relatedLocalNetwork.getInstanceId());
doReturn(aaiAICVpnBindingOp).when(SPY_bbInputSetupUtils).getAICVpnBindingFromNetwork(aaiLocalNetwork);
doReturn(proxy).when(SPY_bbInputSetup).getServiceProxy(service);
Configuration configuration = new Configuration();
configuration.setConfigurationId("configurationId");
gBB.getServiceInstance().getConfigurations().add(configuration);
List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
configurationCustList.add(configurationCust);
doNothing().when(SPY_bbInputSetup).populateConfiguration(any(BBInputSetupParameter.class));
gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(BBInputSetupParameter.class));
assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId");
assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId");
assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), "AICVpnBindingId");
assertEquals(gBB.getServiceInstance().getServiceProxies().get(0).getType(), "transport");
}
use of org.onap.so.serviceinstancebeans.RelatedInstance in project so by onap.
the class MembersValidation method validate.
@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo();
RelatedInstanceList[] relatedInstanceList = info.getSir().getRequestDetails().getRelatedInstanceList();
boolean vnfRelatedInstance = false;
if (requestInfo == null) {
throw new ValidationException("requestInfo", true);
} else if (empty(requestInfo.getRequestorId())) {
throw new ValidationException("requestorId", true);
} else if (empty(requestInfo.getSource())) {
throw new ValidationException("source", true);
}
if (relatedInstanceList == null) {
throw new ValidationException("related instances", true);
} else {
for (RelatedInstanceList instanceList : relatedInstanceList) {
RelatedInstance relatedInstance = instanceList.getRelatedInstance();
ModelType modelType = relatedInstance.getModelInfo().getModelType();
if (empty(relatedInstance.getInstanceId())) {
throw new ValidationException("instanceId in relatedInstances", true);
}
if (modelType == null) {
throw new ValidationException("modelType in relatedInstance", true);
}
if (modelType == ModelType.vnf) {
vnfRelatedInstance = true;
}
}
if (!vnfRelatedInstance) {
throw new ValidationException("vnf relatedInstance", true);
}
}
return info;
}
Aggregations