Search in sources :

Example 1 with ContrailNetwork

use of org.onap.so.adapters.nwrest.ContrailNetwork 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 2 with ContrailNetwork

use of org.onap.so.adapters.nwrest.ContrailNetwork in project so by onap.

the class StackService method updateNetwork.

private void updateNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout, MutableBoolean success) throws NetworkException {
    backout.setFalse();
    UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
    HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
    if (params == null) {
        params = new HashMap<>();
    }
    String shared = null;
    String external = null;
    String physicalNetworkName = null;
    List<Integer> vlans = null;
    List<RouteTarget> routeTargets = null;
    List<String> fqdns = null;
    List<String> routeTable = null;
    if (params.containsKey(SHARED))
        shared = params.get(SHARED);
    if (params.containsKey(EXTERNAL))
        external = params.get(EXTERNAL);
    if (req.isContrailRequest()) {
        ContrailNetwork ctn = req.getContrailNetwork();
        if (ctn == null) {
            ctn = new ContrailNetwork();
            req.setContrailNetwork(ctn);
        }
        if (shared == null && ctn.getShared() != null) {
            shared = ctn.getShared();
        }
        if (shared == null && ctn.getExternal() != null) {
            external = ctn.getExternal();
        }
        routeTargets = req.getContrailNetwork().getRouteTargets();
        fqdns = req.getContrailNetwork().getPolicyFqdns();
        routeTable = req.getContrailNetwork().getRouteTableFqdns();
    } else {
        ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
        if (pvn == null) {
            pvn = new ProviderVlanNetwork();
            req.setProviderVlanNetwork(pvn);
        }
        physicalNetworkName = req.getProviderVlanNetwork().getPhysicalNetworkName();
        vlans = req.getProviderVlanNetwork().getVlans();
    }
    networkAdapterImpl.updateNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), req.getModelCustomizationUuid(), req.getNetworkStackId(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared, external, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(), canonicalStackId);
    success.setTrue();
}
Also used : HashMap(java.util.HashMap) ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork) StringReader(java.io.StringReader) UpdateNetworkRequest(org.onap.so.adapters.nwrest.UpdateNetworkRequest) ProviderVlanNetwork(org.onap.so.adapters.nwrest.ProviderVlanNetwork) RouteTarget(org.onap.so.openstack.beans.RouteTarget)

Example 3 with ContrailNetwork

use of org.onap.so.adapters.nwrest.ContrailNetwork in project so by onap.

the class StackService method createNetwork.

private void createNetwork(String xmlRequest, Holder<String> canonicalStackId, MutableBoolean backout, MutableBoolean success, MutableBoolean os3) throws NetworkException {
    CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
    HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams();
    if (params == null) {
        params = new HashMap<>();
    }
    String shared = null;
    String external = null;
    String physicalNetworkName = null;
    List<Integer> vlans = null;
    List<RouteTarget> routeTargets = null;
    List<String> fqdns = null;
    List<String> routeTable = null;
    if (params.containsKey(SHARED))
        shared = params.get(SHARED);
    if (params.containsKey(EXTERNAL))
        external = params.get(EXTERNAL);
    if (req.isContrailRequest()) {
        ContrailNetwork ctn = req.getContrailNetwork();
        if (ctn == null) {
            ctn = new ContrailNetwork();
            req.setContrailNetwork(ctn);
        }
        if (shared == null && ctn.getShared() != null) {
            shared = ctn.getShared();
        }
        if (shared == null && ctn.getExternal() != null) {
            external = ctn.getExternal();
        }
        routeTargets = req.getContrailNetwork().getRouteTargets();
        fqdns = req.getContrailNetwork().getPolicyFqdns();
        routeTable = req.getContrailNetwork().getRouteTableFqdns();
    } else {
        ProviderVlanNetwork pvn = req.getProviderVlanNetwork();
        if (pvn == null) {
            pvn = new ProviderVlanNetwork();
            req.setProviderVlanNetwork(pvn);
        }
        physicalNetworkName = req.getProviderVlanNetwork().getPhysicalNetworkName();
        vlans = req.getProviderVlanNetwork().getVlans();
    }
    networkAdapterImpl.createNetwork(req.getCloudSiteId(), req.getTenantId(), req.getNetworkType(), req.getModelCustomizationUuid(), req.getNetworkName(), physicalNetworkName, vlans, routeTargets, shared, external, req.getFailIfExists(), false, req.getSubnets(), fqdns, routeTable, req.getMsoRequest(), canonicalStackId, os3);
    success.setTrue();
    backout.setValue(req.getBackout());
}
Also used : CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) HashMap(java.util.HashMap) ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork) StringReader(java.io.StringReader) ProviderVlanNetwork(org.onap.so.adapters.nwrest.ProviderVlanNetwork) RouteTarget(org.onap.so.openstack.beans.RouteTarget)

Example 4 with ContrailNetwork

use of org.onap.so.adapters.nwrest.ContrailNetwork in project so by onap.

the class NetworkAdapterObjectMapper method buildContrailNetwork.

private ContrailNetwork buildContrailNetwork(L3Network l3Network, Customer customer) {
    ContrailNetwork contrailNetwork = new ContrailNetwork();
    contrailNetwork.setExternal(Optional.ofNullable(l3Network.isIsExternalNetwork()).orElse(false).toString());
    contrailNetwork.setShared(Optional.ofNullable(l3Network.isIsSharedNetwork()).orElse(false).toString());
    contrailNetwork.setPolicyFqdns(buildPolicyFqdns(l3Network.getNetworkPolicies()));
    contrailNetwork.setRouteTableFqdns(buildRouteTableFqdns(l3Network.getContrailNetworkRouteTableReferences()));
    if (customer != null)
        contrailNetwork.setRouteTargets(buildRouteTargets(customer.getVpnBindings()));
    // RouteTargets(routeTargets); --- is set in getAAINetworkVpnBinding
    return contrailNetwork;
}
Also used : ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork)

Example 5 with ContrailNetwork

use of org.onap.so.adapters.nwrest.ContrailNetwork 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;
}
Also used : ContrailNetwork(org.onap.so.adapters.nwrest.ContrailNetwork) CreateNetworkRequest(org.onap.so.adapters.nwrest.CreateNetworkRequest) ModelInfoNetwork(org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork) ProviderVlanNetwork(org.onap.so.adapters.nwrest.ProviderVlanNetwork)

Aggregations

ContrailNetwork (org.onap.so.adapters.nwrest.ContrailNetwork)5 ProviderVlanNetwork (org.onap.so.adapters.nwrest.ProviderVlanNetwork)4 HashMap (java.util.HashMap)3 StringReader (java.io.StringReader)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 UpdateNetworkRequest (org.onap.so.adapters.nwrest.UpdateNetworkRequest)2 ModelInfoNetwork (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork)2 RouteTarget (org.onap.so.openstack.beans.RouteTarget)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)1 HostRoute (org.onap.so.bpmn.servicedecomposition.bbobjects.HostRoute)1 NetworkPolicy (org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy)1 RouteTableReference (org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference)1 RouteTarget (org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget)1 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)1 Subnet (org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet)1 VpnBinding (org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding)1 MsoRequest (org.onap.so.entity.MsoRequest)1