Search in sources :

Example 1 with Subnet

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.

the class AAIUpdateTasksTest method updateNetworkAAITest.

@Test
public void updateNetworkAAITest() {
    L3Network spy = spy(new L3Network());
    L3Network shallowCopy = mock(L3Network.class);
    Subnet mockSubnet = mock(Subnet.class);
    Subnet shallowCopySubnet = mock(Subnet.class);
    when(mockSubnet.shallowCopyId()).thenReturn(shallowCopySubnet);
    doReturn(shallowCopy).when(spy).shallowCopyId();
    doNothing().when(aaiNetworkResources).updateNetwork(network);
    doNothing().when(aaiNetworkResources).updateSubnet(network, subnet);
    spy.getSubnets().add(mockSubnet);
    aaiUpdateTasks.updateNetworkAAI(spy, OrchestrationStatus.CREATED);
    verify(shallowCopy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
    verify(spy, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
    verify(shallowCopySubnet, times(1)).setOrchestrationStatus(OrchestrationStatus.CREATED);
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Example 2 with Subnet

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet 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"));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork) MsoRequest(org.onap.so.entity.MsoRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) UpdateNetworkRequest(org.onap.so.adapters.nwrest.UpdateNetworkRequest) ProviderVlanNetwork(org.onap.so.adapters.nwrest.ProviderVlanNetwork) NetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy) RouteTableReference(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference) VpnBinding(org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding) RouteTarget(org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Example 3 with Subnet

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.

the class AAINetworkResourcesTest method getSubnetTest.

@Test
public void getSubnetTest() throws Exception {
    final String content = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiSubnetsMapped_to_aai.json")));
    AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(content);
    Optional<org.onap.aai.domain.yang.Subnet> oSubnet = Optional.empty();
    AAIResourceUri subnetUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().l3Network("ModelInvariantUUID").subnet("serviceModelVersionId"));
    doReturn(aaiResultWrapper).when(MOCK_aaiResourcesClient).get(isA(AAIResourceUri.class));
    oSubnet = aaiNetworkResources.getSubnet(subnetUri);
    verify(MOCK_aaiResourcesClient, times(1)).get(any(AAIResourceUri.class));
    if (oSubnet.isPresent()) {
        org.onap.aai.domain.yang.Subnet subnet = oSubnet.get();
        assertThat(aaiResultWrapper.asBean(org.onap.aai.domain.yang.Subnet.class).get(), sameBeanAs(subnet));
    }
}
Also used : AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Test(org.junit.Test)

Example 4 with Subnet

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.

the class BBInputSetupMapperLayer method mapAAISubnet.

protected Subnet mapAAISubnet(org.onap.aai.domain.yang.Subnet aaiSubnet) {
    Subnet subnet = modelMapper.map(aaiSubnet, Subnet.class);
    mapAllHostRoutesIntoSubnet(aaiSubnet, subnet);
    return subnet;
}
Also used : Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)

Example 5 with Subnet

use of org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet in project so by onap.

the class NetworkAdapterObjectMapperTest method buildCreateNetworkRequestFromBbobjectTest.

@Test
public void buildCreateNetworkRequestFromBbobjectTest() 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.setNetworkType(l3Network.getNetworkType());
    expectedCreateNetworkRequest.setBackout(false);
    expectedCreateNetworkRequest.setFailIfExists(false);
    expectedCreateNetworkRequest.setNetworkTechnology("CONTRAIL");
    MsoRequest msoRequest = new MsoRequest();
    msoRequest.setRequestId(requestContext.getMsoRequestId());
    msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
    expectedCreateNetworkRequest.setMsoRequest(msoRequest);
    expectedCreateNetworkRequest.setSkipAAI(true);
    HashMap<String, String> networkParams = new HashMap<String, String>();
    networkParams.put("shared", "true");
    networkParams.put("external", "false");
    networkParams.put("testUserInputKey", "testUserInputValue");
    expectedCreateNetworkRequest.setNetworkParams(networkParams);
    expectedCreateNetworkRequest.setNotificationUrl("endpoint/NetworkAResponse/messageId");
    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.setNetworkTechnology("Contrail");
    l3Network.setIsSharedNetwork(true);
    l3Network.setIsExternalNetwork(false);
    doReturn("endpoint/").when(SPY_networkAdapterObjectMapper).getEndpoint();
    doReturn("messageId").when(SPY_networkAdapterObjectMapper).getRandomUuid();
    CreateNetworkRequest createNetworkRequest = SPY_networkAdapterObjectMapper.createNetworkRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, l3Network, userInput, cloudRegionPo, customer);
    assertThat(createNetworkRequest, sameBeanAs(expectedCreateNetworkRequest).ignoring("contrailRequest").ignoring("contrailNetwork").ignoring("providerVlanNetwork").ignoring("subnets").ignoring("messageId"));
}
Also used : CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) HashMap(java.util.HashMap) MsoRequest(org.onap.so.entity.MsoRequest) ArrayList(java.util.ArrayList) HostRoute(org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute) Subnet(org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet) Test(org.junit.Test)

Aggregations

Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)11 Test (org.junit.Test)8 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)6 ArrayList (java.util.ArrayList)5 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)3 MsoRequest (org.onap.so.entity.MsoRequest)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 HashMap (java.util.HashMap)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)2 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)2 Map (java.util.Map)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 ContrailNetwork (org.onap.so.adapters.nwrest.ContrailNetwork)1 CreateNetworkResponse (org.onap.so.adapters.nwrest.CreateNetworkResponse)1 ProviderVlanNetwork (org.onap.so.adapters.nwrest.ProviderVlanNetwork)1 UpdateNetworkRequest (org.onap.so.adapters.nwrest.UpdateNetworkRequest)1 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)1