use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.
the class NetworkAdapterCreateTasks method processResponseFromOpenstack.
public void processResponseFromOpenstack(BuildingBlockExecution execution) {
try {
L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
if (createNetworkResponse != null) {
l3Network.setHeatStackId(createNetworkResponse.getNetworkStackId());
if (createNetworkResponse.getNetworkCreated()) {
// setting rollback TRUE only if network was actually created (not a silent success OP)
execution.setVariable("networkAdapterCreateRollback", true);
}
} else {
throw new Exception("No response was sent back from NetworkAdapter subflow.");
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.
the class NetworkAdapterCreateTasks method rollbackCreateNetwork.
// TODO is this even used anywhere?
public void rollbackCreateNetwork(BuildingBlockExecution execution) {
try {
GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse");
Map<String, String> userInput = gBBInput.getUserInput();
String cloudRegionPo = execution.getVariable("cloudRegionPo");
networkAdapterResources.rollbackCreateNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.
the class NetworkAdapterImpl method postProcessNetworkAdapter.
public void postProcessNetworkAdapter(BuildingBlockExecution execution) {
try {
String workflowResponse = (String) execution.getVariable("WorkflowResponse");
if (workflowResponse != null) {
Optional<String> responseType = findResponseType(workflowResponse);
if ("createNetworkResponse".equals(responseType.get())) {
CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) unmarshalXml(workflowResponse, CreateNetworkResponse.class);
execution.setVariable("createNetworkResponse", createNetworkResponse);
} else if ("deleteNetworkResponse".equals(responseType.get())) {
DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(workflowResponse, DeleteNetworkResponse.class);
execution.setVariable("deleteNetworkResponse", deleteNetworkResponse);
} else if ("updateNetworkResponse".equals(responseType.get())) {
UpdateNetworkResponse updateNetworkResponse = (UpdateNetworkResponse) unmarshalXml(workflowResponse, UpdateNetworkResponse.class);
execution.setVariable("updateNetworkResponse", updateNetworkResponse);
} else {
logger.warn("Unable to determine network response type");
}
}
} catch (Exception e) {
logger.error("Error Network Adapter post process", e);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), Components.OPENSTACK);
}
}
use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.
the class AAIUpdateTasksTest method updateNetworkCreatedTest.
@Test
public void updateNetworkCreatedTest() throws Exception {
CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
createNetworkResponse.setNetworkFqdn("testNetworkFqdn");
createNetworkResponse.setNetworkStackId("testNetworkStackId");
HashMap<String, String> subnetMap = new HashMap<>();
subnetMap.put("testSubnetId", "testNeutronSubnetId");
createNetworkResponse.setSubnetMap(subnetMap);
network.getSubnets().add(subnet);
execution.setVariable("createNetworkResponse", createNetworkResponse);
doNothing().when(aaiNetworkResources).updateNetwork(network);
doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
aaiUpdateTasks.updateNetworkCreated(execution);
verify(aaiNetworkResources, times(1)).updateNetwork(network);
verify(aaiNetworkResources, times(1)).updateSubnet(network, subnet);
assertEquals(createNetworkResponse.getNetworkFqdn(), network.getContrailNetworkFqdn());
assertEquals(OrchestrationStatus.CREATED, network.getOrchestrationStatus());
assertEquals(createNetworkResponse.getNetworkStackId(), network.getHeatStackId());
assertEquals(createNetworkResponse.getNeutronNetworkId(), network.getNeutronNetworkId());
String neutronSubnetId = createNetworkResponse.getSubnetMap().entrySet().iterator().next().getValue();
assertEquals(neutronSubnetId, network.getSubnets().get(0).getNeutronSubnetId());
}
use of org.onap.so.adapters.nwrest.CreateNetworkResponse in project so by onap.
the class NetworkAdapterObjectMapperTest method createNetworkRollbackRequestMapperTest.
@Test
public void createNetworkRollbackRequestMapperTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
RollbackNetworkRequest expectedRollbackNetworkRequest = new RollbackNetworkRequest();
expectedRollbackNetworkRequest.setMessageId(requestContext.getMsoRequestId());
NetworkRollback networkRollback = new NetworkRollback();
networkRollback.setCloudId(cloudRegionPo);
networkRollback.setNetworkCreated(true);
networkRollback.setNetworkId(l3Network.getNetworkId());
networkRollback.setNetworkType(l3Network.getNetworkType());
networkRollback.setTenantId(cloudRegion.getTenantId());
expectedRollbackNetworkRequest.setNetworkRollback(networkRollback);
expectedRollbackNetworkRequest.setSkipAAI(true);
CreateNetworkResponse createNetworkResponse = new CreateNetworkResponse();
createNetworkResponse.setNetworkCreated(true);
RollbackNetworkRequest rollbackNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRollbackRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, createNetworkResponse);
assertThat(rollbackNetworkRequest, sameBeanAs(expectedRollbackNetworkRequest).ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("networkParams").ignoring("messageId"));
}
Aggregations