From 68377161605e39c8c74ea77d0b504177480788f3 Mon Sep 17 00:00:00 2001 From: "Gao, Chenfei (cg287m)" Date: Thu, 22 Jun 2017 14:48:41 -0400 Subject: [POLICY-22] Reorganizing drools-apps Change-Id: I5f9bb3908f8d55c466dd847ae5e01a424e9ba364 Signed-off-by: Gao, Chenfei (cg287m) Signed-off-by: Pamela Dragosh --- controlloop/common/model-impl/aai/pom.xml | 26 ++++ .../java/org/onap/policy/aai/AAIGETResponse.java | 40 +++++ .../policy/aai/AAINQF199/AAINQF199CloudRegion.java | 51 ++++++ .../aai/AAINQF199/AAINQF199ExtraProperties.java | 42 +++++ .../aai/AAINQF199/AAINQF199ExtraProperty.java | 48 ++++++ .../policy/aai/AAINQF199/AAINQF199GenericVNF.java | 82 ++++++++++ .../aai/AAINQF199/AAINQF199InstanceFilters.java | 43 ++++++ .../AAINQF199/AAINQF199InventoryResponseItem.java | 64 ++++++++ .../AAINQF199/AAINQF199InventoryResponseItems.java | 42 +++++ .../policy/aai/AAINQF199/AAINQF199Manager.java | 108 +++++++++++++ .../policy/aai/AAINQF199/AAINQF199NamedQuery.java | 41 +++++ .../aai/AAINQF199/AAINQF199QueryParameters.java | 40 +++++ .../policy/aai/AAINQF199/AAINQF199Request.java | 65 ++++++++ .../aai/AAINQF199/AAINQF199RequestWrapper.java | 39 +++++ .../policy/aai/AAINQF199/AAINQF199Response.java | 42 +++++ .../aai/AAINQF199/AAINQF199ResponseWrapper.java | 40 +++++ .../aai/AAINQF199/AAINQF199ServiceInstance.java | 55 +++++++ .../onap/policy/aai/AAINQF199/AAINQF199Tenant.java | 45 ++++++ .../policy/aai/AAINQF199/AAINQF199VServer.java | 54 +++++++ .../policy/aai/AAINQF199/AAINQF199VfModule.java | 69 +++++++++ .../aai/src/main/java/org/onap/policy/aai/PNF.java | 75 +++++++++ .../main/java/org/onap/policy/aai/PNFInstance.java | 97 ++++++++++++ .../src/main/java/org/onap/policy/aai/PNFType.java | 39 +++++ .../org/onap/policy/aai/RelatedToPropertyItem.java | 35 +++++ .../java/org/onap/policy/aai/RelationshipItem.java | 36 +++++ .../java/org/onap/policy/aai/RelationshipList.java | 36 +++++ .../org/onap/policy/aai/util/Serialization.java | 32 ++++ controlloop/common/model-impl/appc/pom.xml | 45 ++++++ .../java/org/onap/policy/appc/CommonHeader.java | 124 +++++++++++++++ .../main/java/org/onap/policy/appc/Request.java | 104 +++++++++++++ .../main/java/org/onap/policy/appc/Response.java | 112 ++++++++++++++ .../java/org/onap/policy/appc/ResponseCode.java | 63 ++++++++ .../java/org/onap/policy/appc/ResponseStatus.java | 70 +++++++++ .../java/org/onap/policy/appc/ResponseValue.java | 61 ++++++++ .../org/onap/policy/appc/util/Serialization.java | 82 ++++++++++ .../appc/src/main/resources/definitions.yaml | 118 ++++++++++++++ controlloop/common/model-impl/events/README.md | 7 + controlloop/common/model-impl/events/pom.xml | 16 ++ .../onap/policy/controlloop/ControlLoopEvent.java | 69 +++++++++ .../policy/controlloop/ControlLoopEventStatus.java | 54 +++++++ .../controlloop/ControlLoopNotification.java | 62 ++++++++ .../controlloop/ControlLoopNotificationType.java | 72 +++++++++ .../policy/controlloop/ControlLoopOperation.java | 139 +++++++++++++++++ .../controlloop/ControlLoopOperationWrapper.java | 38 +++++ .../policy/controlloop/ControlLoopTargetType.java | 55 +++++++ .../controlloop/PhysicalControlLoopEvent.java | 41 +++++ .../PhysicalControlLoopNotification.java | 40 +++++ .../controlloop/VirtualControlLoopEvent.java | 52 +++++++ .../VirtualControlLoopNotification.java | 53 +++++++ .../policy/controlloop/util/Serialization.java | 124 +++++++++++++++ .../events/src/main/resources/definitions.yaml | 114 ++++++++++++++ controlloop/common/model-impl/mso/pom.xml | 51 ++++++ .../org/onap/policy/mso/MSOAsyncRequestStatus.java | 63 ++++++++ .../org/onap/policy/mso/MSOCloudConfiguration.java | 44 ++++++ .../org/onap/policy/mso/MSOInstanceReferences.java | 44 ++++++ .../main/java/org/onap/policy/mso/MSOManager.java | 102 ++++++++++++ .../java/org/onap/policy/mso/MSOModelInfo.java | 56 +++++++ .../org/onap/policy/mso/MSOPolicyException.java | 43 ++++++ .../org/onap/policy/mso/MSORelatedInstance.java | 49 ++++++ .../policy/mso/MSORelatedInstanceListElement.java | 42 +++++ .../main/java/org/onap/policy/mso/MSORequest.java | 60 +++++++ .../org/onap/policy/mso/MSORequestDetails.java | 57 +++++++ .../java/org/onap/policy/mso/MSORequestError.java | 59 +++++++ .../java/org/onap/policy/mso/MSORequestInfo.java | 66 ++++++++ .../org/onap/policy/mso/MSORequestParameters.java | 47 ++++++ .../org/onap/policy/mso/MSORequestReferences.java | 38 +++++ .../java/org/onap/policy/mso/MSORequestStatus.java | 51 ++++++ .../main/java/org/onap/policy/mso/MSOResponse.java | 48 ++++++ .../org/onap/policy/mso/MSOServiceException.java | 48 ++++++ .../org/onap/policy/mso/MSOSubscriberInfo.java | 47 ++++++ .../org/onap/policy/mso/util/Serialization.java | 32 ++++ .../java/org/openecomp/policy/mso/TestDemo.java | 172 +++++++++++++++++++++ controlloop/common/model-impl/pom.xml | 46 ++++++ controlloop/common/model-impl/rest/pom.xml | 52 +++++++ .../java/org/onap/policy/rest/RESTManager.java | 115 ++++++++++++++ controlloop/common/model-impl/sdc/README.md | 3 + controlloop/common/model-impl/sdc/pom.xml | 11 ++ .../main/java/org/onap/policy/sdc/Resource.java | 119 ++++++++++++++ .../java/org/onap/policy/sdc/ResourceInstance.java | 109 +++++++++++++ .../java/org/onap/policy/sdc/ResourceType.java | 40 +++++ .../src/main/java/org/onap/policy/sdc/Service.java | 111 +++++++++++++ .../java/org/onap/policy/sdc/ServiceInstance.java | 121 +++++++++++++++ .../sdc/src/main/resources/definitions.yaml | 76 +++++++++ .../sdc/src/test/resources/service_trinity.yaml | 3 + .../sdc/src/test/resources/service_vSCP.yaml | 2 + .../sdc/src/test/resources/service_vUSP.yaml | 2 + .../common/model-impl/trafficgenerator/pom.xml | 46 ++++++ .../policy/vnf/trafficgenerator/PGRequest.java | 41 +++++ .../onap/policy/vnf/trafficgenerator/PGStream.java | 42 +++++ .../policy/vnf/trafficgenerator/PGStreams.java | 42 +++++ .../vnf/trafficgenerator/util/Serialization.java | 32 ++++ .../onap/policy/vnf/trafficgenerator/TestDemo.java | 51 ++++++ 92 files changed, 5384 insertions(+) create mode 100644 controlloop/common/model-impl/aai/pom.xml create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199CloudRegion.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperties.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperty.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199GenericVNF.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InstanceFilters.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199NamedQuery.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199QueryParameters.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Request.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199RequestWrapper.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Response.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ServiceInstance.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Tenant.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VServer.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VfModule.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFType.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java create mode 100644 controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java create mode 100644 controlloop/common/model-impl/appc/pom.xml create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java create mode 100644 controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java create mode 100644 controlloop/common/model-impl/appc/src/main/resources/definitions.yaml create mode 100644 controlloop/common/model-impl/events/README.md create mode 100644 controlloop/common/model-impl/events/pom.xml create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java create mode 100644 controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java create mode 100644 controlloop/common/model-impl/events/src/main/resources/definitions.yaml create mode 100644 controlloop/common/model-impl/mso/pom.xml create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOAsyncRequestStatus.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOCloudConfiguration.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOInstanceReferences.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOModelInfo.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOPolicyException.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstance.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstanceListElement.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequest.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestDetails.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestError.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestInfo.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestParameters.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestReferences.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestStatus.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOResponse.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOServiceException.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOSubscriberInfo.java create mode 100644 controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/util/Serialization.java create mode 100644 controlloop/common/model-impl/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java create mode 100644 controlloop/common/model-impl/pom.xml create mode 100644 controlloop/common/model-impl/rest/pom.xml create mode 100644 controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java create mode 100644 controlloop/common/model-impl/sdc/README.md create mode 100644 controlloop/common/model-impl/sdc/pom.xml create mode 100644 controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java create mode 100644 controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java create mode 100644 controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java create mode 100644 controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java create mode 100644 controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java create mode 100644 controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml create mode 100644 controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml create mode 100644 controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml create mode 100644 controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml create mode 100644 controlloop/common/model-impl/trafficgenerator/pom.xml create mode 100644 controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java create mode 100644 controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java create mode 100644 controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java create mode 100644 controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java create mode 100644 controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java (limited to 'controlloop/common/model-impl') diff --git a/controlloop/common/model-impl/aai/pom.xml b/controlloop/common/model-impl/aai/pom.xml new file mode 100644 index 000000000..da412a138 --- /dev/null +++ b/controlloop/common/model-impl/aai/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + + aai + + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + + + + com.google.code.gson + gson + 2.5 + provided + + + org.onap.policy.drools-applications + rest + 1.1.0-SNAPSHOT + + + diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.java new file mode 100644 index 000000000..d2e2d710f --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAIGETResponse.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 AAIGETResponse implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7311418432051756161L; + + @SerializedName("relationship-list") + public RelationshipList relationshipList; + + public AAIGETResponse() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199CloudRegion.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199CloudRegion.java new file mode 100644 index 000000000..4c80c4a41 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199CloudRegion.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199CloudRegion 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 AAINQF199CloudRegion() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperties.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperties.java new file mode 100644 index 000000000..ca5863a46 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperties.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.AAINQF199; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199ExtraProperties implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 4109625574744702319L; + + @SerializedName("extra-property") + public List extraProperty = new LinkedList(); + + public AAINQF199ExtraProperties() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperty.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperty.java new file mode 100644 index 000000000..7280ff9bc --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperty.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199ExtraProperty implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3861240617222397736L; + + @SerializedName("property-name") + public String propertyName; + + @SerializedName("property-value") + public String propertyValue; + + public AAINQF199ExtraProperty() { + } + + public AAINQF199ExtraProperty(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/AAINQF199/AAINQF199GenericVNF.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199GenericVNF.java new file mode 100644 index 000000000..8d667bb75 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199GenericVNF.java @@ -0,0 +1,82 @@ +/*- + * ============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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199GenericVNF 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; + + public AAINQF199GenericVNF() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InstanceFilters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InstanceFilters.java new file mode 100644 index 000000000..80ab73d74 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InstanceFilters.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.AAINQF199; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199InstanceFilters implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8993824591338121185L; + + @SerializedName("instance-filter") + public List>> instanceFilter = new LinkedList>>(); + + public AAINQF199InstanceFilters() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java new file mode 100644 index 000000000..d896c931b --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199InventoryResponseItem implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7142072567154675183L; + + @SerializedName("model-name") + public String modelName; + + @SerializedName("vf-module") + public AAINQF199VfModule vfModule; + + @SerializedName("service-instance") + public AAINQF199ServiceInstance serviceInstance; + + @SerializedName("vserver") + public AAINQF199VServer vserver; + + @SerializedName("tenant") + public AAINQF199Tenant tenant; + + @SerializedName("cloud-region") + public AAINQF199CloudRegion cloudRegion; + + @SerializedName("generic-vnf") + public AAINQF199GenericVNF genericVNF; + + @SerializedName("extra-properties") + public AAINQF199ExtraProperties extraProperties; + + @SerializedName("inventory-response-items") + public AAINQF199InventoryResponseItems items; + + public AAINQF199InventoryResponseItem() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java new file mode 100644 index 000000000..d3d17093f --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.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.AAINQF199; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199InventoryResponseItems implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7602807659381179004L; + + @SerializedName("inventory-response-item") + public List inventoryResponseItems = new LinkedList(); + + public AAINQF199InventoryResponseItems() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java new file mode 100644 index 000000000..e02021a43 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java @@ -0,0 +1,108 @@ +/*- + * ============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.AAINQF199; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.onap.policy.aai.AAIGETResponse; +import org.onap.policy.aai.util.Serialization; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; + +import com.google.gson.JsonSyntaxException; + +public final class AAINQF199Manager { + + public static AAINQF199Response postQuery(String url, String username, String password, AAINQF199Request request, UUID requestID) { + + Map 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"; + + Pair httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request)); + + if (httpDetails == null) { + System.out.println("AAI POST Null Response to " + url); + return null; + } + + System.out.println(url); + System.out.println(httpDetails.a); + System.out.println(httpDetails.b); + if (httpDetails.a == 200) { + try { + AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class); + return response; + } catch (JsonSyntaxException e) { + System.err.println("Failed to deserialize into AAIResponse" + e.getLocalizedMessage()); + } + } + + return null; + } + + public static AAIGETResponse getQuery(String urlGet, String username, String password, UUID requestID, String vnfId) { + + Map headers = new HashMap(); + headers.put("X-FromAppId", "POLICY"); + headers.put("X-TransactionId", requestID.toString()); + headers.put("Accept", "application/json"); + + urlGet = urlGet + "/aai/v8/network/generic-vnfs/generic-vnf/" + vnfId; + + int attemptsLeft = 3; + AAIGETResponse responseGet = null; + + while(attemptsLeft-- > 0){ + + Pair httpDetailsGet = RESTManager.get(urlGet, username, password, headers); + if (httpDetailsGet == null) { + System.out.println("AAI GET Null Response to " + urlGet); + return null; + } + + System.out.println(urlGet); + System.out.println(httpDetailsGet.a); + System.out.println(httpDetailsGet.b); + + if (httpDetailsGet.a == 200) { + try { + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETResponse.class); + return responseGet; + } catch (JsonSyntaxException e) { + System.err.println("Failed to deserialize into AAIResponse" + e.getLocalizedMessage()); + } + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) {} + + } + + return null; + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199NamedQuery.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199NamedQuery.java new file mode 100644 index 000000000..922d67f39 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199NamedQuery.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.AAINQF199; + +import java.io.Serializable; +import java.util.UUID; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199NamedQuery implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3277980060302645333L; + + @SerializedName("named-query-uuid") + public UUID namedQueryUUID; + + public AAINQF199NamedQuery() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199QueryParameters.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199QueryParameters.java new file mode 100644 index 000000000..8812a2483 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199QueryParameters.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199QueryParameters implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -4291227193197126982L; + + @SerializedName("named-query") + public AAINQF199NamedQuery namedQuery; + + public AAINQF199QueryParameters() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Request.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Request.java new file mode 100644 index 000000000..0feb6d73b --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Request.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + + +/* + * + * { + "query-parameters": { + "named-query": { + "named-query-uuid": "f199cb88-5e69-4b1f-93e0-6f257877d066" + } + }, + "instance-filters": { + "instance-filter": [ + { + "vserver": { + "vserver-name": "dfw1lb01lb01" + } + } + ] + } +} + + * + */ + +public class AAINQF199Request implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("query-parameters") + public AAINQF199QueryParameters queryParameters; + @SerializedName("instance-filters") + public AAINQF199InstanceFilters instanceFilters; + + public AAINQF199Request() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199RequestWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199RequestWrapper.java new file mode 100644 index 000000000..fdd630ba8 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199RequestWrapper.java @@ -0,0 +1,39 @@ +/*- + * ============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.AAINQF199; + +import java.util.UUID; + +public class AAINQF199RequestWrapper { + + public UUID requestID; + public AAINQF199Request aainqf199request; + + public AAINQF199RequestWrapper() { + + } + + public AAINQF199RequestWrapper(UUID requestID, AAINQF199Request aainqf199request){ + this.requestID = requestID; + this.aainqf199request = aainqf199request; + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Response.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Response.java new file mode 100644 index 000000000..68a011b98 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Response.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.AAINQF199; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199Response implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8411407444051746101L; + + @SerializedName("inventory-response-item") + public List inventoryResponseItems = new LinkedList(); + + public AAINQF199Response() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java new file mode 100644 index 000000000..d4fe8f86d --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ResponseWrapper.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.AAINQF199; + +import java.util.UUID; + +import org.onap.policy.aai.AAINQF199.AAINQF199Response; + +public class AAINQF199ResponseWrapper { + + public UUID requestID; + public AAINQF199Response aainqf199response; + + public AAINQF199ResponseWrapper() { + + } + + public AAINQF199ResponseWrapper(UUID requestID, AAINQF199Response aainqf199response){ + this.requestID = requestID; + this.aainqf199response = aainqf199response; + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ServiceInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ServiceInstance.java new file mode 100644 index 000000000..8aa4a1b2a --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ServiceInstance.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199ServiceInstance 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 AAINQF199ServiceInstance() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Tenant.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Tenant.java new file mode 100644 index 000000000..763c052ca --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Tenant.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199Tenant 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 AAINQF199Tenant() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VServer.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VServer.java new file mode 100644 index 000000000..8667544eb --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VServer.java @@ -0,0 +1,54 @@ +/*- + * ============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.AAINQF199; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199VServer { + + @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 AAINQF199VServer() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VfModule.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VfModule.java new file mode 100644 index 000000000..50161fb8a --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VfModule.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.AAINQF199; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class AAINQF199VfModule 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 AAINQF199VfModule() { + } +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java new file mode 100644 index 000000000..d8074e0a8 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNF.java @@ -0,0 +1,75 @@ +/*- + * ============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; + +public class PNF implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3535108358668248501L; + + public String PNFName; + public PNFType PNFType; + + public PNF() { + + } + + public PNF(PNF pnf) { + this.PNFName = pnf.PNFName; + this.PNFType = pnf.PNFType; + } + + @Override + public String toString() { + return "PNF [PNFName=" + PNFName + ", PNFType=" + PNFType + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((PNFName == null) ? 0 : PNFName.hashCode()); + result = prime * result + ((PNFType == null) ? 0 : PNFType.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PNF other = (PNF) obj; + if (PNFName == null) { + if (other.PNFName != null) + return false; + } else if (!PNFName.equals(other.PNFName)) + return false; + if (PNFType != other.PNFType) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java new file mode 100644 index 000000000..21d1d50ac --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFInstance.java @@ -0,0 +1,97 @@ +/*- + * ============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; + +public class PNFInstance implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3694152433472165034L; + + public String PNFName; + public String PNFInstanceName; + public PNFType PNFType; + public String PNFSerial; + + public PNFInstance() { + + } + + public PNFInstance(PNFInstance instance) { + if (instance == null) { + return; + } + this.PNFName = instance.PNFName; + this.PNFInstanceName = instance.PNFInstanceName; + this.PNFType = instance.PNFType; + this.PNFSerial = instance.PNFSerial; + } + + @Override + public String toString() { + return "PNFInstance [PNFName=" + PNFName + ", PNFInstanceName=" + PNFInstanceName + ", PNFType=" + PNFType + + ", PNFSerial=" + PNFSerial + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((PNFInstanceName == null) ? 0 : PNFInstanceName.hashCode()); + result = prime * result + ((PNFName == null) ? 0 : PNFName.hashCode()); + result = prime * result + ((PNFSerial == null) ? 0 : PNFSerial.hashCode()); + result = prime * result + ((PNFType == null) ? 0 : PNFType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PNFInstance other = (PNFInstance) obj; + if (PNFInstanceName == null) { + if (other.PNFInstanceName != null) + return false; + } else if (!PNFInstanceName.equals(other.PNFInstanceName)) + return false; + if (PNFName == null) { + if (other.PNFName != null) + return false; + } else if (!PNFName.equals(other.PNFName)) + return false; + if (PNFSerial == null) { + if (other.PNFSerial != null) + return false; + } else if (!PNFSerial.equals(other.PNFSerial)) + return false; + if (PNFType != other.PNFType) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFType.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFType.java new file mode 100644 index 000000000..e3d068877 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/PNFType.java @@ -0,0 +1,39 @@ +/*- + * ============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; + +public enum PNFType { + ENODEB("eNodeB"), + PSERVER("pserver") + ; + + private String type; + + private PNFType(String type) { + this.type = type; + } + + public String toString() { + return this.type; + + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.java new file mode 100644 index 000000000..7b5bcafa7 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelatedToPropertyItem.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 com.google.gson.annotations.SerializedName; + +public class RelatedToPropertyItem { + + @SerializedName("property-key") + public String propertyKey; + @SerializedName("property-value") + public String propertyValue; + + public RelatedToPropertyItem() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java new file mode 100644 index 000000000..0cfc82ec9 --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java @@ -0,0 +1,36 @@ +/*- + * ============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 RelationshipItem { + + @SerializedName("related-to-property") + public List relatedToProperty = new LinkedList(); + + public RelationshipItem() { + } + +} 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 new file mode 100644 index 000000000..36d34f75b --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipList.java @@ -0,0 +1,36 @@ +/*- + * ============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 RelationshipList { + + @SerializedName("relationship") + public List relationship = new LinkedList(); + + public RelationshipList() { + } + +} diff --git a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java new file mode 100644 index 000000000..785c173eb --- /dev/null +++ b/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/util/Serialization.java @@ -0,0 +1,32 @@ +/*- + * ============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.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public final class Serialization { + + final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() + .setPrettyPrinting() +// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter()) + .create(); +} diff --git a/controlloop/common/model-impl/appc/pom.xml b/controlloop/common/model-impl/appc/pom.xml new file mode 100644 index 000000000..ae6ff0f5f --- /dev/null +++ b/controlloop/common/model-impl/appc/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + appc + + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + + + + junit + junit + 4.12 + provided + + + com.google.code.gson + gson + 2.5 + provided + + + diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java new file mode 100644 index 000000000..4df25ecc5 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc; + +import java.io.Serializable; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + +public class CommonHeader implements Serializable { + + private static final long serialVersionUID = -3581658269910980336L; + + public Instant TimeStamp = Instant.now(); + public String APIver = "1.01"; + public String OriginatorID; + public UUID RequestID; + public String SubRequestID; + public Collection RequestTrack = new ArrayList(); + public Collection> Flags = new ArrayList>(); + + public CommonHeader() { + + } + + public CommonHeader(CommonHeader commonHeader) { + this.OriginatorID = commonHeader.OriginatorID; + this.RequestID = commonHeader.RequestID; + this.SubRequestID = commonHeader.SubRequestID; + if (commonHeader.RequestTrack != null) { + this.RequestTrack.addAll(commonHeader.RequestTrack); + } + if (commonHeader.Flags != null) { + this.Flags.addAll(commonHeader.Flags); + } + } + + @Override + public String toString() { + return "CommonHeader [TimeStamp=" + TimeStamp + ", APIver=" + APIver + ", OriginatorID=" + OriginatorID + + ", RequestID=" + RequestID + ", SubrequestID=" + SubRequestID + ", RequestTrack=" + RequestTrack + + ", Flags=" + Flags + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((APIver == null) ? 0 : APIver.hashCode()); + result = prime * result + ((Flags == null) ? 0 : Flags.hashCode()); + result = prime * result + ((OriginatorID == null) ? 0 : OriginatorID.hashCode()); + result = prime * result + ((RequestID == null) ? 0 : RequestID.hashCode()); + result = prime * result + ((RequestTrack == null) ? 0 : RequestTrack.hashCode()); + result = prime * result + ((SubRequestID == null) ? 0 : SubRequestID.hashCode()); + result = prime * result + ((TimeStamp == null) ? 0 : TimeStamp.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CommonHeader other = (CommonHeader) obj; + if (APIver == null) { + if (other.APIver != null) + return false; + } else if (!APIver.equals(other.APIver)) + return false; + if (Flags == null) { + if (other.Flags != null) + return false; + } else if (!Flags.equals(other.Flags)) + return false; + if (OriginatorID == null) { + if (other.OriginatorID != null) + return false; + } else if (!OriginatorID.equals(other.OriginatorID)) + return false; + if (RequestID == null) { + if (other.RequestID != null) + return false; + } else if (!RequestID.equals(other.RequestID)) + return false; + if (RequestTrack == null) { + if (other.RequestTrack != null) + return false; + } else if (!RequestTrack.equals(other.RequestTrack)) + return false; + if (SubRequestID == null) { + if (other.SubRequestID != null) + return false; + } else if (!SubRequestID.equals(other.SubRequestID)) + return false; + if (TimeStamp == null) { + if (other.TimeStamp != null) + return false; + } else if (!TimeStamp.equals(other.TimeStamp)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java new file mode 100644 index 000000000..fbf0d8ee5 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class Request implements Serializable{ + + private static final long serialVersionUID = -3912323643990646431L; + + public CommonHeader CommonHeader; + public String Action; + public String TargetID; + public String ObjectID; + public Map Payload = new HashMap(); + + public Request() { + + } + + public CommonHeader getCommonHeader() { + return CommonHeader; + } + + public Map getPayload() { + return Payload; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((Action == null) ? 0 : Action.hashCode()); + result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode()); + result = prime * result + ((ObjectID == null) ? 0 : ObjectID.hashCode()); + result = prime * result + ((Payload == null) ? 0 : Payload.hashCode()); + result = prime * result + ((TargetID == null) ? 0 : TargetID.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Request other = (Request) obj; + if (Action == null) { + if (other.Action != null) + return false; + } else if (!Action.equals(other.Action)) + return false; + if (CommonHeader == null) { + if (other.CommonHeader != null) + return false; + } else if (!CommonHeader.equals(other.CommonHeader)) + return false; + if (ObjectID == null) { + if (other.ObjectID != null) + return false; + } else if (!ObjectID.equals(other.ObjectID)) + return false; + if (Payload == null) { + if (other.Payload != null) + return false; + } else if (!Payload.equals(other.Payload)) + return false; + if (TargetID == null) { + if (other.TargetID != null) + return false; + } else if (!TargetID.equals(other.TargetID)) + return false; + return true; + } + + @Override + public String toString() { + return "Request [CommonHeader=" + CommonHeader + ", Action=" + Action + ", TargetID=" + TargetID + ", ObjectID=" + + ObjectID + ", Payload=" + Payload + "]"; + } + +} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java new file mode 100644 index 000000000..f9f494625 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class Response implements Serializable { + + private static final long serialVersionUID = 434953706339865151L; + + public CommonHeader CommonHeader; + public ResponseStatus Status = new ResponseStatus(); + public Map Payload = new HashMap(); + + public Response() { + + } + + public Response(Request request) { + this.CommonHeader = new CommonHeader(request.CommonHeader); + if (request.Payload != null) { + this.Payload.putAll(request.Payload); + } + } + + public CommonHeader getCommonHeader() { + return CommonHeader; + } + + public void setCommonHeader(CommonHeader commonHeader) { + CommonHeader = commonHeader; + } + + public ResponseStatus getStatus() { + return Status; + } + + public void setStatus(ResponseStatus status) { + Status = status; + } + + public Map getPayload() { + return Payload; + } + + public void setPayload(Map payload) { + Payload = payload; + } + + @Override + public String toString() { + return "Response [CommonHeader=" + CommonHeader + ", Status=" + Status + ", Payload=" + Payload + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode()); + result = prime * result + ((Payload == null) ? 0 : Payload.hashCode()); + result = prime * result + ((Status == null) ? 0 : Status.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Response other = (Response) obj; + if (CommonHeader == null) { + if (other.CommonHeader != null) + return false; + } else if (!CommonHeader.equals(other.CommonHeader)) + return false; + if (Payload == null) { + if (other.Payload != null) + return false; + } else if (!Payload.equals(other.Payload)) + return false; + if (Status == null) { + if (other.Status != null) + return false; + } else if (!Status.equals(other.Status)) + return false; + return true; + } + + + +} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java new file mode 100644 index 000000000..9bc9bb13e --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc; + +public enum ResponseCode { + ACCEPT(100), + ERROR(200), + REJECT(300), + SUCCESS(400), + FAILURE(500) + ; + + private Integer code; + + private ResponseCode(int code) { + this.code = code; + } + + public int getValue() { + return this.code; + } + + public String toString() { + return Integer.toString(this.code); + } + + public static ResponseCode toResponseCode(int code) { + if (code == ACCEPT.code) { + return ACCEPT; + } + if (code == ERROR.code) { + return ERROR; + } + if (code == REJECT.code) { + return REJECT; + } + if (code == SUCCESS.code) { + return SUCCESS; + } + if (code == FAILURE.code) { + return FAILURE; + } + return null; + } +} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java new file mode 100644 index 000000000..6319dd8ad --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc; + +import java.io.Serializable; + +public class ResponseStatus implements Serializable { + + private static final long serialVersionUID = 2421770469587860452L; + + public int Code; + public String Value; + public String Description; + + @Override + public String toString() { + return "ResponseStatus [Code=" + Code + ", Value=" + Value + ", Description=" + Description + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Code; + result = prime * result + ((Description == null) ? 0 : Description.hashCode()); + result = prime * result + ((Value == null) ? 0 : Value.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ResponseStatus other = (ResponseStatus) obj; + if (Code != other.Code) + return false; + if (Description == null) { + if (other.Description != null) + return false; + } else if (!Description.equals(other.Description)) + return false; + if (Value == null) { + if (other.Value != null) + return false; + } else if (!Value.equals(other.Value)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java new file mode 100644 index 000000000..4de0f81f9 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc; + +public enum ResponseValue { + ACCEPT("ACCEPT"), + ERROR("ERROR"), + REJECT("REJECT"), + SUCCESS("SUCCESS"), + FAILURE("FAILURE") + ; + + private String value; + + private ResponseValue(String value) { + this.value = value; + } + + public String toString() { + return this.value; + } + + public static ResponseValue toResponseValue(String value) { + if (value.toString().equals(ACCEPT.toString())) { + return ACCEPT; + } + if (value.toString().equals(ERROR.toString())) { + return ERROR; + } + if (value.toString().equals(REJECT.toString())) { + return REJECT; + } + if (value.toString().equals(SUCCESS.toString())) { + return SUCCESS; + } + if (value.toString().equals(FAILURE.toString())) { + return FAILURE; + } + + return null; + } + +} diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java new file mode 100644 index 000000000..8a801c32b --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * 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.appc.util; + +import java.lang.reflect.Type; +import java.time.Instant; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +public final class Serialization { + + public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx"); + + public static class gsonUTCAdapter implements JsonSerializer, JsonDeserializer { + + public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) + throws JsonParseException { + try { + return ZonedDateTime.parse(element.getAsString(), format); + } catch (Exception e) { + System.err.println(e); + } + return null; + } + + public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) { + return new JsonPrimitive(datetime.format(format)); + } + } + public static class gsonInstantAdapter implements JsonSerializer, JsonDeserializer { + + @Override + public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return Instant.ofEpochMilli(json.getAsLong()); + } + + @Override + public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.toEpochMilli()); + } + + } + + public static final Gson gsonPretty = new GsonBuilder() + .disableHtmlEscaping() + .setPrettyPrinting() + .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter()) + .registerTypeAdapter(Instant.class, new gsonInstantAdapter()) +// .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance()) +// .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus()) + .create(); + +} diff --git a/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml b/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml new file mode 100644 index 000000000..680a9929c --- /dev/null +++ b/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml @@ -0,0 +1,118 @@ +### +# ============LICENSE_START======================================================= +# appc +# ================================================================================ +# 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========================================================= +### + +Request: + type: object + properties: + CommonHeader: + type: object + properties: + TimeStamp: + type: string + APIver: + type: string + value: '1.01' + OriginatorID: + type: string + RequestID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + SubRequestID: + type: string + Flags: + type: object + required: + - TimeStamp + - APIver + - OriginatorID + - RequestID + Action: + type: string + enum: + - Audit + - ActionStatus + - BlockAudits + - Configure + - HealthCheck + - Install + - LiveUpgrade + - Migrate + - ModifyConfig + - Query + - Rebuild + - Reconfigure + - Restart + - Rollback + - Scale + - Start + - Stop + - Sync + - Terminate + - Test + - Upgrade + TargetID: + type: string + ObjectID: + type: string + Payload: + type: object + required: + - CommonHeader + - Action + - TargetID +Response: + type: object + properties: + CommonHeader: + type: object + properties: + TimeStamp: + type: string + APIver: + type: string + OriginatorID: + type: string + RequestID: + type: string + SubRequestID: + type: string + Flags: + type: object + required: + - TimeStamp + - APIver + - OriginatorID + - RequestID + Status: + type: object + properties: + Code: + type: integer + Value: + type: string + required: + - Code + - Value + Payload: + type: object + required: + - CommonHeader + - Status + diff --git a/controlloop/common/model-impl/events/README.md b/controlloop/common/model-impl/events/README.md new file mode 100644 index 000000000..1347d78a6 --- /dev/null +++ b/controlloop/common/model-impl/events/README.md @@ -0,0 +1,7 @@ +Policy Control Loop + +This is the implementation of the Policy's Control Loop messages. This includes the Events consumed and Notifications produced by the ECOMP Policy Platform. + + + + diff --git a/controlloop/common/model-impl/events/pom.xml b/controlloop/common/model-impl/events/pom.xml new file mode 100644 index 000000000..e7f4f9482 --- /dev/null +++ b/controlloop/common/model-impl/events/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + events + + + com.google.code.gson + gson + 2.5 + + + diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java new file mode 100644 index 000000000..df099ed5e --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEvent.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +import java.io.Serializable; +import java.util.UUID; + +public abstract class ControlLoopEvent implements Serializable { + + private static final long serialVersionUID = 2391252138583119195L; + + public String closedLoopControlName; + public String version = "1.0.2"; + public UUID requestID; + public String closedLoopEventClient; + public ControlLoopTargetType target_type; + public String target; + public String from; + public String policyScope; + public String policyName; + public String policyVersion; + public ControlLoopEventStatus closedLoopEventStatus; + + public ControlLoopEvent() { + + } + + public ControlLoopEvent(ControlLoopEvent event) { + if (event == null) { + return; + } + this.closedLoopControlName = event.closedLoopControlName; + this.requestID = event.requestID; + this.closedLoopEventClient = event.closedLoopEventClient; + this.target_type = event.target_type; + this.target = event.target; + this.from = event.from; + this.policyScope = event.policyScope; + this.policyName = event.policyName; + this.policyVersion = event.policyVersion; + this.closedLoopEventStatus = event.closedLoopEventStatus; + } + + public boolean isEventStatusValid() { + if (this.closedLoopEventStatus == null) { + return false; + } + return true; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java new file mode 100644 index 000000000..f74b626cb --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopEventStatus.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +public enum ControlLoopEventStatus { + ONSET("ONSET"), + ABATED("ABATED") + ; + + private String status; + + private ControlLoopEventStatus(String status) { + this.status = status; + } + + public String toString() { + return this.status; + } + + public static ControlLoopEventStatus toStatus(String status) { + if (ONSET.status.equalsIgnoreCase(status)) { + return ONSET; + } + if (ABATED.status.equalsIgnoreCase(status)) { + return ABATED; + } + // + // In case DCAE uses the old abatement + // + if (status.equalsIgnoreCase("abatement")) { + return ABATED; + } + return null; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java new file mode 100644 index 000000000..8e29b1de3 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotification.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +import java.io.Serializable; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +public abstract class ControlLoopNotification implements Serializable { + + private static final long serialVersionUID = 7538596984567127915L; + + public String closedLoopControlName; + public String version = "1.0.2"; + public UUID requestID; + public String closedLoopEventClient; + public ControlLoopTargetType target_type; + public String target; + public String from; + public String policyScope; + public String policyName; + public String policyVersion; + public ControlLoopNotificationType notification; + public String message; + public ZonedDateTime notificationTime = ZonedDateTime.now(ZoneOffset.UTC);; + public Integer OPS_CL_timer; + public List history = new LinkedList(); + + public ControlLoopNotification() { + + } + + public ControlLoopNotification(ControlLoopEvent event) { + this.closedLoopControlName = event.closedLoopControlName; + this.requestID = event.requestID; + this.closedLoopEventClient = event.closedLoopEventClient; + this.target_type = event.target_type; + this.target = event.target; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java new file mode 100644 index 000000000..5417baed9 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopNotificationType.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +public enum ControlLoopNotificationType { + ACTIVE("ACTIVE"), + REJECTED("REJECTED"), + OPERATION("OPERATION"), + OPERATION_SUCCESS("OPERATION: SUCCESS"), + OPERATION_FAILURE("OPERATION: FAILURE"), + FINAL_FAILURE("FINAL: FAILURE"), + FINAL_SUCCESS("FINAL: SUCCESS"), + FINAL_OPENLOOP("FINAL: OPENLOOP") + ; + + private String type; + + private ControlLoopNotificationType(String type) { + this.type = type; + } + + public String toString() { + return this.type; + } + + public static ControlLoopNotificationType toType(String type) { + if (ACTIVE.toString().equals(type)) { + return ACTIVE; + } + if (REJECTED.toString().equals(type)) { + return REJECTED; + } + if (OPERATION.toString().equals(type)) { + return OPERATION; + } + if (OPERATION_SUCCESS.toString().equals(type)) { + return OPERATION_SUCCESS; + } + if (OPERATION_FAILURE.toString().equals(type)) { + return OPERATION_FAILURE; + } + if (FINAL_FAILURE.toString().equals(type)) { + return FINAL_FAILURE; + } + if (FINAL_SUCCESS.toString().equals(type)) { + return FINAL_SUCCESS; + } + if (FINAL_OPENLOOP.toString().equals(type)) { + return FINAL_OPENLOOP; + } + return null; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java new file mode 100644 index 000000000..ce721b43d --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperation.java @@ -0,0 +1,139 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +import java.io.Serializable; +import java.time.Instant; + +public class ControlLoopOperation implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 8662706581293017099L; + + public String actor; + public String operation; + public String target; + public Instant start = Instant.now(); + public Instant end; + public String subRequestId; + public String outcome; + public String message; + + public ControlLoopOperation() { + + } + + public ControlLoopOperation(ControlLoopOperation op) { + this.actor = op.actor; + this.operation = op.operation; + this.target = op.target; + this.start = op.start; + this.end = op.end; + this.subRequestId = op.subRequestId; + this.outcome = op.outcome; + this.message = op.message; + } + + public String toMessage() { + return "actor="+actor+",operation="+operation+",target="+target+",subRequestId="+subRequestId; + } + + public String toHistory() { + return "actor="+actor+",operation="+operation+",target="+target+",start="+start+",end="+end+",subRequestId="+subRequestId+",outcome="+outcome+",message="+message; + } + + @Override + public String toString() { + return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start=" + + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message=" + + message + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((actor == null) ? 0 : actor.hashCode()); + result = prime * result + ((end == null) ? 0 : end.hashCode()); + result = prime * result + ((message == null) ? 0 : message.hashCode()); + result = prime * result + ((operation == null) ? 0 : operation.hashCode()); + result = prime * result + ((outcome == null) ? 0 : outcome.hashCode()); + result = prime * result + ((start == null) ? 0 : start.hashCode()); + result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode()); + result = prime * result + ((target == null) ? 0 : target.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ControlLoopOperation other = (ControlLoopOperation) obj; + if (actor == null) { + if (other.actor != null) + return false; + } else if (!actor.equals(other.actor)) + return false; + if (end == null) { + if (other.end != null) + return false; + } else if (!end.equals(other.end)) + return false; + if (message == null) { + if (other.message != null) + return false; + } else if (!message.equals(other.message)) + return false; + if (operation == null) { + if (other.operation != null) + return false; + } else if (!operation.equals(other.operation)) + return false; + if (outcome == null) { + if (other.outcome != null) + return false; + } else if (!outcome.equals(other.outcome)) + return false; + if (start == null) { + if (other.start != null) + return false; + } else if (!start.equals(other.start)) + return false; + if (subRequestId == null) { + if (other.subRequestId != null) + return false; + } else if (!subRequestId.equals(other.subRequestId)) + return false; + if (target == null) { + if (other.target != null) + return false; + } else if (!target.equals(other.target)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java new file mode 100644 index 000000000..fb3942b63 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopOperationWrapper.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +import java.util.UUID; + +public class ControlLoopOperationWrapper { + + public UUID requestID; + public ControlLoopOperation operation; + + public ControlLoopOperationWrapper() { + + } + + public ControlLoopOperationWrapper(UUID requestID, ControlLoopOperation operation) { + this.requestID = requestID; + this.operation = operation; + } +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java new file mode 100644 index 000000000..c8bd1a80c --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +public enum ControlLoopTargetType { + VM("VM"), + VF("VF"), + VFC("VFC"), + ENODEB("eNodeB") + ; + + private String type; + + private ControlLoopTargetType(String type) { + this.type = type; + } + + public String toString() { + return this.type; + } + + public static ControlLoopTargetType toType(String type) { + if (VM.toString().equals(type)) { + return VM; + } + if (VF.toString().equals(type)) { + return VF; + } + if (VFC.toString().equals(type)) { + return VFC; + } + if (ENODEB.toString().equals(type)) { + return ENODEB; + } + return null; + } +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java new file mode 100644 index 000000000..aca072eaa --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +public class PhysicalControlLoopEvent extends ControlLoopEvent { + + /** + * + */ + private static final long serialVersionUID = -7282930271094849487L; + + public PhysicalControlLoopEvent() { + } + + public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) { + super(event); + if (event == null) { + return; + } + } + + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java new file mode 100644 index 000000000..c904d6740 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +public class PhysicalControlLoopNotification extends ControlLoopNotification { + + /** + * + */ + private static final long serialVersionUID = 8105197217140032892L; + + public PhysicalControlLoopNotification() { + } + + public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) { + super(event); + if (event == null) { + return; + } + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java new file mode 100644 index 000000000..bc3d2beb7 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopEvent.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; + +public class VirtualControlLoopEvent extends ControlLoopEvent { + + /** + * + */ + private static final long serialVersionUID = -5752405682246066226L; + public Instant closedLoopAlarmStart; + public Instant closedLoopAlarmEnd; + public Map AAI = new HashMap(); + + public VirtualControlLoopEvent() { + } + + public VirtualControlLoopEvent(VirtualControlLoopEvent event) { + super(event); + if (event == null) { + return; + } + if (event.AAI != null) { + this.AAI = new HashMap(event.AAI); + } + this.closedLoopAlarmStart = event.closedLoopAlarmStart; + this.closedLoopAlarmEnd = event.closedLoopAlarmEnd; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java new file mode 100644 index 000000000..f97c609c7 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/VirtualControlLoopNotification.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop; + +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; + +public class VirtualControlLoopNotification extends ControlLoopNotification { + + /** + * + */ + private static final long serialVersionUID = 5354756047932144017L; + + public Map AAI = new HashMap(); + public Instant closedLoopAlarmStart; + public Instant closedLoopAlarmEnd; + + public VirtualControlLoopNotification() { + } + + public VirtualControlLoopNotification(VirtualControlLoopEvent event) { + super(event); + if (event == null) { + return; + } + if (event.AAI != null) { + this.AAI = new HashMap(event.AAI); + } + this.closedLoopAlarmStart = event.closedLoopAlarmStart; + this.closedLoopAlarmEnd = event.closedLoopAlarmEnd; + } + +} diff --git a/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java new file mode 100644 index 000000000..a45947733 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * controlloop + * ================================================================================ + * 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.controlloop.util; + +import java.lang.reflect.Type; +import java.time.Instant; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import org.onap.policy.controlloop.ControlLoopNotificationType; +import org.onap.policy.controlloop.ControlLoopTargetType; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +public final class Serialization { + + public static class notificationTypeAdapter implements JsonSerializer, JsonDeserializer { + + @Override + public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc, + JsonSerializationContext context) { + return new JsonPrimitive(src.toString()); + } + + @Override + public ControlLoopNotificationType deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) throws JsonParseException { + return ControlLoopNotificationType.toType(json.getAsString()); + } + + } + + public static class targetTypeAdapter implements JsonSerializer, JsonDeserializer { + + @Override + public JsonElement serialize(ControlLoopTargetType src, Type typeOfSrc, + JsonSerializationContext context) { + return new JsonPrimitive(src.toString()); + } + + @Override + public ControlLoopTargetType deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) throws JsonParseException { + return ControlLoopTargetType.toType(json.getAsString()); + } + + } + + public static class gsonUTCAdapter implements JsonSerializer, JsonDeserializer { + public static DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx"); + + public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) + throws JsonParseException { + try { + return ZonedDateTime.parse(element.getAsString(), format); + } catch (Exception e) { + System.err.println(e); + } + return null; + } + + public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) { + return new JsonPrimitive(datetime.format(format)); + } + } + + public static class gsonInstantAdapter implements JsonSerializer, JsonDeserializer { + + @Override + public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return Instant.ofEpochMilli(json.getAsLong()); + } + + @Override + public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.toEpochMilli()); + } + + } + + final static public Gson gson = new GsonBuilder().disableHtmlEscaping() + .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter()) + .registerTypeAdapter(Instant.class, new gsonInstantAdapter()) + .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter()) + .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter()) + .create(); + + + final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() + .setPrettyPrinting() + .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter()) + .registerTypeAdapter(Instant.class, new gsonInstantAdapter()) + .registerTypeAdapter(ControlLoopNotificationType.class, new notificationTypeAdapter()) + .registerTypeAdapter(ControlLoopTargetType.class, new targetTypeAdapter()) + .create(); + +} diff --git a/controlloop/common/model-impl/events/src/main/resources/definitions.yaml b/controlloop/common/model-impl/events/src/main/resources/definitions.yaml new file mode 100644 index 000000000..cbe422b82 --- /dev/null +++ b/controlloop/common/model-impl/events/src/main/resources/definitions.yaml @@ -0,0 +1,114 @@ +AAI: + type: object + properties: + AICVServerSelfLink: + type: string + VNF_NAME: + type: string + AICVMID: + type: string + AICTenantID: + type: string + LOC_ID: + type: string + in_maint: + type: boolean + AICIdentity: + type: string + Prov_status: + type: string + OAM_IPV4: + type: string + is_closed_loop_disabled: + type: boolean + VM_NAME: + type: string + OAM_IPV6: + type: string + required: + - AICVServerSelfLink + - AICIdentity + - is_closed_loop_disabled +ControlLoop: + type: object + description: Common fields for control loop events and notifications + properties: + closedLoopControlName: + type: string + description: A UNIQUE string identifying the Closed Loop ID this event is for. There are no semantics behind this string. + serviceInstance: + $ref: '../../../com.att.ecomp.policy.asdc/src/main/resources/definitions.yaml#/serviceInstance' + resourceInstance: + $ref: '../../../com.att.ecomp.policy.asdc/src/main/resources/definitions.yaml#/resourceInstance' + requestID: + type: string + description: This is required via ECOMP Platform Logging Requirements. + pattern: /[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/ + triggerID: + type: string + description: ID that maps back to Highland Park. Concatenation between eventID and firstEPOCH. + triggerSourceName: + type: string + description: pulled from eventSourceName of trigger H.P. alarm. The contents of this field should also be contained in the AAI Json sub-tag (see below). + closedLoopAlarmStart: + type: string + description: firstEpoch. UTC Timestamp when this event was detected by DCAE. Conform to ECOMP Logging requirements. + closedLoopAlarmEnd: + type: string + description: lastEpoch. UTC Timestamp when this event was detected as cleared by DCAE. Conform to ECOMP Logging requirements. + closedLoopEventClient: + type: string + description: Open DCAE sub-system that detected the event and published this event message. + target: + type: string + description: The target entity that is being administered. This could be VM_NAME, VNF_NAME, etc. This should map to a field name in the AAI sub-tag shown below. + AAI: + $ref: '#/AAI' + from: + type: string + policyScope: + type: string + policyName: + type: string + policyVersion: + type: string + required: + - closedLoopControlName + - requestID + - triggerID + - triggerSourceName + - closedLoopAlarmStart + - closedLoopEventClient + - target + - AAI + - from + - policyScope + - policyName + - policyVersion +Event: + allOf: + - $ref: '#/ControlLoop' + - properties: + closedLoopEventStatus: + type: string + description: The status for the event within Open DCAE. A value of “ONSET” indicates the event has been encountered. “ABATED” indicates the event has been abated. + valid_values: + - ONSET + - ABATEMENT + - required: + - closedLoopEventStatus +Notification: + - $ref: '#/ControlLoop' + - properties: + notification: + type: string + notificationTime: + type: string + message: + type: string + OPS_CL_timer: + type: int + - required: + - notification + - notificationTime + - OPS_CL_timer diff --git a/controlloop/common/model-impl/mso/pom.xml b/controlloop/common/model-impl/mso/pom.xml new file mode 100644 index 000000000..8e584a8ea --- /dev/null +++ b/controlloop/common/model-impl/mso/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + mso + + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + + + + junit + junit + 4.12 + provided + + + com.google.code.gson + gson + 2.5 + provided + + + org.onap.policy.drools-applications + rest + ${project.version} + + + diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOAsyncRequestStatus.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOAsyncRequestStatus.java new file mode 100644 index 000000000..7e7451a60 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOAsyncRequestStatus.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import com.google.gson.annotations.SerializedName; + +public class MSOAsyncRequestStatus implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("correlator") + public String correlator; + + @SerializedName("requestId") + public String requestId; + + @SerializedName("instanceReferences") + public MSOInstanceReferences instanceReferences; + + @SerializedName("startTime") + public LocalDateTime startTime; + + @SerializedName("finishTime") + public LocalDateTime finishTime; + + @SerializedName("requestScope") + public String requestScope; + + @SerializedName("requestType") + public String requestType; + + @SerializedName("requestStatus") + public MSORequestStatus requestStatus; + + + public MSOAsyncRequestStatus() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOCloudConfiguration.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOCloudConfiguration.java new file mode 100644 index 000000000..965ada24d --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOCloudConfiguration.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSOCloudConfiguration implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("lcpCloudRegionId") + public String lcpCloudRegionId; + + @SerializedName("tenantId") + public String tenantId; + + public MSOCloudConfiguration() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOInstanceReferences.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOInstanceReferences.java new file mode 100644 index 000000000..f751c3a43 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOInstanceReferences.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSOInstanceReferences implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("requestId") + public String requestId; + + @SerializedName("instanceId") + public String instanceId; + + public MSOInstanceReferences() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java new file mode 100644 index 000000000..79725901a --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOManager.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.util.HashMap; +import java.util.Map; + +import org.onap.policy.mso.util.Serialization; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; + +import com.google.gson.JsonSyntaxException; + +public final class MSOManager { + + public static MSOResponse createModuleInstance(String url, String urlBase, String username, String password, MSORequest request) { + + // + // Call REST + // + Map headers = new HashMap(); + //headers.put("X-FromAppId", "POLICY"); + //headers.put("X-TransactionId", requestID.toString()); + headers.put("Accept", "application/json"); + + // + // 201 - CREATED - you are done just return + // + + Pair httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request)); + + if (httpDetails == null) { + return null; + } + + if (httpDetails.a == 202) { + try { + MSOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, MSOResponse.class); + + String body = Serialization.gsonPretty.toJson(response); + System.out.println("***** Response to post:"); + System.out.println(body); + + String requestId = response.requestReferences.requestId; + int attemptsLeft = 20; + + //String getUrl = "/orchestrationRequests/v2/"+requestId; + String urlGet = urlBase + "/orchestrationRequests/v2/"+requestId; + MSOResponse responseGet = null; + + while(attemptsLeft-- > 0){ + + Pair httpDetailsGet = RESTManager.get(urlGet, username, password, headers); + responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, MSOResponse.class); + body = Serialization.gsonPretty.toJson(responseGet); + System.out.println("***** Response to get:"); + System.out.println(body); + + if(httpDetailsGet.a == 200){ + if(responseGet.request.requestStatus.requestState.equalsIgnoreCase("COMPLETE") || + responseGet.request.requestStatus.requestState.equalsIgnoreCase("FAILED")){ + System.out.println("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState); + return responseGet; + } + } + Thread.sleep(20000); + } + + System.out.println("***** ######## VF Module Creation timeout. Status: ("+responseGet.request.requestStatus.requestState+")"); + return responseGet; + } catch (JsonSyntaxException e) { + System.err.println("Failed to deserialize into MSOResponse" + e.getLocalizedMessage()); + } catch (InterruptedException e) { + System.err.println("Interrupted exception: " + e.getLocalizedMessage()); + } + } + + + + + return null; + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOModelInfo.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOModelInfo.java new file mode 100644 index 000000000..9efea94b1 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOModelInfo.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSOModelInfo implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("modelType") + public String modelType; + + @SerializedName("modelInvariantId") + public String modelInvariantId; + + @SerializedName("modelNameVersionId") + public String modelNameVersionId; + + @SerializedName("modelName") + public String modelName; + + @SerializedName("modelVersion") + public String modelVersion; + + @SerializedName("modelCustomizationName") + public String modelCustomizationName; + + public MSOModelInfo() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOPolicyException.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOPolicyException.java new file mode 100644 index 000000000..97e85132a --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOPolicyException.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class MSOPolicyException implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("messageId") + public String messageId; + + @SerializedName("text") + public String text; + + public MSOPolicyException() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstance.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstance.java new file mode 100644 index 000000000..0eec72f70 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstance.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + + +import com.google.gson.annotations.SerializedName; + +public class MSORelatedInstance implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("instanceId") + public String instanceId; + + @SerializedName("instanceName") + public String instanceName; + + @SerializedName("modelInfo") + public MSOModelInfo modelInfo; + + + public MSORelatedInstance() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstanceListElement.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstanceListElement.java new file mode 100644 index 000000000..dfeed32f2 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORelatedInstanceListElement.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSORelatedInstanceListElement implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("relatedInstance") + public MSORelatedInstance relatedInstance; + + + public MSORelatedInstanceListElement() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequest.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequest.java new file mode 100644 index 000000000..fa4e7892b --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import com.google.gson.annotations.SerializedName; + +public class MSORequest implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("requestId") + public String requestId; + + @SerializedName("startTime") + //public LocalDateTime startTime; + public String startTime; + + @SerializedName("finishTime") + public LocalDateTime finishTime; + + @SerializedName("requestScope") + public String requestScope; + + @SerializedName("requestType") + public String requestType; + + @SerializedName("requestDetails") + public MSORequestDetails requestDetails; + + @SerializedName("requestStatus") + public MSORequestStatus requestStatus; + + public MSORequest() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestDetails.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestDetails.java new file mode 100644 index 000000000..180285765 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestDetails.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class MSORequestDetails implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("modelInfo") + public MSOModelInfo modelInfo; + + @SerializedName("cloudConfiguration") + public MSOCloudConfiguration cloudConfiguration; + + @SerializedName("requestInfo") + public MSORequestInfo requestInfo; + + @SerializedName("subscriberInfo") + public MSOSubscriberInfo subscriberInfo; + + @SerializedName("relatedInstanceList") + public List relatedInstanceList= new LinkedList(); + + @SerializedName("requestParameters") + public MSORequestParameters requestParameters; + + public MSORequestDetails() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestError.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestError.java new file mode 100644 index 000000000..849103e6d --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestError.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class MSORequestError implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + + @SerializedName("policyException") + public MSOPolicyException policyException; + + + @SerializedName("serviceException") + public MSOServiceException serviceException; + + /* + @SerializedName("messageId") + public String messageId; + + @SerializedName("text") + public String text; + + @SerializedName("url") + public String url; + + @SerializedName("variables") + public String variables; + */ + + public MSORequestError() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestInfo.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestInfo.java new file mode 100644 index 000000000..5c771b6e3 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestInfo.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSORequestInfo implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("instanceName") + public String instanceName; + + @SerializedName("source") + public String source; + + @SerializedName("productFamilyId") + public String productFamilyId; + + @SerializedName("suppressRollback") + public boolean suppressRollback; + + @SerializedName("billingAccountNumber") + public String billingAccountNumber; + + @SerializedName("callbackUrl") + public String callbackUrl; + + @SerializedName("correlator") + public String correlator; + + @SerializedName("orderNumber") + public String orderNumber; + + @SerializedName("orderVersion") + public Integer orderVersion; + + + public MSORequestInfo() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestParameters.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestParameters.java new file mode 100644 index 000000000..043a8e848 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestParameters.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + + +import com.google.gson.annotations.SerializedName; + +public class MSORequestParameters implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("subscriptionServiceType") + public String subscriptionServiceType; + + @SerializedName("userParams") + public List> userParams = new LinkedList>(); + + public MSORequestParameters() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestReferences.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestReferences.java new file mode 100644 index 000000000..c641db4bb --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestReferences.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSORequestReferences implements Serializable { + + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("instanceId") + public String instanceId; + + @SerializedName("requestId") + public String requestId; + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestStatus.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestStatus.java new file mode 100644 index 000000000..598e9cbdc --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSORequestStatus.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class MSORequestStatus implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("percentProgress") + public int percentProgress; + + @SerializedName("requestState") + public String requestState; + + @SerializedName("timestamp") + //public LocalDateTime timestamp; + public String timestamp; + + @SerializedName("wasRolledBack") + public boolean wasRolledBack; + + + public MSORequestStatus() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOResponse.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOResponse.java new file mode 100644 index 000000000..2106959fb --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOResponse.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class MSOResponse implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("requestReferences") + public MSORequestReferences requestReferences; + + @SerializedName("requestError") + public MSORequestError requestError; + + @SerializedName("request") + public MSORequest request; + + + + public MSOResponse() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOServiceException.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOServiceException.java new file mode 100644 index 000000000..3322bf8f3 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOServiceException.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class MSOServiceException implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("messageId") + public String messageId; + + @SerializedName("text") + public String text; + + @SerializedName("variables") + public List variables = new LinkedList(); + + public MSOServiceException() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOSubscriberInfo.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOSubscriberInfo.java new file mode 100644 index 000000000..957c4c70c --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/MSOSubscriberInfo.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class MSOSubscriberInfo implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("globalSubscriberId") + public String globalSubscriberId; + + @SerializedName("subscriberCommonSiteId") + public String subscriberCommonSiteId; + + @SerializedName("subscriberName") + public String subscriberName; + + public MSOSubscriberInfo() { + } + +} diff --git a/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/util/Serialization.java b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/util/Serialization.java new file mode 100644 index 000000000..24eb2951a --- /dev/null +++ b/controlloop/common/model-impl/mso/src/main/java/org/onap/policy/mso/util/Serialization.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.mso.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public final class Serialization { + + final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() + .setPrettyPrinting() + .create(); + +} diff --git a/controlloop/common/model-impl/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java b/controlloop/common/model-impl/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java new file mode 100644 index 000000000..c6c750568 --- /dev/null +++ b/controlloop/common/model-impl/mso/src/test/java/org/openecomp/policy/mso/TestDemo.java @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * 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.openecomp.policy.mso; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.policy.mso.MSOCloudConfiguration; +import org.onap.policy.mso.MSOModelInfo; +import org.onap.policy.mso.MSORelatedInstance; +import org.onap.policy.mso.MSORelatedInstanceListElement; +import org.onap.policy.mso.MSORequest; +import org.onap.policy.mso.MSORequestDetails; +import org.onap.policy.mso.MSORequestInfo; +import org.onap.policy.mso.MSORequestParameters; +import org.onap.policy.mso.util.Serialization; + +public class TestDemo { + + @Test + public void test() { + + MSORequest request = new MSORequest(); + request.requestDetails = new MSORequestDetails(); + request.requestDetails.modelInfo = new MSOModelInfo(); + request.requestDetails.cloudConfiguration = new MSOCloudConfiguration(); + request.requestDetails.requestInfo = new MSORequestInfo(); + request.requestDetails.requestParameters = new MSORequestParameters(); + + request.requestDetails.modelInfo.modelType = "vfModule"; + request.requestDetails.modelInfo.modelInvariantId = "ff5256d2-5a33-55df-13ab-12abad84e7ff"; + request.requestDetails.modelInfo.modelNameVersionId = "fe6478e5-ea33-3346-ac12-ab121484a3fe"; + request.requestDetails.modelInfo.modelName = "vSAMP12..base..module-0"; + request.requestDetails.modelInfo.modelVersion = "1"; + + request.requestDetails.cloudConfiguration.lcpCloudRegionId = "mdt1"; + request.requestDetails.cloudConfiguration.tenantId = "88a6ca3ee0394ade9403f075db23167e"; + + request.requestDetails.requestInfo.instanceName = "MSOTEST103a-vSAMP12_base_module-0"; + request.requestDetails.requestInfo.source = "VID"; + request.requestDetails.requestInfo.suppressRollback = true; + + MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement(); + MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement(); + MSORelatedInstanceListElement relatedInstanceListElement3 = new MSORelatedInstanceListElement(); + relatedInstanceListElement1.relatedInstance = new MSORelatedInstance(); + relatedInstanceListElement2.relatedInstance = new MSORelatedInstance(); + relatedInstanceListElement3.relatedInstance = new MSORelatedInstance(); + + relatedInstanceListElement1.relatedInstance.instanceId = "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"; + relatedInstanceListElement1.relatedInstance.instanceName = "MSOTESTVOL103a-vSAMP12_base_module-0_vol"; + relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo(); + relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "volumeGroup"; + + relatedInstanceListElement2.relatedInstance.instanceId = "serviceInstanceId"; + relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo(); + relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "service"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "ff3514e3-5a33-55df-13ab-12abad84e7ff"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "fe6985cd-ea33-3346-ac12-ab121484a3fe"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "parent service model name"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "1.0"; + + relatedInstanceListElement3.relatedInstance.instanceId = "vnfInstanceId"; + relatedInstanceListElement3.relatedInstance.modelInfo = new MSOModelInfo(); + relatedInstanceListElement3.relatedInstance.modelInfo.modelType = "vnf"; + relatedInstanceListElement3.relatedInstance.modelInfo.modelInvariantId = "ff5256d1-5a33-55df-13ab-12abad84e7ff"; + relatedInstanceListElement3.relatedInstance.modelInfo.modelNameVersionId = "fe6478e4-ea33-3346-ac12-ab121484a3fe"; + relatedInstanceListElement3.relatedInstance.modelInfo.modelName = "vSAMP12"; + relatedInstanceListElement3.relatedInstance.modelInfo.modelVersion = "1.0"; + relatedInstanceListElement3.relatedInstance.modelInfo.modelCustomizationName = "vSAMP12 1"; + + request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1); + request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2); + request.requestDetails.relatedInstanceList.add(relatedInstanceListElement3); + + Map userParam1 = new HashMap(); + userParam1.put("name1", "value1"); + + Map userParam2 = new HashMap(); + userParam2.put("name2", "value2"); + + request.requestDetails.requestParameters.userParams.add(userParam1); + request.requestDetails.requestParameters.userParams.add(userParam2); + + String body = Serialization.gsonPretty.toJson(request); + System.out.println(body); + + //MSOResponse response = MSOManager.createModuleInstance("http://localhost:7780/", "my_username", "my_passwd", request); + + //body = Serialization.gsonPretty.toJson(response); + //System.out.println(body); + + } + + @Test + public void testHack() { + + System.out.println("** HACK **"); + + MSORequest request = new MSORequest(); + // + request.requestDetails = new MSORequestDetails(); + request.requestDetails.modelInfo = new MSOModelInfo(); + request.requestDetails.cloudConfiguration = new MSOCloudConfiguration(); + request.requestDetails.requestInfo = new MSORequestInfo(); + request.requestDetails.requestParameters = new MSORequestParameters(); + request.requestDetails.requestParameters.userParams = null; + + request.requestDetails.modelInfo.modelType = "vfModule"; + request.requestDetails.modelInfo.modelInvariantId = "a9c4a35a-de48-451a-9e4e-343f2ac52928"; + request.requestDetails.modelInfo.modelNameVersionId = "e0d98ad1-238d-4555-b439-023d3f9079f6"; + request.requestDetails.modelInfo.modelName = "0d9e0d9d352749f4B3cb..dnsscaling..module-0"; + request.requestDetails.modelInfo.modelVersion = "2.0"; + + request.requestDetails.cloudConfiguration.lcpCloudRegionId = "DFW"; + request.requestDetails.cloudConfiguration.tenantId = "1015548"; + + request.requestDetails.requestInfo.instanceName = "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"; + request.requestDetails.requestInfo.source = "POLICY"; + request.requestDetails.requestInfo.suppressRollback = false; + + MSORelatedInstanceListElement relatedInstanceListElement1 = new MSORelatedInstanceListElement(); + MSORelatedInstanceListElement relatedInstanceListElement2 = new MSORelatedInstanceListElement(); + relatedInstanceListElement1.relatedInstance = new MSORelatedInstance(); + relatedInstanceListElement2.relatedInstance = new MSORelatedInstance(); + + String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; + relatedInstanceListElement1.relatedInstance.instanceId = serviceInstanceId; + relatedInstanceListElement1.relatedInstance.modelInfo = new MSOModelInfo(); + relatedInstanceListElement1.relatedInstance.modelInfo.modelType = "service"; + relatedInstanceListElement1.relatedInstance.modelInfo.modelInvariantId = "24329a0c-1d57-4210-b1af-a65df64e9d59"; + relatedInstanceListElement1.relatedInstance.modelInfo.modelNameVersionId = "ac642881-8e7e-4217-bd64-16ad41c42e30"; + relatedInstanceListElement1.relatedInstance.modelInfo.modelName = "5116d67e-0b4f-46bf-a46f"; + relatedInstanceListElement1.relatedInstance.modelInfo.modelVersion = "2.0"; + + String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; + relatedInstanceListElement2.relatedInstance.instanceId = vnfInstanceId; + relatedInstanceListElement2.relatedInstance.modelInfo = new MSOModelInfo(); + relatedInstanceListElement2.relatedInstance.modelInfo.modelType = "vnf"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelInvariantId = "09fd971e-db5f-475d-997c-cf6704b6b8fe"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelNameVersionId = "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelName = "9e4c31d2-4b25-4d9e-9fb4"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelVersion = "2.0"; + relatedInstanceListElement2.relatedInstance.modelInfo.modelCustomizationName = "0d9e0d9d-3527-49f4-b3cb 2"; + + request.requestDetails.relatedInstanceList.add(relatedInstanceListElement1); + request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2); + + String body = Serialization.gsonPretty.toJson(request); + System.out.println(body); + } + +} diff --git a/controlloop/common/model-impl/pom.xml b/controlloop/common/model-impl/pom.xml new file mode 100644 index 000000000..94c3f345a --- /dev/null +++ b/controlloop/common/model-impl/pom.xml @@ -0,0 +1,46 @@ + + + + + 4.0.0 + + model-impl + pom + + + org.onap.policy.drools-applications + common + 1.1.0-SNAPSHOT + + + + aai + appc + events + mso + rest + sdc + trafficgenerator + + + + diff --git a/controlloop/common/model-impl/rest/pom.xml b/controlloop/common/model-impl/rest/pom.xml new file mode 100644 index 000000000..96c5bb98a --- /dev/null +++ b/controlloop/common/model-impl/rest/pom.xml @@ -0,0 +1,52 @@ + + + + 4.0.0 + + rest + + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + + + + junit + junit + 4.12 + provided + + + com.google.code.gson + gson + 2.5 + provided + + + org.apache.httpcomponents + httpclient + 4.5.2 + provided + + + diff --git a/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java new file mode 100644 index 000000000..e42ab1693 --- /dev/null +++ b/controlloop/common/model-impl/rest/src/main/java/org/onap/policy/rest/RESTManager.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * rest + * ================================================================================ + * 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.rest; + +import java.io.IOException; +import java.util.Map; + +import org.apache.http.HttpResponse; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; + +public final class RESTManager { + + public static class Pair { + public final A a; + public final B b; + + public Pair(A a, B b) { + this.a = a; + this.b = b; + } + } + + public static Pair post(String url, String username, String password, Map headers, String contentType, String body) { + CredentialsProvider credentials = new BasicCredentialsProvider(); + credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); + + System.out.println("HTTP REQUEST: " + url + " -> " + username + ((password!=null)?password.length():"-") + " -> " + contentType); + if (headers != null) { + System.out.println("Headers: "); + headers.forEach((name, value) -> { + System.out.println(name + " -> " + value); + }); + } + System.out.println(body); + + try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) { + + HttpPost post = new HttpPost(url); + for (String key : headers.keySet()) { + post.addHeader(key, headers.get(key)); + } + post.addHeader("Content-Type", contentType); + + StringEntity input = new StringEntity(body); + input.setContentType(contentType); + post.setEntity(input); + + HttpResponse response = client.execute(post); + + String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); + System.out.println("HTTP POST Response Status Code: " + response.getStatusLine().getStatusCode()); + System.out.println("HTTP POST Response Body:"); + System.out.println(returnBody); + + return new Pair(response.getStatusLine().getStatusCode(), returnBody); + } catch (IOException e) { + System.err.println("Failed to POST to " + url + e.getLocalizedMessage()); + return null; + } + + } + + public static Pair get(String url, String username, String password, Map headers) { + + CredentialsProvider credentials = new BasicCredentialsProvider(); + credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); + + try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) { + + HttpGet get = new HttpGet(url); + for (String key : headers.keySet()) { + get.addHeader(key, headers.get(key)); + } + + HttpResponse response = client.execute(get); + + String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); + System.out.println("HTTP GET Response Status Code: " + response.getStatusLine().getStatusCode()); + System.out.println("HTTP GET Response Body:"); + System.out.println(returnBody); + + return new Pair(response.getStatusLine().getStatusCode(), returnBody); + } catch (IOException e) { + System.err.println("Failed to GET to " + url + e.getLocalizedMessage()); + return null; + } + } +} diff --git a/controlloop/common/model-impl/sdc/README.md b/controlloop/common/model-impl/sdc/README.md new file mode 100644 index 000000000..2a17461e5 --- /dev/null +++ b/controlloop/common/model-impl/sdc/README.md @@ -0,0 +1,3 @@ +ECOMP ASDC + + diff --git a/controlloop/common/model-impl/sdc/pom.xml b/controlloop/common/model-impl/sdc/pom.xml new file mode 100644 index 000000000..9a80bc6a4 --- /dev/null +++ b/controlloop/common/model-impl/sdc/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + sdc + + diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java new file mode 100644 index 000000000..99b770475 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Resource.java @@ -0,0 +1,119 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * 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.sdc; + +import java.io.Serializable; +import java.util.UUID; + +public class Resource implements Serializable { + + private static final long serialVersionUID = -913729158733348027L; + + public UUID resourceUUID; + public UUID resourceInvariantUUID; + public String resourceName; + public String resourceVersion; + public ResourceType resourceType; + + public Resource() { + + } + + public Resource(Resource resource) { + this.resourceUUID = resource.resourceUUID; + this.resourceInvariantUUID = resource.resourceInvariantUUID; + this.resourceName = resource.resourceName; + this.resourceVersion = resource.resourceVersion; + this.resourceType = resource.resourceType; + } + + public Resource(UUID uuid) { + this.resourceUUID = uuid; + } + + public Resource(String name, ResourceType type) { + this.resourceName = name; + this.resourceType = type; + } + + public Resource(UUID uuid, UUID invariantUUID, String name, String version, ResourceType type) { + this.resourceUUID = uuid; + this.resourceInvariantUUID = invariantUUID; + this.resourceName = name; + this.resourceVersion = version; + this.resourceType = type; + } + + @Override + public String toString() { + return "Resource [resourceUUID=" + resourceUUID + ", resourceInvariantUUID=" + resourceInvariantUUID + + ", resourceName=" + resourceName + ", resourceVersion=" + resourceVersion + ", resourceType=" + + resourceType + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((resourceInvariantUUID == null) ? 0 : resourceInvariantUUID.hashCode()); + result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode()); + result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); + result = prime * result + ((resourceUUID == null) ? 0 : resourceUUID.hashCode()); + result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Resource other = (Resource) obj; + if (resourceInvariantUUID == null) { + if (other.resourceInvariantUUID != null) + return false; + } else if (!resourceInvariantUUID.equals(other.resourceInvariantUUID)) + return false; + if (resourceName == null) { + if (other.resourceName != null) + return false; + } else if (!resourceName.equals(other.resourceName)) + return false; + if (resourceType == null) { + if (other.resourceType != null) + return false; + } else if (!resourceType.equals(other.resourceType)) + return false; + if (resourceUUID == null) { + if (other.resourceUUID != null) + return false; + } else if (!resourceUUID.equals(other.resourceUUID)) + return false; + if (resourceVersion == null) { + if (other.resourceVersion != null) + return false; + } else if (!resourceVersion.equals(other.resourceVersion)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java new file mode 100644 index 000000000..108163a34 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceInstance.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * 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.sdc; + +import java.io.Serializable; +import java.util.UUID; + +public class ResourceInstance implements Serializable { + private static final long serialVersionUID = -5506162340393802424L; + + public String resourceInstanceName; + public String resourceName; + public UUID resourceInvariantUUID; + public String resourceVersion; + public ResourceType resourceType; + public UUID resourceUUID; + + public ResourceInstance() { + + } + + public ResourceInstance(ResourceInstance instance) { + if (instance == null) { + return; + } + this.resourceInstanceName = instance.resourceInstanceName; + this.resourceName = instance.resourceName; + this.resourceInvariantUUID = instance.resourceInvariantUUID; + this.resourceVersion = instance.resourceVersion; + this.resourceType = instance.resourceType; + this.resourceUUID = instance.resourceUUID; + } + + @Override + public String toString() { + return "ResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName + + ", resourceInvariantUUID=" + resourceInvariantUUID + ", resourceVersion=" + resourceVersion + + ", resourceType=" + resourceType + ", resourceUUID=" + resourceUUID + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode()); + result = prime * result + ((resourceInvariantUUID == null) ? 0 : resourceInvariantUUID.hashCode()); + result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode()); + result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode()); + result = prime * result + ((resourceUUID == null) ? 0 : resourceUUID.hashCode()); + result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ResourceInstance other = (ResourceInstance) obj; + if (resourceInstanceName == null) { + if (other.resourceInstanceName != null) + return false; + } else if (!resourceInstanceName.equals(other.resourceInstanceName)) + return false; + if (resourceInvariantUUID == null) { + if (other.resourceInvariantUUID != null) + return false; + } else if (!resourceInvariantUUID.equals(other.resourceInvariantUUID)) + return false; + if (resourceName == null) { + if (other.resourceName != null) + return false; + } else if (!resourceName.equals(other.resourceName)) + return false; + if (resourceType != other.resourceType) + return false; + if (resourceUUID == null) { + if (other.resourceUUID != null) + return false; + } else if (!resourceUUID.equals(other.resourceUUID)) + return false; + if (resourceVersion == null) { + if (other.resourceVersion != null) + return false; + } else if (!resourceVersion.equals(other.resourceVersion)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java new file mode 100644 index 000000000..ee2fc89fd --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ResourceType.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * 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.sdc; + +public enum ResourceType { + VF("VF"), + VFC("VFC"), + VL("VL"), + CP("CP") + ; + + private String type; + + private ResourceType(String type) { + this.type = type; + } + + public String toString() { + return this.type; + } + +} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java new file mode 100644 index 000000000..4b97168b8 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/Service.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * 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.sdc; + +import java.io.Serializable; +import java.util.UUID; + +public class Service implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -1249276698549996806L; + + public UUID serviceUUID; + public UUID serviceInvariantUUID; + public String serviceName; + public String serviceVersion; + + public Service() { + + } + + public Service(UUID uuid) { + this.serviceUUID = uuid; + } + + public Service(String name) { + this.serviceName = name; + } + + public Service(UUID uuid, UUID invariantUUID, String name, String version) { + this.serviceUUID = uuid; + this.serviceInvariantUUID = invariantUUID; + this.serviceName = name; + this.serviceVersion = version; + } + + public Service(Service service) { + this.serviceUUID = service.serviceUUID; + this.serviceInvariantUUID = service.serviceInvariantUUID; + this.serviceName = service.serviceName; + this.serviceVersion = service.serviceVersion; + } + + @Override + public String toString() { + return "Service [serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID + + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((serviceInvariantUUID == null) ? 0 : serviceInvariantUUID.hashCode()); + result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); + result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode()); + result = prime * result + ((serviceVersion == null) ? 0 : serviceVersion.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Service other = (Service) obj; + if (serviceInvariantUUID == null) { + if (other.serviceInvariantUUID != null) + return false; + } else if (!serviceInvariantUUID.equals(other.serviceInvariantUUID)) + return false; + if (serviceName == null) { + if (other.serviceName != null) + return false; + } else if (!serviceName.equals(other.serviceName)) + return false; + if (serviceUUID == null) { + if (other.serviceUUID != null) + return false; + } else if (!serviceUUID.equals(other.serviceUUID)) + return false; + if (serviceVersion == null) { + if (other.serviceVersion != null) + return false; + } else if (!serviceVersion.equals(other.serviceVersion)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java new file mode 100644 index 000000000..519f88712 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/main/java/org/onap/policy/sdc/ServiceInstance.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * 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.sdc; + +import java.io.Serializable; +import java.util.UUID; + +public class ServiceInstance implements Serializable { + private static final long serialVersionUID = 6285260780966679625L; + + public UUID personaModelUUID; + public UUID serviceUUID; + public UUID serviceInstanceUUID; + public UUID widgetModelUUID; + public String widgetModelVersion; + public String serviceName; + public String serviceInstanceName; + + public ServiceInstance() { + + } + + public ServiceInstance(ServiceInstance instance) { + if (instance == null) { + return; + } + this.personaModelUUID = instance.personaModelUUID; + this.serviceUUID = instance.serviceUUID; + this.serviceInstanceUUID = instance.serviceInstanceUUID; + this.widgetModelUUID = instance.widgetModelUUID; + this.widgetModelVersion = instance.widgetModelVersion; + this.serviceName = instance.serviceName; + this.serviceInstanceName = instance.serviceInstanceName; + } + + @Override + public String toString() { + return "ServiceInstance [personaModelUUID=" + personaModelUUID + ", serviceUUID=" + serviceUUID + + ", serviceInstanceUUID=" + serviceInstanceUUID + ", widgetModelUUID=" + widgetModelUUID + + ", widgetModelVersion=" + widgetModelVersion + ", serviceName=" + serviceName + + ", serviceInstanceName=" + serviceInstanceName + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((personaModelUUID == null) ? 0 : personaModelUUID.hashCode()); + result = prime * result + ((serviceInstanceName == null) ? 0 : serviceInstanceName.hashCode()); + result = prime * result + ((serviceInstanceUUID == null) ? 0 : serviceInstanceUUID.hashCode()); + result = prime * result + ((serviceName == null) ? 0 : serviceName.hashCode()); + result = prime * result + ((serviceUUID == null) ? 0 : serviceUUID.hashCode()); + result = prime * result + ((widgetModelUUID == null) ? 0 : widgetModelUUID.hashCode()); + result = prime * result + ((widgetModelVersion == null) ? 0 : widgetModelVersion.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ServiceInstance other = (ServiceInstance) obj; + if (personaModelUUID == null) { + if (other.personaModelUUID != null) + return false; + } else if (!personaModelUUID.equals(other.personaModelUUID)) + return false; + if (serviceInstanceName == null) { + if (other.serviceInstanceName != null) + return false; + } else if (!serviceInstanceName.equals(other.serviceInstanceName)) + return false; + if (serviceInstanceUUID == null) { + if (other.serviceInstanceUUID != null) + return false; + } else if (!serviceInstanceUUID.equals(other.serviceInstanceUUID)) + return false; + if (serviceName == null) { + if (other.serviceName != null) + return false; + } else if (!serviceName.equals(other.serviceName)) + return false; + if (serviceUUID == null) { + if (other.serviceUUID != null) + return false; + } else if (!serviceUUID.equals(other.serviceUUID)) + return false; + if (widgetModelUUID == null) { + if (other.widgetModelUUID != null) + return false; + } else if (!widgetModelUUID.equals(other.widgetModelUUID)) + return false; + if (widgetModelVersion == null) { + if (other.widgetModelVersion != null) + return false; + } else if (!widgetModelVersion.equals(other.widgetModelVersion)) + return false; + return true; + } + +} diff --git a/controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml b/controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml new file mode 100644 index 000000000..6fb1f7cfa --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/main/resources/definitions.yaml @@ -0,0 +1,76 @@ +Service: + type: Object + properties: + serviceUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + serviceInvariantUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + serviceName: + type: string + serviceVersion: + type: string +Resource: + type: Object + properties: + resourceUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + resourceInvariantUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + resourceName: + type: string + resourceVersion: + type: string + resourceType: + type: string + valid_values: + - VF + - VFC + - CP + - VL +ServiceInstance: + type: Object + properties: + personaModelUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + serviceUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + serviceInstanceUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + widgetModelUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + widgetModelVersion: + type: string + serviceName: + type: string + serviceInstanceName: + type: string +ResourceInstance: + type: object + properties: + resourceInstanceName: + type: string + resourceName: + type: string + resourceInvariantUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" + resourceVersion: + type: string + resourceType: + type: string + valid_values: + - VF + - VFC + - CP + - VL + resourceUUID: + type: string + pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" diff --git a/controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml b/controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml new file mode 100644 index 000000000..2dda7d705 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/resources/service_trinity.yaml @@ -0,0 +1,3 @@ +Service: + serviceName: trinity + \ No newline at end of file diff --git a/controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml b/controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml new file mode 100644 index 000000000..c56961ec9 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/resources/service_vSCP.yaml @@ -0,0 +1,2 @@ +Service: + serviceName: vSCP \ No newline at end of file diff --git a/controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml b/controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml new file mode 100644 index 000000000..e63636d39 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/resources/service_vUSP.yaml @@ -0,0 +1,2 @@ +Service: + serviceName: vUSP diff --git a/controlloop/common/model-impl/trafficgenerator/pom.xml b/controlloop/common/model-impl/trafficgenerator/pom.xml new file mode 100644 index 000000000..e822f1d9e --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + trafficgenerator + + + org.onap.policy.drools-applications + model-impl + 1.1.0-SNAPSHOT + + + + + junit + junit + 4.12 + provided + + + com.google.code.gson + gson + 2.5 + provided + + + diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java new file mode 100644 index 000000000..d08d9422e --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGRequest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * 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.vnf.trafficgenerator; + +import java.io.Serializable; + + +import com.google.gson.annotations.SerializedName; + +public class PGRequest implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3283942659786236032L; + + @SerializedName("pg-streams") + public PGStreams pgStreams; + + public PGRequest() { + } + +} diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java new file mode 100644 index 000000000..de5a2c37d --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStream.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * 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.vnf.trafficgenerator; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +public class PGStream implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5567635677419358210L; + + @SerializedName("id") + public String streamId; + @SerializedName("is-enabled") + public String isEnabled; + + public PGStream() { + } + +} diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java new file mode 100644 index 000000000..dc0d4084f --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/PGStreams.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * 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.vnf.trafficgenerator; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +public class PGStreams implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 5567635677419358210L; + + @SerializedName("pg-stream") + public List pgStream= new LinkedList(); + + public PGStreams() { + } + +} diff --git a/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java new file mode 100644 index 000000000..e64991d94 --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/src/main/java/org/onap/policy/vnf/trafficgenerator/util/Serialization.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * 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.vnf.trafficgenerator.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public final class Serialization { + + final static public Gson gsonPretty = new GsonBuilder().disableHtmlEscaping() + .setPrettyPrinting() +// .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter()) + .create(); +} diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java new file mode 100644 index 000000000..656234ca2 --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * 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.vnf.trafficgenerator; + + +import org.junit.Test; +import org.onap.policy.vnf.trafficgenerator.PGRequest; +import org.onap.policy.vnf.trafficgenerator.PGStream; +import org.onap.policy.vnf.trafficgenerator.PGStreams; +import org.onap.policy.vnf.trafficgenerator.util.Serialization; + +public class TestDemo { + + @Test + public void test() { + PGRequest request = new PGRequest(); + request.pgStreams = new PGStreams(); + + PGStream pgStream; + for(int i = 0; i < 5; i++){ + pgStream = new PGStream(); + pgStream.streamId = "fw_udp"+(i+1); + pgStream.isEnabled = "true"; + request.pgStreams.pgStream.add(pgStream); + } + + String body = Serialization.gsonPretty.toJson(request); + System.out.println(body); + + // fail("Not yet implemented"); + } + +} -- cgit 1.2.3-korg