Search in sources :

Example 1 with SriovVf

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

the class AaiHelper method getPserverToPciIdMap.

/**
 * From the list vserver objects build a map of compute hosts's name and the PCI IDs linked to it.
 *
 * @param vservers List of vserver AAI objects
 * @return a map of compute names to the PCI ids associated with the compute
 */
public Map<String, List<String>> getPserverToPciIdMap(final List<Vserver> vservers) {
    Map<String, List<String>> pserverToPciIdMap = new HashMap<>();
    for (Vserver vserver : vservers) {
        if (vserver.getLInterfaces() != null) {
            List<String> pciIds = vserver.getLInterfaces().getLInterface().stream().filter(lInterface -> lInterface.getSriovVfs() != null && CollectionUtils.isNotEmpty(lInterface.getSriovVfs().getSriovVf())).flatMap(lInterface -> lInterface.getSriovVfs().getSriovVf().stream()).map(SriovVf::getPciId).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(pciIds)) {
                List<String> matchingPservers = extractRelationshipDataValue(vserver.getRelationshipList(), HeatBridgeConstants.AAI_PSERVER, HeatBridgeConstants.AAI_PSERVER_HOSTNAME);
                Preconditions.checkState(matchingPservers != null && matchingPservers.size() == 1, "Invalid pserver relationships for vserver: " + vserver.getVserverName());
                pserverToPciIdMap.put(matchingPservers.get(0), pciIds);
            }
        }
    }
    return pserverToPciIdMap;
}
Also used : AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) Network(org.openstack4j.model.network.Network) Relationship(org.onap.aai.domain.yang.Relationship) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) Server(org.openstack4j.model.compute.Server) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) HeatBridgeConstants(org.onap.so.heatbridge.constants.HeatBridgeConstants) Pserver(org.onap.aai.domain.yang.Pserver) L3Network(org.onap.aai.domain.yang.L3Network) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) Port(org.openstack4j.model.network.Port) RelationshipData(org.onap.aai.domain.yang.RelationshipData) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) Logger(org.slf4j.Logger) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) Collection(java.util.Collection) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) HeatBridgeException(org.onap.so.heatbridge.HeatBridgeException) Subnet(org.openstack4j.model.network.Subnet) Collectors(java.util.stream.Collectors) List(java.util.List) Vserver(org.onap.aai.domain.yang.Vserver) Optional(java.util.Optional) Flavor(org.onap.aai.domain.yang.Flavor) PInterface(org.onap.aai.domain.yang.PInterface) Preconditions(com.google.common.base.Preconditions) SriovVf(org.onap.aai.domain.yang.SriovVf) Image(org.onap.aai.domain.yang.Image) Vserver(org.onap.aai.domain.yang.Vserver) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) List(java.util.List)

Example 2 with SriovVf

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

the class HeatBridgeImpl method createVlanAndSriovVF.

