use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.
the class NamingServiceCreateTasks method createVpnBondingServiceName.
public void createVpnBondingServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
NamingRequestObject namingRequestObject = new NamingRequestObject();
namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
namingRequestObject.setPolicyInstanceNameValue(serviceInstance.getModelInfoServiceInstance().getNamingPolicy());
namingRequestObject.setNamingTypeValue(NamingServiceConstants.NAMING_TYPE_SERVICE);
namingRequestObject.setServiceModelNameValue(serviceInstance.getModelInfoServiceInstance().getModelName());
namingRequestObject.setModelVersionValue(serviceInstance.getModelInfoServiceInstance().getModelVersion());
namingRequestObject.setNetworkNameValue(network.getNetworkName());
namingRequestObject.setVpnNameValue(vpnBinding.getVpnName());
namingRequestObject.setResourceNameValue(NamingServiceConstants.RESOURCE_NAME_SERVICE_INSTANCE_NAME);
String generatedVpnBondingServiceName = "";
try {
generatedVpnBondingServiceName = namingServiceResources.generateServiceInstanceName(namingRequestObject);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
serviceInstance.setServiceInstanceName(generatedVpnBondingServiceName);
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.
the class NetworkAdapterObjectMapperTest method updateNetworkRequestMapperTest.
@Test
public void updateNetworkRequestMapperTest() throws UnsupportedEncodingException {
org.onap.so.openstack.beans.Subnet subnet = new org.onap.so.openstack.beans.Subnet();
subnet.setSubnetId("subnetId");
subnet.setGatewayIp("NULL");
subnet.setHostRoutes(new ArrayList<org.onap.so.openstack.beans.HostRoute>());
List<org.onap.so.openstack.beans.Subnet> subnets = new ArrayList<>();
subnets.add(subnet);
ProviderVlanNetwork providerVlanNetwork = new ProviderVlanNetwork("physicalNetworkName", new ArrayList<Integer>());
List<String> policyFqdns = Arrays.asList("networkPolicyFqdn");
org.onap.so.openstack.beans.RouteTarget expectedRouteTarget = new org.onap.so.openstack.beans.RouteTarget();
expectedRouteTarget.setRouteTarget("globalRouteTarget");
ContrailNetwork contrailNetwork = new ContrailNetwork();
contrailNetwork.setPolicyFqdns(policyFqdns);
contrailNetwork.setRouteTableFqdns(new ArrayList<String>());
contrailNetwork.setRouteTargets(new ArrayList<org.onap.so.openstack.beans.RouteTarget>());
contrailNetwork.getRouteTargets().add(expectedRouteTarget);
contrailNetwork.getRouteTableFqdns().add("routeTableReferenceFqdn");
MsoRequest msoRequest = new MsoRequest();
msoRequest.setServiceInstanceId("testServiceInstanceId1");
ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
modelInfoNetwork.setNetworkType("networkType");
modelInfoNetwork.setModelCustomizationUUID("modelCustomizationUuid");
modelInfoNetwork.setModelVersion("modelVersion");
Subnet actualSubnet = new Subnet();
actualSubnet.setSubnetId("subnetId");
actualSubnet.setDhcpEnabled(false);
actualSubnet.setIpVersion("4");
RouteTarget routeTarget = new RouteTarget();
routeTarget.setGlobalRouteTarget("globalRouteTarget");
VpnBinding vpnBinding = new VpnBinding();
vpnBinding.setVpnId("vpnId");
vpnBinding.getRouteTargets().add(routeTarget);
Customer customer = new Customer();
customer.getVpnBindings().add(vpnBinding);
ServiceSubscription serviceSubscription = new ServiceSubscription();
customer.setServiceSubscription(serviceSubscription);
// set Customer on service instance
customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
NetworkPolicy networkPolicy = new NetworkPolicy();
networkPolicy.setNetworkPolicyId("networkPolicyId");
networkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
RouteTableReference routeTableReference = new RouteTableReference();
routeTableReference.setRouteTableReferenceFqdn("routeTableReferenceFqdn");
l3Network.setModelInfoNetwork(modelInfoNetwork);
l3Network.setPhysicalNetworkName("physicalNetworkName");
l3Network.getSubnets().add(actualSubnet);
l3Network.getNetworkPolicies().add(networkPolicy);
l3Network.getContrailNetworkRouteTableReferences().add(routeTableReference);
l3Network.setIsSharedNetwork(false);
l3Network.setIsExternalNetwork(false);
HashMap<String, String> networkParams = new HashMap<String, String>();
networkParams.put("shared", "false");
networkParams.put("external", "false");
networkParams.put("testUserInputKey", "testUserInputValue");
UpdateNetworkRequest expectedUpdateNetworkRequest = new UpdateNetworkRequest();
expectedUpdateNetworkRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
expectedUpdateNetworkRequest.setTenantId(cloudRegion.getTenantId());
expectedUpdateNetworkRequest.setNetworkId(l3Network.getNetworkId());
expectedUpdateNetworkRequest.setNetworkStackId(l3Network.getHeatStackId());
expectedUpdateNetworkRequest.setNetworkName(l3Network.getNetworkName());
expectedUpdateNetworkRequest.setNetworkType(l3Network.getModelInfoNetwork().getNetworkType());
expectedUpdateNetworkRequest.setNetworkTypeVersion(l3Network.getModelInfoNetwork().getModelVersion());
expectedUpdateNetworkRequest.setModelCustomizationUuid(l3Network.getModelInfoNetwork().getModelCustomizationUUID());
expectedUpdateNetworkRequest.setSubnets(subnets);
expectedUpdateNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
expectedUpdateNetworkRequest.setContrailNetwork(contrailNetwork);
expectedUpdateNetworkRequest.setNetworkParams(networkParams);
expectedUpdateNetworkRequest.setMsoRequest(msoRequest);
expectedUpdateNetworkRequest.setSkipAAI(true);
expectedUpdateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
expectedUpdateNetworkRequest.setMessageId("messageId");
expectedUpdateNetworkRequest.setNotificationUrl("http://localhost:28080/mso/WorkflowMesssage/NetworkAResponse/messageId");
doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
doReturn("http://localhost:28080/mso/WorkflowMesssage").when(SPY_networkAdapterObjectMapper).getEndpoint();
UpdateNetworkRequest actualUpdateNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkUpdateRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, customer);
assertThat(actualUpdateNetworkRequest, sameBeanAs(expectedUpdateNetworkRequest).ignoring("msoRequest.requestId"));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.
the class AAIVpnBindingResourcesTest method createVpnBindingTest.
@Test
public void createVpnBindingTest() {
doNothing().when(MOCK_aaiResourcesClient).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
org.onap.aai.domain.yang.VpnBinding mappedVpnBinding = new org.onap.aai.domain.yang.VpnBinding();
mappedVpnBinding.setVpnName("test");
doReturn(mappedVpnBinding).when(MOCK_aaiObjectMapper).mapVpnBinding(isA(VpnBinding.class));
VpnBinding vpnBinding = buildVpnBinding();
aaiVpnBindingResources.createVpnBinding(vpnBinding);
verify(MOCK_aaiResourcesClient, times(1)).create(isA(AAIResourceUri.class), isA(org.onap.aai.domain.yang.VpnBinding.class));
verify(MOCK_aaiObjectMapper, times(1)).mapVpnBinding(isA(VpnBinding.class));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.
the class BBInputSetupMapperLayer method mapAAIVpnBinding.
public VpnBinding mapAAIVpnBinding(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) {
VpnBinding vpnBinding = modelMapper.map(aaiVpnBinding, VpnBinding.class);
mapAllRouteTargetsToAAIVpnBinding(aaiVpnBinding, vpnBinding);
return vpnBinding;
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding in project so by onap.
the class BBInputSetup method getGBBMacroNoUserParamsCreate.
protected GeneralBuildingBlock getGBBMacroNoUserParamsCreate(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap, String bbName, String key, GeneralBuildingBlock gBB, Service service) throws Exception {
ServiceInstance serviceInstance = gBB.getServiceInstance();
BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setExecuteBB(executeBB).setRequestId(executeBB.getRequestId()).setServiceInstance(serviceInstance).setService(service).setBbName(bbName).setLookupKeyMap(lookupKeyMap).setKey(key).build();
if (bbName.contains(NETWORK) && !bbName.contains(NETWORK_COLLECTION)) {
String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
parameter.setResourceId(networkId);
parameter.setModelInfo(new ModelInfo());
if ((!Boolean.TRUE.equals(executeBB.getBuildingBlock().isVirtualLink()))) {
NetworkResourceCustomization networkCust = getNetworkCustomizationByKey(key, service);
if (networkCust != null) {
parameter.getModelInfo().setModelCustomizationUuid(networkCust.getModelCustomizationUUID());
this.populateL3Network(parameter);
} else {
logger.debug("Could not find a network customization with key: {}", key);
}
} else {
logger.debug("Orchestrating on Collection Network Resource Customization");
CollectionNetworkResourceCustomization collectionNetworkResourceCust = bbInputSetupUtils.getCatalogCollectionNetworkResourceCustByID(key);
L3Network l3Network = getVirtualLinkL3Network(lookupKeyMap, bbName, key, networkId, collectionNetworkResourceCust, serviceInstance);
NetworkResourceCustomization networkResourceCustomization = mapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
if (l3Network != null) {
l3Network.setModelInfoNetwork(mapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization));
}
}
} else if (bbName.contains("Configuration")) {
parameter.setResourceId(lookupKeyMap.get(ResourceKey.CONFIGURATION_ID));
parameter.setModelInfo(new ModelInfo());
parameter.getModelInfo().setModelCustomizationUuid(key);
parameter.setConfigurationResourceKeys(executeBB.getConfigurationResourceKeys());
parameter.setRequestDetails(executeBB.getRequestDetails());
this.populateConfiguration(parameter);
}
if (executeBB.getWorkflowResourceIds() != null) {
parameter.setResourceId(executeBB.getWorkflowResourceIds().getNetworkCollectionId());
this.populateNetworkCollectionAndInstanceGroupAssign(parameter);
}
RelatedInstance relatedVpnBinding = bbInputSetupUtils.getRelatedInstanceByType(executeBB.getRequestDetails(), ModelType.vpnBinding);
RelatedInstance relatedLocalNetwork = bbInputSetupUtils.getRelatedInstanceByType(executeBB.getRequestDetails(), ModelType.network);
if (relatedVpnBinding != null && relatedLocalNetwork != null) {
org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId());
org.onap.aai.domain.yang.L3Network aaiLocalNetwork = bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId());
VpnBinding vpnBinding = mapperLayer.mapAAIVpnBinding(aaiVpnBinding);
L3Network localNetwork = mapperLayer.mapAAIL3Network(aaiLocalNetwork);
Optional<org.onap.aai.domain.yang.VpnBinding> aaiAICVpnBindingOp = bbInputSetupUtils.getAICVpnBindingFromNetwork(aaiLocalNetwork);
if (aaiAICVpnBindingOp.isPresent()) {
localNetwork.getVpnBindings().add(mapperLayer.mapAAIVpnBinding(aaiAICVpnBindingOp.get()));
}
ServiceProxy serviceProxy = getServiceProxy(service);
gBB.getServiceInstance().getServiceProxies().add(serviceProxy);
gBB.getCustomer().getVpnBindings().add(vpnBinding);
lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
gBB.getServiceInstance().getNetworks().add(localNetwork);
lookupKeyMap.put(ResourceKey.NETWORK_ID, localNetwork.getNetworkId());
}
return gBB;
}
Aggregations