use of org.onap.aaiclient.client.aai.entities.Relationships in project so by onap.
the class AppcRunTasks method getVserversForAppc.
protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws RuntimeException {
AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf);
if (aaiRW == null || aaiRW.getRelationships() == null || !aaiRW.getRelationships().isPresent()) {
return;
}
Relationships relationships = aaiRW.getRelationships().get();
List<AAIResourceUri> vserverUris = relationships.getRelatedUris(Types.VSERVER);
JSONArray vserverIds = new JSONArray();
JSONArray vserverSelfLinks = new JSONArray();
if (vserverUris != null) {
for (AAIResourceUri j : vserverUris) {
if (j != null) {
if (j.getURIKeys() != null) {
String vserverId = j.getURIKeys().get(AAIFluentTypeBuilder.Types.VSERVER.getUriParams().vserverId);
vserverIds.put(vserverId);
}
aaiVnfResources.getVserver(j).ifPresent((vserver) -> {
String vserverSelfLink = vserver.getVserverSelflink();
vserverSelfLinks.put(vserverSelfLink);
});
}
}
}
JSONObject vmidsArray = new JSONObject();
JSONObject vserveridsArray = new JSONObject();
vmidsArray.put("vmIds", vserverSelfLinks.toString());
vserveridsArray.put("vserverIds", vserverIds.toString());
logger.debug("vmidsArray is: {}", vmidsArray.toString());
logger.debug("vserveridsArray is: {}", vserveridsArray.toString());
execution.setVariable("vmIdList", vmidsArray.toString());
execution.setVariable("vserverIdList", vserveridsArray.toString());
}
Aggregations