protected void createVlanAndSriovVF(final Port port, final LInterface lIf, final String hostName) throws HeatBridgeException {
    // add back all vlan logic
    Vlan vlan = new Vlan();
    Network network = osClient.getNetworkById(port.getNetworkId());
    if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) {
        vlan.setVlanInterface(port.getName() + network.getProviderSegID());
        vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID()));
        vlan.setVlanIdInner(0L);
        vlan.setInMaint(false);
        vlan.setIsIpUnnumbered(false);
        vlan.setIsPrivate(false);
        transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).vlan(vlan.getVlanInterface())), Optional.of(vlan));
    }
    if (!lIf.getInterfaceType().equals(SRIOV)) {
        if (nodeType == NodeType.GREENFIELD) {
            validatePhysicalNetwork(port, network);
            processOVS(lIf, hostName, NodeType.GREENFIELD.getInterfaceName());
        } else {
            processOVS(lIf, hostName, NodeType.BROWNFIELD.getInterfaceName());
        }
    }
    List<String> privateVlans = (ArrayList<String>) port.getProfile().get(PRIVATE_VLANS);
    List<String> publicVlans = (ArrayList<String>) port.getProfile().get(PUBLIC_VLANS);
    List<String> vlans = null;
    if (publicVlans != null && !publicVlans.isEmpty()) {
        vlans = publicVlans.stream().filter(publicVlan -> !Strings.isNullOrEmpty(publicVlan)).collect(Collectors.toList());
    } else {
        vlans = new ArrayList<>();
    }
    if (privateVlans != null && !privateVlans.isEmpty()) {
        List<String> temp = privateVlans.stream().filter(privateVlan -> !Strings.isNullOrEmpty(privateVlan)).collect(Collectors.toList());
        vlans.addAll(temp);
    }
    vlans.stream().forEach(vlanLocal -> logger.debug("Vlan Id: {}", vlanLocal));
    processVlanTag(lIf, vlans);
    if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
        SriovVf sriovVf = new SriovVf();
        sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString());
        sriovVf.setNeutronNetworkId(port.getNetworkId());
        sriovVf.setVfVlanFilter("0");
        sriovVf.setVfVlanAntiSpoofCheck(false);
        sriovVf.setVfMacAntiSpoofCheck(false);
        transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf(sriovVf.getPciId())), Optional.of(sriovVf));
    }
}
Also used : Depth(org.onap.aaiclient.client.graphinventory.entities.uri.Depth) AaiHelper(org.onap.so.heatbridge.helpers.AaiHelper) AAIUriFactory(org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory) Node(org.onap.aaiclient.client.graphinventory.entities.Node) Server(org.openstack4j.model.compute.Server) LoggerFactory(org.slf4j.LoggerFactory) HeatBridgeUtils(org.onap.so.heatbridge.utils.HeatBridgeUtils) StringUtils(org.apache.commons.lang3.StringUtils) DSLQueryBuilder(org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder) Map(java.util.Map) Resource(org.openstack4j.model.heat.Resource) AAIDSLQueryClient(org.onap.aaiclient.client.aai.AAIDSLQueryClient) Vlan(org.onap.aai.domain.yang.Vlan) UriBuilder(javax.ws.rs.core.UriBuilder) Pserver(org.onap.aai.domain.yang.Pserver) TypeReference(com.fasterxml.jackson.core.type.TypeReference) L3Network(org.onap.aai.domain.yang.L3Network) DSLQuery(org.onap.aaiclient.client.graphinventory.entities.DSLQuery) AAISingleTransactionClient(org.onap.aaiclient.client.aai.AAISingleTransactionClient) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) L3InterfaceIpv4AddressList(org.onap.aai.domain.yang.L3InterfaceIpv4AddressList) Collectors(java.util.stream.Collectors) MsoCloudClientFactoryImpl(org.onap.so.heatbridge.factory.MsoCloudClientFactoryImpl) NotFoundException(javax.ws.rs.NotFoundException) IPAddressString(inet.ipaddr.IPAddressString) Objects(java.util.Objects) NetworkType(org.openstack4j.model.network.NetworkType) VolumeAttachment(org.openstack4j.model.storage.block.VolumeAttachment) List(java.util.List) Environment(org.springframework.core.env.Environment) InetAddressValidator(org.apache.commons.validator.routines.InetAddressValidator) SriovPf(org.onap.aai.domain.yang.SriovPf) Optional(java.util.Optional) WebApplicationException(javax.ws.rs.WebApplicationException) Flavor(org.onap.aai.domain.yang.Flavor) Results(org.onap.aaiclient.client.aai.entities.Results) Volume(org.onap.aai.domain.yang.Volume) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Image(org.onap.aai.domain.yang.Image) CloudIdentity(org.onap.so.db.catalog.beans.CloudIdentity) L3InterfaceIpv6AddressList(org.onap.aai.domain.yang.L3InterfaceIpv6AddressList) Network(org.openstack4j.model.network.Network) Relationship(org.onap.aai.domain.yang.Relationship) Types(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types) BulkProcessFailed(org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) RelationshipList(org.onap.aai.domain.yang.RelationshipList) CollectionUtils(org.apache.commons.collections.CollectionUtils) ServerType(org.onap.so.db.catalog.beans.ServerType) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode) OpenstackClientFactoryImpl(org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl) IP(org.openstack4j.model.network.IP) Start(org.onap.aaiclient.client.graphinventory.entities.Start) HeatBridgeConstants(org.onap.so.heatbridge.constants.HeatBridgeConstants) SpringContextHelper(org.onap.so.spring.SpringContextHelper) LInterface(org.onap.aai.domain.yang.LInterface) Nonnull(javax.annotation.Nonnull) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper) org.onap.aaiclient.client.graphinventory.entities.__(org.onap.aaiclient.client.graphinventory.entities.__) Port(org.openstack4j.model.network.Port) Subnets(org.onap.aai.domain.yang.Subnets) AAIResourcesClient(org.onap.aaiclient.client.aai.AAIResourcesClient) Format(org.onap.aaiclient.client.graphinventory.Format) Logger(org.slf4j.Logger) AAIFluentTypeBuilder(org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) Subnet(org.openstack4j.model.network.Subnet) Pathed(org.onap.aaiclient.client.graphinventory.entities.Pathed) TraversalBuilder(org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder) Vserver(org.onap.aai.domain.yang.Vserver) PInterface(org.onap.aai.domain.yang.PInterface) Preconditions(com.google.common.base.Preconditions) SriovVf(org.onap.aai.domain.yang.SriovVf) NodeType(org.onap.so.cloud.resource.beans.NodeType) OpenstackClient(org.onap.so.heatbridge.openstack.api.OpenstackClient) L3Network(org.onap.aai.domain.yang.L3Network) Network(org.openstack4j.model.network.Network) ArrayList(java.util.ArrayList) SriovVf(org.onap.aai.domain.yang.SriovVf) Vlan(org.onap.aai.domain.yang.Vlan) IPAddressString(inet.ipaddr.IPAddressString)

Aggregations

Preconditions (com.google.common.base.Preconditions)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 CollectionUtils (org.apache.commons.collections.CollectionUtils)2 StringUtils (org.apache.commons.lang3.StringUtils)2 Flavor (org.onap.aai.domain.yang.Flavor)2 Image (org.onap.aai.domain.yang.Image)2 L3Network (org.onap.aai.domain.yang.L3Network)2 PInterface (org.onap.aai.domain.yang.PInterface)2 Pserver (org.onap.aai.domain.yang.Pserver)2 Relationship (org.onap.aai.domain.yang.Relationship)2 RelationshipList (org.onap.aai.domain.yang.RelationshipList)2 SriovVf (org.onap.aai.domain.yang.SriovVf)2 Vserver (org.onap.aai.domain.yang.Vserver)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1