use new SO API for scale-out 49/63149/3
authorJim Hahn <jrh3@att.com>
Mon, 27 Aug 2018 19:32:14 +0000 (15:32 -0400)
committerJim Hahn <jrh3@att.com>
Tue, 28 Aug 2018 14:56:27 +0000 (10:56 -0400)
Updated licenses and serialization IDs.
Moved hashCode() and equals() methods to be in same location as in the
original code so it can be more easily compared.
Changed vDNS yaml timeout and retry to 1200 and 0, respectively, to match
the original values.
Removed extra newline from yaml, to match original yaml.
Reformatted source to wrap lines at 120 characters and removing trailing
white space.

Change-Id: I3f5e59a1f44750347de49164f587d4ffefdee8b4
Issue-ID: POLICY-962
Signed-off-by: Jim Hahn <jrh3@att.com>
19 files changed:
controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java
controlloop/common/actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/TestSOActorServiceProvider.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqGenericVnf.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/AaiNqVfModule.java
controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqGenericVnfTest.java
controlloop/common/model-impl/aai/src/test/java/org/onap/policy/aai/AaiNqVfModuleTest.java
controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SOManager.java
controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestDetails.java
controlloop/common/model-impl/so/src/main/java/org/onap/policy/so/SORequestParameters.java
controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSOManager.java
controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java
controlloop/common/policy-yaml/src/test/resources/v2.0.0/policy_ONAP_demo_vDNS.yaml
controlloop/common/simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
controlloop/common/simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
controlloop/packages/basex-controlloop/src/files/bin/create-cl-casablanca
controlloop/packages/basex-controlloop/src/files/bin/push-policies-casablanca
controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vDNS.yaml
controlloop/templates/archetype-cl-casablanca/src/main/resources/META-INF/maven/archetype-metadata.xml
controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/config/vDNS.yaml

index f68c6f6..ccc13a5 100644 (file)
 
 package org.onap.policy.controlloop.actor.so;
 
+import java.lang.reflect.Type;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 import org.drools.core.WorkingMemory;
 import org.onap.policy.aai.AaiNqExtraProperty;
 import org.onap.policy.aai.AaiNqInventoryResponseItem;
@@ -44,6 +47,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+import com.google.gson.reflect.TypeToken;
 
 public class SOActorServiceProvider implements Actor {
     private static final Logger logger = LoggerFactory.getLogger(SOActorServiceProvider.class);
@@ -59,9 +63,19 @@ public class SOActorServiceProvider implements Actor {
 
     private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_VF_MODULE_CREATE);
     private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
-            .put(RECIPE_VF_MODULE_CREATE, ImmutableList.of(TARGET_VFC)).build();
+                    .put(RECIPE_VF_MODULE_CREATE, ImmutableList.of(TARGET_VFC)).build();
 
-    // Static variables required to hold the IDs of the last service item and VNF item. Note that in
+    // name of request parameters within policy payload
+    public static final String REQ_PARAM_NM = "requestParameters";
+
+    // name of configuration parameters within policy payload
+    public static final String CONFIG_PARAM_NM = "configurationParameters";
+
+    // used to decode configuration parameters via gson
+    public static Type CONFIG_TYPE = new TypeToken<List<Map<String, String>>>() {}.getType();
+
+    // Static variables required to hold the IDs of the last service item and VNF item.
+    // Note that in
     // a multithreaded deployment this WILL break
     private static String lastVNFItemVnfId;
     private static String lastServiceItemServiceInstanceId;
@@ -87,17 +101,19 @@ public class SOActorServiceProvider implements Actor {
     }
 
     /**
-     * Constructs a SO request conforming to the lcm API. The actual request is constructed and then
-     * placed in a wrapper object used to send through DMAAP.
+     * Constructs a SO request conforming to the lcm API. The actual request is
+     * constructed and then placed in a wrapper object used to send through DMAAP.
      *
      * @param onset the event that is reporting the alert for policy to perform an action
-     * @param operation the control loop operation specifying the actor, operation, target, etc.
-     * @param policy the policy the was specified from the yaml generated by CLAMP or through the
-     *        Policy GUI/API
+     * @param operation the control loop operation specifying the actor, operation,
+     *        target, etc.
+     * @param policy the policy the was specified from the yaml generated by CLAMP or
+     *        through the Policy GUI/API
      * @param aaiResponseWrapper wrapper for AAI vserver named-query response
      * @return a SO request conforming to the lcm API using the DMAAP wrapper
      */
-    public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy, AaiNqResponseWrapper aaiResponseWrapper) {
+    public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy,
+                    AaiNqResponseWrapper aaiResponseWrapper) {
         String modelNamePropertyKey = "model-ver.model-name";
         String modelVersionPropertyKey = "model-ver.model-version";
         String modelVersionIdPropertyKey = "model-ver.model-version-id";
@@ -120,10 +136,10 @@ public class SOActorServiceProvider implements Actor {
         // Extract the items we're interested in from the response
         try {
             vnfItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
-                    .getInventoryResponseItems().get(0);
+                            .getInventoryResponseItems().get(0);
         } catch (Exception e) {
             logger.error("VNF Item not found in AAI response {}", Serialization.gsonPretty.toJson(aaiResponseWrapper),
-                    e);
+                            e);
             return null;
         }
 
@@ -131,16 +147,16 @@ public class SOActorServiceProvider implements Actor {
             vnfServiceItem = vnfItem.getItems().getInventoryResponseItems().get(0);
         } catch (Exception e) {
             logger.error("VNF Service Item not found in AAI response {}",
-                    Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
+                            Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
             return null;
         }
 
         try {
             tenantItem = aaiResponseWrapper.getAaiNqResponse().getInventoryResponseItems().get(0).getItems()
-                    .getInventoryResponseItems().get(1);
+                            .getInventoryResponseItems().get(1);
         } catch (Exception e) {
             logger.error("Tenant Item not found in AAI response {}",
-                    Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
+                            Serialization.gsonPretty.toJson(aaiResponseWrapper), e);
             return null;
         }
 
@@ -172,15 +188,17 @@ public class SOActorServiceProvider implements Actor {
         //
         request.getRequestDetails().getCloudConfiguration().setTenantId(tenantItem.getTenant().getTenantId());
         request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId(
-                tenantItem.getItems().getInventoryResponseItems().get(0).getCloudRegion().getCloudRegionId());
+                        tenantItem.getItems().getInventoryResponseItems().get(0).getCloudRegion().getCloudRegionId());
 
         //
         // modelInfo
         //
         request.getRequestDetails().getModelInfo().setModelType("vfModule");
         request.getRequestDetails().getModelInfo()
-                .setModelInvariantId(vfModuleItem.getVfModule().getModelInvariantId());
+                        .setModelInvariantId(vfModuleItem.getVfModule().getModelInvariantId());
         request.getRequestDetails().getModelInfo().setModelVersionId(vfModuleItem.getVfModule().getModelVersionId());
+        request.getRequestDetails().getModelInfo()
+                        .setModelCustomizationId(vfModuleItem.getVfModule().getModelCustomizationId());
 
         for (AaiNqExtraProperty prop : vfModuleItem.getExtraProperties().getExtraProperty()) {
             if (prop.getPropertyName().equals(modelNamePropertyKey)) {
@@ -193,7 +211,8 @@ public class SOActorServiceProvider implements Actor {
         //
         // requestInfo
         //
-        request.getRequestDetails().getRequestInfo().setInstanceName(aaiResponseWrapper.genVfModuleName());
+        String vfModuleName = aaiResponseWrapper.genVfModuleName();
+        request.getRequestDetails().getRequestInfo().setInstanceName(vfModuleName);
         request.getRequestDetails().getRequestInfo().setSource("POLICY");
         request.getRequestDetails().getRequestInfo().setSuppressRollback(false);
         request.getRequestDetails().getRequestInfo().setRequestorId("policy");
@@ -201,27 +220,35 @@ public class SOActorServiceProvider implements Actor {
         //
         // relatedInstanceList
         //
+        SORelatedInstanceListElement relatedInstanceListElement0 = new SORelatedInstanceListElement();
         SORelatedInstanceListElement relatedInstanceListElement1 = new SORelatedInstanceListElement();
         SORelatedInstanceListElement relatedInstanceListElement2 = new SORelatedInstanceListElement();
         relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance());
         relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance());
 
+        // Volume Group Item
+        relatedInstanceListElement0.setRelatedInstance(new SORelatedInstance());
+        relatedInstanceListElement0.getRelatedInstance().setInstanceId(UUID.randomUUID().toString());
+        relatedInstanceListElement0.getRelatedInstance().setInstanceName(vfModuleName + "_vol");
+        relatedInstanceListElement0.getRelatedInstance().setModelInfo(new SOModelInfo());
+        relatedInstanceListElement0.getRelatedInstance().getModelInfo().setModelType("volumeGroup");
+
         // Service Item
         relatedInstanceListElement1.getRelatedInstance()
-                .setInstanceId(vnfServiceItem.getServiceInstance().getServiceInstanceId());
+                        .setInstanceId(vnfServiceItem.getServiceInstance().getServiceInstanceId());
         relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo());
         relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service");
         relatedInstanceListElement1.getRelatedInstance().getModelInfo()
-                .setModelInvariantId(vnfServiceItem.getServiceInstance().getModelInvariantId());
+                        .setModelInvariantId(vnfServiceItem.getServiceInstance().getModelInvariantId());
         for (AaiNqExtraProperty prop : vnfServiceItem.getExtraProperties().getExtraProperty()) {
             if (prop.getPropertyName().equals(modelNamePropertyKey)) {
                 relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue());
             } else if (prop.getPropertyName().equals(modelVersionPropertyKey)) {
                 relatedInstanceListElement1.getRelatedInstance().getModelInfo()
-                        .setModelVersion(prop.getPropertyValue());
+                                .setModelVersion(prop.getPropertyValue());
             } else if (prop.getPropertyName().equals(modelVersionIdPropertyKey)) {
-              relatedInstanceListElement1.getRelatedInstance().getModelInfo()
-                      .setModelVersionId(prop.getPropertyValue());
+                relatedInstanceListElement1.getRelatedInstance().getModelInfo()
+                                .setModelVersionId(prop.getPropertyValue());
             }
         }
 
@@ -230,28 +257,38 @@ public class SOActorServiceProvider implements Actor {
         relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo());
         relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf");
         relatedInstanceListElement2.getRelatedInstance().getModelInfo()
-                .setModelInvariantId(vnfItem.getGenericVnf().getModelInvariantId());
+                        .setModelInvariantId(vnfItem.getGenericVnf().getModelInvariantId());
         for (AaiNqExtraProperty prop : vnfItem.getExtraProperties().getExtraProperty()) {
             if (prop.getPropertyName().equals(modelNamePropertyKey)) {
                 relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName(prop.getPropertyValue());
             } else if (prop.getPropertyName().equals(modelVersionPropertyKey)) {
                 relatedInstanceListElement2.getRelatedInstance().getModelInfo()
-                        .setModelVersion(prop.getPropertyValue());
+                                .setModelVersion(prop.getPropertyValue());
             } else if (prop.getPropertyName().equals(modelVersionIdPropertyKey)) {
                 relatedInstanceListElement2.getRelatedInstance().getModelInfo()
-                        .setModelVersionId(prop.getPropertyValue());
+                                .setModelVersionId(prop.getPropertyValue());
             }
         }
-        relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName(vnfItem
-                .getGenericVnf().getVnfType().substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1));
+        relatedInstanceListElement2.getRelatedInstance().getModelInfo()
+                        .setModelCustomizationName(vnfItem.getGenericVnf().getVnfType()
+                                        .substring(vnfItem.getGenericVnf().getVnfType().lastIndexOf('/') + 1));
+        relatedInstanceListElement2.getRelatedInstance().getModelInfo()
+                        .setModelCustomizationId(vnfItem.getGenericVnf().getModelCustomizationId());
 
         // Insert the Service Item and VNF Item
+        request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement0);
         request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1);
         request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2);
 
