Search in sources :

Example 1 with DSLStartNode

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

the class DSLQueryBuilderTest method whereTest.

@Test
public void whereTest() {
    DSLQueryBuilder<Start, Start> builder = TraversalBuilder.fragment(new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "att-nc"), __.key("cloud-region-id", "test")));
    builder.to(__.node(Types.VLAN_TAG)).where(__.node(Types.OWNING_ENTITY, __.key("owning-entity-name", "name"))).to(__.node(Types.VLAN_TAG, __.key("vlan-id-outer", "108")).output());
    assertEquals("cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'test') > " + "vlan-tag (> owning-entity('owning-entity-name', 'name')) > " + "vlan-tag*('vlan-id-outer', '108')", builder.build().get());
}
Also used : Start(org.onap.aaiclient.client.graphinventory.entities.Start) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode) Test(org.junit.Test)

Example 2 with DSLStartNode

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

the class DSLQueryBuilderTest method selectOutputFilterOnNodeTest.

@Test
public void selectOutputFilterOnNodeTest() {
    DSLStartNode node = new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", "CloudOwner"));
    DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(node).output("cloud-region-id");
    assertEquals("cloud-region{'cloud-region-id'}('cloud-owner', 'CloudOwner')", builder.build().toString());
}
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) DSLStartNode(org.onap.aaiclient.client.graphinventory.entities.DSLStartNode) Test(org.junit.Test)

Example 3 with DSLStartNode

use of org.onap.aaiclient.client.graphinventory.entities.DSLStartNode 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 4 with DSLStartNode

use of org.onap.aaiclient.client.graphinventory.entities.DSLStartNode 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 5 with DSLStartNode

use of org.onap.aaiclient.client.graphinventory.entities.DSLStartNode 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

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