Search in sources :

Example 11 with RelationshipList

use of org.onap.aai.domain.yang.RelationshipList in project so by onap.

the class HeatBridgeImpl method buildAddVserverLInterfacesToAaiAction.

@Override
public void buildAddVserverLInterfacesToAaiAction(final List<Resource> stackResources, final List<String> oobMgtNetIds, String cloudOwner) throws HeatBridgeException {
    Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT);
    List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE);
    if (portIds == null)
        return;
    for (String portId : portIds) {
        boolean isL2Multicast = false;
        Port port = osClient.getPortById(portId);
        Network network = osClient.getNetworkById(port.getNetworkId());
        if (!StringUtils.isEmpty(port.getDeviceId())) {
            LInterface lIf = new LInterface();
            lIf.setInterfaceId(port.getId());
            lIf.setInterfaceName(port.getName());
            lIf.setMacaddr(port.getMacAddress());
            lIf.setNetworkName(network.getName());
            lIf.setIsPortMirrored(false);
            lIf.setIsIpUnnumbered(false);
            lIf.setInMaint(false);
            if (port.getProfile() != null && port.getProfile().get("trusted") != null) {
                String trusted = port.getProfile().get("trusted").toString();
                if (Boolean.parseBoolean(trusted)) {
                    isL2Multicast = true;
                }
            }
            lIf.setL2Multicasting(isL2Multicast);
            lIf.setInterfaceType(getInterfaceType(nodeType, port.getvNicType()));
            lIf.setRelationshipList(new RelationshipList());
            if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) {
                lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER);
            } else {
                lIf.setInterfaceRole(port.getvNicType());
            }
            // Update l-interface to the vserver
            transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName())), Optional.of(lIf));
            updateLInterfaceIps(port, lIf);
            if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) {
                Server server = getOpenstackServerById(port.getDeviceId());
                createVlanAndSriovVF(port, lIf, server.getHypervisorHostname());
                updateSriovPfToSriovVF(port, lIf);
            }
        }
    }
}
Also used : RelationshipList(org.onap.aai.domain.yang.RelationshipList) Server(org.openstack4j.model.compute.Server) Port(org.openstack4j.model.network.Port) L3Network(org.onap.aai.domain.yang.L3Network) Network(org.openstack4j.model.network.Network) LInterface(org.onap.aai.domain.yang.LInterface) IPAddressString(inet.ipaddr.IPAddressString)

Aggregations

RelationshipList (org.onap.aai.domain.yang.RelationshipList)11 Relationship (org.onap.aai.domain.yang.Relationship)10 Test (org.junit.Test)6 VfModule (org.onap.aai.domain.yang.VfModule)4 Server (org.openstack4j.model.compute.Server)4 ArrayList (java.util.ArrayList)3 AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)3 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)3 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 AaiHelper (org.onap.so.heatbridge.helpers.AaiHelper)3 Pair (org.javatuples.Pair)2 Ignore (org.junit.Ignore)2 GenericVnf (org.onap.aai.domain.yang.GenericVnf)2 L3Network (org.onap.aai.domain.yang.L3Network)2 ServiceInstance (org.onap.aai.domain.yang.ServiceInstance)2 Resource (org.onap.so.bpmn.infrastructure.workflow.tasks.Resource)2 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)2 CollectionResource (org.onap.so.db.catalog.beans.CollectionResource)2 Flavor (org.openstack4j.model.compute.Flavor)2