use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.
the class AAICreateTasks method createNetworkPolicies.
/**
* This method is used to put the network policy in A&AI.
*
* @param execution @throws
*/
public void createNetworkPolicies(BuildingBlockExecution execution) {
try {
String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
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(NETWORK_POLICY_FQDN_PARAM, fqdn);
Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(uri);
if (!oNetPolicy.isPresent()) {
logger.debug("This network policy FQDN is not in AAI yet: {}", fqdn);
String networkPolicyId = UUID.randomUUID().toString();
logger.debug("Adding network-policy with network-policy-id {}", networkPolicyId);
NetworkPolicy networkPolicy = new NetworkPolicy();
networkPolicy.setNetworkPolicyId(networkPolicyId);
networkPolicy.setNetworkPolicyFqdn(fqdn);
networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID));
aaiNetworkResources.createNetworkPolicy(networkPolicy);
}
}
}
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri 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.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.
the class CreateVFModule method getNodeType.
protected NodeType getNodeType(CloudRegion cloudRegion) {
AAIResourceUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()));
AAIResourcesClient client = getAAIClient();
Optional<Relationships> relationships = client.get(cloudRegionUri).getRelationships();
if (relationships.isPresent()) {
AAIPluralResourceUri networkTechsGreenfieldUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())).relatedTo(Types.NETWORK_TECHNOLOGIES.getFragment()).queryParam("network-technology-name", NodeType.GREENFIELD.getNetworkTechnologyName());
AAIResultWrapper networkTechsGreenfield = client.get(networkTechsGreenfieldUri);
if (networkTechsGreenfield != null && !networkTechsGreenfield.isEmpty()) {
return NodeType.GREENFIELD;
}
}
return NodeType.BROWNFIELD;
}
use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.
the class AAIDataRetrievalTest method getVolumeGroupsOfVnfTest.
@Test
public void getVolumeGroupsOfVnfTest() throws Exception {
VolumeGroups volumeGroups = getVolumeGroups();
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId")).relatedTo(Types.VOLUME_GROUPS.getFragment());
doReturn(Optional.of(volumeGroups)).when(aaiResourcesClient).get(VolumeGroups.class, uri);
List<VolumeGroup> volumeGroupList = aaiDataRetrieval.getVolumeGroupsOfVnf("vnfId");
assertEquals("vg1", volumeGroupList.get(0).getVolumeGroupId());
Optional<String> volumeGroupIds = aaiDataRetrieval.getVolumeGroupIdsByVnfId("vnfId");
assertEquals(Optional.of("vg1,vg2"), volumeGroupIds);
}
use of org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri in project so by onap.
the class AAIDataRetrievalTest method getVfModulesOfVnfTest.
@Test
public void getVfModulesOfVnfTest() {
VfModules vfModules = getVfModules();
AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf("vnfId").vfModules());
doReturn(Optional.of(vfModules)).when(aaiResourcesClient).get(VfModules.class, uri);
List<VfModule> vfModulesList = aaiDataRetrieval.getVfModulesOfVnf("vnfId");
assertEquals("vfm1", vfModulesList.get(0).getVfModuleId());
Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId("vnfId");
assertEquals(Optional.of("vfm1,vfm2"), vfModuleIds);
}
Aggregations