From 02b85efab5f18527023accc1ca20b614b16fee30 Mon Sep 17 00:00:00 2001 From: jhh Date: Thu, 1 Aug 2019 15:20:21 -0500 Subject: Add AAI test tooling to telemetry. Issue-ID: POLICY-1956 Signed-off-by: jhh Change-Id: Icceab57db9c19364afbedbf63ecc8e52c1572cba Signed-off-by: jhh --- .../eventmanager/ControlLoopEventManager.java | 56 +++++++++++++--------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'controlloop/common/eventmanager/src') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 57df6b3f4..7d42f8f76 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -81,9 +81,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable { public static final String GENERIC_VNF_PROV_STATUS = "generic-vnf.prov-status"; public static final String VSERVER_PROV_STATUS = "vserver.prov-status"; - private static final String AAI_URL = "aai.url"; - private static final String AAI_USERNAME_PROPERTY = "aai.username"; - private static final String AAI_PASS_PROPERTY = "aai.password"; + public static final String AAI_URL = "aai.url"; + public static final String AAI_USERNAME_PROPERTY = "aai.username"; + public static final String AAI_PASS_PROPERTY = "aai.password"; private static final String QUERY_AAI_ERROR_MSG = "Exception from queryAai: "; @@ -961,26 +961,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { logger.warn("Missing vserver-name for AAI request {}", onset.getRequestId()); return null; } - - // create AAI named-query request with UUID started with "" - AaiNqRequest aaiNqRequest = new AaiNqRequest(); - AaiNqQueryParameters aaiNqQueryParam = new AaiNqQueryParameters(); - AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); - final AaiNqInstanceFilters aaiNqInstanceFilter = new AaiNqInstanceFilters(); - - // queryParameters - aaiNqNamedQuery.setNamedQueryUuid(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469")); - aaiNqQueryParam.setNamedQuery(aaiNqNamedQuery); - aaiNqRequest.setQueryParameters(aaiNqQueryParam); - // - // instanceFilters - // - Map> aaiNqInstanceFilterMap = new HashMap<>(); - Map aaiNqInstanceFilterMapItem = new HashMap<>(); - aaiNqInstanceFilterMapItem.put("vserver-name", vserverName); - aaiNqInstanceFilterMap.put("vserver", aaiNqInstanceFilterMapItem); - aaiNqInstanceFilter.getInstanceFilter().add(aaiNqInstanceFilterMap); - aaiNqRequest.setInstanceFilters(aaiNqInstanceFilter); + AaiNqRequest aaiNqRequest = getAaiNqRequest(vserverName); if (logger.isDebugEnabled()) { logger.debug("AAI Request sent: {}", Serialization.gsonPretty.toJson(aaiNqRequest)); @@ -1007,6 +988,35 @@ public class ControlLoopEventManager implements LockCallback, Serializable { return nqVserverResponse; } + /** + * Gets an AAI Named Query Request object. + * + * @param vserverName vserver name. + * @return the AAI Named Query Request object. + */ + public static AaiNqRequest getAaiNqRequest(String vserverName) { + // create AAI named-query request with UUID started with "" + AaiNqRequest aaiNqRequest = new AaiNqRequest(); + AaiNqQueryParameters aaiNqQueryParam = new AaiNqQueryParameters(); + AaiNqNamedQuery aaiNqNamedQuery = new AaiNqNamedQuery(); + final AaiNqInstanceFilters aaiNqInstanceFilter = new AaiNqInstanceFilters(); + + // queryParameters + aaiNqNamedQuery.setNamedQueryUuid(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469")); + aaiNqQueryParam.setNamedQuery(aaiNqNamedQuery); + aaiNqRequest.setQueryParameters(aaiNqQueryParam); + // + // instanceFilters + // + Map> aaiNqInstanceFilterMap = new HashMap<>(); + Map aaiNqInstanceFilterMapItem = new HashMap<>(); + aaiNqInstanceFilterMapItem.put("vserver-name", vserverName); + aaiNqInstanceFilterMap.put("vserver", aaiNqInstanceFilterMapItem); + aaiNqInstanceFilter.getInstanceFilter().add(aaiNqInstanceFilterMap); + aaiNqRequest.setInstanceFilters(aaiNqInstanceFilter); + return aaiNqRequest; + } + /** * This method reads and validates environmental properties coming from the policy engine. Null properties cause an * {@link IllegalArgumentException} runtime exception to be thrown -- cgit 1.2.3-korg