Search in sources :

Example 1 with Pserver

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

the class AAIRestClientImpl method getListOfPservers.

protected List<Pserver> getListOfPservers(String jsonInput) throws IOException {
    ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper();
    Results<Map<String, Pserver>> resultsFromJson = mapper.readValue(jsonInput, new TypeReference<Results<Map<String, Pserver>>>() {
    });
    List<Pserver> results = new ArrayList<>();
    for (Map<String, Pserver> m : resultsFromJson.getResult()) {
        results.add(m.get("pserver"));
    }
    return results;
}
Also used : Results(org.onap.aaiclient.client.aai.entities.Results) Pserver(org.onap.aai.domain.yang.Pserver) ArrayList(java.util.ArrayList) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with Pserver

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

the class AAIValidatorImpl method isPhysicalServerLocked.

@Override
public boolean isPhysicalServerLocked(String vnfId) throws IOException {
    List<Pserver> pservers;
    boolean isLocked = false;
    pservers = client.getPhysicalServerByVnfId(vnfId);
    if (pservers != null) {
        for (Pserver pserver : pservers) {
            if (pserver.isInMaint()) {
                isLocked = true;
                return isLocked;
            }
        }
    }
    return isLocked;
}
Also used : Pserver(org.onap.aai.domain.yang.Pserver)

Example 3 with Pserver

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

the class AAIValidatorTest method getPserversNotLocked.

public List<Pserver> getPserversNotLocked() {
    Pserver pserver1 = new Pserver();
    pserver1.setInMaint(false);
    Pserver pserver2 = new Pserver();
    pserver2.setInMaint(false);
    List<Pserver> pservers = new ArrayList<Pserver>();
    pservers.add(pserver1);
    pservers.add(pserver2);
    return pservers;
}
Also used : Pserver(org.onap.aai.domain.yang.Pserver) ArrayList(java.util.ArrayList)

Example 4 with Pserver

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

the class HeatBridgeImpl method createPserversAndPinterfacesIfNotPresentInAai.

@Override
public void createPserversAndPinterfacesIfNotPresentInAai(final List<Resource> stackResources) throws HeatBridgeException {
    if (stackResources == null) {
        return;
    }
    Map<String, Pserver> serverHostnames = getPserverMapping(stackResources);
    createPServerIfNotExists(serverHostnames);
    List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE);
    for (String portId : portIds) {
        Port port = osClient.getPortById(portId);
        if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
            Pserver foundServer = serverHostnames.get(port.getHostId());
            if (foundServer != null) {
                createPServerPInterfaceIfNotExists(foundServer.getHostname(), aaiHelper.buildPInterface(port));
            }
        }
    }
}
Also used : Pserver(org.onap.aai.domain.yang.Pserver) Port(org.openstack4j.model.network.Port) IPAddressString(inet.ipaddr.IPAddressString)

Example 5 with Pserver

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

the class HeatBridgeImpl method createTransactionToDeleteSriovPfFromPserver.

private void createTransactionToDeleteSriovPfFromPserver(List<AAIResourceUri> vserverUris) {
    Map<String, List<String>> pserverToPciIdMap = getPserverToPciIdMap(vserverUris);
    for (Map.Entry<String, List<String>> entry : pserverToPciIdMap.entrySet()) {
        String pserverName = entry.getKey();
        List<String> pciIds = entry.getValue();
        Optional<Pserver> pserver = resourcesClient.get(Pserver.class, AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName)).depth(Depth.TWO));
        if (pserver.isPresent()) {
            // For each pserver/p-interface match sriov-vfs by pic-id and delete them.
            pserver.get().getPInterfaces().getPInterface().stream().filter(pIf -> pIf.getSriovPfs() != null && CollectionUtils.isNotEmpty(pIf.getSriovPfs().getSriovPf())).forEach(pIf -> pIf.getSriovPfs().getSriovPf().forEach(sriovPf -> {
                if (pciIds.contains(sriovPf.getPfPciId())) {
                    logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + " from PServer: " + pserverName);
                    if (env.getProperty("heatBridgeDryrun", Boolean.class, false)) {
                        logger.debug("Would delete Sriov Pf: {}", AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName).pInterface(pIf.getInterfaceName()).sriovPf(sriovPf.getPfPciId())).build());
                    } else {
                        resourcesClient.delete(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName).pInterface(pIf.getInterfaceName()).sriovPf(sriovPf.getPfPciId())));
                    }
                }
            }));
        }
    }
}
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) Pserver(org.onap.aai.domain.yang.Pserver) L3InterfaceIpv4AddressList(org.onap.aai.domain.yang.L3InterfaceIpv4AddressList) List(java.util.List) L3InterfaceIpv6AddressList(org.onap.aai.domain.yang.L3InterfaceIpv6AddressList) ArrayList(java.util.ArrayList) RelationshipList(org.onap.aai.domain.yang.RelationshipList) IPAddressString(inet.ipaddr.IPAddressString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

Pserver (org.onap.aai.domain.yang.Pserver)12 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 IPAddressString (inet.ipaddr.IPAddressString)4 Map (java.util.Map)4 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)4 Server (org.openstack4j.model.compute.Server)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Preconditions (com.google.common.base.Preconditions)3 List (java.util.List)3 Optional (java.util.Optional)3 Collectors (java.util.stream.Collectors)3 CollectionUtils (org.apache.commons.collections.CollectionUtils)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Flavor (org.onap.aai.domain.yang.Flavor)3 Image (org.onap.aai.domain.yang.Image)3 L3Network (org.onap.aai.domain.yang.L3Network)3 PInterface (org.onap.aai.domain.yang.PInterface)3 Relationship (org.onap.aai.domain.yang.Relationship)3 RelationshipList (org.onap.aai.domain.yang.RelationshipList)3