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);
}
}
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);
}
}
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);
}
Aggregations