use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class CloudInfoFromAAI method getCloudInfoFromAAI.
protected Optional<CloudRegion> getCloudInfoFromAAI(ServiceInstance serviceInstance) throws JsonProcessingException {
Optional<Relationships> relationshipsOp = Optional.empty();
if (!serviceInstance.getVnfs().isEmpty()) {
GenericVnf vnf = serviceInstance.getVnfs().get(0);
org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
AAIResultWrapper vnfWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVnf));
relationshipsOp = getRelationshipsFromWrapper(vnfWrapper);
} else if (!serviceInstance.getNetworks().isEmpty()) {
L3Network network = serviceInstance.getNetworks().get(0);
org.onap.aai.domain.yang.L3Network aaiL3Network = bbInputSetupUtils.getAAIL3Network(network.getNetworkId());
AAIResultWrapper networkWrapper = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiL3Network));
relationshipsOp = getRelationshipsFromWrapper(networkWrapper);
} else {
logger.debug("BBInputSetup could not find a cloud region or tenant, since there are no resources under the SI.");
return Optional.empty();
}
if (relationshipsOp.isPresent()) {
return getRelatedCloudRegionAndTenant(relationshipsOp.get());
} else {
logger.debug("BBInputSetup could not find a cloud region or tenant");
return Optional.empty();
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class GeneralTopologyObjectMapperTest method buildNetworkInformationNoModelTest.
@Test
public void buildNetworkInformationNoModelTest() {
L3Network network = new L3Network();
network.setNetworkId("my-network-id");
network.setNetworkType("my-network-type");
network.setNetworkTechnology("my-network-technology");
GenericResourceApiNetworkinformationNetworkInformation networkInformation = new GenericResourceApiNetworkinformationNetworkInformation();
networkInformation.setNetworkId("my-network-id");
networkInformation.setNetworkType("my-network-type");
networkInformation.networkTechnology("my-network-technology");
networkInformation.setFromPreload(null);
assertThat(networkInformation, sameBeanAs(genObjMapper.buildNetworkInformation(network)));
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class UnassignNetworkBBTest method checkRelationshipRelatedToTrueTest.
@Test
public void checkRelationshipRelatedToTrueTest() throws Exception {
expectedException.expect(BpmnError.class);
network = setL3Network();
network.setNetworkId("testNetworkId1");
final String aaiResponse = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "unassignNetworkBB_queryAAIResponse_.json")));
AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiResponse);
Optional<org.onap.aai.domain.yang.L3Network> l3network = aaiResultWrapper.asBean(org.onap.aai.domain.yang.L3Network.class);
doReturn(network).when(extractPojosForBB).extractByKey(execution, ResourceKey.NETWORK_ID);
doReturn(aaiResultWrapper).when(aaiNetworkResources).queryNetworkWrapperById(network);
doReturn(true).when(networkBBUtils).isRelationshipRelatedToExists(any(Optional.class), eq("vf-module"));
unassignNetworkBB.checkRelationshipRelatedTo(execution, "vf-module");
assertThat(execution.getVariable("ErrorUnassignNetworkBB"), notNullValue());
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class AAIQueryTasks method querySubnet.
public void querySubnet(BuildingBlockExecution execution) {
try {
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
if (!networkRelationships.isPresent()) {
throw (new Exception(ERROR_MSG));
}
List<AAIResourceUri> subnetsUriList = networkRelationships.get().getRelatedUris(Types.SUBNET);
if (!subnetsUriList.isEmpty()) {
for (AAIResourceUri subnetUri : subnetsUriList) {
Optional<Subnet> oSubnet = aaiNetworkResources.getSubnet(subnetUri);
if (oSubnet.isPresent()) {
l3network.getSubnets().add(modelMapper.map(oSubnet.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet.class));
}
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network in project so by onap.
the class AAIQueryTasks method queryNetworkTableRef.
/**
* BPMN access method to query data for network table ref from the AAI result wrapper The resulting route table
* reference is mapped to the corresponding bbobject and added to the network bbobject contrail network route table
* references list
*
* @param execution
*/
public void queryNetworkTableRef(BuildingBlockExecution execution) {
try {
L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
if (!networkRelationships.isPresent()) {
throw (new Exception(ERROR_MSG));
}
List<AAIResourceUri> routeTableUriList = networkRelationships.get().getRelatedUris(Types.ROUTE_TABLE_REFERENCE);
if (!routeTableUriList.isEmpty()) {
for (AAIResourceUri routeTableUri : routeTableUriList) {
Optional<RouteTableReference> oRouteTableReference = aaiNetworkResources.getRouteTable(routeTableUri);
if (oRouteTableReference.isPresent()) {
org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference = modelMapper.map(oRouteTableReference.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class);
l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference);
}
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
Aggregations