Add pnfs resources handling in service macro create 48/99848/2
authorpwielebs <piotr.wielebski@nokia.com>
Fri, 20 Dec 2019 09:57:48 +0000 (10:57 +0100)
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>
Fri, 20 Dec 2019 11:03:27 +0000 (12:03 +0100)
Issue-ID: SO-2568
Signed-off-by: Piotr Wielebski <piotr.wielebski@nokia.com>
Change-Id: If6c6ad5469c9637af119c811e6f87ea00a282f18

bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ResourceKey.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
common/src/main/java/org/onap/so/serviceinstancebeans/Pnfs.java [new file with mode: 0644]
common/src/main/java/org/onap/so/serviceinstancebeans/Resources.java

index 8608fee..30a6e1f 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Nokia
+ * ================================================================================
  * 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
@@ -31,5 +33,6 @@ public enum ResourceKey {
     NETWORK_COLLECTION_ID,
     VPN_ID,
     VPN_BONDING_LINK_ID,
-    INSTANCE_GROUP_ID;
+    INSTANCE_GROUP_ID,
+    PNF
 }
index dc07d13..e8be273 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Nokia
+ * ================================================================================
  * 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
@@ -30,6 +32,7 @@ public class WorkflowResourceIds implements Serializable {
      */
     private static final long serialVersionUID = 8591599114353940105L;
     private String serviceInstanceId;
+    private String pnfId;
     private String vnfId;
     private String networkId;
     private String volumeGroupId;
@@ -40,10 +43,10 @@ public class WorkflowResourceIds implements Serializable {
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("vnfId", vnfId)
-                .append("networkId", networkId).append("volumeGroupId", volumeGroupId).append("vfModuleId", vfModuleId)
-                .append("networkCollectionId", networkCollectionId).append("configurationId", configurationId)
-                .toString();
+        return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("pnfId", pnfId)
+                .append("vnfId", vnfId).append("networkId", networkId).append("volumeGroupId", volumeGroupId)
+                .append("vfModuleId", vfModuleId).append("networkCollectionId", networkCollectionId)
+                .append("configurationId", configurationId).toString();
     }
 
     public String getServiceInstanceId() {
@@ -54,6 +57,14 @@ public class WorkflowResourceIds implements Serializable {
         this.serviceInstanceId = serviceInstanceId;
     }
 
+    public String getPnfId() {
+        return pnfId;
+    }
+
+    public void setPnfId(String pnfId) {
+        this.pnfId = pnfId;
+    }
+
     public String getVnfId() {
         return vnfId;
     }
index 88c36be..6b96bc3 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
+ * Modifications Copyright (c) 2019 Nokia
+ * ================================================================================
  * 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
@@ -26,6 +28,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.UUID;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -33,27 +36,12 @@ import org.camunda.bpm.engine.delegate.JavaDelegate;
 import org.javatuples.Pair;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.common.DelegateExecutionImpl;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.*;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
 import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
@@ -89,6 +77,7 @@ import org.onap.so.serviceinstancebeans.CloudConfiguration;
 import org.onap.so.serviceinstancebeans.ModelInfo;
 import org.onap.so.serviceinstancebeans.ModelType;
 import org.onap.so.serviceinstancebeans.Networks;
+import org.onap.so.serviceinstancebeans.Pnfs;
 import org.onap.so.serviceinstancebeans.RelatedInstance;
 import org.onap.so.serviceinstancebeans.RelatedInstanceList;
 import org.onap.so.serviceinstancebeans.RequestDetails;
@@ -115,6 +104,7 @@ public class BBInputSetup implements JavaDelegate {
     private static final String VF_MODULE = "VfModule";
     private static final String NETWORK = "Network";
     private static final String VNF = "Vnf";
+    private static final String PNF = "Pnf";
     private static final String NETWORK_COLLECTION = "NetworkCollection";
     private static final String PREPROV = "PREPROV";
     private static final String CREATEVOLUME = "CreateVolume";
@@ -243,6 +233,7 @@ public class BBInputSetup implements JavaDelegate {
         lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId());
         lookupKeyMap.put(ResourceKey.NETWORK_ID, workflowResourceIds.getNetworkId());
         lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, workflowResourceIds.getVnfId());
+        lookupKeyMap.put(ResourceKey.PNF, workflowResourceIds.getPnfId());
         lookupKeyMap.put(ResourceKey.VF_MODULE_ID, workflowResourceIds.getVfModuleId());
         lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, workflowResourceIds.getVolumeGroupId());
         lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, workflowResourceIds.getConfigurationId());
@@ -806,6 +797,13 @@ public class BBInputSetup implements JavaDelegate {
         }
     }
 