+        // Request Parameters
+        request.getRequestDetails().setRequestParameters(buildRequestParameters(policy));
+
+        // Configuration Parameters
+        request.getRequestDetails().setConfigurationParameters(buildConfigurationParameters(policy));
+
         // Save the instance IDs for the VNF and service to static fields
         preserveInstanceIds(vnfItem.getGenericVnf().getVnfId(),
-                vnfServiceItem.getServiceInstance().getServiceInstanceId());
+                        vnfServiceItem.getServiceInstance().getServiceInstanceId());
 
         if (logger.isDebugEnabled()) {
             logger.debug("SO request sent: {}", Serialization.gsonPretty.toJson(request));
@@ -261,8 +298,8 @@ public class SOActorServiceProvider implements Actor {
     }
 
     /**
-     * This method is needed to get the serviceInstanceId and vnfInstanceId which is used in the
-     * asyncSORestCall.
+     * This method is needed to get the serviceInstanceId and vnfInstanceId which is used
+     * in the asyncSORestCall.
      *
      * @param requestId the request Id
      * @param wm the working memory
@@ -271,7 +308,7 @@ public class SOActorServiceProvider implements Actor {
     public static void sendRequest(String requestId, WorkingMemory wm, Object request) {
         SOManager soManager = new SOManager();
         soManager.asyncSORestCall(requestId, wm, lastServiceItemServiceInstanceId, lastVNFItemVnfId,
-                (SORequest) request);
+                        (SORequest) request);
     }
 
     /**
@@ -288,8 +325,47 @@ public class SOActorServiceProvider implements Actor {
     }
 
     /**
-     * This method is called to remember the last service instance ID and VNF Item VNF ID. Note
-     * these fields are static, beware for multithreaded deployments
+     * Builds the request parameters from the policy payload.
+     *
+     * @param policy the policy
+     * @return the request parameters, or {@code null} if the payload is {@code null}
+     */
+    private SORequestParameters buildRequestParameters(Policy policy) {
+        if (policy.getPayload() == null) {
+            return null;
+        }
+
+        String json = policy.getPayload().get(REQ_PARAM_NM);
+        if (json == null) {
+            return null;
+        }
+
+        return Serialization.gsonPretty.fromJson(json, SORequestParameters.class);
+    }
+
+    /**
+     * Builds the configuration parameters from the policy payload.
+     *
+     * @param policy the policy
+     * @return the configuration parameters, or {@code null} if the payload is
+     *         {@code null}
+     */
+    private List<Map<String, String>> buildConfigurationParameters(Policy policy) {
+        if (policy.getPayload() == null) {
+            return null;
+        }
+
+        String json = policy.getPayload().get(CONFIG_PARAM_NM);
+        if (json == null) {
+            return null;
+        }
+
+        return Serialization.gsonPretty.fromJson(json, CONFIG_TYPE);
+    }
+
+    /**
+     * This method is called to remember the last service instance ID and VNF Item VNF ID.
+     * Note these fields are static, beware for multithreaded deployments
      *
      * @param vnfInstanceId update the last VNF instance ID to this value
      * @param serviceInstanceId update the last service instance ID to this value
index 25bbda0..c315536 100644 (file)
@@ -9,9 +9,9 @@
  * 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.
@@ -28,6 +28,10 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 import java.util.UUID;
 import org.apache.commons.io.IOUtils;
 import org.junit.Test;
@@ -37,6 +41,7 @@ import org.onap.policy.controlloop.ControlLoopOperation;
 import org.onap.policy.controlloop.VirtualControlLoopEvent;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.so.SORequest;
+import org.onap.policy.so.SORequestParameters;
 import org.onap.policy.so.util.Serialization;
 
 public class TestSOActorServiceProvider {
@@ -59,6 +64,8 @@ public class TestSOActorServiceProvider {
         assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp));
 
         policy.setRecipe("VF Module Create");
+
+        // empty policy payload
         SORequest request = new SOActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
         assertNotNull(request);
 
@@ -66,6 +73,15 @@ public class TestSOActorServiceProvider {
         assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId());
         assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId());
 
+        // non-empty policy payload
+        policy.setPayload(makePayload());
+        request = new SOActorServiceProvider().constructRequest(onset, operation, policy, aaiNqResp);
+        assertNotNull(request);
+        assertEquals(true, request.getRequestDetails().getRequestParameters().isUsePreload());
+        assertEquals("avalue", request.getRequestDetails().getRequestParameters().getUserParams().get(0).get("akey"));
+        assertEquals(1, request.getRequestDetails().getConfigurationParameters().size());
+        assertEquals("cvalue", request.getRequestDetails().getConfigurationParameters().get(0).get("ckey"));
+
         // null response
         assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy, null));
 
@@ -97,16 +113,65 @@ public class TestSOActorServiceProvider {
         assertEquals(0, sp.recipePayloads("VF Module Create").size());
     }
 
+    /**
+     * Creates a policy payload containing request & configuration parameters.
+     *
+     * @return the payload
+     */
+    private Map<String, String> makePayload() {
+        Map<String, String> payload = new TreeMap<>();
+
+        payload.put(SOActorServiceProvider.REQ_PARAM_NM, makeReqParams());
+        payload.put(SOActorServiceProvider.CONFIG_PARAM_NM, makeConfigParams());
+
+        return payload;
+    }
+
+    /**
+     * Creates request parameters.
+     *
+     * @return request parameters, encoded as JSON
+     */
+    private String makeReqParams() {
+        SORequestParameters params = new SORequestParameters();
+
+        params.setUsePreload(true);
+
+        Map<String, String> map = new TreeMap<>();
+        map.put("akey", "avalue");
+
+        List<Map<String, String>> lst = new LinkedList<>();
+        lst.add(map);
+
+        params.setUserParams(lst);
+
+        return Serialization.gsonPretty.toJson(params);
+    }
+
+    /**
+     * Creates configuration parameters.
+     *
+     * @return configuration parameters, encoded as JSON
+     */
+    private String makeConfigParams() {
+        Map<String, String> map = new TreeMap<>();
+        map.put("ckey", "cvalue");
+
+        List<Map<String, String>> lst = new LinkedList<>();
+        lst.add(map);
+
+        return Serialization.gsonPretty.toJson(lst);
+    }
+
     /**
      * Reads an AAI vserver named-query response from a file.
-     * 
+     *
      * @param onset the ONSET event
      * @param fileName name of the file containing the JSON response
      * @return output from the AAI vserver named-query
      * @throws IOException if the file cannot be read
      */
-    private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName)
-                    throws IOException {
+    private AaiNqResponseWrapper loadAaiResponse(VirtualControlLoopEvent onset, String fileName) throws IOException {
         String resp = IOUtils.toString(getClass().getResource(fileName), StandardCharsets.UTF_8);
         AaiNqResponse aaiNqResponse = Serialization.gsonPretty.fromJson(resp, AaiNqResponse.class);
 
index 342fefb..788d236 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 package org.onap.policy.aai;
 
 import com.google.gson.annotations.SerializedName;
-
 import java.io.Serializable;
 
 public class AaiNqGenericVnf implements Serializable {
 
-    private static final long serialVersionUID = 834322706248060559L;
+    private static final long serialVersionUID = 834322706248060560L;
 
     @SerializedName("vnf-id")
     private String vnfId;
@@ -79,6 +78,9 @@ public class AaiNqGenericVnf implements Serializable {
     @SerializedName("model-version-id")
     private String modelVersionId;
 
+    @SerializedName("model-customization-id")
+    private String modelCustomizationId = null;
+
     public String getVnfId() {
         return vnfId;
     }
@@ -147,6 +149,10 @@ public class AaiNqGenericVnf implements Serializable {
         return modelVersionId;
     }
 
+    public String getModelCustomizationId() {
+        return modelCustomizationId;
+    }
+
     public void setVnfId(String vnfId) {
         this.vnfId = vnfId;
     }
@@ -214,4 +220,8 @@ public class AaiNqGenericVnf implements Serializable {
     public void setModelVersionId(String modelVersionId) {
         this.modelVersionId = modelVersionId;
     }
+
+    public void setModelCustomizationId(String modelCustomizationId) {
+        this.modelCustomizationId = modelCustomizationId;
+    }
 }
index 923092a..d8021af 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * aai
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
 package org.onap.policy.aai;
 
 import com.google.gson.annotations.SerializedName;
-
 import java.io.Serializable;
 
 public class AaiNqVfModule implements Serializable {
-    private static final long serialVersionUID = 8019133081429638231L;
+    private static final long serialVersionUID = 8019133081429638232L;
 
     @SerializedName("vf-module-id")
     private String vfModuleId;
@@ -66,6 +65,9 @@ public class AaiNqVfModule implements Serializable {
     @SerializedName("model-version-id")
     private String modelVersionId;
 
+    @SerializedName("model-customization-id")
+    private String modelCustomizationId = null;
+
     public String getVfModuleId() {
         return vfModuleId;
     }
@@ -118,6 +120,10 @@ public class AaiNqVfModule implements Serializable {
         return modelVersionId;
     }
 
+    public String getModelCustomizationId() {
+        return modelCustomizationId;
+    }
+
     public void setVfModuleId(String vfModuleId) {
         this.vfModuleId = vfModuleId;
     }
@@ -169,4 +175,8 @@ public class AaiNqVfModule implements Serializable {
     public void setModelVersionId(String modelVersionId) {
         this.modelVersionId = modelVersionId;
     }
+
+    public void setModelCustomizationId(String modelCustomizationId) {
+        this.modelCustomizationId = modelCustomizationId;
+    }
 }
index 680e66e..4ca91e7 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -22,7 +22,6 @@ package org.onap.policy.aai;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -45,6 +44,7 @@ public class AaiNqGenericVnfTest {
         aaiNqGenericVnf.setIsClosedLoopDisabled(false);
         aaiNqGenericVnf.setModelInvariantId("653d2caa-7e47-4614-95b3-26c8d82755b8");
         aaiNqGenericVnf.setModelVersionId("98f410f6-4c63-447b-97d2-42508437cec0");
+        aaiNqGenericVnf.setModelCustomizationId("SomeCustomizationId");
         aaiNqGenericVnf.setOperationalState("active");
         aaiNqGenericVnf.setPersonaModelId("653d2caa-7e47-4614-95b3-26c8d82755b8");
         aaiNqGenericVnf.setPersonaModelVersion("98f410f6-4c63-447b-97d2-42508437cec0");
@@ -64,6 +64,7 @@ public class AaiNqGenericVnfTest {
         assertEquals(false, aaiNqGenericVnf.getIsClosedLoopDisabled());
         assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getModelInvariantId());
         assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getModelVersionId());
+        assertEquals("SomeCustomizationId", aaiNqGenericVnf.getModelCustomizationId());
         assertEquals("active", aaiNqGenericVnf.getOperationalState());
         assertEquals("653d2caa-7e47-4614-95b3-26c8d82755b8", aaiNqGenericVnf.getPersonaModelId());
         assertEquals("98f410f6-4c63-447b-97d2-42508437cec0", aaiNqGenericVnf.getPersonaModelVersion());
index 1bbb711..b4fbd76 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -22,7 +22,6 @@ package org.onap.policy.aai;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -56,6 +55,7 @@ public class AaiNqVfModuleTest {
         aaiNqVfModule.setContrailServiceInstanceFqdn("example-contrail-service-instance-fqdn-val-86796");
         aaiNqVfModule.setModelInvariantId("SomeId");
         aaiNqVfModule.setModelVersionId("SomeVersion");
+        aaiNqVfModule.setModelCustomizationId("SomeCustomizationId");
         assertNotNull(aaiNqVfModule);
         assertEquals("example-vf-module-id-val-49261", aaiNqVfModule.getVfModuleId());
         assertEquals("example-vf-module-name-val-73074", aaiNqVfModule.getVfModuleName());
@@ -68,9 +68,10 @@ public class AaiNqVfModuleTest {
         assertEquals("example-widget-model-id-val-92571", aaiNqVfModule.getWidgetModelId());
         assertEquals("example-widget-model-version-val-83317", aaiNqVfModule.getWidgetModelVersion());
         assertEquals("example-contrail-service-instance-fqdn-val-86796",
-                aaiNqVfModule.getContrailServiceInstanceFqdn());
+                        aaiNqVfModule.getContrailServiceInstanceFqdn());
         assertEquals("SomeId", aaiNqVfModule.getModelInvariantId());
         assertEquals("SomeVersion", aaiNqVfModule.getModelVersionId());
+        assertEquals("SomeCustomizationId", aaiNqVfModule.getModelCustomizationId());
         logger.info(Serialization.gsonPretty.toJson(aaiNqVfModule));
     }
 
index ae43f5b..92d52f4 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -22,14 +22,12 @@ package org.onap.policy.so;
 
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonSyntaxException;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-
 import org.drools.core.WorkingMemory;
 import org.onap.policy.drools.system.PolicyEngine;
 import org.onap.policy.rest.RESTManager;
@@ -40,15 +38,15 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * This class handles the interface towards SO (Service Orchestrator) for the ONAP Policy Framework.
- * The SO API is defined at this link:
+ * This class handles the interface towards SO (Service Orchestrator) for the ONAP Policy
+ * Framework. The SO API is defined at this link:
  * http://onap.readthedocs.io/en/latest/submodules/so.git/docs/SO_R1_Interface.html#get-orchestration-request
- * 
+ *
  */
 public final class SOManager {
     private static final Logger logger = LoggerFactory.getLogger(SOManager.class);
     private static final Logger netLogger =
-            LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER);
+                    LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER);
     private static ExecutorService executors = Executors.newCachedThreadPool();
 
     private static final int SO_RESPONSE_ERROR = 999;
@@ -73,7 +71,7 @@ public final class SOManager {
 
     /**
      * Create a service instance in SO.
-     * 
+     *
      * @param url the SO URL
      * @param urlBase the base URL
      * @param username user name on SO
@@ -82,13 +80,13 @@ public final class SOManager {
      * @return
      */
     public SOResponse createModuleInstance(final String url, final String urlBase, final String username,
-            final String password, final SORequest request) {
+                    final String password, final SORequest request) {
         // Issue the HTTP POST request to SO to create the service instance
         String requestJson = Serialization.gsonPretty.toJson(request);
         netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}{}", "SO", url, username, password, createSimpleHeaders(), MEDIA_TYPE,
-                LINE_SEPARATOR, requestJson);
+                        LINE_SEPARATOR, requestJson);
         Pair<Integer, String> httpResponse =
-                restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson);
+                        restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, requestJson);
 
         // Process the response from SO
         SOResponse response = waitForSOOperationCompletion(urlBase, username, password, url, httpResponse);
@@ -100,9 +98,9 @@ public final class SOManager {
     }
 
     /**
-     * This method makes an asynchronous Rest call to MSO and inserts the response into Drools
-     * working memory.
-     * 
+     * This method makes an asynchronous Rest call to MSO and inserts the response into
+     * Drools working memory.
+     *
      * @param wm the Drools working memory
      * @param url the URL to use on the POST request
      * @param urlBase the SO base URL
@@ -112,7 +110,7 @@ public final class SOManager {
      * @return a concurrent Future for the thread that handles the request
      */
     public Future<SOResponse> asyncSORestCall(final String requestID, final WorkingMemory wm,
-            final String serviceInstanceId, final String vnfInstanceId, final SORequest request) {
+                    final String serviceInstanceId, final String vnfInstanceId, final SORequest request) {
         return executors.submit(new AsyncSORestCallThread(requestID, wm, serviceInstanceId, vnfInstanceId, request));
     }
 
@@ -128,7 +126,7 @@ public final class SOManager {
 
         /**
          * Constructor, sets the context of the request.
-         * 
+         *
          * @param requestID The request ID
          * @param wm reference to the Drools working memory
          * @param serviceInstanceId the service instance in SO to use
@@ -136,7 +134,7 @@ public final class SOManager {
          * @param request the request itself
          */
         private AsyncSORestCallThread(final String requestID, final WorkingMemory wm, final String serviceInstanceId,
-                final String vnfInstanceId, final SORequest request) {
+                        final String vnfInstanceId, final SORequest request) {
             this.requestID = requestID;
             this.wm = wm;
             this.serviceInstanceId = serviceInstanceId;
@@ -154,15 +152,15 @@ public final class SOManager {
             String password = PolicyEngine.manager.getEnvironmentProperty("so.password");
 
             // The URL of the request we will POST
-            String url =
-                    urlBase + "/serviceInstances/v5/" + serviceInstanceId + "/vnfs/" + vnfInstanceId + "/vfModules";
+            String url = urlBase + "/serviceInstantiation/v7/" + serviceInstanceId + "/vnfs/" + vnfInstanceId
+                            + "/vfModules/scaleOut";
 
             // Create a JSON representation of the request
             String soJson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create().toJson(request);
 
             netLogger.info("[OUT|{}|{}|]{}{}", "SO", url, LINE_SEPARATOR, soJson);
             Pair<Integer, String> httpResponse =
-                    restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
+                            restManager.post(url, username, password, createSimpleHeaders(), MEDIA_TYPE, soJson);
 
             // Process the response from SO
             SOResponse response = waitForSOOperationCompletion(urlBase, username, password, url, httpResponse);
@@ -177,7 +175,7 @@ public final class SOManager {
 
     /**
      * Wait for the SO operation we have ordered to complete.
-     * 
+     *
      * @param urlBaseSO The base URL for SO
      * @param username user name on SO
      * @param password password on SO
@@ -186,7 +184,8 @@ public final class SOManager {
      * @return The parsed final response of SO to the request
      */
     private SOResponse waitForSOOperationCompletion(final String urlBaseSO, final String username,
-            final String password, final String initialRequestURL, final Pair<Integer, String> initialHTTPResponse) {
+                    final String password, final String initialRequestURL,
+                    final Pair<Integer, String> initialHTTPResponse) {
         // Process the initial response from SO, the response to a post
         SOResponse response = processSOResponse(initialRequestURL, initialHTTPResponse);
         if (SO_RESPONSE_ERROR == response.getHttpResponseCode()) {
@@ -201,7 +200,8 @@ public final class SOManager {
 
         // Wait for the response from SO
         for (int attemptsLeft = GET_REQUESTS_BEFORE_TIMEOUT; attemptsLeft >= 0; attemptsLeft--) {
-            // The SO request may have completed even on the first request so we check the response
+            // The SO request may have completed even on the first request so we check the
+            // response
             // here before
             // issuing any other requests
             if (isRequestStateFinished(latestHTTPResponse, response)) {
@@ -220,7 +220,7 @@ public final class SOManager {
 
             // Issue a GET to find the current status of our request
             netLogger.info("[OUT|{}|{}|{}|{}|{}|{}|]{}", "SO", urlGet, username, password, createSimpleHeaders(),
-                    MEDIA_TYPE, LINE_SEPARATOR);
+                            MEDIA_TYPE, LINE_SEPARATOR);
             Pair<Integer, String> httpResponse = restManager.get(urlGet, username, password, createSimpleHeaders());
 
             // Get our response
@@ -240,7 +240,7 @@ public final class SOManager {
 
     /**
      * Parse the response message from SO into a SOResponse object.
-     * 
+     *
      * @param requestURL The URL of the HTTP request
      * @param httpDetails The HTTP message returned from SO
      * @return The parsed response
@@ -248,7 +248,8 @@ public final class SOManager {
     private SOResponse processSOResponse(final String requestURL, final Pair<Integer, String> httpResponse) {
         SOResponse response = new SOResponse();
 
-        // A null httpDetails indicates a HTTP problem, a valid response from SO must be either 200
+        // A null httpDetails indicates a HTTP problem, a valid response from SO must be
+        // either 200
         // or 202
         if (!httpResultIsNullFree(httpResponse) || (httpResponse.a != 200 && httpResponse.a != 202)) {
             logger.error("Invalid HTTP response received from SO");
@@ -282,7 +283,7 @@ public final class SOManager {
 
     /**
      * Method to allow tuning of REST get timeout.
-     * 
+     *
      * @param restGetTimeout the timeout value
      */
     protected void setRestGetTimeout(final long restGetTimeout) {
@@ -291,18 +292,18 @@ public final class SOManager {
 
     /**
      * Check that the request state of a response is defined.
-     * 
+     *
      * @param response The response to check
      * @return true if the request for the response is defined
      */
     private boolean isRequestStateDefined(final SOResponse response) {
         return response != null && response.getRequest() != null && response.getRequest().getRequestStatus() != null
-                && response.getRequest().getRequestStatus().getRequestState() != null;
+                        && response.getRequest().getRequestStatus().getRequestState() != null;
     }
 
     /**
      * Check that the request state of a response is finished.
-     * 
+     *
      * @param latestHTTPDetails the HTTP details of the response
      * @param response The response to check
      * @return true if the request for the response is finished
@@ -318,7 +319,7 @@ public final class SOManager {
 
     /**
      * Check that a HTTP operation result has no nulls.
-     * 
+     *
      * @param httpOperationResult the result to check
      * @return true if no nulls are found
      */
@@ -328,7 +329,7 @@ public final class SOManager {
 
     /**
      * Create simple HTTP headers for unauthenticated requests to SO.
-     * 
+     *
      * @return the HTTP headers
      */
     private Map<String, String> createSimpleHeaders() {
index 72e35d9..13d25cf 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * so
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -23,7 +23,7 @@ package org.onap.policy.so;
 import java.io.Serializable;
 import java.util.LinkedList;
 import java.util.List;
-
+import java.util.Map;
 import com.google.gson.annotations.SerializedName;
 
 public class SORequestDetails implements Serializable {
@@ -48,6 +48,9 @@ public class SORequestDetails implements Serializable {
     @SerializedName("requestParameters")
     private SORequestParameters requestParameters;
 
+    @SerializedName("configurationParameters")
+    private List<Map<String, String>> configurationParameters = new LinkedList<>();
+
     public SORequestDetails() {
 
     }
@@ -73,38 +76,37 @@ public class SORequestDetails implements Serializable {
         if (cloudConfiguration == null) {
             if (other.cloudConfiguration != null)
                 return false;
-        }
-        else if (!cloudConfiguration.equals(other.cloudConfiguration))
+        } else if (!cloudConfiguration.equals(other.cloudConfiguration))
+            return false;
+        if (configurationParameters == null) {
+            if (other.configurationParameters != null)
+                return false;
+        } else if (!configurationParameters.equals(other.configurationParameters))
             return false;
         if (modelInfo == null) {
             if (other.modelInfo != null)
                 return false;
-        }
-        else if (!modelInfo.equals(other.modelInfo))
+        } else if (!modelInfo.equals(other.modelInfo))
             return false;
         if (relatedInstanceList == null) {
             if (other.relatedInstanceList != null)
                 return false;
-        }
-        else if (!relatedInstanceList.equals(other.relatedInstanceList))
+        } else if (!relatedInstanceList.equals(other.relatedInstanceList))
             return false;
         if (requestInfo == null) {
             if (other.requestInfo != null)
                 return false;
-        }
-        else if (!requestInfo.equals(other.requestInfo))
+        } else if (!requestInfo.equals(other.requestInfo))
             return false;
         if (requestParameters == null) {
             if (other.requestParameters != null)
                 return false;
-        }
-        else if (!requestParameters.equals(other.requestParameters))
+        } else if (!requestParameters.equals(other.requestParameters))
             return false;
         if (subscriberInfo == null) {
             if (other.subscriberInfo != null)
                 return false;
-        }
-        else if (!subscriberInfo.equals(other.subscriberInfo))
+        } else if (!subscriberInfo.equals(other.subscriberInfo))
             return false;
         return true;
     }
@@ -129,6 +131,10 @@ public class SORequestDetails implements Serializable {
         return requestParameters;
     }
 
+    public List<Map<String, String>> getConfigurationParameters() {
+        return configurationParameters;
+    }
+
     public SOSubscriberInfo getSubscriberInfo() {
         return subscriberInfo;
     }
@@ -137,13 +143,13 @@ public class SORequestDetails implements Serializable {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result
-                + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode());
+        result = prime * result + ((cloudConfiguration == null) ? 0 : cloudConfiguration.hashCode());
+        result = prime * result + ((configurationParameters == null) ? 0 : configurationParameters.hashCode());
         result = prime * result + ((modelInfo == null) ? 0 : modelInfo.hashCode());
-        result = prime * result
-                + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode());
+        result = prime * result + ((relatedInstanceList == null) ? 0 : relatedInstanceList.hashCode());
         result = prime * result + ((requestInfo == null) ? 0 : requestInfo.hashCode());
         result = prime * result + ((requestParameters == null) ? 0 : requestParameters.hashCode());
+        result = prime * result + ((subscriberInfo == null) ? 0 : subscriberInfo.hashCode());
         return result;
     }
 
@@ -163,6 +169,10 @@ public class SORequestDetails implements Serializable {
         this.requestParameters = requestParameters;
     }
 
+    public void setConfigurationParameters(List<Map<String, String>> configurationParameters) {
+        this.configurationParameters = configurationParameters;
+    }
+
     public void setSubscriberInfo(SOSubscriberInfo subscriberInfo) {
         this.subscriberInfo = subscriberInfo;
     }
@@ -173,10 +183,10 @@ public class SORequestDetails implements Serializable {
 
     @Override
     public String toString() {
-        return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration="
-                + cloudConfiguration + ", requestInfo=" + requestInfo + ", relatedInstanceList="
-                + relatedInstanceList + ", requestParameters=" + requestParameters +
-                ", subscriberInfo=" + subscriberInfo + "]";
+        return "SORequestDetails [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration
+                        + ", requestInfo=" + requestInfo + ", subscriberInfo=" + subscriberInfo
+                        + ", relatedInstanceList=" + relatedInstanceList + ", requestParameters=" + requestParameters
+                        + ", configurationParameters=" + configurationParameters + "]";
     }
 
 }
index 1697520..7ea20de 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * so
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 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.
@@ -24,16 +24,18 @@ import java.io.Serializable;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-
 import com.google.gson.annotations.SerializedName;
 
 public class SORequestParameters implements Serializable {
 
-    private static final long serialVersionUID = -3283942659786236032L;
+    private static final long serialVersionUID = -3283942659786236033L;
 
     @SerializedName("subscriptionServiceType")
     private String subscriptionServiceType;
 
+    @SerializedName("usePreload")
+    private boolean usePreload;
+
     @SerializedName("userParams")
     private List<Map<String, String>> userParams = new LinkedList<>();
 
@@ -45,6 +47,10 @@ public class SORequestParameters implements Serializable {
         return subscriptionServiceType;
     }
 
+    public boolean isUsePreload() {
+        return usePreload;
+    }
+
     public List<Map<String, String>> getUserParams() {
         return userParams;
     }
@@ -53,6 +59,10 @@ public class SORequestParameters implements Serializable {
         this.subscriptionServiceType = subscriptionServiceType;
     }
 
+    public void setUsePreload(boolean usePreload) {
+        this.usePreload = usePreload;
+    }
+
     public void setUserParams(List<Map<String, String>> userParams) {
         this.userParams = userParams;
     }
index 8643626..4a7fdda 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -24,12 +24,10 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import java.io.IOException;
 import java.net.URI;
 import java.util.UUID;
 import java.util.concurrent.Future;
-
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
@@ -46,14 +44,14 @@ import org.junit.Test;
 import org.onap.policy.drools.system.PolicyEngine;
 
 public class TestSOManager {
-    private static final String BASE_URI    = "http://localhost:46553/TestSOManager";
+    private static final String BASE_URI = "http://localhost:46553/TestSOManager";
     private static final String BASE_SO_URI = BASE_URI + "/SO";
     private static HttpServer server;
 
     @BeforeClass
     public static void setUp() {
         final ResourceConfig rc = new ResourceConfig(TestSoDummyServer.class);
-        server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);  
+        server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
     }
 
     @AfterClass
@@ -77,13 +75,16 @@ public class TestSOManager {
         assertNotNull(manager);
         manager.setRestGetTimeout(100);
 
-        SOResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", "citizen", null);
+        SOResponse response =
+                        manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", "citizen", null);
         assertNull(response);
 
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", null);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", null);
         assertNull(response);
 
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", new SORequest());
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", new SORequest());
         assertNull(response);
 
         SORequest request = new SORequest();
@@ -94,16 +95,19 @@ public class TestSOManager {
         request.setRequestStatus(new SORequestStatus());
         request.getRequestStatus().setRequestState("ONGOING");
 
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNull(response);
 
         request.setRequestType("ReturnCompleted");
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNotNull(response);
         assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
 
         request.setRequestType("ReturnFailed");
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNotNull(response);
         assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState());
 
@@ -111,14 +115,16 @@ public class TestSOManager {
 
         request.setRequestType("ReturnOnging200");
         request.setRequestScope(new Integer(10).toString());
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNotNull(response);
         assertNotNull(response.getRequest());
         assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
 
         request.setRequestType("ReturnOnging202");
         request.setRequestScope(new Integer(20).toString());
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNotNull(response);
         assertNotNull(response.getRequest());
         assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
@@ -126,13 +132,15 @@ public class TestSOManager {
         // Test timeout after 20 attempts for a response
         request.setRequestType("ReturnOnging202");
         request.setRequestScope(new Integer(21).toString());
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNull(response);
 
         // Test bad response after 3 attempts for a response
         request.setRequestType("ReturnBadAfterWait");
         request.setRequestScope(new Integer(3).toString());
-        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstances/v5", BASE_SO_URI, "sean", "citizen", request);
+        response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean",
+                        "citizen", request);
         assertNull(response);
     }
 
@@ -148,31 +156,31 @@ public class TestSOManager {
         WorkingMemory wm = new DummyWorkingMemory();
 
         PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999");
-        Future<SOResponse> asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
+        Future<SOResponse> asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm,
+                        UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals(999, response.getHttpResponseCode());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
-        
+
         PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI);
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), null);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals(999, response.getHttpResponseCode());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), new SORequest());
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), new SORequest());
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals(999, response.getHttpResponseCode());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
@@ -184,33 +192,33 @@ public class TestSOManager {
         request.setRequestStatus(new SORequestStatus());
         request.getRequestStatus().setRequestState("ONGOING");
 
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals(999, response.getHttpResponseCode());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
         request.setRequestType("ReturnCompleted");
 
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
         request.setRequestType("ReturnFailed");
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
@@ -218,49 +226,49 @@ public class TestSOManager {
 
         request.setRequestType("ReturnOnging200");
         request.setRequestScope(new Integer(10).toString());
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertNotNull(response.getRequest());
             assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
         request.setRequestType("ReturnOnging202");
         request.setRequestScope(new Integer(20).toString());
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertNotNull(response.getRequest());
             assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
         // Test timeout after 20 attempts for a response
         request.setRequestType("ReturnOnging202");
         request.setRequestScope(new Integer(21).toString());
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals(999, response.getHttpResponseCode());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
 
         // Test bad response after 3 attempts for a response
         request.setRequestType("ReturnBadAfterWait");
         request.setRequestScope(new Integer(3).toString());
-        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request);
+        asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(),
+                        UUID.randomUUID().toString(), request);
         try {
             SOResponse response = asyncRestCallFuture.get();
             assertEquals(999, response.getHttpResponseCode());
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             fail("test should not throw an exception");
         }
     }
index 907ca69..3485231 100644 (file)
@@ -4,12 +4,14 @@
  * ================================================================================
  * Copyright (C) 2018 Ericsson. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2018 AT&T. 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.
@@ -22,13 +24,11 @@ package org.onap.policy.so;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Response;
-
 import com.google.gson.Gson;
 
 @Path("/SO")
@@ -45,7 +45,8 @@ public class TestSoDummyServer {
     @Path("/Stats")
     public Response serviceGetStats() {
         statMessagesReceived++;
-        return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build();
+        return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived
+                        + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build();
     }
 
     @GET
@@ -56,7 +57,7 @@ public class TestSoDummyServer {
     }
 
     @POST
-    @Path("/serviceInstances/v5")
+    @Path("/serviceInstantiation/v7")
     public Response servicePostRequest(final String jsonString) {
         postMessagesReceived++;
 
@@ -67,8 +68,7 @@ public class TestSoDummyServer {
         SORequest request = null;
         try {
             request = new Gson().fromJson(jsonString, SORequest.class);
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return Response.status(400).build();
         }
 
@@ -82,8 +82,10 @@ public class TestSoDummyServer {
 
         if ("ReturnBadJson".equals(request.getRequestType())) {
             return Response.status(200)
-                    .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}")
-                    .build();
+                            .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived
+                                            + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": "
+                                            + putMessagesReceived + "}")
+                            .build();
         }
 
         SOResponse response = new SOResponse();
@@ -95,18 +97,14 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("COMPLETE");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         if ("ReturnFailed".equals(request.getRequestType())) {
             response.getRequest().getRequestStatus().setRequestState("FAILED");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         if ("ReturnOnging202".equals(request.getRequestType())) {
@@ -115,9 +113,7 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("ONGOING");
             response.setHttpResponseCode(202);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         if ("ReturnOnging200".equals(request.getRequestType())) {
@@ -126,9 +122,7 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("ONGOING");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
 
@@ -138,20 +132,16 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("ONGOING");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         return null;
     }
 
     @POST
-    @Path("/serviceInstances/v5/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules")
-    public Response servicePostRequestVfModules(
-            @PathParam("serviceInstanceId") final String serviceInstanceId,
-            @PathParam("vnfInstanceId") final String vnfInstanceId,
-            final String jsonString) {
+    @Path("/serviceInstantiation/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
+    public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId,
+                    @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) {
         postMessagesReceived++;
 
         if (jsonString == null) {
@@ -161,8 +151,7 @@ public class TestSoDummyServer {
         SORequest request = null;
         try {
             request = new Gson().fromJson(jsonString, SORequest.class);
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             return Response.status(400).build();
         }
 
@@ -176,8 +165,10 @@ public class TestSoDummyServer {
 
         if ("ReturnBadJson".equals(request.getRequestType())) {
             return Response.status(200)
-                    .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}")
-                    .build();
+                            .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived
+                                            + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": "
+                                            + putMessagesReceived + "}")
+                            .build();
         }
 
         SOResponse response = new SOResponse();
@@ -189,18 +180,14 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("COMPLETE");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         if ("ReturnFailed".equals(request.getRequestType())) {
             response.getRequest().getRequestStatus().setRequestState("FAILED");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         if ("ReturnOnging202".equals(request.getRequestType())) {
@@ -209,9 +196,7 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("ONGOING");
             response.setHttpResponseCode(202);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         if ("ReturnOnging200".equals(request.getRequestType())) {
@@ -220,9 +205,7 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("ONGOING");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
 
@@ -232,9 +215,7 @@ public class TestSoDummyServer {
             response.getRequest().getRequestStatus().setRequestState("ONGOING");
             response.setHttpResponseCode(200);
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         return null;
@@ -250,9 +231,7 @@ public class TestSoDummyServer {
         if (--iterationsLeft > 0) {
             response.getRequest().setRequestScope(new Integer(iterationsLeft).toString());
             String responseString = new Gson().toJson(response, SOResponse.class);
-            return Response.status(response.getHttpResponseCode())
-                    .entity(responseString)
-                    .build();
+            return Response.status(response.getHttpResponseCode()).entity(responseString).build();
         }
 
         ongoingRequestMap.remove(nsInstanceId);
@@ -265,8 +244,6 @@ public class TestSoDummyServer {
         response.getRequest().setRequestScope("0");
         response.setHttpResponseCode(200);
         String responseString = new Gson().toJson(response, SOResponse.class);
-        return Response.status(response.getHttpResponseCode())
-                .entity(responseString)
-                .build();
+        return Response.status(response.getHttpResponseCode()).entity(responseString).build();
     }
 }
index 0daff74..08b82d9 100644 (file)
@@ -50,6 +50,9 @@ policies:
     recipe: VF Module Create
     target:
       resourceID: 59a2ee3fB58045feB5a1.nodes.heat.vdns
+    payload:
+      requestParameters: '{"usePreload":true,"userParams":[{"name":"gtp_bind_addr","value":"vmme_private_ip_0"},{"name":"mmc","value":"001"},{"name":"mme_addr","value":"vmme_private_ip_0"},{"name":"mnc","value":"01"},{"name":"n_prob","value":"50"},{"name":"vnfHostIpAddress","value":"veb_private_ip_0"}]}'
+      configurationParameters: '[{"availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]","xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"}]'
     retry: 0
     timeout: 1200
     success: final_success
index 0d08aa2..35abf55 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
 package org.onap.policy.simulators;
 
 import java.util.UUID;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-
 import org.onap.policy.so.SORequest;
 import org.onap.policy.so.SORequestReferences;
 import org.onap.policy.so.SORequestStatus;
 import org.onap.policy.so.SOResponse;
-
 import com.att.aft.dme2.internal.gson.Gson;
 
-@Path("/serviceInstances")
+@Path("/serviceInstantiation")
 public class SoSimulatorJaxRs {
-    
-       /**
+
+    /**
      * SO post query.
-     * 
+     *
      * @param serviceInstanceId the service instance Id
      * @param vnfInstanceId the VNF Id
      * @return the response
      */
     @POST
-    @Path("/v5/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules")
+    @Path("/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut")
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces("application/json")
-    public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId, @PathParam("vnfInstanceId") final String vnfInstanceId)
-    {
+    public String soPostQuery(@PathParam("serviceInstanceId") final String serviceInstanceId,
+                    @PathParam("vnfInstanceId") final String vnfInstanceId) {
         final SORequest request = new SORequest();
         final SORequestStatus requestStatus = new SORequestStatus();
         requestStatus.setRequestState("COMPLETE");
         request.setRequestStatus(requestStatus);
         request.setRequestId(UUID.randomUUID());
-        
+
         final SOResponse response = new SOResponse();
-        
+
         final SORequestReferences requestReferences = new SORequestReferences();
         final String requestId = UUID.randomUUID().toString();
         requestReferences.setRequestId(requestId);
         response.setRequestReferences(requestReferences);
-        
+
         response.setRequest(request);
 
         return new Gson().toJson(response);
index 837c52c..4e0654d 100644 (file)
@@ -22,10 +22,8 @@ package org.onap.policy.simulators;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
-
 import java.util.HashMap;
 import java.util.UUID;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -96,7 +94,7 @@ public class SoSimulatorTest {
         // requestInfo
         //
         request.getRequestDetails().getRequestInfo()
-                .setInstanceName("vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8");
+                        .setInstanceName("vDNS_Ete_Named90e1ab3-dcd5-4877-9edb-eadfc84e32c8");
         request.getRequestDetails().getRequestInfo().setSource("POLICY");
         request.getRequestDetails().getRequestInfo().setSuppressRollback(false);
         request.getRequestDetails().getRequestInfo().setRequestorId("policy");
@@ -112,9 +110,9 @@ public class SoSimulatorTest {
         relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo());
         relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service");
         relatedInstanceListElement1.getRelatedInstance().getModelInfo()
-                .setModelInvariantId("4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b");
+                        .setModelInvariantId("4fcbc1c0-7793-46d8-8aa1-fa1c2ed9ec7b");
         relatedInstanceListElement1.getRelatedInstance().getModelInfo()
-                .setModelVersionId("5c996219-b2e2-4c76-9b43-7e8672a33c1d");
+                        .setModelVersionId("5c996219-b2e2-4c76-9b43-7e8672a33c1d");
         relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("8330e932-2a23-4943-8606");
         relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("1.0");
         //
@@ -122,13 +120,13 @@ public class SoSimulatorTest {
         relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo());
         relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf");
         relatedInstanceListElement2.getRelatedInstance().getModelInfo()
-                .setModelInvariantId("033a32ed-aa65-4764-a736-36f2942f1aa0");
+                        .setModelInvariantId("033a32ed-aa65-4764-a736-36f2942f1aa0");
         relatedInstanceListElement2.getRelatedInstance().getModelInfo()
-                .setModelVersionId("d4d072dc-4e21-4a03-9524-628985819a8e");
+                        .setModelVersionId("d4d072dc-4e21-4a03-9524-628985819a8e");
         relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("c15ce9e1-e914-4c8f-b8bb");
         relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1");
         relatedInstanceListElement2.getRelatedInstance().getModelInfo()
-                .setModelCustomizationName("c15ce9e1-e914-4c8f-b8bb 1");
+                        .setModelCustomizationName("c15ce9e1-e914-4c8f-b8bb 1");
         //
         request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1);
         request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2);
@@ -139,9 +137,9 @@ public class SoSimulatorTest {
     @Test
     public void testResponse() {
         final String request = Serialization.gsonPretty.toJson(this.createTestRequest());
-        final Pair<Integer, String> httpDetails =
-                new RESTManager().post("http://localhost:6667/serviceInstances/v5/12345/vnfs/12345/vfModules",
-                        "username", "password", new HashMap<>(), "application/json", request);
+        final Pair<Integer, String> httpDetails = new RESTManager().post(
+                        "http://localhost:6667/serviceInstantiation/v7/12345/vnfs/12345/vfModules/scaleOut", "username",
+                        "password", new HashMap<>(), "application/json", request);
         assertNotNull(httpDetails);
         final SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
         assertNotNull(response);
index d326574..dd88b5c 100644 (file)
@@ -47,7 +47,7 @@ VFW_CONTROL_LOOP_YAML="controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoop
 # vDNS Policy Parameters
 VDNS_CONTROL_LOOP_NAME="ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3"
 VDNS_POLICY_NAME="vdns"
-VDNS_CONTROL_LOOP_YAML="controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard"
+VDNS_CONTROL_LOOP_YAML="controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++payload%3A%0D%0A++++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue,%22userParams%22%3A%5B%7B%22name%22%3A%22gtp_bind_addr%22,%22value%22%3A%22vmme_private_ip_0%22%7D,%7B%22name%22%3A%22mmc%22,%22value%22%3A%22001%22%7D,%7B%22name%22%3A%22mme_addr%22,%22value%22%3A%22vmme_private_ip_0%22%7D,%7B%22name%22%3A%22mnc%22,%22value%22%3A%2201%22%7D,%7B%22name%22%3A%22n_prob%22,%22value%22%3A%2250%22%7D,%7B%22name%22%3A%22vnfHostIpAddress%22,%22value%22%3A%22veb_private_ip_0%22%7D%5D%7D%27%0D%0A++++++configurationParameters%3A+%27%5B%7B%22availability-zone%22%3A%22$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone%5B0%5D%22,%22xtz-123%22%3A%22$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone%5B0%5D%22%7D%5D%27%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard"
 
 # VoLTE Policy Parameters
 VOLTE_CONTROL_LOOP_NAME="ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b"
index 685deb1..5bd23f4 100644 (file)
@@ -94,7 +94,7 @@ echo
 echo "Inserting vDNS Policy..."
 curl --silent --user @1b3rt:31nst31n -X PUT --header 'Content-Type: text/plain' -d '{
        "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
-       "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard",
+       "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++payload%3A%0D%0A++++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue,%22userParams%22%3A%5B%7B%22name%22%3A%22gtp_bind_addr%22,%22value%22%3A%22vmme_private_ip_0%22%7D,%7B%22name%22%3A%22mmc%22,%22value%22%3A%22001%22%7D,%7B%22name%22%3A%22mme_addr%22,%22value%22%3A%22vmme_private_ip_0%22%7D,%7B%22name%22%3A%22mnc%22,%22value%22%3A%2201%22%7D,%7B%22name%22%3A%22n_prob%22,%22value%22%3A%2250%22%7D,%7B%22name%22%3A%22vnfHostIpAddress%22,%22value%22%3A%22veb_private_ip_0%22%7D%5D%7D%27%0D%0A++++++configurationParameters%3A+%27%5B%7B%22availability-zone%22%3A%22$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone%5B0%5D%22,%22xtz-123%22%3A%22$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone%5B0%5D%22%7D%5D%27%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard",
        "policyName": "vdns",
        "policyScope": "DCAE",
        "policyVersion": "1.2.0"
index 6a905c2..71ee386 100644 (file)
@@ -15,7 +15,7 @@ controlLoop:
   version: 2.0.0
   controlLoopName: ${closedLoopControlName}
   trigger_policy: unique-policy-id-1-scale-up
-  timeout: 3600
+  timeout: 1200
   abatement: false
  
 policies:
@@ -26,7 +26,10 @@ policies:
     recipe: VF Module Create
     target:
       type: VNF
-    retry: 3
+    payload:
+      requestParameters: '{"usePreload":true,"userParams":[{"name":"gtp_bind_addr","value":"vmme_private_ip_0"},{"name":"mmc","value":"001"},{"name":"mme_addr","value":"vmme_private_ip_0"},{"name":"mnc","value":"01"},{"name":"n_prob","value":"50"},{"name":"vnfHostIpAddress","value":"veb_private_ip_0"}]}'
+      configurationParameters: '[{"availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]","xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"}]'
+    retry: 0
     timeout: 1200
     success: final_success
     failure: final_failure
index 2acec10..4ef4100 100644 (file)
@@ -50,7 +50,7 @@
        <defaultValue>vdns</defaultValue>
      </requiredProperty>
      <requiredProperty key="vdnsControlLoopYaml">
-               <defaultValue>controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard</defaultValue>
+               <defaultValue>controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++payload%3A%0D%0A++++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue,%22userParams%22%3A%5B%7B%22name%22%3A%22gtp_bind_addr%22,%22value%22%3A%22vmme_private_ip_0%22%7D,%7B%22name%22%3A%22mmc%22,%22value%22%3A%22001%22%7D,%7B%22name%22%3A%22mme_addr%22,%22value%22%3A%22vmme_private_ip_0%22%7D,%7B%22name%22%3A%22mnc%22,%22value%22%3A%2201%22%7D,%7B%22name%22%3A%22n_prob%22,%22value%22%3A%2250%22%7D,%7B%22name%22%3A%22vnfHostIpAddress%22,%22value%22%3A%22veb_private_ip_0%22%7D%5D%7D%27%0D%0A++++++configurationParameters%3A+%27%5B%7B%22availability-zone%22%3A%22$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone%5B0%5D%22,%22xtz-123%22%3A%22$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone%5B0%5D%22%7D%5D%27%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard</defaultValue>
      </requiredProperty>
      <requiredProperty key="volteClosedLoopControlName">
        <defaultValue>ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b</defaultValue>
index d4ed173..ff5c089 100644 (file)
@@ -26,6 +26,9 @@ policies:
     recipe: VF Module Create
     target:
       type: VNF
+    payload:
+      requestParameters: '{"usePreload":true,"userParams":[{"name":"gtp_bind_addr","value":"vmme_private_ip_0"},{"name":"mmc","value":"001"},{"name":"mme_addr","value":"vmme_private_ip_0"},{"name":"mnc","value":"01"},{"name":"n_prob","value":"50"},{"name":"vnfHostIpAddress","value":"veb_private_ip_0"}]}'
+      configurationParameters: '[{"availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]","xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"}]'
     retry: 3
     timeout: 1200
     success: final_success