Search in sources :

Example 1 with DSLQuery

use of org.onap.aaiclient.client.graphinventory.entities.DSLQuery in project so by onap.

the class AAIDataRetrieval method getLinterfacesOfVnf.

public List<LInterface> getLinterfacesOfVnf(String vnfId) {
    DSLStartNode startNode = new DSLStartNode(Types.GENERIC_VNF, __.key("vnf-id", vnfId));
    DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(startNode).to(__.node(Types.VSERVER).to(__.node(Types.L_INTERFACE).output()));
    List<LInterface> linterfaces = getAAIDSLQueryClient().querySingleResource(new DSLQuery(builder.build()), LInterface.class);
    return linterfaces;
}
Also used : Start(org.onap.aaiclient.client.graphinventory.entities.Start) Node(org.onap.aaiclient.client.graphinventory.entities.Node) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode) LInterface(org.onap.aai.domain.yang.LInterface) DSLQuery(org.onap.aaiclient.client.graphinventory.entities.DSLQuery) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode)

Example 2 with DSLQuery

use of org.onap.aaiclient.client.graphinventory.entities.DSLQuery in project so by onap.

the class HeatBridgeImpl method createVlanTagUri.

protected String createVlanTagUri(String vlanIdOuter) throws HeatBridgeException {
    int vlanOuterInt = Integer.parseInt(vlanIdOuter);
    DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", cloudOwner), __.key("cloud-region-id", cloudRegionId))).to(__.node(Types.VLAN_RANGE)).to(__.node(Types.VLAN_TAG, __.key("vlan-id-outer", vlanOuterInt)).output());
    String results = getAAIDSLClient().query(Format.PATHED, new DSLQuery(builder.build()));
    Optional<String> vlanTagURI = findLinkedURI(results);
    if (vlanTagURI.isPresent())
        return vlanTagURI.get();
    else
        throw new HeatBridgeException("Cannot find VlanTag Related Link " + vlanIdOuter);
}
Also used : Start(org.onap.aaiclient.client.graphinventory.entities.Start) Node(org.onap.aaiclient.client.graphinventory.entities.Node) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode) DSLQuery(org.onap.aaiclient.client.graphinventory.entities.DSLQuery) IPAddressString(inet.ipaddr.IPAddressString) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode)

Example 3 with DSLQuery

use of org.onap.aaiclient.client.graphinventory.entities.DSLQuery in project so by onap.

the class HeatBridgeImpl method updateSriovPfToSriovVF.

/**
 * Needs to be corrected according to the specification that is in draft If pserver/p-interface does not have a
 * SRIOV-PF object matching the PCI-ID of the Openstack port object, then create it in AAI. Openstack SRIOV Port
 * object has pci-id (to match sriov-pf on pserver/p-interface), physical-network ID (that matches the p-interface
 * name).
 *
 * @param port Openstack port object
 * @param lIf AAI l-interface object
 * @throws HeatBridgeException
 */
protected void updateSriovPfToSriovVF(final Port port, final LInterface lIf) throws HeatBridgeException {
    if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) {
        AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()));
        boolean relationshipExist = sriovVfHasSriovPfRelationship(sriovVfUri);
        Server server = getOpenstackServerById(port.getDeviceId());
        String pserverHostName = server.getHypervisorHostname();
        lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName);
        if (!relationshipExist) {
            AAIResourceUri pserverUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName));
            if (resourcesClient.exists(pserverUri)) {
                String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PF_PCI_SLOT_KEY).toString();
                DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(new DSLStartNode(Types.PSERVER, __.key("hostname", pserverHostName))).to(__.node(Types.P_INTERFACE).to(__.node(Types.SRIOV_PF, __.key("pf-pci-id", pfPciId)).output()));
                List<Pathed> results = getAAIDSLClient().queryPathed(new DSLQuery(builder.build()));
                if (results.size() == 1) {
                    AAIResourceUri sriovPfUri = AAIUriFactory.createResourceFromExistingURI(Types.SRIOV_PF, UriBuilder.fromUri(results.get(0).getResourceLink()).build());
                    transaction.connect(sriovPfUri, sriovVfUri);
                } else {
                    throw new HeatBridgeException("Unable to find sriov-pf related link " + pfPciId + ". Unexpected results size" + results.size());
                }
            } else {
                logger.error("Pserver {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.", pserverHostName);
                throw new HeatBridgeException("Pserver " + pserverHostName + " does not exist in AAI");
            }
        }
    }
}
Also used : Server(org.openstack4j.model.compute.Server) Pathed(org.onap.aaiclient.client.graphinventory.entities.Pathed) Start(org.onap.aaiclient.client.graphinventory.entities.Start) Node(org.onap.aaiclient.client.graphinventory.entities.Node) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) DSLQuery(org.onap.aaiclient.client.graphinventory.entities.DSLQuery) IPAddressString(inet.ipaddr.IPAddressString) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode)

Aggregations

DSLQuery (org.onap.aaiclient.client.graphinventory.entities.DSLQuery)3 DSLStartNode (org.onap.aaiclient.client.graphinventory.entities.DSLStartNode)3 Node (org.onap.aaiclient.client.graphinventory.entities.Node)3 Start (org.onap.aaiclient.client.graphinventory.entities.Start)3 IPAddressString (inet.ipaddr.IPAddressString)2 LInterface (org.onap.aai.domain.yang.LInterface)1 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)1 Pathed (org.onap.aaiclient.client.graphinventory.entities.Pathed)1 Server (org.openstack4j.model.compute.Server)1