+    private void populatePnf(Pnfs pnf, String pnfId, ServiceInstance serviceInstance) {
+        Pnf genericPnf = new Pnf();
+        genericPnf.setPnfId(pnfId);
+        genericPnf.setPnfName(pnf.getInstanceName());
+        serviceInstance.getPnfs().add(genericPnf);
+    }
+
     protected boolean instanceGroupInList(GenericVnf vnf, String instanceGroupId) {
         for (InstanceGroup instanceGroup : vnf.getInstanceGroups()) {
             if (instanceGroup.getId() != null && instanceGroup.getId().equalsIgnoreCase(instanceGroupId)) {
@@ -1456,6 +1454,11 @@ public class BBInputSetup implements JavaDelegate {
             this.populateGenericVnf(executeBB.getRequestId(), vnfs.getModelInfo(), vnfs.getInstanceName(),
                     vnfs.getPlatform(), vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null,
                     vnfId, vnfType, vnfs.getInstanceParams(), productFamilyId, applicationId);
+        } else if (bbName.contains(PNF)) {
+            String pnfId = lookupKeyMap.get(ResourceKey.PNF);
+            resources.getPnfs().stream()
+                    .filter(pnf -> Objects.equals(key, pnf.getModelInfo().getModelCustomizationId())).findFirst()
+                    .ifPresent(pnf -> this.populatePnf(pnf, pnfId, serviceInstance));
         } else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP)) {
             Pair<Vnfs, VfModules> vnfsAndVfModules = getVfModulesAndItsVnfsByKey(key, resources);
             if (vnfsAndVfModules != null) {
index aa71ee5..bb70853 100644 (file)
@@ -59,6 +59,10 @@ public class ExtractPojosForBB {
                     serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
                     result = lookupObjectInList(serviceInstance.getVnfs(), value);
                     break;
+                case PNF:
+                    serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+                    result = lookupObjectInList(serviceInstance.getPnfs(), value);
+                    break;
                 case NETWORK_ID:
                     serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
                     result = lookupObjectInList(serviceInstance.getNetworks(), value);
index 483b626..8ee3979 100644 (file)
@@ -1934,6 +1934,7 @@ public class BBInputSetupTest {
         String serviceInstanceId = "serviceInstanceId";
         String networkId = "networkId";
         String vnfId = "vnfId";
+        String pnfId = "pnfId";
         String vfModuleId = "vfModuleId";
         String volumeGroupId = "volumeGroupId";
         String configurationId = "configurationId";
@@ -1942,6 +1943,7 @@ public class BBInputSetupTest {
         expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
         expected.put(ResourceKey.NETWORK_ID, networkId);
         expected.put(ResourceKey.GENERIC_VNF_ID, vnfId);
+        expected.put(ResourceKey.PNF, pnfId);
         expected.put(ResourceKey.VF_MODULE_ID, vfModuleId);
         expected.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId);
         expected.put(ResourceKey.CONFIGURATION_ID, configurationId);
@@ -1951,6 +1953,7 @@ public class BBInputSetupTest {
         workflowResourceIds.setServiceInstanceId(serviceInstanceId);
         workflowResourceIds.setNetworkId(networkId);
         workflowResourceIds.setVnfId(vnfId);
+        workflowResourceIds.setPnfId(pnfId);
         workflowResourceIds.setVfModuleId(vfModuleId);
         workflowResourceIds.setVolumeGroupId(volumeGroupId);
         workflowResourceIds.setConfigurationId(configurationId);
index 68f33c1..99ba352 100644 (file)
@@ -75,17 +75,7 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization;
 import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
 import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
 import org.onap.so.db.catalog.client.CatalogDbClient;
-import org.onap.so.serviceinstancebeans.CloudConfiguration;
-import org.onap.so.serviceinstancebeans.ModelInfo;
-import org.onap.so.serviceinstancebeans.ModelType;
-import org.onap.so.serviceinstancebeans.Networks;
-import org.onap.so.serviceinstancebeans.RelatedInstance;
-import org.onap.so.serviceinstancebeans.RequestDetails;
-import org.onap.so.serviceinstancebeans.RequestInfo;
-import org.onap.so.serviceinstancebeans.Service;
-import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
-import org.onap.so.serviceinstancebeans.VfModules;
-import org.onap.so.serviceinstancebeans.Vnfs;
+import org.onap.so.serviceinstancebeans.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -730,6 +720,8 @@ public class WorkflowAction {
                 workflowResourceIds.setServiceInstanceId(serviceInstanceId);
                 if (resource == WorkflowType.VNF) {
                     workflowResourceIds.setVnfId(resourceId);
+                } else if (resource == WorkflowType.PNF) {
+                    workflowResourceIds.setPnfId(resourceId);
                 } else if (resource == WorkflowType.VFMODULE) {
                     workflowResourceIds.setVfModuleId(resourceId);
                 } else if (resource == WorkflowType.VOLUMEGROUP) {
@@ -1173,6 +1165,13 @@ public class WorkflowAction {
                             }
                         }
                     }
+                    if (validate.getResources().getPnfs() != null) {
+                        for (Pnfs pnf : validate.getResources().getPnfs()) {
+                            resourceCounter.add(new Resource(WorkflowType.PNF,
+                                    pnf.getModelInfo().getModelCustomizationId(), false));
+                            foundRelated = true;
+                        }
+                    }
                     if (validate.getResources().getNetworks() != null) {
                         for (Networks network : validate.getResources().getNetworks()) {
                             resourceCounter.add(new Resource(WorkflowType.NETWORK,
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Pnfs.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Pnfs.java
new file mode 100644 (file)
index 0000000..f601ebc
--- /dev/null
@@ -0,0 +1,114 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Nokia
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.serviceinstancebeans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@JsonRootName(value = "pnfs")
+@JsonInclude(JsonInclude.Include.NON_DEFAULT)
+public class Pnfs implements Serializable {
+
+    private static final long serialVersionUID = 8081495240474276501L;
+    @JsonProperty("modelInfo")
+    protected ModelInfo modelInfo;
+    @JsonProperty("cloudConfiguration")
+    protected CloudConfiguration cloudConfiguration;
+    @JsonProperty("instanceName")
+    protected String instanceName;
+    @JsonProperty("platform")
+    protected Platform platform;
+    @JsonProperty("lineOfBusiness")
+    protected LineOfBusiness lineOfBusiness;
+    @JsonProperty("productFamilyId")
+    protected String productFamilyId;
+    @JsonProperty("instanceParams")
+    private List<Map<String, String>> instanceParams = new ArrayList<>();
+
+
+    public ModelInfo getModelInfo() {
+        return modelInfo;
+    }
+
+    public void setModelInfo(ModelInfo modelInfo) {
+        this.modelInfo = modelInfo;
+    }
+
+    public CloudConfiguration getCloudConfiguration() {
+        return cloudConfiguration;
+    }
+
+    public void setCloudConfiguration(CloudConfiguration cloudConfiguration) {
+        this.cloudConfiguration = cloudConfiguration;
+    }
+
+    public String getInstanceName() {
+        return instanceName;
+    }
+
+    public void setInstanceName(String instanceName) {
+        this.instanceName = instanceName;
+    }
+
+    public Platform getPlatform() {
+        return platform;
+    }
+
+    public void setPlatform(Platform platform) {
+        this.platform = platform;
+    }
+
+    public LineOfBusiness getLineOfBusiness() {
+        return lineOfBusiness;
+    }
+
+    public void setLineOfBusiness(LineOfBusiness lineOfBusiness) {
+        this.lineOfBusiness = lineOfBusiness;
+    }
+
+    public String getProductFamilyId() {
+        return productFamilyId;
+    }
+
+    public void setProductFamilyId(String productFamilyId) {
+        this.productFamilyId = productFamilyId;
+    }
+
+    public List<Map<String, String>> getInstanceParams() {
+        return instanceParams;
+    }
+
+    public void setInstanceParams(List<Map<String, String>> instanceParams) {
+        this.instanceParams = instanceParams;
+    }
+
+    @Override
+    public String toString() {
+        return "Pnfs [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration + ", instanceName="
+                + instanceName + ", platform=" + platform + ", " + "lineOfBusiness=" + lineOfBusiness
+                + ", productFamilyId=" + productFamilyId + ", instanceParams=" + instanceParams + "]";
+    }
+
+}
index 2123b2f..acac8c4 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Nokia
+ * ================================================================================
  * 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
@@ -36,6 +38,8 @@ public class Resources implements Serializable {
     private static final long serialVersionUID = 2194797231782624520L;
     @JsonProperty("vnfs")
     private List<Vnfs> vnfs = new ArrayList<>();
+    @JsonProperty("pnfs")
+    private List<Pnfs> pnfs = new ArrayList<>();
     @JsonProperty("networks")
     private List<Networks> networks = new ArrayList<>();
 
@@ -47,6 +51,14 @@ public class Resources implements Serializable {
         this.vnfs = vnfs;
     }
 
+    public List<Pnfs> getPnfs() {
+        return pnfs;
+    }
+
+    public void setPnfs(List<Pnfs> pnfs) {
+        this.pnfs = pnfs;
+    }
+
     public List<Networks> getNetworks() {
         return networks;
     }