summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java16
-rw-r--r--controlloop/common/actors/actor.vfc/pom.xml7
-rw-r--r--controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java50
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java12
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java16
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199CloudRegion.java51
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperties.java42
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperty.java48
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199GenericVNF.java85
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InstanceFilters.java43
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java64
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java42
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java116
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199NamedQuery.java41
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199QueryParameters.java40
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Request.java65
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199RequestWrapper.java39
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Response.java43
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java40
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ServiceInstance.java55
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Tenant.java45
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VServer.java61
-rw-r--r--controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VfModule.java69
-rw-r--r--controlloop/common/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java2
-rw-r--r--controlloop/common/msb/pom.xml51
-rw-r--r--controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceException.java40
-rw-r--r--controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java107
-rw-r--r--controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java58
-rw-r--r--controlloop/common/msb/src/main/java/org/onap/policy/msb/client/Node.java56
-rw-r--r--controlloop/common/msb/src/main/resources/msb.policy.properties22
-rw-r--r--controlloop/common/msb/src/test/java/org/onap/policy/msb/client/MSBServiceManagerTest.java116
-rw-r--r--controlloop/common/pom.xml1
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java4
-rw-r--r--controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java4
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl6
-rw-r--r--controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java4
-rw-r--r--controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl4
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java4
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java42
-rw-r--r--controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java3
40 files changed, 560 insertions, 1054 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
index a014c7a80..8c1b23af9 100644
--- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
+++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
@@ -136,10 +136,10 @@ public class SOActorServiceProvider implements Actor {
}
- /**
+ /**
* Constructs and sends an AAI vserver Named Query
*
- * @param eventRequestID
+ * @param onset
* @returns the response to the AAI Named Query
*/
private AAINQResponseWrapper AaiNamedQueryRequest(VirtualControlLoopEvent onset) {
@@ -239,9 +239,9 @@ public class SOActorServiceProvider implements Actor {
int nonBaseIndex = -1;
List<AAINQInventoryResponseItem> inventoryItems = namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems;
for (AAINQInventoryResponseItem m : inventoryItems) {
- if (m.vfModule != null && m.vfModule.isBaseVfModule == true) {
+ if (m.vfModule != null && m.vfModule.isBaseVfModule) {
baseIndex = inventoryItems.indexOf(m);
- } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) {
+ } else if (m.vfModule != null && m.vfModule.orchestrationStatus == null) {
nonBaseIndex = inventoryItems.indexOf(m);
}
//
@@ -302,7 +302,7 @@ public class SOActorServiceProvider implements Actor {
}
// Extracted fields should not be null
- if (checkExtractedFields() == false) {
+ if (!checkExtractedFields()) {
System.err.println("some fields are missing from AAI response.");
return;
}
@@ -338,7 +338,7 @@ public class SOActorServiceProvider implements Actor {
*/
public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
- if (policy.getActor().equals("SO") && policy.getRecipe().equals("VF Module Create")) {
+ if ("SO".equals(policy.getActor()) && "VF Module Create".equals(policy.getRecipe())) {
// perform named query request and handle response
AaiNamedQueryRequest(onset);
} else {
@@ -348,7 +348,7 @@ public class SOActorServiceProvider implements Actor {
// check if the fields extracted from named query response are
// not null so we can proceed with SO request
- if (checkExtractedFields() == false) {
+ if (!checkExtractedFields()) {
System.err.println("AAI response is missing some required fields. Cannot proceed with SO Request construction.");
return null;
@@ -553,7 +553,7 @@ public class SOActorServiceProvider implements Actor {
}
/**
- * @param serviceItemModeInvariantlId the serviceItemModelInvariantId to set
+ * @param serviceItemModelInvariantId the serviceItemModelInvariantId to set
*/
private void setServiceItemModelInvariantId(String serviceItemModelInvariantId) {
this.serviceItemModelInvariantId = serviceItemModelInvariantId;
diff --git a/controlloop/common/actors/actor.vfc/pom.xml b/controlloop/common/actors/actor.vfc/pom.xml
index c52b6aed7..223be4bda 100644
--- a/controlloop/common/actors/actor.vfc/pom.xml
+++ b/controlloop/common/actors/actor.vfc/pom.xml
@@ -34,6 +34,11 @@
<version>1.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
index 1ea65faa5..469faa46c 100644
--- a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
+++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java
@@ -28,6 +28,7 @@ import org.onap.policy.vfc.VFCHealAdditionalParams;
import org.onap.policy.vfc.VFCHealActionVmInfo;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.policy.Policy;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
import com.google.common.collect.ImmutableList;
@@ -66,53 +67,50 @@ public class VFCActorServiceProvider implements Actor {
public static VFCRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
Policy policy) {
-
// Construct an VFC request
VFCRequest request = new VFCRequest();
- // TODO: Verify service-instance-id is part of onset event
- request.nsInstanceId = getAAIServiceInstance(onset); // onset.AAI.get("service-instance.service-instance-id");
- request.requestId = onset.requestID;
+ request.nsInstanceId = getAAIServiceInstance(onset);
+ request.requestId = onset.requestID;
request.healRequest = new VFCHealRequest();
request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id");
request.healRequest.cause = operation.message;
request.healRequest.additionalParams = new VFCHealAdditionalParams();
- switch (policy.getRecipe()) {
- case "Restart":
- // TODO: check target??
- request.healRequest.additionalParams.action = "restartvm";
- request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
- // TODO: Verify vserver-id and vserver-name is part of onset event
- request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id");
- request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name");
- break;
- default:
- // TODO: default
- break;
+ if ("Restart".equalsIgnoreCase(policy.getRecipe())) {
+ request.healRequest.additionalParams.action = "restartvm";
+ request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
+ request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id");
+ request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name");
+ } else {
+ request = null;
}
return request;
}
private static String getAAIServiceInstance(VirtualControlLoopEvent event) {
- AAIGETVnfResponse response = null;
+ AAIGETVnfResponse response;
UUID requestID = event.requestID;
String serviceInstance = event.AAI.get("service-instance.service-instance-id");
String vnfName = event.AAI.get("generic-vnf.vnf-name");
String vnfID = event.AAI.get("generic-vnf.vnf-id");
- String urlBase = "http://localhost:6666";
- String username = "testUser";
- String password = "testPass";
if (serviceInstance == null) {
+ String aaiUrl = PolicyEngine.manager.getEnvironmentProperty("aai.url");
+ String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username");
+ String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
try {
if (vnfName != null) {
- String url = urlBase + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
- response = AAIManager.getQueryByVnfName(url, username, password, requestID, vnfName);
- serviceInstance = response.serviceId;
+ String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
+ response = AAIManager.getQueryByVnfName(url, aaiUsername, aaiPassword, requestID, vnfName);
+ if (response != null) {
+ serviceInstance = response.serviceId;
+ }
} else if (vnfID != null) {
- String url = urlBase + "/aai/v11/network/generic-vnfs/generic-vnf/";
- response = AAIManager.getQueryByVnfID(url, username, password, requestID, vnfID);
- serviceInstance = response.serviceId;
+ String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf/";
+ response = AAIManager.getQueryByVnfID(url, aaiUsername, aaiPassword, requestID, vnfID);
+ if (response != null) {
+ serviceInstance = response.serviceId;
+ }
} else {
logger.error("getAAIServiceInstance failed");
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 0d4aa938c..7aaac9ead 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -629,7 +629,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
try {
if (vserverName != null) {
aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
- aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user");
+ aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name=";
String url = aaiHostURL + aaiGetQueryByVserver;
@@ -650,19 +650,17 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
String vnfName = event.AAI.get("generic-vnf.vnf-name");
String vnfID = event.AAI.get("generic-vnf.vnf-id");
+ aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
+ aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.username");
+ aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
+
try {
if (vnfName != null) {
- aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
- aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user");
- aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
String aaiGetQueryByVnfName = "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
String url = aaiHostURL + aaiGetQueryByVnfName;
logger.info("url: " + url);
response = AAIManager.getQueryByVnfName(url, aaiUser, aaiPassword, requestID, vnfName);
} else if (vnfID != null) {
- aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
- aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user");
- aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
String aaiGetQueryByVnfID = "/aai/v11/network/generic-vnfs/generic-vnf/";
String url = aaiHostURL + aaiGetQueryByVnfID;
logger.info("url: " + url);
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index 10cf173fc..e13352ac0 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -346,13 +346,16 @@ public class ControlLoopOperationManager implements Serializable {
return null;
} else if (response instanceof SOResponse) {
SOResponse msoResponse = (SOResponse) response;
+
+ Integer operationAttempt = this.attempts;
+
switch (msoResponse.httpResponseCode) {
case 200:
case 202:
//
// Consider it as success
//
- this.completeOperation(new Integer(1), msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS);
+ this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS);
if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
return null;
}
@@ -361,20 +364,23 @@ public class ControlLoopOperationManager implements Serializable {
//
// Consider it as failure
//
- this.completeOperation(new Integer(1), msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE);
+ this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE);
if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
return null;
}
+ // increment operation attempts for retries
+ this.attempts += 1;
return PolicyResult.FAILURE;
}
} else if (response instanceof VFCResponse) {
VFCResponse vfcResponse = (VFCResponse) response;
+ Integer operationAttempt = this.attempts;
if (vfcResponse.responseDescriptor.getStatus().equalsIgnoreCase("finished")) {
//
// Consider it as success
//
- this.completeOperation(new Integer(1), " Success", PolicyResult.SUCCESS);
+ this.completeOperation(operationAttempt, " Success", PolicyResult.SUCCESS);
if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
return null;
}
@@ -383,10 +389,12 @@ public class ControlLoopOperationManager implements Serializable {
//
// Consider it as failure
//
- this.completeOperation(new Integer(1), " Failed", PolicyResult.FAILURE);
+ this.completeOperation(operationAttempt, " Failed", PolicyResult.FAILURE);
if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) {
return null;
}
+ // increment operation attempts for retries
+ this.attempts += 1;
return PolicyResult.FAILURE;
}
}
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
deleted file mode 100644
index 4c80c4a41..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199CloudRegion.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index ca5863a46..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperties.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============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<AAINQF199ExtraProperty> extraProperty = new LinkedList<AAINQF199ExtraProperty>();
-
- 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
deleted file mode 100644
index 7280ff9bc..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ExtraProperty.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index eb19ad95e..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199GenericVNF.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============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;
-
- @SerializedName("model-invariant-id")
- public String modelInvariantId;
-
- 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
deleted file mode 100644
index 80ab73d74..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InstanceFilters.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============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<Map<String, Map<String, String>>> instanceFilter = new LinkedList<Map<String, Map<String, String>>>();
-
- 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
deleted file mode 100644
index d896c931b..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItem.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index d3d17093f..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199InventoryResponseItems.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============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<AAINQF199InventoryResponseItem> inventoryResponseItems = new LinkedList<AAINQF199InventoryResponseItem>();
-
- 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
deleted file mode 100644
index 00f62cf10..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Manager.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * ============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 org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.gson.JsonSyntaxException;
-
-public final class AAINQF199Manager {
- private static final Logger logger = LoggerFactory.getLogger(AAINQF199Manager.class);
-
- public static AAINQF199Response postQuery(String url, String username, String password, AAINQF199Request request, UUID requestID) {
-
- Map<String, String> headers = new HashMap<>();
- headers.put("X-FromAppId", "POLICY");
- headers.put("X-TransactionId", requestID.toString());
- headers.put("Accept", "application/json");
-
- url = url + "/aai/search/named-query";
-
- Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
-
- logger.debug("Performing AAI POST to " + url + "\nSending: \n" + Serialization.gsonPretty.toJson(request) + "END");
-
- if (httpDetails == null) {
- logger.debug("AAI POST - Null Response from {}", url);
- return null;
- }
-
- logger.debug(url);
- logger.debug("{}", httpDetails.a);
- logger.debug("{}", httpDetails.b);
- if (httpDetails.a == 200) {
- try {
- AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class);
- return response;
- } catch (JsonSyntaxException e) {
- logger.error("postQuery threw: ", e);
- }
- }
-
- return null;
- }
-
- public static AAIGETResponse getQuery(String urlGet, String username, String password, UUID requestID, String vnfId) {
-
- Map<String, String> 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<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
- if (httpDetailsGet == null) {
- logger.debug("AAI GET Null Response to {}", urlGet);
- return null;
- }
-
- logger.debug(urlGet);
- logger.debug("{}", httpDetailsGet.a);
- logger.debug("{}", httpDetailsGet.b);
-
- if (httpDetailsGet.a == 200) {
- try {
- responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, AAIGETResponse.class);
- return responseGet;
- } catch (JsonSyntaxException e) {
- logger.error("getQuery threw: ", e);
- }
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- logger.error(e.getMessage());
- Thread.currentThread().interrupt();
- }
-
- }
-
- 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
deleted file mode 100644
index 922d67f39..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199NamedQuery.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 8812a2483..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199QueryParameters.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 0feb6d73b..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Request.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index fdd630ba8..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199RequestWrapper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index bcecc04b9..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Response.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============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<AAINQF199InventoryResponseItem> 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
deleted file mode 100644
index d4fe8f86d..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ResponseWrapper.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 8aa4a1b2a..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199ServiceInstance.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 763c052ca..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199Tenant.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============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
deleted file mode 100644
index 823dc76a0..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VServer.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * ============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 AAINQF199VServer implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -6718526692734215643L;
-
- @SerializedName("vserver-id")
- public String vserverId;
-
- @SerializedName("vserver-name")
- public String vserverName;
-
- @SerializedName("vserver-name2")
- public String vserverName2;
-
- @SerializedName("prov-status")
- public String provStatus;
-
- @SerializedName("vserver-selflink")
- public String vserverSelflink;
-
- @SerializedName("in-maint")
- public Boolean inMaint;
-
- @SerializedName("is-closed-loop-disabled")
- public Boolean isClosedLoopDisabled;
-
- @SerializedName("resource-version")
- public String resourceVersion;
-
- public 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
deleted file mode 100644
index 50161fb8a..000000000
--- a/controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AAINQF199/AAINQF199VfModule.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============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/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
index 9578d9ac2..37b148beb 100644
--- 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
@@ -80,6 +80,7 @@ public final class Serialization {
private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ @Override
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
throws JsonParseException {
try {
@@ -90,6 +91,7 @@ public final class Serialization {
return null;
}
+ @Override
public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
return new JsonPrimitive(datetime.format(format));
}
diff --git a/controlloop/common/msb/pom.xml b/controlloop/common/msb/pom.xml
new file mode 100644
index 000000000..9b66a1159
--- /dev/null
+++ b/controlloop/common/msb/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>model-impl</artifactId>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>msb</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.msb.java-sdk</groupId>
+ <artifactId>msb-java-sdk</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>1.2.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project> \ No newline at end of file
diff --git a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceException.java b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceException.java
new file mode 100644
index 000000000..f5bbdb5f2
--- /dev/null
+++ b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceException.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright 2017 ZTE, Inc. and others.
+ *
+ * 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.
+ ******************************************************************************/
+
+package org.onap.policy.msb.client;
+
+public class MSBServiceException extends Exception {
+
+ public MSBServiceException() {
+ super();
+ }
+
+ public MSBServiceException(String message, Throwable cause, boolean enableSuppression,
+ boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ public MSBServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public MSBServiceException(String message) {
+ super(message);
+ }
+
+ public MSBServiceException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java
new file mode 100644
index 000000000..cc3ff71e3
--- /dev/null
+++ b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceFactory.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright 2017 ZTE, Inc. and others.
+ *
+ * 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.
+ ******************************************************************************/
+package org.onap.policy.msb.client;
+
+import org.onap.msb.sdk.discovery.common.RouteException;
+import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
+import org.onap.msb.sdk.discovery.entity.NodeInfo;
+import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Iterator;
+import java.util.Properties;
+
+
+public class MSBServiceFactory {
+ private static final Logger logger = LoggerFactory.getLogger(MSBServiceFactory.class);
+ private static final String msbPropertyFile = "msb.policy.properties";
+ private static final String MSB_IP = "msb.ip";
+ private static final String MSB_PORT = "msb.port";
+ private MSBServiceClient msbClient;
+ private Properties properties;
+
+ public MSBServiceFactory() throws MSBServiceException,IOException{
+ this.init();
+ this.msbClient = new MSBServiceClient(properties.getProperty(MSB_IP), Integer.parseInt(properties.getProperty(MSB_PORT)));
+ }
+ public MSBServiceFactory (MSBServiceClient msbClient) {
+ this.msbClient = msbClient;
+ }
+
+ private void init() throws MSBServiceException,IOException {
+ properties = new Properties();
+ Path file = Paths.get(System.getProperty(msbPropertyFile));
+ if (file == null) {
+ throw new MSBServiceException("No msb.policy.properties specified.");
+ }
+ if (Files.notExists(file)) {
+ throw new MSBServiceException("No msb.policy.properties specified.");
+ }
+
+ if (Files.isReadable(file) == false) {
+ throw new MSBServiceException ("Repository is NOT readable: " + file.toAbsolutePath());
+ }
+ try(InputStream is = new FileInputStream(file.toFile())){
+ properties.load(is);
+ }
+ }
+
+
+ public Node getNode(String serviceName,String version){
+ return this.build(serviceName,version);
+ }
+
+ public Node getNode(String actor){
+ Node node = null;
+ switch (actor) {
+ case "AAI":
+ node = this.build("aai-search","v11");
+ return node;
+ case "SO":
+ node = this.build("so","v2");
+ return node;
+ case "VFC":
+ node = this.build("nfvo-nslcm","v1");
+ return node;
+ default:
+ logger.info("MSBServiceManager: policy has an unknown actor.");
+ }
+ return node;
+ }
+
+ private Node build(String serviceName,String version){
+ Node node = new Node();
+ node.setName(serviceName);
+ try {
+ MicroServiceFullInfo serviceInfo = msbClient.queryMicroServiceInfo(serviceName,version);
+ Iterator iterator = serviceInfo.getNodes().iterator();
+ while(iterator.hasNext()) {
+ NodeInfo nodeInfo = (NodeInfo)iterator.next();
+ node.setIp(nodeInfo.getIp());
+ node.setPort(nodeInfo.getPort());
+ }
+ } catch (RouteException e) {
+ logger.info("MSBServiceManager:",e);
+ }
+ return node;
+ }
+}
diff --git a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java
new file mode 100644
index 000000000..cbff8d88a
--- /dev/null
+++ b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/MSBServiceManager.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright 2017 ZTE, Inc. and others.
+ *
+ * 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.
+ ******************************************************************************/
+package org.onap.policy.msb.client;
+
+import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+public class MSBServiceManager implements Serializable {
+ private static final Logger logger = LoggerFactory.getLogger(MSBServiceManager.class);
+ private static final long serialVersionUID = -2517971308551895215L;
+ private MSBServiceFactory factory;
+
+ public MSBServiceManager() throws MSBServiceException,IOException {
+ this.factory = new MSBServiceFactory();
+ }
+
+ public MSBServiceManager(MSBServiceClient msbClient){
+
+ this.factory = new MSBServiceFactory(msbClient);
+ }
+
+ /**
+ * Get the IP and port of the components registered in the MSB
+ * @param actor AAI or SO or VFC
+ * @return
+ */
+ public Node getNode(String actor){
+
+ return factory.getNode(actor);
+ }
+
+ /**
+ * Get the IP and port of the components registered in the MSB
+ * @param serviceName the service name registered in the MSB
+ * @param version the service version registered in the MSB
+ * @return
+ */
+ public Node getNode(String serviceName,String version){
+
+ return factory.getNode(serviceName,version);
+ }
+
+}
diff --git a/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/Node.java b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/Node.java
new file mode 100644
index 000000000..5c06939bf
--- /dev/null
+++ b/controlloop/common/msb/src/main/java/org/onap/policy/msb/client/Node.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright 2017 ZTE, Inc. and others.
+ *
+ * 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.
+ ******************************************************************************/
+package org.onap.policy.msb.client;
+
+import java.io.Serializable;
+
+public class Node implements Serializable {
+ private static final long serialVersionUID = -5028618045561310837L;
+ private String name;
+ private String ip;
+ private String port;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ @Override
+ public String toString() {
+ return "Node{" +
+ "name='" + name + '\'' +
+ ", ip='" + ip + '\'' +
+ ", port='" + port + '\'' +
+ '}';
+ }
+}
diff --git a/controlloop/common/msb/src/main/resources/msb.policy.properties b/controlloop/common/msb/src/main/resources/msb.policy.properties
new file mode 100644
index 000000000..bb372ec85
--- /dev/null
+++ b/controlloop/common/msb/src/main/resources/msb.policy.properties
@@ -0,0 +1,22 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP-PDP
+# ================================================================================
+# 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=========================================================
+###
+
+msb.ip=127.0.0.1
+msb.port=10081 \ No newline at end of file
diff --git a/controlloop/common/msb/src/test/java/org/onap/policy/msb/client/MSBServiceManagerTest.java b/controlloop/common/msb/src/test/java/org/onap/policy/msb/client/MSBServiceManagerTest.java
new file mode 100644
index 000000000..9ab54f7ea
--- /dev/null
+++ b/controlloop/common/msb/src/test/java/org/onap/policy/msb/client/MSBServiceManagerTest.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright 2017 ZTE, Inc. and others.
+ *
+ * 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.
+ ******************************************************************************/
+package org.onap.policy.msb.client;
+
+import org.junit.*;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.msb.sdk.discovery.common.RouteException;
+import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;
+import org.onap.msb.sdk.discovery.entity.NodeInfo;
+import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
+import org.onap.policy.msb.client.MSBServiceManager;
+import org.onap.policy.msb.client.Node;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+public class MSBServiceManagerTest {
+ @Mock
+ private MSBServiceClient msbClient;
+
+ private MSBServiceManager msbManager;
+
+ public MSBServiceManagerTest(){}
+
+ @BeforeClass
+ public static void setUpClass(){}
+
+ @AfterClass
+ public static void tearDownClass(){}
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ msbManager = new MSBServiceManager(msbClient);
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ @Test
+ public void testByActor () throws RouteException,UnknownHostException {
+ MicroServiceFullInfo serviceInfo = this.build(InetAddress.getLocalHost().getHostAddress(),"8843");
+ when(msbClient.queryMicroServiceInfo("aai-search","v11")).thenReturn(serviceInfo);
+ Node node = msbManager.getNode("AAI");
+ assertNotNull(node);
+ serviceInfo = this.build(InetAddress.getLocalHost().getHostAddress(),"8840");
+ when(msbClient.queryMicroServiceInfo("so","v2")).thenReturn(serviceInfo);
+ node = msbManager.getNode("SO");
+ assertNotNull(node);
+
+ serviceInfo = this.build(InetAddress.getLocalHost().getHostAddress(),"8082");
+ when(msbClient.queryMicroServiceInfo("nfvo-nslcm","v1")).thenReturn(serviceInfo);
+ node = msbManager.getNode("VFC");
+ assertNotNull(node);
+
+ }
+
+ @Test
+ public void testByActor_when_actorNotExist_returnNull () throws RouteException,UnknownHostException {
+ MicroServiceFullInfo serviceInfo = this.build(InetAddress.getLocalHost().getHostAddress(),"8843");
+ when(msbClient.queryMicroServiceInfo("aai-search","v11")).thenReturn(serviceInfo);
+ Node node = msbManager.getNode("DDD");
+ assertNull(node);
+ }
+
+ @Test
+ public void testByServiceNameAndVersion () throws RouteException,UnknownHostException {
+ MicroServiceFullInfo serviceInfo = this.build(InetAddress.getLocalHost().getHostAddress(),"8843");
+ when(msbClient.queryMicroServiceInfo("aai-search","v11")).thenReturn(serviceInfo);
+ Node node = msbManager.getNode("aai-search","v11");
+ assertNotNull(node);
+ }
+
+ @Test
+ public void testByServiceNameAndVersion_when_serice_notRegistedToMSB () throws RouteException,UnknownHostException {
+ MicroServiceFullInfo serviceInfo = this.build(InetAddress.getLocalHost().getHostAddress(),"8843");
+ when(msbClient.queryMicroServiceInfo("aai-search","v11")).thenThrow(new RouteException());
+ Node node = msbManager.getNode("aai-search","v11");
+ assertNotNull(node);
+ assertTrue(node.getName() == "aai-search");
+ assertTrue(node.getIp() == null);
+ assertTrue(node.getPort() == null);
+ }
+
+ public static MicroServiceFullInfo build(String ip,String port){
+ MicroServiceFullInfo serviceInfo = new MicroServiceFullInfo();
+ Set<NodeInfo> nodes = new HashSet<NodeInfo>();
+ NodeInfo node= new NodeInfo();
+ node.setPort(port);
+ node.setIp(ip);
+ nodes.add(node);
+ serviceInfo.setNodes(nodes);
+ return serviceInfo;
+ }
+
+}
diff --git a/controlloop/common/pom.xml b/controlloop/common/pom.xml
index 39f1b7038..8725d7956 100644
--- a/controlloop/common/pom.xml
+++ b/controlloop/common/pom.xml
@@ -40,6 +40,7 @@
<module>policy-yaml</module>
<module>simulators</module>
<module>feature-controlloop-utils</module>
+ <module>msb</module>
</modules>
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
index 59e97c239..ad106e555 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java
@@ -36,6 +36,7 @@ public class AaiSimulatorJaxRs {
@GET
@Path("/v8/network/generic-vnfs/generic-vnf/{vnfId}")
+ @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String aaiGetQuery (@PathParam("vnfID") String vnfId)
{
@@ -63,6 +64,7 @@ public class AaiSimulatorJaxRs {
@GET
@Path("/v11/network/generic-vnfs/generic-vnf?vnf-name={vnfName}")
+ @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String getByVnfName (@PathParam("vnfName") String vnfName)
{
@@ -72,6 +74,7 @@ public class AaiSimulatorJaxRs {
@GET
@Path("/v11/network/generic-vnfs/generic-vnf/{vnfId}")
+ @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String getByVnfId (@PathParam("vnfId") String vnfId)
{
@@ -81,6 +84,7 @@ public class AaiSimulatorJaxRs {
@GET
@Path("/v11/nodes/vservers?vserver-name={vserverName}")
+ @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String getByVserverName (@PathParam("vserverName") String vserverName)
{
diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
index 926536e31..53ae7bc4b 100644
--- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
+++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/VfcSimulatorJaxRs.java
@@ -20,6 +20,7 @@
package org.onap.policy.simulators;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -27,12 +28,14 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
@Path("/api/nslcm/v1")
public class VfcSimulatorJaxRs {
@POST
@Path("/ns/{nsInstanceId}/heal")
+ @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String vfcPostQuery(@PathParam("nsInstanceId") String nsInstanceId,
@Context final HttpServletResponse response)
@@ -47,6 +50,7 @@ public class VfcSimulatorJaxRs {
@GET
@Path("/jobs/{jobId}")
+ @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String vfcGetQuery(@PathParam("jobId") String jobId) {
return "{\"jobId\" : "+jobId+",\"responseDescriptor\" : {\"progress\" : \"40\",\"status\" : \"finished\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\": 101 ,\"responseHistoryList\": [{\"progress\" : \"40\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"1\"}, {\"progress\" : \"41\",\"status\" : \"proccessing\",\"statusDescription\" : \"OMC VMs are decommissioned in VIM\",\"errorCode\" : null,\"responseId\" : \"2\"}]}}";
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index b10cc3bb7..343221f0d 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -506,7 +506,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
$manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, getGuardApprovalStatus() == "Permit" )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
$lock : TargetLock (requestID == $event.requestID)
then
@@ -620,7 +620,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
// to the CallGuardTask() and set the first argument to null
// (instead of XacmlPdpEngine).
//
- boolean guardEnabled = false;
+ boolean guardEnabled = true;
if(guardEnabled){
@@ -682,7 +682,7 @@ rule "${policyName}.GUARD.RESPONSE"
PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
- if("Permit".equals($guardResponse.result)){
+ if("Permit".equalsIgnoreCase($guardResponse.result)){
modify($operation){setGuardApprovalStatus($guardResponse.result)};
}
diff --git a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
index 6f79c6a74..333fde6b2 100644
--- a/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
+++ b/controlloop/templates/template.demo.v1.0.0/template.demo/src/test/java/org/onap/policy/template/demo/TestSO.java
@@ -33,8 +33,8 @@ import org.onap.policy.mso.SORequest;
import org.onap.policy.mso.SORequestDetails;
import org.onap.policy.mso.SORequestInfo;
import org.onap.policy.mso.SORequestParameters;
-import org.onap.policy.aai.AAINQF199.AAINQF199Response;
-import org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
+import org.onap.policy.aai.AAINQResponse;
+import org.onap.policy.aai.AAINQResponseWrapper;
import org.onap.policy.mso.util.Serialization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
index 64101ac56..6976e9937 100644
--- a/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
+++ b/controlloop/templates/template.demo/src/main/resources/ControlLoop_Template_xacml_guard.drl
@@ -473,7 +473,7 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
$manager : ControlLoopEventManager( closedLoopControlName == $event.closedLoopControlName, requestID == $event.requestID )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, getGuardApprovalStatus() == "Permit" )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.closedLoopControlName, onset.requestID == $event.requestID, "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
$lock : TargetLock (requestID == $event.requestID)
then
//
@@ -657,7 +657,7 @@ rule "${policyName}.GUARD.RESPONSE"
- if("Permit".equals($guardResponse.result)){
+ if("Permit".equalsIgnoreCase($guardResponse.result)){
modify($operation){setGuardApprovalStatus($guardResponse.result)};
}
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
index f8f906867..8e8ac355c 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/Util.java
@@ -126,6 +126,10 @@ public final class Util {
return org.onap.policy.simulators.Util.buildVfcSim();
}
+ public static HttpServletServer buildGuardSim() throws InterruptedException, IOException {
+ return org.onap.policy.simulators.Util.buildGuardSim();
+ }
+
private static String generatePolicy(String ruleContents,
String closedLoopControlName,
String policyScope,
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
index 53c924598..9743f8808 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java
@@ -28,6 +28,8 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.UUID;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
@@ -41,7 +43,9 @@ import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.TargetType;
+import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
+import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.guard.PolicyGuard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,7 +56,33 @@ public class VCPEControlLoopTest {
private KieSession kieSession;
private Util.Pair<ControlLoopPolicy, String> pair;
- private PolicyEngineJUnitImpl engine;
+ private PolicyEngineJUnitImpl engine;
+
+ static {
+ /* Set environment properties */
+ PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
+ PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
+ PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
+
+ PolicyEngine.manager.setEnvironmentProperty("guard.url", "http://localhost:6669/pdp/api/getDecision");
+ PolicyEngine.manager.setEnvironmentProperty("guard.username", "GUARD");
+ PolicyEngine.manager.setEnvironmentProperty("guard.password", "GUARD");
+ }
+
+ @BeforeClass
+ public static void setUpSimulator() {
+ try {
+ Util.buildAaiSim();
+ Util.buildGuardSim();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @AfterClass
+ public static void tearDownSimulator() {
+ HttpServletServer.factory.destroy();
+ }
@Test
public void successTest() {
@@ -168,7 +198,7 @@ public class VCPEControlLoopTest {
* See if Guard permits this action, if it does
* not then the test should fail
*/
- if (((VirtualControlLoopNotification)obj).message.contains("Guard result: Permit")) {
+ if (((VirtualControlLoopNotification)obj).message.contains("Guard result: PERMIT")) {
/*
* A notification should be sent out of the Policy
@@ -395,13 +425,10 @@ public class VCPEControlLoopTest {
event.target = "generic-vnf.vnf-id";
event.closedLoopAlarmStart = Instant.now();
event.AAI = new HashMap<>();
- event.AAI.put("cloud-region.identity-url", "foo");
- event.AAI.put("vserver.selflink", "bar");
- event.AAI.put("vserver.is-closed-loop-disabled", "false");
event.AAI.put("generic-vnf.vnf-id", "testGenericVnfId");
event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
kieSession.insert(event);
- Thread.sleep(1000);
+ Thread.sleep(2000);
}
/**
@@ -421,9 +448,6 @@ public class VCPEControlLoopTest {
event.closedLoopAlarmStart = Instant.now().minusSeconds(5);
event.closedLoopAlarmEnd = Instant.now();
event.AAI = new HashMap<>();
- event.AAI.put("cloud-region.identity-url", "foo");
- event.AAI.put("vserver.selflink", "bar");
- event.AAI.put("vserver.is-closed-loop-disabled", "false");
event.AAI.put("generic-vnf.vnf-id", "testGenericVnfId");
event.closedLoopEventStatus = ControlLoopEventStatus.ABATED;
kieSession.insert(event);
diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
index 4cd005471..a63344d35 100644
--- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
+++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java
@@ -415,9 +415,6 @@ public class VFWControlLoopTest {
event.target = "generic-vnf.vnf-id";
event.closedLoopAlarmStart = Instant.now();
event.AAI = new HashMap<>();
- event.AAI.put("cloud-region.identity-url", "foo");
- event.AAI.put("vserver.selflink", "bar");
- event.AAI.put("vserver.is-closed-loop-disabled", "false");
event.AAI.put("generic-vnf.vnf-id", "testGenericVnfID");
event.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
kieSession.insert(event);