Search in sources :

Example 1 with NetworkPolicy

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

the class AAIQueryTasks method queryNetworkPolicy.

/**
 * BPMN access method to query data for network policies from the AAI result wrapper From the resulting network
 * policy, the network policy fqdn parameter is added to the network bbobject contrail network policy fqdns list
 *
 * @param execution
 */
public void queryNetworkPolicy(BuildingBlockExecution execution) {
    try {
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network);
        Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships();
        if (!networkRelationships.isPresent()) {
            throw (new Exception(ERROR_MSG));
        }
        List<AAIResourceUri> netPoliciesUriList = networkRelationships.get().getRelatedUris(Types.NETWORK_POLICY);
        if (!netPoliciesUriList.isEmpty()) {
            for (AAIResourceUri netPolicyUri : netPoliciesUriList) {
                Optional<NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri);
                if (oNetPolicy.isPresent()) {
                    l3network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class));
                }
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : L3Network(org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network) Relationships(org.onap.aaiclient.client.aai.entities.Relationships) NetworkPolicy(org.onap.aai.domain.yang.NetworkPolicy) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Example 2 with NetworkPolicy

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

the class AAIDeleteTasks method deleteNetworkPolicies.

public void deleteNetworkPolicies(BuildingBlockExecution execution) {
    try {
        String fqdns = execution.getVariable(contrailNetworkPolicyFqdnList);
        if (fqdns != null && !fqdns.isEmpty()) {
            String[] fqdnList = fqdns.split(",");
            int fqdnCount = fqdnList.length;
            if (fqdnCount > 0) {
                for (int i = 0; i < fqdnCount; i++) {
                    String fqdn = fqdnList[i];
                    AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies());
                    uri.queryParam(networkPolicyFqdnParam, fqdn);
                    Optional<NetworkPolicies> oNetPolicies = aaiNetworkResources.getNetworkPolicies(uri);
                    if (oNetPolicies.isPresent()) {
                        NetworkPolicies networkPolicies = oNetPolicies.get();
                        List<NetworkPolicy> networkPolicyList = networkPolicies.getNetworkPolicy();
                        if (networkPolicyList != null && !networkPolicyList.isEmpty()) {
                            NetworkPolicy networkPolicy = networkPolicyList.get(0);
                            String networkPolicyId = networkPolicy.getNetworkPolicyId();
                            logger.debug("Deleting network-policy with network-policy-id {}", networkPolicyId);
                            aaiNetworkResources.deleteNetworkPolicy(networkPolicyId);
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : AAIPluralResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri) NetworkPolicy(org.onap.aai.domain.yang.NetworkPolicy) NetworkPolicies(org.onap.aai.domain.yang.NetworkPolicies)

Example 3 with NetworkPolicy

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

the class AAINetworkResources method createNetworkPolicy.

public void createNetworkPolicy(org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy networkPolicy) {
    NetworkPolicy aaiNetworkPolicy = aaiObjectMapper.mapNetworkPolicy(networkPolicy);
    String networkPolicyId = networkPolicy.getNetworkPolicyId();
    AAIResourceUri netUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicy(networkPolicyId));
    injectionHelper.getAaiClient().create(netUri, aaiNetworkPolicy);
}
Also used : NetworkPolicy(org.onap.aai.domain.yang.NetworkPolicy) AAIResourceUri(org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)

Aggregations

NetworkPolicy (org.onap.aai.domain.yang.NetworkPolicy)3 AAIResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri)2 NetworkPolicies (org.onap.aai.domain.yang.NetworkPolicies)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 AAIPluralResourceUri (org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri)1 L3Network (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network)1