diff options
author | Joseph Chou <jc2555@att.com> | 2017-09-06 16:54:33 -0400 |
---|---|---|
committer | Joseph Chou <jc2555@att.com> | 2017-09-12 17:15:44 -0400 |
commit | 5bd93f34b7221c8c141785574082253fcb61d276 (patch) | |
tree | 7d39dc59ed0118f56de79634f078476020fb078c /controlloop | |
parent | 045198cd1a5a73ffe6630e6833e1d021585fb82f (diff) |
ONAP code for AAI, consolidate name and get query
Adding AAI GET query feature to support ONAP project (1 commit)
Issue-ID: POLICY-103
Change-Id: I0a55f41c3edd7a0bc0562ae4e12a19f262a50d74
Signed-off-by: Joseph Chou <jc2555@att.com>
Diffstat (limited to 'controlloop')
32 files changed, 1918 insertions, 23 deletions
diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml index 3efecdc8a..69d858a07 100644 --- a/controlloop/common/eventmanager/pom.xml +++ b/controlloop/common/eventmanager/pom.xml @@ -136,6 +136,11 @@ <version>1.1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> - + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + <scope>provided</scope> + </dependency> </dependencies> </project> 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 b61eabc4b..bc7f3c32d 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 @@ -26,7 +26,11 @@ import java.net.URLDecoder; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; +import java.util.List; import java.util.UUID; +import java.util.HashMap; +import java.util.Map; +import java.util.Iterator; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -45,6 +49,13 @@ import org.onap.policy.guard.TargetLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.onap.policy.aai.AAIManager; +import org.onap.policy.aai.AAIGETVserverResponse; +import org.onap.policy.aai.AAIGETVnfResponse; +import org.onap.policy.aai.RelatedToPropertyItem; +import org.onap.policy.aai.RelationshipList; +import org.onap.policy.aai.Relationship; + public class ControlLoopEventManager implements LockCallback, Serializable { /** @@ -68,6 +79,8 @@ public class ControlLoopEventManager implements LockCallback, Serializable { private LinkedList<ControlLoopOperation> controlLoopHistory = new LinkedList<>(); private ControlLoopOperationManager currentOperation = null; private TargetLock targetLock = null; + private static AAIGETVnfResponse vnfResponse = null; + private static AAIGETVserverResponse vserverResponse = null; private static Collection<String> requiredAAIKeys = new ArrayList<>(); static { @@ -501,6 +514,14 @@ public class ControlLoopEventManager implements LockCallback, Serializable { return 0; } + public AAIGETVnfResponse getVnfResponse() { + return vnfResponse; + } + + public AAIGETVserverResponse getVserverResponse() { + return vserverResponse; + } + public static void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException { if (event.closedLoopEventStatus == null || (event.closedLoopEventStatus != ControlLoopEventStatus.ONSET && @@ -516,14 +537,34 @@ public class ControlLoopEventManager implements LockCallback, Serializable { if (event.AAI == null) { throw new ControlLoopException("AAI is null"); } - if (event.AAI.get("vserver.is-closed-loop-disabled") == null) { - throw new ControlLoopException("vserver.is-closed-loop-disabled information missing"); + if (event.AAI.get("generic-vnf.vnf-id") == null && event.AAI.get("vserver.vserver-name") == null && + event.AAI.get("generic-vnf.vnf-name") == null) { + throw new ControlLoopException("generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing"); } - if (event.AAI.get("vserver.is-closed-loop-disabled").equalsIgnoreCase("true") || - event.AAI.get("vserver.is-closed-loop-disabled").equalsIgnoreCase("T") || - event.AAI.get("vserver.is-closed-loop-disabled").equalsIgnoreCase("yes") || - event.AAI.get("vserver.is-closed-loop-disabled").equalsIgnoreCase("Y")) { - throw new ControlLoopException("vserver.is-closed-loop-disabled is set to true"); + if (event.AAI.get("vserver.is-closed-loop-disabled") == null) { + try { + if (event.AAI.get("generic-vnf.vnf-id") != null) { + vnfResponse = getAAIVnfInfo(event); + if (vnfResponse != null && isClosedLoopDisabled(vnfResponse) == true) { + throw new ControlLoopException("is-closed-loop-disabled is set to true"); + } + } else if (event.AAI.get("generic-vnf.vnf-name") != null) { + vnfResponse = getAAIVnfInfo(event); + if (vnfResponse != null && isClosedLoopDisabled(vnfResponse) == true) { + throw new ControlLoopException("is-closed-loop-disabled is set to true"); + } + } else if (event.AAI.get("vserver.vserver-name") != null) { + vserverResponse = getAAIVserverInfo(event); + if (vserverResponse != null && isClosedLoopDisabled(vserverResponse) == true) { + throw new ControlLoopException("is-closed-loop-disabled is set to true"); + } + } + } catch (Exception e) { + logger.error("Exception from getAAIInfo: ", e); + throw new ControlLoopException("Exception from getAAIInfo: " + e.toString()); + } + } else if (isClosedLoopDisabled(event)) { + throw new ControlLoopException("is-closed-loop-disabled is set to true"); } if (event.target == null || event.target.length() < 1) { throw new ControlLoopException("No target field"); @@ -536,7 +577,90 @@ public class ControlLoopEventManager implements LockCallback, Serializable { } } } + + public static boolean isClosedLoopDisabled(AAIGETVnfResponse aaiResponse) { + RelationshipList relationshipList = new RelationshipList(); + if (aaiResponse != null && aaiResponse.isClosedLoopDisabled != null) { + String value = aaiResponse.isClosedLoopDisabled; + if ("true".equalsIgnoreCase(value) || "T".equalsIgnoreCase(value) || + "yes".equalsIgnoreCase(value) || "Y".equalsIgnoreCase(value)) { + return true; + } + } + + return false; + } + + public static boolean isClosedLoopDisabled(AAIGETVserverResponse aaiResponse) { + RelationshipList relationshipList = new RelationshipList(); + if (aaiResponse != null && aaiResponse.isClosedLoopDisabled != null) { + String value = aaiResponse.isClosedLoopDisabled; + if ("true".equalsIgnoreCase(value) || "T".equalsIgnoreCase(value) || + "yes".equalsIgnoreCase(value) || "Y".equalsIgnoreCase(value)) { + return true; + } + } + + return false; + } + + public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) { + if ("true".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || + "T".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || + "yes".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || + "Y".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled"))) { + return true; + } + return false; + } + + public static AAIGETVserverResponse getAAIVserverInfo(VirtualControlLoopEvent event) throws ControlLoopException { + String user = "POLICY"; + String password = "POLICY"; + UUID requestID = event.requestID; + AAIGETVserverResponse response = null; + String vserverName = event.AAI.get("vserver.vserver-name"); + try { + if (vserverName != null) { + AAIManager manager = new AAIManager(); + String url = "https://aai-ext1.test.att.com:8443/aai/v11/nodes/vservers?vserver-name="; + response = manager.getQueryByVserverName(url, user, password, requestID, vserverName); + } + } catch (Exception e) { + logger.error("getAAIVserverInfo exception: ", e); + throw new ControlLoopException("Exception in getAAIVserverInfo: ", e); + } + + return response; + } + + public static AAIGETVnfResponse getAAIVnfInfo(VirtualControlLoopEvent event) throws ControlLoopException { + String user = "POLICY"; + String password = "POLICY"; + UUID requestID = event.requestID; + AAIGETVnfResponse response = null; + String vnfName = event.AAI.get("generic-vnf.vnf-name"); + String vnfID = event.AAI.get("generic-vnf.vnf-id"); + + try { + if (vnfName != null) { + AAIManager manager = new AAIManager(); + String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf?vnf-name="; + response = manager.getQueryByVnfName(url, user, password, requestID, vnfName); + } else if (vnfID != null) { + AAIManager manager = new AAIManager(); + String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/"; + response = manager.getQueryByVnfID(url, user, password, requestID, vnfID); + } + } catch (Exception e) { + logger.error("getAAIVnfInfo exception: ", e); + throw new ControlLoopException("Exception in getAAIVnfInfo: ", e); + } + + return response; + } + @Override public boolean isActive() { // TODO diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index fa52e8557..ef7a1a94c 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -20,14 +20,259 @@ package org.onap.policy.controlloop.eventmanager; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.time.Instant; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; import org.junit.Test; +import org.onap.policy.aai.AAIGETVserverResponse; +import org.onap.policy.aai.AAIGETVnfResponse; +import org.onap.policy.aai.RelatedToPropertyItem; +import org.onap.policy.aai.Relationship; +import org.onap.policy.aai.RelationshipData; +import org.onap.policy.aai.RelationshipDataItem; +import org.onap.policy.aai.RelationshipList; +import org.onap.policy.aai.AAIManager; +import org.onap.policy.aai.RelatedToProperty; +import org.onap.policy.appc.Request; +import org.onap.policy.appc.Response; +import org.onap.policy.appc.ResponseCode; +import org.onap.policy.appc.ResponseValue; +import org.onap.policy.controlloop.ControlLoopEventStatus; + +import org.onap.policy.controlloop.VirtualControlLoopEvent; +import org.onap.policy.controlloop.ControlLoopException; +import org.onap.policy.controlloop.Util; +import org.onap.policy.controlloop.policy.ControlLoopPolicy; +import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.processor.ControlLoopProcessor; +import org.onap.policy.controlloop.processor.ControlLoopProcessorTest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ControlLoopEventManagerTest { + private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManagerTest.class); + + private static VirtualControlLoopEvent onset; + static { + onset = new VirtualControlLoopEvent(); + onset.closedLoopControlName = "ControlLoop-vUSP"; + onset.requestID = UUID.randomUUID(); + onset.target = "VM_NAME"; + onset.closedLoopAlarmStart = Instant.now(); + onset.AAI = new HashMap<String, String>(); + onset.AAI.put("cloud-region.identity-url", "foo"); + onset.AAI.put("vserver.selflink", "bar"); + onset.AAI.put("generic-vnf.vnf-id", "83f674e8-7555-44d7-9a39-bdc3770b0491"); + onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + } + + @Test + public void testGetAAIInfo() { + final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml"); + onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName(); + try { + ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID); + onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + + String user = "POLICY"; + String password = "POLICY"; + String vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491"; + String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/"; + AAIGETVnfResponse response = getQueryByVnfID2(url, user, password, onset.requestID, vnfID); + assertNotNull(response); + logger.info("testGetAAIInfo test result is " + (response == null ? "null" : "not null")); + } catch (Exception e) { + fail(e.getMessage()); + logger.error("testGetAAIInfo Exception: ", e); + } + } @Test - public void test() { - //fail("MICHAEL - Not yet implemented"); + public void testIsClosedLoopDisabled() { + // + // Load up the policy + // + final Util.Pair<ControlLoopPolicy, String> pair = Util.loadYaml("src/test/resources/test.yaml"); + onset.closedLoopControlName = pair.a.getControlLoop().getControlLoopName(); + + try { + ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID); + onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + + logger.info("testIsClosedLoopDisabled --"); + AAIManager manager = new AAIManager(); + String user = "POLICY"; + String password = "POLICY"; + String vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491"; + String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/"; + AAIGETVnfResponse response = getQueryByVnfID2(url, user, password, onset.requestID, vnfID); + assertNotNull(response); + boolean disabled = eventManager.isClosedLoopDisabled(response); + logger.info("QueryByVnfID - isClosedLoopDisabled: " + disabled); + + String vnfName = "lll_vnf_010317"; + url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf?vnf-name="; + response = getQueryByVnfName2(url, user, password, onset.requestID, vnfName); + assertNotNull(response); + disabled = eventManager.isClosedLoopDisabled(response); + logger.info("QueryByVnfName2 - isClosedLoopDisabled: " + disabled); + + String vserverName = "USMSO1SX7NJ0103UJZZ01-vjunos0"; + url = "https://aai-ext1.test.att.com:8443//aai/v11/nodes/vservers?vserver-name="; + AAIGETVserverResponse response2 = getQueryByVserverName2(url, user, password, onset.requestID, vserverName); + assertNotNull(response); + disabled = eventManager.isClosedLoopDisabled(response); + logger.info("QueryByVserverName - isClosedLoopDisabled: " + disabled); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + // Simulate a response + public static AAIGETVnfResponse getQueryByVnfID2(String urlGet, String username, String password, UUID requestID, String key) { + AAIGETVnfResponse response = new AAIGETVnfResponse(); + + response.vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491"; + response.vnfName = "lll_vnf_010317"; + response.vnfType = "Basa-122216-Service/VidVsamp12BaseVolume 1"; + response.serviceId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; + response.orchestrationStatus = "Created"; + response.inMaint = "false"; + response.isClosedLoopDisabled = "false"; + response.resourceVersion = "1494001988835"; + response.modelInvariantId = "f18be3cd-d446-456e-9109-121d9b62feaa"; + + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + RelationshipData relationshipData = new RelationshipData(); + RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); + + relationshipDataItem.relationshipKey = "customer.global-customer-id"; + relationshipDataItem.relationshipValue = "MSO_1610_ST"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-subscription.service-type"; + relationshipDataItem.relationshipValue = "MSO-dev-service-type"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; + relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationshipData.relationshipData.add(relationshipDataItem); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + RelatedToPropertyItem item = new RelatedToPropertyItem(); + item.propertyKey = "service-instance.service-instance-name"; + item.propertyValue = "lll_svc_010317"; + relatedToProperty.relatedTo.add(item); + + relationship.relatedTo = "service-instance"; + relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationship.relationshipData = relationshipData; + relationship.relatedToProperty = relatedToProperty; + + relationshipList.relationshipList.add(relationship); + response.relationshipList = relationshipList; + + return response; + } + + public static AAIGETVnfResponse getQueryByVnfName2(String urlGet, String username, String password, UUID requestID, String key) { + AAIGETVnfResponse response = new AAIGETVnfResponse(); + + response.vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491"; + response.vnfName = "lll_vnf_010317"; + response.vnfType = "Basa-122216-Service/VidVsamp12BaseVolume 1"; + response.serviceId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; + response.orchestrationStatus = "Created"; + response.inMaint = "false"; + response.isClosedLoopDisabled = "false"; + response.resourceVersion = "1494001988835"; + response.modelInvariantId = "f18be3cd-d446-456e-9109-121d9b62feaa"; + + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + RelationshipData relationshipData = new RelationshipData(); + RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); + + relationshipDataItem.relationshipKey = "customer.global-customer-id"; + relationshipDataItem.relationshipValue = "MSO_1610_ST"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-subscription.service-type"; + relationshipDataItem.relationshipValue = "MSO-dev-service-type"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; + relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationshipData.relationshipData.add(relationshipDataItem); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + RelatedToPropertyItem item = new RelatedToPropertyItem(); + item.propertyKey = "service-instance.service-instance-name"; + item.propertyValue = "lll_svc_010317"; + relatedToProperty.relatedTo.add(item); + + relationship.relatedTo = "service-instance"; + relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationship.relationshipData = relationshipData; + relationship.relatedToProperty = relatedToProperty; + + relationshipList.relationshipList.add(relationship); + response.relationshipList = relationshipList; + + return response; } -} + public static AAIGETVserverResponse getQueryByVserverName2(String urlGet, String username, String password, UUID requestID, String key) { + AAIGETVserverResponse response = new AAIGETVserverResponse(); + + response.vserverID = "d0668d4f-c25e-4a1b-87c4-83845c01efd8"; + response.vserverName = "USMSO1SX7NJ0103UJZZ01-vjunos0"; + response.vserverName2 = "vjunos0"; + response.vserverSelflink = "https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8"; + response.inMaint = "false"; + response.isClosedLoopDisabled = "false"; + response.resourceVersion = "1494001931513"; + + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + RelationshipData relationshipData = new RelationshipData(); + RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); + + relationshipDataItem.relationshipKey = "customer.global-customer-id"; + relationshipDataItem.relationshipValue = "MSO_1610_ST"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-subscription.service-type"; + relationshipDataItem.relationshipValue = "MSO-dev-service-type"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; + relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationshipData.relationshipData.add(relationshipDataItem); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + RelatedToPropertyItem item = new RelatedToPropertyItem(); + item.propertyKey = "service-instance.service-instance-name"; + item.propertyValue = "lll_svc_010317"; + relatedToProperty.relatedTo.add(item); + + relationship.relatedTo = "service-instance"; + relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationship.relationshipData = relationshipData; + relationship.relatedToProperty = relatedToProperty; + + relationshipList.relationshipList.add(relationship); + response.relationshipList = relationshipList; + + return response; + } +}
\ No newline at end of file diff --git a/controlloop/common/model-impl/aai/pom.xml b/controlloop/common/model-impl/aai/pom.xml index da412a138..dcf6f3741 100644 --- a/controlloop/common/model-impl/aai/pom.xml +++ b/controlloop/common/model-impl/aai/pom.xml @@ -22,5 +22,11 @@ <artifactId>rest</artifactId> <version>1.1.0-SNAPSHOT</version> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java new file mode 100644 index 000000000..57140cebe --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponseWrapper.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.UUID; +import org.onap.policy.aai.AAIGETResponse; + +public class AAIGETResponseWrapper implements Serializable { + public UUID requestID; + public AAIGETResponse aairesponse; + + public AAIGETResponseWrapper() { + + } + + public AAIGETResponseWrapper(UUID requestID, AAIGETResponse aairesponse){ + this.requestID = requestID; + this.aairesponse = aairesponse; + } +}
\ No newline at end of file diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java new file mode 100644 index 000000000..24361c7f6 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVnfResponse.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAIGETVnfResponse implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -6247505944905898870L; + + @SerializedName("vnf-id") + public String vnfID; + + @SerializedName("vnf-name") + public String vnfName; + + @SerializedName("vnf-type") + public String vnfType; + + @SerializedName("service-id") + public String serviceId; + + @SerializedName("orchestration-status") + public String orchestrationStatus; + + @SerializedName("in-maint") + public String inMaint; + + @SerializedName("is-closed-loop-disabled") + public String isClosedLoopDisabled; + + @SerializedName("resource-version") + public String resourceVersion; + + @SerializedName("model-invariant-id") + public String modelInvariantId; + + @SerializedName("relationship-list") + public RelationshipList relationshipList; + + public AAIGETVnfResponse() { + } + +}
\ No newline at end of file diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java new file mode 100644 index 000000000..b318f72ef --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETVserverResponse.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class AAIGETVserverResponse implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -6247505944905898870L; + + @SerializedName("vserver-id") + public String vserverID; + + @SerializedName("vserver-name") + public String vserverName; + + @SerializedName("vserver-name2") + public String vserverName2; + + @SerializedName("vserver-selflink") + public String vserverSelflink; + + @SerializedName("in-maint") + public String inMaint; + + @SerializedName("is-closed-loop-disabled") + public String isClosedLoopDisabled; + + @SerializedName("resource-version") + public String resourceVersion; + + @SerializedName("model-invariant-id") + public String modelInvariantId; + + public RelationshipList relationshipList; + + public AAIGETVserverResponse() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java new file mode 100644 index 000000000..51954ac6f --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIManager.java @@ -0,0 +1,201 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.onap.policy.aai.AAIGETVserverResponse; +import org.onap.policy.aai.AAIGETVnfResponse; +import org.onap.policy.aai.RelatedToPropertyItem; +import org.onap.policy.aai.RelationshipDataItem; +import org.onap.policy.aai.RelationshipData; +import org.onap.policy.aai.util.Serialization; +import org.onap.policy.aai.AAINQRequest; +import org.onap.policy.aai.AAINQResponse; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.JsonSyntaxException; + +public final class AAIManager { + private static final Logger logger = LoggerFactory.getLogger(AAIManager.class); + + public static AAINQResponse postQuery(String url, String username, String password, AAINQRequest request, UUID requestID) { + + Map<String, String> headers = new HashMap<>(); + headers.put("X-FromAppId", "POLICY"); + headers.put("X-TransactionId", requestID.toString()); + headers.put("Accept", "application/json"); + + url = url + "/aai/search/named-query"; + + logger.debug("ESTManager.post before"); + Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request)); + logger.debug("ESTManager.post after"); + + if (httpDetails == null) { + logger.info("AAI POST Null Response to " + url); + return null; + } + + logger.info(url); + logger.info(httpDetails.a.toString()); + logger.info(httpDetails.b); + if (httpDetails.a == 200) { + try { + AAINQResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQResponse.class); + return response; + } catch (JsonSyntaxException e) { + logger.error("postQuery threw: ", e); + } + } + + return null; + } + + public static AAIGETVserverResponse getQueryByVserverName(String urlGet, String username, String password, UUID requestID, String key) { + + Map<String, String> headers = new HashMap<>(); + headers.put("X-FromAppId", "POLICY"); + headers.put("X-TransactionId", requestID.toString()); + headers.put("Accept", "application/json"); + + urlGet = urlGet + key; + + int attemptsLeft = 3; + AAIGETVserverResponse responseGet = null; + + while(attemptsLeft-- > 0){ + + Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers); + if (httpDetailsGet == null) { + logger.info("AAI GET Null Response to " + urlGet); + return null; + } + + logger.info(urlGet); + logger.info(httpDetailsGet.a.toString()); + logger.info(httpDetailsGet.b); + + if (httpDetailsGet.a == 200) { + try { + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVserverResponse.class); + return responseGet; + } catch (JsonSyntaxException e) { + logger.error("postQuery threw: ", e); + } + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { Thread.currentThread().interrupt(); } + } + + return null; + } + + public static AAIGETVnfResponse getQueryByVnfID(String urlGet, String username, String password, UUID requestID, String key) { + + Map<String, String> headers = new HashMap<>(); + headers.put("X-FromAppId", "POLICY"); + headers.put("X-TransactionId", requestID.toString()); + headers.put("Accept", "application/json"); + + urlGet = urlGet + key; + + int attemptsLeft = 3; + AAIGETVnfResponse responseGet = null; + + while(attemptsLeft-- > 0){ + + Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers); + if (httpDetailsGet == null) { + logger.info("AAI GET Null Response to " + urlGet); + return null; + } + + logger.info(urlGet); + logger.info(httpDetailsGet.a.toString()); + logger.info(httpDetailsGet.b); + + if (httpDetailsGet.a == 200) { + try { + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVnfResponse.class); + return responseGet; + } catch (JsonSyntaxException e) { + logger.error("postQuery threw: ", e); + } + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { Thread.currentThread().interrupt(); } + + } + + return null; + } + + public static AAIGETVnfResponse getQueryByVnfName(String urlGet, String username, String password, UUID requestID, String key) { + + Map<String, String> headers = new HashMap<>(); + headers.put("X-FromAppId", "POLICY"); + headers.put("X-TransactionId", requestID.toString()); + headers.put("Accept", "application/json"); + + urlGet = urlGet + key; + + int attemptsLeft = 3; + AAIGETVnfResponse responseGet = null; + + while(attemptsLeft-- > 0){ + + Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers); + if (httpDetailsGet == null) { + logger.info("AAI GET Null Response to " + urlGet); + return null; + } + + logger.info(urlGet); + logger.info(httpDetailsGet.a.toString()); + logger.info(httpDetailsGet.b); + + if (httpDetailsGet.a == 200) { + try { + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETVnfResponse.class); + return responseGet; + } catch (JsonSyntaxException e) { + logger.error("postQuery threw: ", e); + } + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { Thread.currentThread().interrupt(); } + + } + + return null; + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java new file mode 100644 index 000000000..cbe2b9730 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQCloudRegion.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQCloudRegion implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -897231529157222683L; + + @SerializedName("cloud-owner") + public String cloudOwner; + + @SerializedName("cloud-region-id") + public String cloudRegionId; + + @SerializedName("cloud-region-version") + public String cloudRegionVersion; + + @SerializedName("complex-name") + public String complexName; + + @SerializedName("resource-version") + public String resourceVersion; + + public AAINQCloudRegion() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java new file mode 100644 index 000000000..6f451ce8d --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperties.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class AAINQExtraProperties implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 4109625574744702319L; + + @SerializedName("extra-property") + public List<AAINQExtraProperty> extraProperty = new LinkedList<AAINQExtraProperty>(); + + public AAINQExtraProperties() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperty.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperty.java new file mode 100644 index 000000000..4a968c5e6 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQExtraProperty.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQExtraProperty implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3861240617222397736L; + + @SerializedName("property-name") + public String propertyName; + + @SerializedName("property-value") + public String propertyValue; + + public AAINQExtraProperty() { + } + + public AAINQExtraProperty(String propertyName, String propertyValue) { + this.propertyName = propertyName; + this.propertyValue = propertyValue; + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java new file mode 100644 index 000000000..beec3204d --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQGenericVNF.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQGenericVNF implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 834322706248060559L; + + @SerializedName("vnf-id") + public String vnfID; + + @SerializedName("vnf-name") + public String vnfName; + + @SerializedName("vnf-name2") + public String vnfName2; + + @SerializedName("vnf-type") + public String vnfType; + + @SerializedName("service-id") + public String serviceId; + + @SerializedName("prov-status") + public String provStatus; + + @SerializedName("operational-state") + public String operationalState; + + @SerializedName("ipv4-oam-address") + public String ipv4OamAddress; + + @SerializedName("ipv4-loopback0-address") + public String ipv4Loopback0Address; + + @SerializedName("in-maint") + public Boolean inMaint; + + @SerializedName("is-closed-loop-disabled") + public Boolean isClosedLoopDisabled; + + @SerializedName("resource-version") + public String resourceVersion; + + @SerializedName("encrypted-access-flag") + public Boolean encrypedAccessFlag; + + @SerializedName("persona-model-id") + public String personaModelId; + + @SerializedName("persona-model-version") + public String personaModelVersion; + + @SerializedName("model-invariant-id") + public String modelInvariantId; + + public AAINQGenericVNF() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java new file mode 100644 index 000000000..b122279d6 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInstanceFilters.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.google.gson.annotations.SerializedName; + +public class AAINQInstanceFilters implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8993824591338121185L; + + @SerializedName("instance-filter") + public List<Map<String, Map<String, String>>> instanceFilter = new LinkedList<>(); + + public AAINQInstanceFilters() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java new file mode 100644 index 000000000..1dece7da0 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItem.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQInventoryResponseItem implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7142072567154675183L; + + @SerializedName("model-name") + public String modelName; + + @SerializedName("vf-module") + public AAINQVfModule vfModule; + + @SerializedName("service-instance") + public AAINQServiceInstance serviceInstance; + + @SerializedName("vserver") + public AAINQVServer vserver; + + @SerializedName("tenant") + public AAINQTenant tenant; + + @SerializedName("cloud-region") + public AAINQCloudRegion cloudRegion; + + @SerializedName("generic-vnf") + public AAINQGenericVNF genericVNF; + + @SerializedName("extra-properties") + public AAINQExtraProperties extraProperties; + + @SerializedName("inventory-response-items") + public AAINQInventoryResponseItems items; + + public AAINQInventoryResponseItem() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java new file mode 100644 index 000000000..f4ee0fa3e --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQInventoryResponseItems.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class AAINQInventoryResponseItems implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7602807659381179004L; + + @SerializedName("inventory-response-item") + public List<AAINQInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); + + public AAINQInventoryResponseItems() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java new file mode 100644 index 000000000..7ed82e1e9 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQNamedQuery.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.UUID; + +import com.google.gson.annotations.SerializedName; + +public class AAINQNamedQuery implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3277980060302645333L; + + @SerializedName("named-query-uuid") + public UUID namedQueryUUID; + + public AAINQNamedQuery() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java new file mode 100644 index 000000000..eca372bf6 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQQueryParameters.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQQueryParameters implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -4291227193197126982L; + + @SerializedName("named-query") + public AAINQNamedQuery namedQuery; + + public AAINQQueryParameters() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java new file mode 100644 index 000000000..91d9f1a6e --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQRequest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQRequest implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("query-parameters") + public AAINQQueryParameters queryParameters; + @SerializedName("instance-filters") + public AAINQInstanceFilters instanceFilters; + + public AAINQRequest() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java new file mode 100644 index 000000000..09f983094 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponse.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import org.onap.policy.aai.AAINQInventoryResponseItem; + +public class AAINQResponse implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8411407444051746101L; + + @SerializedName("inventory-response-item") + public List<AAINQInventoryResponseItem> inventoryResponseItems = new LinkedList<>(); + + public AAINQResponse() { + } + +}
\ No newline at end of file diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java new file mode 100644 index 000000000..7bb58eb7d --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQResponseWrapper.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.util.UUID; + +import org.onap.policy.aai.AAINQResponse; + +public class AAINQResponseWrapper { + + public UUID requestID; + public AAINQResponse aainqresponse; + + public AAINQResponseWrapper() { + + } + + public AAINQResponseWrapper(UUID requestID, AAINQResponse aainqresponse){ + this.requestID = requestID; + this.aainqresponse = aainqresponse; + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java new file mode 100644 index 000000000..c6efac781 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQServiceInstance.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQServiceInstance implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8000944396593889586L; + + @SerializedName("service-instance-id") + public String serviceInstanceID; + + @SerializedName("service-instance-name") + public String serviceInstanceName; + + @SerializedName("persona-model-id") + public String personaModelId; + + @SerializedName("persona-model-version") + public String personaModelVersion; + + @SerializedName("service-instance-location-id") + public String serviceInstanceLocationId; + + @SerializedName("resource-version") + public String resourceVersion; + + public AAINQServiceInstance() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java new file mode 100644 index 000000000..98ea83b1f --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQTenant.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQTenant implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 4702784101671984364L; + + @SerializedName("tenant-id") + public String tenantId; + + @SerializedName("tenant-name") + public String tenantName; + + @SerializedName("resource-version") + public String resourceVersion; + + public AAINQTenant() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java new file mode 100644 index 000000000..5a9834fee --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVServer.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQVServer implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -6718526692734215643L; + + @SerializedName("vserver-id") + public String vserverId; + + @SerializedName("vserver-name") + public String vserverName; + + @SerializedName("vserver-name2") + public String vserverName2; + + @SerializedName("prov-status") + public String provStatus; + + @SerializedName("vserver-selflink") + public String vserverSelflink; + + @SerializedName("in-maint") + public Boolean inMaint; + + @SerializedName("is-closed-loop-disabled") + public Boolean isClosedLoopDisabled; + + @SerializedName("resource-version") + public String resourceVersion; + + public AAINQVServer() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java new file mode 100644 index 000000000..d3249d834 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQVfModule.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQVfModule implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8019133081429638231L; + + @SerializedName("vf-module-id") + public String vfModuleId; + + @SerializedName("vf-module-name") + public String vfModuleName; + + @SerializedName("heat-stack-id") + public String heatStackId; + + @SerializedName("orchestration-status") + public String orchestrationStatus; + + @SerializedName("is-base-vf-module") + public Boolean isBaseVfModule; + + @SerializedName("resource-version") + public String resourceVersion; + + @SerializedName("persona-model-id") + public String personaModelId; + + @SerializedName("persona-model-version") + public String personaModelVersion; + + @SerializedName("widget-model-id") + public String widgetModelId; + + @SerializedName("widget-model-version") + public String widgetModelVersion; + + @SerializedName("contrail-service-instance-fqdn") + public String contrailServiceInstanceFqdn; + + public AAINQVfModule() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java new file mode 100644 index 000000000..12e80d50e --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToProperty.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class RelatedToProperty { + + @SerializedName("related-to-property") + public List<RelatedToPropertyItem> relatedTo = new LinkedList<RelatedToPropertyItem>(); + + public RelatedToProperty() { + } +} + +
\ No newline at end of file diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java new file mode 100644 index 000000000..8ceb067b1 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/Relationship.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import com.google.gson.annotations.SerializedName; + +public class Relationship { + + @SerializedName("related-to") + public String relatedTo; + @SerializedName("related-link") + public String relatedLink; + + @SerializedName("relationship-data") + public RelationshipData relationshipData = new RelationshipData(); + + @SerializedName("related-to-property") + public RelatedToProperty relatedToProperty = new RelatedToProperty(); + + public Relationship() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java new file mode 100644 index 000000000..e5bc05599 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipData.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.util.List; +import java.util.LinkedList; + +import com.google.gson.annotations.SerializedName; + +public class RelationshipData { + + @SerializedName("relationship-data") + public List<RelationshipDataItem> relationshipData = new LinkedList<>(); + + public RelationshipData() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java new file mode 100644 index 000000000..9b207ef68 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipDataItem.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import java.util.List; +import java.util.LinkedList; + +import com.google.gson.annotations.SerializedName; + +public class RelationshipDataItem { + + @SerializedName("relationship-key") + public String relationshipKey; + @SerializedName("relationship-value") + public String relationshipValue; + + public RelationshipDataItem() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java index 4799733da..14f601730 100644 --- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java @@ -20,22 +20,16 @@ package org.onap.policy.aai; -import java.util.List; -import java.io.Serializable; -import java.util.LinkedList; - import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +import java.util.List; +import java.util.LinkedList; -public class RelationshipList implements Serializable { +public class RelationshipList { - /** - * - */ - private static final long serialVersionUID = -1769880386474240406L; - @SerializedName("relationship") - public List<RelationshipItem> relationship = new LinkedList<RelationshipItem>(); + @SerializedName("relationship-list") + public List<Relationship> relationshipList = new LinkedList<>(); public RelationshipList() { } - } diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java new file mode 100644 index 000000000..3b489155c --- /dev/null +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVnfResponseTest.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.*; +import java.util.List; +import java.util.LinkedList; +import org.onap.policy.aai.RelationshipDataItem; +import org.onap.policy.aai.RelationshipData; +import org.onap.policy.aai.RelatedToPropertyItem; +import org.onap.policy.aai.Relationship; +import org.onap.policy.aai.RelatedToProperty; +import org.onap.policy.aai.RelationshipList; +import org.onap.policy.aai.util.Serialization; +import org.onap.policy.aai.AAIGETVnfResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.junit.Test; + +public class AAIGETVnfResponseTest { + private static final Logger logger = LoggerFactory.getLogger(AAIGETVnfResponseTest.class); + + @Test + public void test() { + AAIGETVnfResponse response = new AAIGETVnfResponse(); + + response.vnfID = "83f674e8-7555-44d7-9a39-bdc3770b0491"; + response.vnfName = "lll_vnf_010317"; + response.vnfType = "Basa-122216-Service/VidVsamp12BaseVolume 1"; + response.serviceId = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"; + response.orchestrationStatus = "Created"; + response.inMaint = "false"; + response.isClosedLoopDisabled = "false"; + response.resourceVersion = "1494001988835"; + response.modelInvariantId = "f18be3cd-d446-456e-9109-121d9b62feaa"; + + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + RelationshipData relationshipData = new RelationshipData(); + RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); + + relationshipDataItem.relationshipKey = "customer.global-customer-id"; + relationshipDataItem.relationshipValue = "MSO_1610_ST"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-subscription.service-type"; + relationshipDataItem.relationshipValue = "MSO-dev-service-type"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; + relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationshipData.relationshipData.add(relationshipDataItem); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + RelatedToPropertyItem item = new RelatedToPropertyItem(); + item.propertyKey = "service-instance.service-instance-name"; + item.propertyValue = "lll_svc_010317"; + relatedToProperty.relatedTo.add(item); + + relationship.relatedTo = "service-instance"; + relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationship.relationshipData = relationshipData; + relationship.relatedToProperty = relatedToProperty; + + relationshipList.relationshipList.add(relationship); + response.relationshipList = relationshipList; + + logger.info(Serialization.gsonPretty.toJson(response)); + } +} diff --git a/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java new file mode 100644 index 000000000..b24826576 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AAIGETVserverResponseTest.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * aai + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.aai; + +import static org.junit.Assert.*; +import java.util.List; +import java.util.LinkedList; +import org.onap.policy.aai.RelationshipDataItem; +import org.onap.policy.aai.RelationshipData; +import org.onap.policy.aai.RelatedToPropertyItem; +import org.onap.policy.aai.Relationship; +import org.onap.policy.aai.RelatedToProperty; +import org.onap.policy.aai.RelationshipList; +import org.onap.policy.aai.util.Serialization; +import org.onap.policy.aai.AAIGETVserverResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.junit.Test; + +public class AAIGETVserverResponseTest { + private static final Logger logger = LoggerFactory.getLogger(AAIGETVserverResponseTest.class); + + @Test + public void test() { + AAIGETVserverResponse response = new AAIGETVserverResponse(); + + response.vserverID = "d0668d4f-c25e-4a1b-87c4-83845c01efd8"; + response.vserverName = "USMSO1SX7NJ0103UJZZ01-vjunos0"; + response.vserverName2 = "vjunos0"; + response.vserverSelflink = "https://aai-ext1.test.aaa.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/aaa-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8"; + response.inMaint = "false"; + response.isClosedLoopDisabled = "false"; + response.resourceVersion = "1494001931513"; + + RelationshipList relationshipList = new RelationshipList(); + Relationship relationship = new Relationship(); + RelationshipData relationshipData = new RelationshipData(); + RelationshipDataItem relationshipDataItem = new RelationshipDataItem(); + + relationshipDataItem.relationshipKey = "customer.global-customer-id"; + relationshipDataItem.relationshipValue = "MSO_1610_ST"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-subscription.service-type"; + relationshipDataItem.relationshipValue = "MSO-dev-service-type"; + relationshipData.relationshipData.add(relationshipDataItem); + + relationshipDataItem.relationshipKey = "service-instance.service-instance-id"; + relationshipDataItem.relationshipValue = "e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationshipData.relationshipData.add(relationshipDataItem); + + RelatedToProperty relatedToProperty = new RelatedToProperty(); + RelatedToPropertyItem item = new RelatedToPropertyItem(); + item.propertyKey = "service-instance.service-instance-name"; + item.propertyValue = "lll_svc_010317"; + relatedToProperty.relatedTo.add(item); + + relationship.relatedTo = "service-instance"; + relationship.relatedLink = "/aai/v11/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/e1e9c97c-02c0-4919-9b4c-eb5d5ef68970"; + relationship.relationshipData = relationshipData; + relationship.relatedToProperty = relatedToProperty; + + relationshipList.relationshipList.add(relationship); + response.relationshipList = relationshipList; + + logger.info(Serialization.gsonPretty.toJson(response)); + } + +}
\ No newline at end of file diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/pom.xml b/controlloop/templates/template.demo.v1.0.0/template.demo/pom.xml index 33abe7786..ff344473c 100644 --- a/controlloop/templates/template.demo.v1.0.0/template.demo/pom.xml +++ b/controlloop/templates/template.demo.v1.0.0/template.demo/pom.xml @@ -103,5 +103,17 @@ <version>${project.version}</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>4.5.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>4.4.4</version> + <scope>test</scope> + </dependency> </dependencies> </project> |