use of org.onap.so.adapters.nwrest.CreateNetworkRequest in project so by onap.
the class NetworkAdapterClientIT method createNetworkTest.
@Test
public void createNetworkTest() throws NetworkAdapterClientException, JsonProcessingException {
CreateNetworkRequest request = new CreateNetworkRequest();
request.setCloudSiteId(TESTING_ID);
CreateNetworkResponse mockResponse = new CreateNetworkResponse();
mockResponse.setNetworkCreated(true);
wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT)).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(200)));
CreateNetworkResponse response = client.createNetwork(request);
assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
}
use of org.onap.so.adapters.nwrest.CreateNetworkRequest in project so by onap.
the class NetworkAdapterResourcesTest method createNetworTest.
@Test
public void createNetworTest() throws Exception {
String cloudRegionPo = "cloudRegionPo";
CreateNetworkRequest expectedCreateNetworkRequest = new CreateNetworkRequest();
expectedCreateNetworkRequest.setCloudSiteId(cloudRegionPo);
expectedCreateNetworkRequest.setTenantId(cloudRegion.getTenantId());
expectedCreateNetworkRequest.setNetworkId(l3Network.getNetworkId());
expectedCreateNetworkRequest.setNetworkName(l3Network.getNetworkName());
expectedCreateNetworkRequest.setBackout(false);
expectedCreateNetworkRequest.setFailIfExists(true);
MsoRequest msoRequest = new MsoRequest();
msoRequest.setRequestId(requestContext.getMsoRequestId());
msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
expectedCreateNetworkRequest.setMsoRequest(msoRequest);
expectedCreateNetworkRequest.setSkipAAI(true);
Subnet openstackSubnet = new Subnet();
HostRoute hostRoute = new HostRoute();
hostRoute.setHostRouteId("hostRouteId");
hostRoute.setNextHop("nextHop");
hostRoute.setRoutePrefix("routePrefix");
openstackSubnet.getHostRoutes().add(hostRoute);
List<Subnet> subnetList = new ArrayList<Subnet>();
subnetList.add(openstackSubnet);
l3Network.getSubnets().add(openstackSubnet);
l3Network.setOrchestrationStatus(OrchestrationStatus.ASSIGNED);
CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
createNetworkRequest.setCloudSiteId("cloudSiteId");
CreateNetworkResponse expectedCreateNetworkResponse = new CreateNetworkResponse();
expectedCreateNetworkResponse.setNetworkStackId("networkStackId");
expectedCreateNetworkResponse.setNetworkCreated(true);
doReturn(expectedCreateNetworkResponse).when(MOCK_networkAdapterClient).createNetwork(isA(CreateNetworkRequest.class));
doReturn(createNetworkRequest).when(MOCK_networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
CreateNetworkResponse actualCreateNetwrokResponse = (networkAdapterResources.createNetwork(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer)).get();
verify(MOCK_networkAdapterClient, times(1)).createNetwork(createNetworkRequest);
verify(MOCK_networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
assertThat(expectedCreateNetworkResponse, Matchers.sameBeanAs(actualCreateNetwrokResponse));
}
use of org.onap.so.adapters.nwrest.CreateNetworkRequest in project so by onap.
the class NetworkAdapterCreateTasksTest method createNetworkTest.
@Test
public void createNetworkTest() {
String cloudRegionPo = "cloudRegionPo";
CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
execution.setVariable("cloudRegionPo", cloudRegionPo);
doReturn(createNetworkRequest).when(networkAdapterObjectMapper).createNetworkRequestMapper(isA(RequestContext.class), isA(CloudRegion.class), isA(OrchestrationContext.class), isA(ServiceInstance.class), isA(L3Network.class), isA(Map.class), isA(String.class), isA(Customer.class));
networkAdapterCreateTasks.createNetwork(execution);
verify(networkAdapterObjectMapper, times(1)).createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
assertEquals(createNetworkRequest.toXmlString(), execution.getVariable("networkAdapterRequest"));
}
use of org.onap.so.adapters.nwrest.CreateNetworkRequest in project so by onap.
the class NetworkAdapterObjectMapper method createNetworkRequestMapper.
public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, Customer customer) {
CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest();
// set cloudSiteId as determined for cloud region PO instead of cloudRegion.getLcpCloudRegionId()
createNetworkRequest.setCloudSiteId(cloudRegionPo);
createNetworkRequest.setTenantId(cloudRegion.getTenantId());
createNetworkRequest.setNetworkId(l3Network.getNetworkId());
createNetworkRequest.setNetworkName(l3Network.getNetworkName());
// TODO fields not available
createNetworkRequest.setNetworkType(l3Network.getNetworkType());
// createNetworkRequest.setNetworkTypeVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
ModelInfoNetwork modelInfoNetwork = l3Network.getModelInfoNetwork();
if (modelInfoNetwork != null) {
createNetworkRequest.setModelCustomizationUuid(modelInfoNetwork.getModelCustomizationUUID());
}
// build and set Subnet list
createNetworkRequest.setSubnets(buildOpenstackSubnetList(l3Network));
// build and set provider Vlan Network
ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network);
createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork);
String networkTechnology = l3Network.getModelInfoNetwork().getNetworkTechnology();
if (networkTechnology == null) {
networkTechnology = l3Network.getNetworkTechnology();
logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology);
}
if (networkTechnology != null) {
createNetworkRequest.setNetworkTechnology(networkTechnology.toUpperCase());
if (createNetworkRequest.getNetworkTechnology().contains("CONTRAIL")) {
createNetworkRequest.setContrailRequest(true);
}
}
// build and set Contrail Network
ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer);
createNetworkRequest.setContrailNetwork(contrailNetwork);
// set Network Parameters from VID request, add "shared" and "external" to this map
createNetworkRequest.setNetworkParams(addSharedAndExternal(userInput, l3Network));
createNetworkRequest = setFlowFlags(createNetworkRequest, orchestrationContext);
createNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance));
String messageId = getRandomUuid();
createNetworkRequest.setMessageId(messageId);
createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId));
return createNetworkRequest;
}
Aggregations