Merge "ensure default flags are set on execution"
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Fri, 6 Nov 2020 14:38:15 +0000 (14:38 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 6 Nov 2020 14:38:15 +0000 (14:38 +0000)
40 files changed:
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/util/RestUtil.java
adapters/mso-nssmf-adapter/src/main/resources/application.yaml
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NssmfAdapterUtils.groovy
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java
common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java
common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetType.java
docs/developer_info/Working_with_so_monitoring.rst
docs/images/configmap.png
docs/images/nodemap.png
docs/images/nodeport.png
docs/images/so-monitoring-config.png [new file with mode: 0644]
docs/images/so-monitoring-password.png [new file with mode: 0644]
docs/images/so-monitoring-secret.png [new file with mode: 0644]
docs/images/so-monitorring-base64-password.png [new file with mode: 0644]
docs/images/ui.png
so-monitoring/so-monitoring-service/src/main/resources/application.yaml
so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplace.java [deleted file]
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplaceVolume.java [deleted file]
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java [deleted file]
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java [deleted file]
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java [deleted file]
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByStackName.java
so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByStackName2.java [moved from so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/resources/QueryResourcesByBaseStackName.java with 65% similarity]
version.properties

index e481084..622a9c9 100644 (file)
@@ -74,17 +74,17 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL
 ('Service-Macro-Create', '7', 'ConfigAssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
 ('Service-Macro-Create', '8', 'AssignPnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
 ('Service-Macro-Create', '9', 'WaitForPnfReadyBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '11', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '12', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '13', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '14', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '15', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '16', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '17', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '18', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '19', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '20', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
-('Service-Macro-Create', '21', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '12', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '13', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '14', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '15', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '16', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '17', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '18', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '19', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '20', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '21', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
+('Service-Macro-Create', '22', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')),
 ('Service-Macro-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
 ('Service-Macro-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
 ('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')),
@@ -228,6 +228,8 @@ values (902, 'VNF-Macro-Modify',2,'ControllerExecutionBB',1,500,'vnf','config-de
 
 INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES
 ('Service-Macro-Create', '10', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT'), 'pnf', 'config-assign');
+INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES
+('Service-Macro-Create', '11', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT'), 'pnf', 'config-deploy');
 
 INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY)
 VALUES
@@ -949,13 +951,3 @@ VALUES
 ('VNFConfigModifyActivity','*','*','*','*','Manual','Abort','*', '*'),
 ('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
 ('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*');
-
-UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-assign' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigAssignVnfBB';
-UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-deploy' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigDeployVnfBB';
-UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='HealthCheck' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB';
-UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vfmodule', ACTION='ScaleOutReconfiguration' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB';
-
-INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES
-('VFModule-Delete', '1', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck"),
-('VFModule-Delete', '2', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vfmodule", "ScaleInReconfiguration"),
-('VFModule-Delete', '6', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck");
\ No newline at end of file
index c4f269c..789f4f2 100644 (file)
@@ -210,10 +210,12 @@ public abstract class BaseNssmfManager implements NssmfManager {
     private void urlHandler() {
         NssmfUrlInfo nssmfUrlInfo =
                 NssmfAdapterConsts.getNssmfUrlInfo(this.executorType, this.esrInfo.getNetworkType(), actionType);
-        this.nssmfUrl = nssmfUrlInfo.getUrl();
-        this.httpMethod = nssmfUrlInfo.getHttpMethod();
-        this.nssmfUrl = nssmfUrl.replaceAll("\\{apiVersion}", getApiVersion());
-        this.params.forEach((k, v) -> this.nssmfUrl = this.nssmfUrl.replaceAll("\\{" + k + "}", v));
+        if (nssmfUrlInfo != null) {
+            this.nssmfUrl = nssmfUrlInfo.getUrl();
+            this.httpMethod = nssmfUrlInfo.getHttpMethod();
+            this.nssmfUrl = nssmfUrl.replaceAll("\\{apiVersion}", getApiVersion());
+            this.params.forEach((k, v) -> this.nssmfUrl = this.nssmfUrl.replaceAll("\\{" + k + "}", v));
+        }
     }
 
     /**
index bb2b83f..72d1b53 100644 (file)
@@ -95,6 +95,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager {
         return marshal(actDeActNssi);
     }
 
+    @Override
     protected RestResponse doQueryJobStatus(ResourceOperationStatus status) throws ApplicationException {
         return doResponseStatus(status);
     }
index 4705e87..88b5071 100644 (file)
@@ -98,7 +98,7 @@ public abstract class InternalNssmfManager extends BaseNssmfManager {
 
     // internal
     private RestResponse sendInternalRequest(String content) {
-        Header header = new BasicHeader("X-Auth-Token", adapterConfig.getInfraAuth());
+        Header header = new BasicHeader("Authorization", adapterConfig.getInfraAuth());
         this.nssmfUrl = adapterConfig.getInfraEndpoint() + this.nssmfUrl;
         return restUtil.send(this.nssmfUrl, this.httpMethod, content, header);
     }
index a7adbe1..7a86c5b 100644 (file)
@@ -270,6 +270,7 @@ public class RestUtil {
     class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
         public static final String METHOD_NAME = "DELETE";
 
+        @Override
         public String getMethod() {
             return METHOD_NAME;
         }
@@ -316,12 +317,15 @@ public class RestUtil {
     public HttpClient getHttpsClient() {
 
         TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
+            @Override
             public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                 return null;
             }
 
+            @Override
             public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
 
+            @Override
             public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {}
         }};
 
@@ -329,10 +333,9 @@ public class RestUtil {
         try {
             SSLContext sc = SSLContext.getInstance("SSL");
             sc.init(null, trustAllCerts, new java.security.SecureRandom());
-            // HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
 
-            SSLConnectionSocketFactory sslsf =
-                    new SSLConnectionSocketFactory(sc, new String[] {"TLSv1"}, null, (s, sslSession) -> true);
+            SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sc,
+                    new String[] {"TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3"}, null, (s, sslSession) -> true);
             return HttpClients.custom().setSSLSocketFactory(sslsf).build();
         } catch (Exception e) {
             throw new IllegalArgumentException(e);
index 8da911d..5501fba 100644 (file)
@@ -59,7 +59,7 @@ mso:
       endpoint: https://so-request-db-adapter.{{ include "common.namespace" . }}:8083
       auth: Basic YnBlbDpwYXNzd29yZDEk
   infra:
-    endpoint: https://so.{{ include "common.namespace" . }}:8080
+    endpoint: http://so.onap:8080
     auth: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==
 
 #Actuator
index bafba3e..1b2fdfe 100644 (file)
@@ -143,8 +143,10 @@ public interface HeatBridgeApi {
      * @param genericVnfId AAI generic-vnf-id
      * @param vfModuleId AAI vf-module-id
      * @param servers Openstack Server list
+     * @throws HeatBridgeException
      */
-    void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers);
+    void buildAddVserversToAaiAction(String genericVnfId, String vfModuleId, List<Server> servers)
+            throws HeatBridgeException;
 
     /**
      * Query and build AAI actions for Openstack Neutron resources associated with a Compute resource to AAI's
index 1264727..8ee87b5 100644 (file)
@@ -317,8 +317,8 @@ public class HeatBridgeImpl implements HeatBridgeApi {
 
     @Override
     public void buildAddVserversToAaiAction(final String genericVnfId, final String vfModuleId,
-            final List<Server> servers) {
-        servers.forEach(server -> {
+            final List<Server> servers) throws HeatBridgeException {
+        for (Server server : servers) {
             Vserver vserver = aaiHelper.buildVserver(server.getId(), server);
 
             // Build vserver relationships to: image, flavor, pserver, vf-module
@@ -326,11 +326,28 @@ public class HeatBridgeImpl implements HeatBridgeApi {
                     aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server));
             AAIResourceUri vserverUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
                     .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId()));
+
             if (resourcesClient.exists(vserverUri)) {
                 AAIResultWrapper existingVserver = resourcesClient.get(vserverUri);
+                AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(
+                        AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
+                if (!existingVserver.hasRelationshipsTo(Types.VNFC)) {
+                    AAIResultWrapper vfModule = resourcesClient.get(vfModuleUri);
+                    if (vfModule.hasRelationshipsTo(Types.VNFC)) {
+                        List<AAIResourceUri> vnfcUris = vfModule.getRelationships().get().getRelatedUris(Types.VNFC);
+                        Optional<AAIResourceUri> foundVnfcURI = vnfcUris.stream().filter(resourceUri -> resourceUri
+                                .getURIKeys().get("vnfc-name").startsWith(vserver.getVserverName())).findFirst();
+                        if (foundVnfcURI.isEmpty()) {
+                            throw new HeatBridgeException("Cannot Find VNFC to create edge to VServer");
+                        }
+                        transaction.connect(vserverUri, foundVnfcURI.get());
+                    } else {
+                        throw new HeatBridgeException(
+                                "VF Module contains no relationships to VNFCS, cannot build edge to VServer");
+                    }
+                }
+
                 if (!existingVserver.hasRelationshipsTo(Types.VF_MODULE)) {
-                    AAIResourceUri vfModuleUri = AAIUriFactory.createResourceUri(
-                            AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
                     transaction.connect(vserverUri, vfModuleUri);
                 }
                 if (!existingVserver.hasRelationshipsTo(Types.PSERVER)) {
@@ -341,7 +358,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
             } else {
                 transaction.create(vserverUri, vserver);
             }
-        });
+        }
     }
 
     @Override
@@ -833,6 +850,10 @@ public class HeatBridgeImpl implements HeatBridgeApi {
         }
     }
 
+    protected void setAAIHelper(AaiHelper aaiHelper) {
+        this.aaiHelper = aaiHelper;
+    }
+
     protected AAIDSLQueryClient getAAIDSLClient() {
         if (aaiDSLClient == null) {
             aaiDSLClient = new AAIDSLQueryClient();
index 8e6f8cc..fef7b5e 100644 (file)
@@ -37,6 +37,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -50,14 +51,20 @@ import org.onap.aai.domain.yang.RelationshipData;
 import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.aai.domain.yang.SriovVf;
 import org.onap.aai.domain.yang.Vserver;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+import org.onap.so.heatbridge.HeatBridgeException;
 import org.onap.so.heatbridge.constants.HeatBridgeConstants;
 import org.openstack4j.model.compute.Server;
 import org.openstack4j.model.network.Network;
 import org.openstack4j.model.network.Port;
 import org.openstack4j.model.network.Subnet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import com.google.common.base.Preconditions;
 
 /**
@@ -66,6 +73,14 @@ import com.google.common.base.Preconditions;
  */
 public class AaiHelper {
 
+    private static final Logger logger = LoggerFactory.getLogger(AaiHelper.class);
+
+    private AAIResourcesClient resourcesClient;
+
+    public AaiHelper() {
+        this.resourcesClient = new AAIResourcesClient();
+    }
+
     /**
      * Build vserver relationship object to entities: pserver, vf-module, image, flavor
      *
@@ -74,9 +89,10 @@ public class AaiHelper {
      * @param genericVnfId AAI generic-vnf identifier
      * @param vfModuleId AAI vf-module identifier
      * @param server Openstack Server object
+     * @throws HeatBridgeException
      */
     public RelationshipList getVserverRelationshipList(final String cloudOwner, final String cloudRegionId,
-            final String genericVnfId, final String vfModuleId, final Server server) {
+            final String genericVnfId, final String vfModuleId, final Server server) throws HeatBridgeException {
         RelationshipList relationshipList = new RelationshipList();
         List<Relationship> relationships = relationshipList.getRelationship();
 
@@ -87,11 +103,10 @@ public class AaiHelper {
             relationships.add(pserverRelationship);
         }
 
-        // vserver to generic-vnf relationship
-        Relationship genericVnfRelationship = buildRelationship(
-                AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId)));
-        relationships.add(genericVnfRelationship);
-
+        // vserver to vnfc relationship
+        if (!StringUtils.isEmpty(server.getName())) {
+            relationships.add(createVnfRelationshiptoVserver(server.getName(), genericVnfId, vfModuleId));
+        }
         // vserver to vf-module relationship
         Relationship vfModuleRelationship = buildRelationship(AAIUriFactory
                 .createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId)));
@@ -114,6 +129,27 @@ public class AaiHelper {
         return relationshipList;
     }
 
+    public Relationship createVnfRelationshiptoVserver(String vserverName, String genericVnfId, String vfModuleId)
+            throws HeatBridgeException {
+        AAIResourceUri vfModuleUri = AAIUriFactory
+                .createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId));
+        AAIResultWrapper vfModule = resourcesClient.get(vfModuleUri);
+        if (vfModule.hasRelationshipsTo(Types.VNFC)) {
+            List<AAIResourceUri> vnfcUris = vfModule.getRelationships().get().getRelatedUris(Types.VNFC);
+            Optional<AAIResourceUri> foundVnfcURI = vnfcUris.stream()
+                    .filter(resourceUri -> resourceUri.getURIKeys().get("vnfc-name").startsWith(vserverName))
+                    .findFirst();
+            if (!foundVnfcURI.isPresent()) {
+                throw new HeatBridgeException("Cannot Find VNFC to create edge to VServer");
+            } else {
+                return buildRelationship(foundVnfcURI.get());
+            }
+        } else {
+            throw new HeatBridgeException("VF Module contains no relationships to VNFCS, cannot build edge to VServer");
+        }
+    }
+
+
     public RelationshipList getLInterfaceRelationshipList(final String pserverName, final String pIfName,
             final String pfPciId) {
         RelationshipList relationshipList = new RelationshipList();
@@ -378,4 +414,8 @@ public class AaiHelper {
         relationship.setRelatedLink(relatedLink.build().toString());
         return relationship;
     }
+
+    public void setAAIResourcesClient(AAIResourcesClient client) {
+        this.resourcesClient = client;
+    }
 }
index c9bee2b..1026284 100644 (file)
@@ -62,6 +62,7 @@ import java.util.Set;
 import org.apache.commons.io.FileUtils;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -72,10 +73,15 @@ import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList;
 import org.onap.aai.domain.yang.LInterface;
 import org.onap.aai.domain.yang.PInterface;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.aai.domain.yang.SriovPf;
+import org.onap.aai.domain.yang.VfModule;
+import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
 import org.onap.aaiclient.client.aai.AAIDSLQueryClient;
 import org.onap.aaiclient.client.aai.AAIResourcesClient;
 import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
 import org.onap.aaiclient.client.aai.entities.Results;
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
@@ -106,6 +112,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.env.Environment;
 import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -151,11 +158,15 @@ public class HeatBridgeImplTest {
     @Mock
     private AAIDSLQueryClient dSLQueryClient;
 
+    @Mock
+    private AAIResourcesClient aaiResourcesClient;
+
     @Spy
     @InjectMocks
     private HeatBridgeImpl heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID,
             REGION_ID, TENANT_ID, NodeType.GREENFIELD);
 
+
     @Before
     public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed {
         when(resourcesClient.beginSingleTransaction()).thenReturn(transaction);
@@ -180,7 +191,30 @@ public class HeatBridgeImplTest {
 
 
     @Test
-    public void testUpdateVserversToAai() throws HeatBridgeException {
+    @Ignore
+    public void testUpdateVserversToAai() throws HeatBridgeException, JsonProcessingException {
+        AaiHelper helper = new AaiHelper();
+        helper.setAAIResourcesClient(resourcesClient);
+        heatbridge.setAAIHelper(helper);
+
+        VfModule module = new VfModule();
+        RelationshipList relationships = new RelationshipList();
+        List<Relationship> listRelationships = relationships.getRelationship();
+        Relationship vnfcRelationship = new Relationship();
+        vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
+        vnfcRelationship.setRelatedTo("vnfc");
+        vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
+
+        listRelationships.add(vnfcRelationship);
+
+        module.setRelationshipList(relationships);
+        AAIResultWrapper wrapper =
+                new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
+
+        when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(
+                AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id"))))
+                        .thenReturn(wrapper);
+
         // Arrange
         Server server1 = mock(Server.class);
 
@@ -226,7 +260,29 @@ public class HeatBridgeImplTest {
     }
 
     @Test
-    public void testUpdateVserversToAaiNoHypervisorName() throws HeatBridgeException {
+    @Ignore
+    public void testUpdateVserversToAaiNoHypervisorName() throws HeatBridgeException, JsonProcessingException {
+        AaiHelper aaiHelper = new AaiHelper();
+        VfModule module = new VfModule();
+        RelationshipList relationships = new RelationshipList();
+        List<Relationship> listRelationships = relationships.getRelationship();
+        Relationship vnfcRelationship = new Relationship();
+        vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
+        vnfcRelationship.setRelatedTo("vnfc");
+        vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
+
+        listRelationships.add(vnfcRelationship);
+
+        module.setRelationshipList(relationships);
+        AAIResultWrapper wrapper =
+                new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
+        when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(
+                AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id"))))
+                        .thenReturn(wrapper);
+
+        aaiHelper.setAAIResourcesClient(aaiResourcesClient);
+        heatbridge.setAAIHelper(aaiHelper);
+
         // Arrange
         Server server1 = mock(Server.class);
 
@@ -269,8 +325,26 @@ public class HeatBridgeImplTest {
     }
 
     @Test
-    public void testCreateRelationships() throws HeatBridgeException {
+    public void testCreateRelationships() throws HeatBridgeException, JsonProcessingException {
         AaiHelper aaiHelper = new AaiHelper();
+        VfModule module = new VfModule();
+        RelationshipList relationships = new RelationshipList();
+        List<Relationship> listRelationships = relationships.getRelationship();
+        Relationship vnfcRelationship = new Relationship();
+        vnfcRelationship.setRelationshipLabel("org.onap.relationships.inventory.Uses");
+        vnfcRelationship.setRelatedTo("vnfc");
+        vnfcRelationship.setRelatedLink("/aai/v22/network/vnfcs/vnfc/test-server1-name");
+
+        listRelationships.add(vnfcRelationship);
+
+        module.setRelationshipList(relationships);
+        AAIResultWrapper wrapper =
+                new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(module));
+        when(aaiResourcesClient.get(AAIUriFactory.createResourceUri(
+                AAIFluentTypeBuilder.network().genericVnf("test-genericVnf-id").vfModule("test-vfModule-id"))))
+                        .thenReturn(wrapper);
+
+        aaiHelper.setAAIResourcesClient(aaiResourcesClient);
         // Arrange
         Server server1 = mock(Server.class);
 
index 775f088..bbe5f0d 100644 (file)
@@ -22,22 +22,15 @@ package org.onap.so.bpmn.common.scripts
 
 import org.apache.commons.lang3.StringUtils
 import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONArray
-import org.json.JSONObject
-import org.onap.logging.filter.base.ErrorCode
 import org.onap.logging.filter.base.ONAPComponents
-import org.onap.logging.ref.slf4j.ONAPLogConstants
+import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
 import org.onap.so.bpmn.core.UrnPropertiesReader
 import org.onap.so.bpmn.core.json.JsonUtils
 import org.onap.so.client.HttpClient
 import org.onap.so.client.HttpClientFactory
-import org.onap.so.logger.LoggingAnchor
-import org.onap.so.logger.MessageEnum
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
-import org.springframework.web.util.UriUtils
 
-import javax.ws.rs.core.MediaType
 import javax.ws.rs.core.Response
 
 /***
@@ -94,56 +87,91 @@ class NssmfAdapterUtils {
 
     }
 
-       public String sendPostRequestNSSMF (DelegateExecution execution, String endPoint, String nssmfRequest) {
-               try {
-
-                       String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution)
-                       String queryEndpoint = nssmfEndpoint + endPoint
-                       def responseData
-                       HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), ONAPComponents.EXTERNAL)
-                       String basicAuthCred = execution.getVariable("BasicAuthHeaderValue")
-                       client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution)))
-
-                       logger.debug('sending POST to NSSMF endpoint: ' + endPoint)
-                       Response response = client.post(nssmfRequest)
-
-                       responseData = response.readEntity(String.class)
-                       if (responseData != null) {
-                               logger.debug("Received data from NSSMF: " + responseData)
-                       }
-
-                       logger.debug('Response code:' + response.getStatus())
-                       logger.debug('Response:' + System.lineSeparator() + responseData)
-                       if (response.getStatus() >= 200 && response.getStatus() < 300) {
-                               // parse response as needed
-                               return responseData
-                       }
-                       else {
-                               return null
-                       }
-               }
-               catch (Exception e) {
-                       logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
-                       throw e
-               }
+    public String sendPostRequestNSSMF (DelegateExecution execution, String endPoint, String nssmfRequest) {
+        try {
 
-       }
+            String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution)
+            String queryEndpoint = nssmfEndpoint + endPoint
+            def responseData
+            HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), ONAPComponents.EXTERNAL)
+            String basicAuthCred = execution.getVariable("BasicAuthHeaderValue")
+            client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution)))
 
+            logger.debug('sending POST to NSSMF endpoint: ' + endPoint)
+            Response response = client.post(nssmfRequest)
+
+            responseData = response.readEntity(String.class)
+            if (responseData != null) {
+                logger.debug("Received data from NSSMF: " + responseData)
+            }
+
+            logger.debug('Response code:' + response.getStatus())
+            logger.debug('Response:' + System.lineSeparator() + responseData)
+            if (response.getStatus() >= 200 && response.getStatus() < 300) {
+                // parse response as needed
+                return responseData
+            }
+            else {
+                return null
+            }
+        }
+        catch (Exception e) {
+            logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
+            throw e
+        }
 
-       private String getBasicDBAuthHeader(DelegateExecution execution) {
+    }
 
-               String encodedString = null
-               try {
-                       String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution)
-                       logger.debug("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB)
+    public String sendPostRequestNSSMF (DelegateExecution execution, String endPoint, NssmfAdapterNBIRequest nssmfRequest) {
+        try {
+
+            String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution)
+            String queryEndpoint = nssmfEndpoint + endPoint
+            def responseData
+            HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), ONAPComponents.EXTERNAL)
+            String basicAuthCred = execution.getVariable("BasicAuthHeaderValue")
+            client.addAdditionalHeader("Authorization", StringUtils.defaultIfEmpty(basicAuthCred, getBasicDBAuthHeader(execution)))
+
+            logger.debug('sending POST to NSSMF endpoint: ' + endPoint)
+            Response response = client.post(nssmfRequest)
+
+            responseData = response.readEntity(String.class)
+            if (responseData != null) {
+                logger.debug("Received data from NSSMF: " + responseData)
+            }
+
+            logger.debug('Response code:' + response.getStatus())
+            logger.debug('Response:' + System.lineSeparator() + responseData)
+            if (response.getStatus() >= 200 && response.getStatus() < 300) {
+                // parse response as needed
+                return responseData
+            }
+            else {
+                return null
+            }
+        }
+        catch (Exception e) {
+            logger.debug("ERROR WHILE QUERYING CATALOG DB: " + e.message)
+            throw e
+        }
+
+    }
+
+    private String getBasicDBAuthHeader(DelegateExecution execution) {
+
+        String encodedString = null
+        try {
+            String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution)
+            logger.debug("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB)
+
+            encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution))
+            execution.setVariable("BasicAuthHeaderValue", encodedString)
+        } catch (IOException ex) {
+            String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
+            logger.error(dataErrorMessage)
+        }
+        return encodedString
+    }
 
-                       encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution))
-                       execution.setVariable("BasicAuthHeaderValue", encodedString)
-               } catch (IOException ex) {
-                       String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
-                       logger.error(dataErrorMessage)
-               }
-               return encodedString
-       }
 
 }
index ff31c46..4eb9eed 100644 (file)
@@ -22,6 +22,7 @@
 
 package org.onap.so.bpmn.common.scripts
 
+import com.google.gson.GsonBuilder
 import org.onap.so.beans.nsmf.oof.NsiReqBody
 import org.onap.so.beans.nsmf.oof.NssiReqBody
 import org.onap.so.beans.nsmf.oof.RequestInfo
@@ -673,7 +674,7 @@ return json.toString()
         requestInfo.setCallbackUrl(callbackUrl)
         requestInfo.setSourceId("so")
         requestInfo.setTimeout(timeOut)
-        //requestInfo.setNumSolutions()
+        requestInfo.setNumSolutions(100)
 
         nsiReqBody.setRequestInfo(requestInfo)
         nsiReqBody.setNSTInfo(nstInfo)
@@ -682,9 +683,7 @@ return json.toString()
         nsiReqBody.setNSSTInfo(nsstInfo)
         nsiReqBody.setPreferReuse(preferReuse)
 
-        ObjectMapper objectMapper = new ObjectMapper()
-
-        return objectMapper.writeValueAsString(nsiReqBody)
+        return bean2JsonStr(nsiReqBody)
     }
 
     public <T> String buildSelectNSSIRequest(String requestId, TemplateInfo nsstInfo, String messageType,
@@ -704,15 +703,16 @@ return json.toString()
         requestInfo.setCallbackUrl(callbackUrl)
         requestInfo.setSourceId("so")
         requestInfo.setTimeout(timeOut)
-        //requestInfo.setNumSolutions()
+        requestInfo.setNumSolutions(100)
 
         nssiReqBody.setRequestInfo(requestInfo)
         nssiReqBody.setSliceProfile(sliceProfile)
         nssiReqBody.setNSSTInfo(nsstInfo)
 
+        return bean2JsonStr(nssiReqBody)
+    }
 
-        ObjectMapper objectMapper = new ObjectMapper()
-
-        return objectMapper.writeValueAsString(nssiReqBody)
+    private static <T> String bean2JsonStr(T t) {
+        return new GsonBuilder().setPrettyPrinting().create().toJson(t)
     }
 }
index 1229c86..c46d504 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1ahlzqg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1ahlzqg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0">
   <bpmn:process id="ControllerExecutionBB" name="ControllerExecutionBB" isExecutable="true">
     <bpmn:startEvent id="StartEvent_1">
       <bpmn:outgoing>SequenceFlow_0gmfit3</bpmn:outgoing>
     <bpmn:sequenceFlow id="SequenceFlow_15gxql1" sourceRef="ExclusiveGateway_13q340y" targetRef="EndEvent_0mnaj50" />
     <bpmn:serviceTask id="ServiceTask_0inxg9l" name="Set Actor, Scope and Action Params" camunda:expression="${ControllerExecution.setControllerActorScopeAction(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
       <bpmn:incoming>SequenceFlow_0gmfit3</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_05j6hg6</bpmn:outgoing>
       <bpmn:outgoing>SequenceFlow_1lspfyy</bpmn:outgoing>
     </bpmn:serviceTask>
-    <bpmn:sequenceFlow id="SequenceFlow_05j6hg6" sourceRef="ServiceTask_0inxg9l" targetRef="ExclusiveGateway_0plxwkg" />
     <bpmn:exclusiveGateway id="ExclusiveGateway_0plxwkg" default="SequenceFlow_1t7hs4k">
       <bpmn:incoming>SequenceFlow_1lspfyy</bpmn:incoming>
-      <bpmn:incoming>SequenceFlow_05j6hg6</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1t7hs4k</bpmn:outgoing>
       <bpmn:outgoing>SequenceFlow_0vzx2yr</bpmn:outgoing>
     </bpmn:exclusiveGateway>
       <bpmndi:BPMNShape id="ServiceTask_0inxg9l_di" bpmnElement="ServiceTask_0inxg9l">
         <dc:Bounds x="259" y="301" width="100" height="80" />
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNEdge id="SequenceFlow_05j6hg6_di" bpmnElement="SequenceFlow_05j6hg6">
-        <di:waypoint x="359" y="341" />
-        <di:waypoint x="399" y="341" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="184" y="240" width="90" height="12" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ExclusiveGateway_0plxwkg_di" bpmnElement="ExclusiveGateway_0plxwkg" isMarkerVisible="true">
         <dc:Bounds x="399" y="316" width="50" height="50" />
         <bpmndi:BPMNLabel>
index 5f0d412..c136d52 100644 (file)
@@ -315,12 +315,14 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
         logger.debug("Start prepareSelectNSTRequest")
         String requestId = execution.getVariable("msoRequestId")
         String messageType = "NSTSelectionResponse"
-        Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") as Map<String, Object>
         execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst")
         execution.setVariable("nstSelection_messageType", messageType)
         execution.setVariable("nstSelection_correlator", requestId)
         String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
         execution.setVariable("nstSelection_timeout", timeout)
+
+        Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") as Map<String, Object>
+        serviceProfile.remove("profileId")
         String oofRequest = oofUtils.buildSelectNSTRequest(requestId, messageType, serviceProfile)
         execution.setVariable("nstSelection_oofRequest", oofRequest)
         logger.debug("Finish prepareSelectNSTRequest")
@@ -349,7 +351,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor {
             TemplateInfo nstInfo = new TemplateInfo()
             nstInfo.setUUID(nstSolution.get("UUID") as String)
             nstInfo.setInvariantUUID(nstSolution.get("invariantUUID") as String)
-            nstInfo.setName(nstSolution.get("name") as String)
+            nstInfo.setName(nstSolution.get("NSTName") as String)
 
             sliceTaskParams.setNSTInfo(nstInfo)
 
index d0c189c..1d7acd3 100644 (file)
@@ -41,7 +41,6 @@ import org.onap.so.beans.nsmf.CnSliceProfile
 import org.onap.so.beans.nsmf.EsrInfo
 import org.onap.so.beans.nsmf.NssiResponse
 import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
-import org.onap.so.beans.nsmf.ResponseDescriptor
 import org.onap.so.beans.nsmf.ServiceInfo
 import org.onap.so.beans.nsmf.SliceTaskInfo
 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
@@ -157,6 +156,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
             logger.info(msg)
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
         }
+        execution.setVariable("sliceTaskParams", sliceParams)
 
         logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
     }
@@ -201,8 +201,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         try {
             AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class)
             Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
-            //todo: if exists
-            if (!si.ifPresent()) {
+            if (!si.isPresent()) {
                 String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
                 logger.debug(msg)
                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
@@ -251,15 +250,13 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         rspi.setOrchestrationStatus(oStatus)
         rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
         rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
-        rspi.setInputParameters(uuiRequest)
-        rspi.setWorkloadContext(useInterval)
-        rspi.setEnvironmentContext(sNSSAI_id)
+        rspi.setInputParameters(execution.getVariable("uuiRequest"))
+        rspi.setWorkloadContext(execution.getVariable("useInterval"))
+        rspi.setEnvironmentContext(execution.getVariable("sNSSAI_id"))
 
         //timestamp format YYYY-MM-DD hh:mm:ss
         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
 
-        execution.setVariable("communicationServiceInstance", rspi)
-
         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(serviceInstanceId))
         client.create(uri, rspi)
 
@@ -312,11 +309,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
 
         AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
-        allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
-        allocateAnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID
-        allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name
         allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile
-        allocateAnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId
 
         EsrInfo esrInfo = new EsrInfo()
         //todo: vendor and network
@@ -339,8 +332,8 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         nbiRequest.setAllocateAnNssi(allocateAnNssi)
 
         execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest)
-        execution.setVariable("anBHSliceTaskInfo", sliceTaskInfo)
-        execution.setVariable("anSubnetType", SubnetType.AN_NF)
+        execution.setVariable("anSliceTaskInfo", sliceTaskInfo)
+        execution.setVariable("anSubnetType", SubnetType.AN)
     }
 
 
@@ -592,7 +585,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         SliceTaskParamsAdapter sliceParams =
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
-        ResponseDescriptor result = execution.getVariable("anNssiAllocateResult") as ResponseDescriptor
+        NssiResponse result = execution.getVariable("anNssiAllocateResult") as NssiResponse
         String nssiId = result.getNssiId()
         String nsiId = sliceParams.getSuggestNsiId()
         String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId
@@ -660,23 +653,25 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
         //sliceParams.setServiceId(nsiServiceInstanceID)
-        AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId))
+        AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(nssiId))
 
         String endpointId = null
 
         try {
             AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class)
             Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
-            //todo: if exists
-            if (!si.ifPresent()) {
+            if (!si.isPresent()) {
                 String msg = "NSSI in the option doesn't exist. " + nssiId
                 logger.debug(msg)
                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
-            }
-
-            if (si.ifPresent()) {
+            } else {
                 ServiceInstance nssiInstance = si.get()
                 //todo: handle relationship and return endpointId
+                if (nssiInstance.relationshipList == null) {
+                    String msg = "relationshipList of " + nssiId + " is null"
+                    logger.debug(msg)
+                    return null
+                }
                 for (Relationship relationship : nssiInstance.relationshipList.getRelationship()) {
                     if (relationship.relationshipLabel){
                         endpointId = relationship //todo
@@ -689,7 +684,7 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         }catch(BpmnError e) {
             throw e
         }catch (Exception ex){
-            String msg = "NSSI suggested in the option doesn't exist. " + nssiId
+            String msg = "Exception: " + ex
             logger.debug(msg)
             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
         }
@@ -735,14 +730,14 @@ class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
         //relation ship
         Relationship relationship = new Relationship()
 
-        AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(targetId))
+        AAIResourceUri targetInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(targetId))
 
-        logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri)
+        logger.info("Creating relationship, targetInstanceUri: " + targetInstanceUri)
 
-        relationship.setRelatedLink(nsiServiceUri.build().toString())
+        relationship.setRelatedLink(targetInstanceUri.build().toString())
 
-        AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sourceId).relationshipAPI())
-        client.create(uri, relationship)
+        AAIResourceUri sourceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sourceId)).relationshipAPI()
+        client.create(sourceInstanceUri, relationship)
     }
 
 }
index 3e834fa..896d7ff 100644 (file)
@@ -139,7 +139,7 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor {
             case SubnetType.CN:
                 sliceTaskParams.cnSliceTaskInfo = sliceTaskInfo
                 break
-            case SubnetType.AN_NF:
+            case SubnetType.AN:
                 sliceTaskParams.anSliceTaskInfo = sliceTaskInfo
                 break
             case SubnetType.TN_BH:
index cfdbe98..2cce68a 100644 (file)
@@ -43,7 +43,7 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition
 import org.onap.so.bpmn.core.json.JsonUtils
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
-import org.springframework.http.ResponseEntity
+import org.springframework.util.StringUtils
 
 class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
@@ -139,7 +139,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
      * @param execution
      */
     public void processDecompositionNSST(DelegateExecution execution) {
-
         List<ServiceDecomposition> nsstServiceDecompositions =
                 execution.getVariable("nsstServiceDecompositions") as List<ServiceDecomposition>
 
@@ -153,6 +152,9 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         int num = execution.getVariable("maxNsstIndex") as Integer
         int index = execution.getVariable("currentNsstIndex") as Integer
 
+        List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
+        nsstInfos.get(index).name = nsstServiceDecomposition.modelInfo.modelName
+        execution.setVariable("nsstInfos", nsstInfos)
         execution.setVariable("currentNsstIndex", index + 1)
 
         if (index >= num) {
@@ -178,17 +180,16 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         List<SubnetCapability> subnetCapabilities = new ArrayList<>()
 
         for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) {
-            SubnetCapability subnetCapability = new SubnetCapability()
-            handleByType(execution, serviceDecomposition, sliceParams, subnetCapability)
-            subnetCapabilities.add(subnetCapability)
+            handleByType(execution, serviceDecomposition, sliceParams, subnetCapabilities)
         }
 
         execution.setVariable("sliceTaskParams", sliceParams)
         execution.setVariable("subnetCapabilities", subnetCapabilities)
+        logger.debug("sliceTaskParams= " + sliceParams.toString())
     }
 
     private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition,
-                              SliceTaskParamsAdapter sliceParams, SubnetCapability subnetCapability) {
+                              SliceTaskParamsAdapter sliceParams, List<SubnetCapability> subnetCapabilities) {
         ModelInfo modelInfo = serviceDecomposition.getModelInfo()
         String vendor = serviceDecomposition.getServiceRole()
         SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory())
@@ -210,7 +211,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                 sliceParams.tnMHSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid()
                 sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName()
                 break
-            case SubnetType.AN_NF:
+            case SubnetType.AN:
                 sliceParams.anSliceTaskInfo.vendor = vendor
                 sliceParams.anSliceTaskInfo.subnetType = subnetType
                 sliceParams.anSliceTaskInfo.networkType = subnetType.networkType
@@ -236,12 +237,14 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
             exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
         }
         String response = querySubnetCapability(execution, vendor, subnetType)
-        ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class)
-
-        Map<String, Object> result = responseEntity.getBody() as Map
-        for (Map.Entry<String, Object> entry : result.entrySet()) {
-            subnetCapability.setDomainType(entry.getKey())
-            subnetCapability.setCapabilityDetails(entry.getValue())
+        if (!StringUtils.isEmpty(response)) {
+            SubnetCapability subnetCapability = new SubnetCapability()
+            Map<String, Object> result = objectMapper.readValue(response, Map.class)
+            for (Map.Entry<String, Object> entry : result.entrySet()) {
+                subnetCapability.setDomainType(entry.getKey())
+                subnetCapability.setCapabilityDetails(entry.getValue())
+            }
+            subnetCapabilities.add(subnetCapability)
         }
     }
 
@@ -254,7 +257,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
             return SubnetType.CN
         }
         if (serviceCategory ==~ /AN.*NF.*/){
-            return SubnetType.AN_NF
+            return SubnetType.AN
         }
         if (serviceCategory ==~ /TN.*BH.*/){
             return SubnetType.TN_BH
@@ -271,9 +274,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
      */
     private String querySubnetCapability(DelegateExecution execution, String vendor, SubnetType subnetType) {
 
-        String strRequest = objectMapper.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetType))
-
-        String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest)
+        String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY,
+                buildQuerySubnetCapRequest(vendor, subnetType))
         return response
     }
 
@@ -284,24 +286,24 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
      * @param networkType
      * @return
      */
-    private static String buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
+    private static NssmfAdapterNBIRequest buildQuerySubnetCapRequest(String vendor, SubnetType subnetType) {
         NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest()
 
-//        List<String> subnetTypes =  new ArrayList<>()
-//        subnetTypes.add(subnetType.subnetType)
-        Map<String, Object> paramMap = new HashMap()
-        paramMap.put("subnetType", subnetType.subnetType)
+        List<String> subnetTypes =  new ArrayList<>()
+
+        subnetTypes.add(subnetType.subnetType)
+
+        Map<String, Object> paramMap = new  HashMap<>()
+        paramMap.put("subnetTypes", subnetTypes)
 
-        request.setSubnetCapabilityQuery(objectMapper.writeValueAsString(paramMap))
+        request.setSubnetCapabilityQuery(paramMap)
 
         EsrInfo esrInfo = new EsrInfo()
         esrInfo.setVendor(vendor)
         esrInfo.setNetworkType(subnetType.networkType)
         request.setEsrInfo(esrInfo)
 
-        String strRequest = objectMapper.writeValueAsString(request)
-
-        return strRequest
+        return request
     }
 
     /**
@@ -328,6 +330,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
 
         Map<String, Object> profileInfo = sliceParams.getServiceProfile()
+        profileInfo.remove("profileId")
         TemplateInfo nstInfo = sliceParams.getNSTInfo()
 
         List<TemplateInfo> nsstInfos = execution.getVariable("nsstInfos") as List<TemplateInfo>
@@ -336,7 +339,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                 execution.getVariable("subnetCapabilities") as List<SubnetCapability>
 
         String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos,
-                messageType, profileInfo, subnetCapabilities, timeout as Integer, preferReuse)
+                messageType, profileInfo, subnetCapabilities, 600, preferReuse)
 
         execution.setVariable("nsiSelection_oofRequest", oofRequest)
         logger.debug("Sending request to OOF: " + oofRequest)
@@ -358,7 +361,13 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         //This needs to be changed to derive a value when we add policy to decide the solution options.
 
         Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class)
+        String requestStatus = resMap.get("requestStatus")
+        if (StringUtils.isEmpty(requestStatus)) {
+            exceptionUtil.buildWorkflowException(execution, 7000, "get nsi from oof error: " + oofResponse)
+        }
+
         List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions")
+
         Map<String, Object> solution = nsiSolutions.get(0)
 
         String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
@@ -378,7 +387,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
             }
         }
         execution.setVariable("sliceTaskParams", sliceTaskParams)
-        //logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson())
         logger.debug("*** Completed options Call to OOF ***")
     }
 
@@ -402,6 +410,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                     sliceParams.tnBHSliceTaskInfo.sliceProfile = sliceProfile as TnSliceProfile
                     break
                 case "an-nf":
+                case "an":
                     sliceParams.anSliceTaskInfo.sliceProfile = sliceProfile as AnSliceProfile
                     break
                 case "cn":
@@ -587,7 +596,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map
 
         TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo
-        Object profileInfo = nssiNeedHandlerInfo.get("sliceProfile")
+        Map<String, Object> profileInfo = nssiNeedHandlerInfo.get("sliceProfile") as Map
+        profileInfo.remove("profileId")
 
         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
         logger.debug( "get NSI option OOF Url: " + urlString)
@@ -602,7 +612,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
         execution.setVariable("nssiSelection_timeout", timeout)
 
         String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType,
-                profileInfo, timeout as Integer)
+                profileInfo, 600)
 
         execution.setVariable("nssiSelection_oofRequest", oofRequest)
         logger.debug("Sending request to OOF: " + oofRequest)
@@ -665,7 +675,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                 sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
                 sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
                 break
-            case SubnetType.AN_NF:
+            case SubnetType.AN:
                 sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId")
                 sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName")
                 break
index 8f150b3..5d95f97 100644 (file)
@@ -1252,9 +1252,12 @@ public class WorkflowAction {
                                             foundVfModuleOrVG = true;
                                         }
 
-                                        if (vfModuleCustomization.getVfModule() != null
-                                                && vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
-                                                && vfModuleCustomization.getHeatEnvironment() != null) {
+                                        if ((vfModuleCustomization.getVfModule() != null)
+                                                && ((vfModuleCustomization.getVfModule().getModuleHeatTemplate() != null
+                                                        && vfModuleCustomization.getHeatEnvironment() != null))
+                                                || (vfModuleCustomization.getVfModule().getModelName() != null
+                                                        && vfModuleCustomization.getVfModule().getModelName()
+                                                                .contains("helm"))) {
                                             foundVfModuleOrVG = true;
                                             Resource resource = new Resource(WorkflowType.VFMODULE,
                                                     vfModuleCustomization.getModelCustomizationUUID(), false);
index 71c50c1..9b6406d 100644 (file)
@@ -40,7 +40,7 @@ public class SliceTaskInfo<T> implements Serializable {
 
     private T sliceProfile;
 
-    private TemplateInfo NSSTInfo;
+    private TemplateInfo NSSTInfo = new TemplateInfo();
 
     private String sliceInstanceId;
 
index 292a0d5..ee3d8ae 100644 (file)
@@ -40,7 +40,7 @@ public class RequestInfo implements Serializable {
 
     private Integer numSolutions;
 
-    private Integer timeout;
+    private Object timeout;
 
     private Map<?, ?> addtnlArgs;
 }
index 4b0136a..536bb04 100644 (file)
@@ -26,15 +26,13 @@ import org.onap.so.beans.nsmf.NetworkType;
 public enum SubnetType {
     AN("AN", NetworkType.ACCESS),
 
-    AN_NF("AN-NF", NetworkType.ACCESS),
-
     CN("CN", NetworkType.CORE),
 
-    TN_FH("TN-FH", NetworkType.TRANSPORT),
+    TN_FH("TN_FH", NetworkType.TRANSPORT),
 
-    TN_MH("TN-MH", NetworkType.TRANSPORT),
+    TN_MH("TN_MH", NetworkType.TRANSPORT),
 
-    TN_BH("TN-BH", NetworkType.TRANSPORT),;
+    TN_BH("TN_BH", NetworkType.TRANSPORT),;
 
     private NetworkType networkType;
 
index 18b6d94..697f2c0 100644 (file)
@@ -1,28 +1,24 @@
 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
 .. http://creativecommons.org/licenses/by/4.0
 .. Copyright 2017 Huawei Technologies Co., Ltd.
+.. Modifications Copyright (c) 2020 Nokia
 
 Working with SO Monitoring
 ==========================
 
-After the SO code is fully deployed, certain changes needs to be made in order to access the so-monitoring ui.
+Starting from Guilin release SO Monitoring uses https and NodePort service during communication with operator.
+Certificates used for communication are generated automatically using AAF and certInitializer, when SO Monitoring 
+is deployed using OOM. For that reason, no additional tasks are needed in order to access the SO Monitoring ui, 
+when the SO is fully deployed. 
 
-1. Change the service type to NodePort
----------------------------------------
-
-By default, the type of the so monitoring service is ClusterIP, which makes the Service only reachable from within the cluster.
-This is changed to NodePort, which is used to expose the service at a static port . Hence we will be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>.
-
-Command used to get the service configuration of so monitoring is:
-
-**sudo kubectl edit svc so-monitoring -n onap**
+SO Monitoring contains also pre-installed certs which can be used in local development environment. **They are 
+for development purpose only!**
 
-.. image:: ../images/nodeport.png
-
-2. Add the credentials to login
---------------------------------
+1. Credentials to login and initial setup
+---------------------------------------------
 
-The override.yaml needs to be added with the login credentials, that is the username and the password in encrypted form.
+Defalut credentials and certs of SO Monitoring, if you want to develop SO Monitoring out of ONAP cluster,
+are stored in the app. Credentials are as follows:
 
 .. code-block:: bash
 
@@ -32,39 +28,109 @@ The override.yaml needs to be added with the login credentials, that is the user
    security:
      usercredentials:
      -                                         
-       username: gui
-       password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+       username: demo
+       password: '$2a$10$ndkDhATUid4a3g0JJVRv2esX4rtB.vzCn7iBhKyR1qZ/wDdvNzjTS'
        role: GUI-Client
 
-This override.yaml can be directly edited in case of local setup using docker.
+Username - demo. Password (**demo123456!**) is bcrypted.
+
 
-When deploying in any environment  using OOM, then after deployment the configmap needs to be edited. As configmap is the one reading the override.yaml.
+This setup is overridden by the override.yaml file which is stored in the OOM project.
+Override.yaml file can be edited directly in case of local ONAP setup. This file is loaded into
+container through configmap.
 
-**Note** : Before deployment , if we add these changes in override.yaml ,then it may give parsing error in configmap while deployment. And after deployment the permissions on override.yaml don't allow us to edit it. So the best option is to edit the configmap using the below command and restart the pod. 
+**Note** : If you want to change config stored in override.yaml on working deployment, you have to edit k8s
+configmap. Due to insufficient permissions it is not possible directly in the container. After that pod have 
+to be restarted.
 
 **kubectl -n onap edit configmap dev-so-monitoring-app-configmap**
 
 .. image:: ../images/configmap.png
 
-Special care needs to be given to the indentation. spring needs to be inline with the mso already present and others added accordingly.
+Special care needs to be given to the indentation. Spring needs to be inline with the mso already present and others
+added accordingly.
+
+**Attention! The default setup of the OOM makes SO Monitoring password is being automatically generated during ONAP
+deployment and injected through k8s secret**
+
+
+2. Setup, retrieve and edit default SO Monitoring password
+----------------------------------------------------------
+
+Automatic generation of password for SO Monitoring during ONAP deployment can be overriden. In result, password 
+can be set up manually. Such case requires to edit ONAP config file, template of which is stored in  
+**oom/kubernetes/onap/values.yaml** file. 
+
+.. image:: ../images/so-monitoring-config.png
+
+Following lines presented in fig. has to be uncommented.
+
+If customized file is used, following code has to be paste under the SO config (be aware of indentation):
+
+.. code-block:: bash
+
+ so:
+   ...
+   so-monitoring:
+     server:
+       monitoring:
+         password: demo123456!
+   ...
+
+Alternative way (**not recommended**) is to add password entry in the **oom/kubernetes/so/components/so-monitoring/values.yaml**
+
+.. code-block:: bash
+
+ ...
+ server:
+   monitoring:
+     password: demo123456!
+ ...
+
+To retrieve actual password for SO Monitoring on existing ONAP install, run the following command:
+
+**kubectl get secret -n onap dev-so-monitoring-app-user-creds -o json | jq -r .data.password | base64 --decode**
+
+.. image:: ../images/so-monitoring-password.png
+
+To change actual password on existing ONAP install, **dev-so-monitoring-app-user-creds** secret has to be modified.
+
+**kubectl edit secret -n onap dev-so-monitoring-app-user-creds**
+
+.. image:: ../images/so-monitoring-secret.png
+
+Edit password entry, which has to be given in base64 form. Base64 form of password can be obtained by running:
+
+**echo 'YOUR_PASSWORD' | base64**
+
+.. image:: ../images/so-monitorring-base64-password.png
+
+Once, password was edited, pod has to be restarted.
+
 
 3. Login to SO Monitoring
 -------------------------
 
-We need to first identify the external port which its mapped to using the following command : 
+Identify the external port which is mapped to SO Monitoring using the following command. The default port is 30224 :
 
 **sudo kubectl -n onap get svc | grep so-monitoring**
 
 .. image:: ../images/nodemap.png
 
-Then access the UI of so monitoring , for example by  http://<IP>:30224/ 
+Then access the UI of SO Monitoring, for example by  https://<IP>:30224/ 
 
-username : gui,
-password: password1$
+.. image:: ../images/ui.png
 
+4. Hiding the SO Monitoring service (ClusterIP)
+---------------------------------------
 
-.. image:: ../images/ui.png
+The SO Monitoring service is set to the NodePort type. It is used to expose the service at a static port.
+Hence there is possibility to contact the NodePort Service, from outside cluster, by requesting <NodeIP>:<NodePort>.
 
+In order to make the service only reachable from within the cluster, ClusterIP service has to be set.
 
+Command used to edit the service configuration of SO Monitoring is:
 
+**sudo kubectl edit svc so-monitoring -n onap**
 
+.. image:: ../images/nodeport.png
index 3683de3..c662e1f 100644 (file)
Binary files a/docs/images/configmap.png and b/docs/images/configmap.png differ
index 8dfda6c..afe1ebf 100644 (file)
Binary files a/docs/images/nodemap.png and b/docs/images/nodemap.png differ
index 53bc02f..d44ea76 100644 (file)
Binary files a/docs/images/nodeport.png and b/docs/images/nodeport.png differ
diff --git a/docs/images/so-monitoring-config.png b/docs/images/so-monitoring-config.png
new file mode 100644 (file)
index 0000000..74c2aeb
Binary files /dev/null and b/docs/images/so-monitoring-config.png differ
diff --git a/docs/images/so-monitoring-password.png b/docs/images/so-monitoring-password.png
new file mode 100644 (file)
index 0000000..89647c7
Binary files /dev/null and b/docs/images/so-monitoring-password.png differ
diff --git a/docs/images/so-monitoring-secret.png b/docs/images/so-monitoring-secret.png
new file mode 100644 (file)
index 0000000..cacf707
Binary files /dev/null and b/docs/images/so-monitoring-secret.png differ
diff --git a/docs/images/so-monitorring-base64-password.png b/docs/images/so-monitorring-base64-password.png
new file mode 100644 (file)
index 0000000..e57db59
Binary files /dev/null and b/docs/images/so-monitorring-base64-password.png differ
index 1c075ba..66382b6 100644 (file)
Binary files a/docs/images/ui.png and b/docs/images/ui.png differ
index ef0b6aa..c57d79c 100644 (file)
@@ -26,6 +26,6 @@ spring:
   security:
     usercredentials:
       -
-        username: gui
+        username: demo
         password: '$2a$10$ndkDhATUid4a3g0JJVRv2esX4rtB.vzCn7iBhKyR1qZ/wDdvNzjTS'
         role: GUI-Client
index 80e50be..383e1bf 100644 (file)
@@ -1,11 +1,9 @@
 package org.onap.so.simulator.actions.aai;
 
 import java.util.Optional;
+import org.onap.aai.domain.yang.VfModule;
 import org.onap.aai.domain.yang.Vnfc;
-import org.onap.aai.domain.yang.Vserver;
-import org.onap.aai.domain.yang.Vservers;
 import org.onap.aaiclient.client.aai.AAIResourcesClient;
-import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
@@ -50,40 +48,28 @@ public class ProcessVnfc extends AbstractTestAction {
                 vnfc.setModelVersionId("9e314c37-2258-4572-a399-c0dd7d5f1aec");
                 vnfc.setModelCustomizationId("2bd95cd4-d7ff-4af0-985d-2adea0339921");
 
+                AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network()
+                        .genericVnf(context.getVariable("vnfId")).vfModule(context.getVariable("vfModuleId")));
+
                 if (aaiResourceClient.exists(vnfcURI)) {
-                    logger.debug("cleaning up VNFC");
-                    aaiResourceClient.delete(vnfcURI);
+                    Optional<VfModule> vfModule = aaiResourceClient.get(vfModuleURI).asBean(VfModule.class);
+                    if (vfModule.get().getVfModuleName().contains("macro")) {
+                        String vnfcName = "ssc_server_1" + vfModule.get().getVfModuleName()
+                                .substring(vfModule.get().getVfModuleName().length() - 1);
+                        vnfc.setVnfcName(vnfcName);
+                        vnfcURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(vnfcName));
+                    } else {
+                        logger.debug("cleaning up VNFC");
+                        aaiResourceClient.delete(vnfcURI);
+                    }
                 }
 
                 logger.debug("creating new VNFC");
                 aaiResourceClient.create(vnfcURI, vnfc);
 
-                AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network()
-                        .genericVnf(context.getVariable("vnfId")).vfModule(context.getVariable("vfModuleId")));
                 logger.debug("creating VNFC edge to vf module");
                 aaiResourceClient.connect(vfModuleURI, vnfcURI);
-            } else if (context.getVariable("requestAction").equals("CreateVfModuleInstance")
-                    && context.getVariable("serviceAction").equals("activate")) {
-                logger.debug("creating edge between vserver and vnfc");
-                AAIResourceUri vnfcURI =
-                        AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc("ssc_server_1"));
-                AAIPluralResourceUri vserverPlural =
-                        AAIUriFactory
-                                .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
-                                        .cloudRegion(context.getVariable("cloudOwner"),
-                                                context.getVariable("cloudRegion"))
-                                        .tenant(context.getVariable("tenant")).vservers())
-                                .queryParam("vserver-name", "ssc_server_1");
-                Optional<Vserver> vserver = aaiResourceClient.getFirst(Vservers.class, Vserver.class, vserverPlural);
-                if (vserver.isPresent()) {
-                    AAIResourceUri vserverURI =
-                            AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
-                                    .cloudRegion(context.getVariable("cloudOwner"), context.getVariable("cloudRegion"))
-                                    .tenant(context.getVariable("tenant")).vserver(vserver.get().getVserverId()));
-                    aaiResourceClient.connect(vserverURI, vnfcURI);
-                }
             }
-
         } catch (Exception e) {
             logger.debug("Exception in ProcessVnfc.doExecute", e);
         }
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplace.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplace.java
deleted file mode 100644 (file)
index f4ac519..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.onap.so.simulator.scenarios.openstack;
-
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
-
-@Scenario("Query-Replace-ID-Name-Resources")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/replace_module/stackId/resources", method = RequestMethod.GET)
-public class QueryResourcesByStackNameModuleReplace extends AbstractSimulatorScenario {
-
-    @Override
-    public void run(ScenarioDesigner scenario) {
-        scenario.http().receive().get();
-
-        scenario.variable("stackName", "replace_module");
-
-        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
-                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
-
-    }
-}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplaceVolume.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryResourcesByStackNameModuleReplaceVolume.java
deleted file mode 100644 (file)
index f6eebeb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.onap.so.simulator.scenarios.openstack;
-
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
-
-@Scenario("Query-Replace-Volume-ID-Name-Resources")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/replace_module_volume_id/stackId/resources",
-        method = RequestMethod.GET)
-public class QueryResourcesByStackNameModuleReplaceVolume extends AbstractSimulatorScenario {
-
-    @Override
-    public void run(ScenarioDesigner scenario) {
-        scenario.http().receive().get();
-
-        scenario.variable("stackName", "replace_module_volume_id");
-
-        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
-                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
-
-    }
-}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro1.java
deleted file mode 100644 (file)
index eb306cc..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.onap.so.simulator.scenarios.openstack.macro;
-
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
-
-@Scenario("Openstack-Query-Stack-Resources-Macro1")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_1/stackId/resources", method = RequestMethod.GET)
-public class QueryResourcesByStackNameMacro1 extends AbstractSimulatorScenario {
-
-
-    @Override
-    public void run(ScenarioDesigner scenario) {
-        scenario.http().receive().get();
-
-        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
-                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
-
-    }
-
-}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro2.java
deleted file mode 100644 (file)
index d2551a2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.onap.so.simulator.scenarios.openstack.macro;
-
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
-
-@Scenario("Openstack-Query-Stack-Resources-Macro2")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_2/stackId/resources", method = RequestMethod.GET)
-public class QueryResourcesByStackNameMacro2 extends AbstractSimulatorScenario {
-
-
-    @Override
-    public void run(ScenarioDesigner scenario) {
-        scenario.http().receive().get();
-
-        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
-                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
-
-    }
-
-}
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/macro/QueryResourcesByStackNameMacro3.java
deleted file mode 100644 (file)
index bb33f2c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.onap.so.simulator.scenarios.openstack.macro;
-
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
-import com.consol.citrus.simulator.scenario.Scenario;
-import com.consol.citrus.simulator.scenario.ScenarioDesigner;
-
-@Scenario("Openstack-Query-Stack-Resources-Macro3")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/macro_module_3/stackId/resources", method = RequestMethod.GET)
-public class QueryResourcesByStackNameMacro3 extends AbstractSimulatorScenario {
-
-
-    @Override
-    public void run(ScenarioDesigner scenario) {
-        scenario.http().receive().get();
-
-        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
-                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
-
-    }
-
-}
index 82b1af4..22d66b0 100644 (file)
@@ -9,18 +9,24 @@ import com.consol.citrus.simulator.scenario.Scenario;
 import com.consol.citrus.simulator.scenario.ScenarioDesigner;
 
 @Scenario("Openstack-Query-Stack-Resources")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/dummy_id/resources", method = RequestMethod.GET)
+@RequestMapping(value = {"/sim/v1/tenantOne/stacks/dummy_id/stackId/resources",
+        "/sim/v1/tenantOne/stacks/base_module_id/stackId/resources",
+        "/sim/v1/tenantOne/stacks/replace_module/stackId/resources",
+        "/sim/v1/tenantOne/stacks/replace_module_volume_id/stackId/resources",
+        "/sim/v1/tenantOne/stacks/macro_module_1/stackId/resources",
+        "/sim/v1/tenantOne/stacks/macro_module_2/stackId/resources",
+        "/sim/v1/tenantOne/stacks/macro_module_3/stackId/resources",
+        "/sim/v1/tenantOne/stacks/created_success_id/stackId/resources",
+        "/sim/v1/tenantOne/stacks/failure__success_id/stackId/resources",
+        "/sim/v1/tenantOne/stacks/created_in_progress_id/stackId/resources"}, method = RequestMethod.GET)
 public class QueryResourcesByStackName extends AbstractSimulatorScenario {
 
-
     @Override
     public void run(ScenarioDesigner scenario) {
         scenario.http().receive().get();
 
-        scenario.variable("stackName", "dummy_id");
-
-        scenario.http().send().response(HttpStatus.OK)
-                .payload(new ClassPathResource("openstack/gr_api/GetStackResources.json"));
+        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
+                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
 
     }
 
@@ -8,9 +8,9 @@ import com.consol.citrus.simulator.scenario.AbstractSimulatorScenario;
 import com.consol.citrus.simulator.scenario.Scenario;
 import com.consol.citrus.simulator.scenario.ScenarioDesigner;
 
-@Scenario("Openstack-Query-Base-Stack-Resources")
-@RequestMapping(value = "/sim/v1/tenantOne/stacks/base_module_id/stackId/resources", method = RequestMethod.GET)
-public class QueryResourcesByBaseStackName extends AbstractSimulatorScenario {
+@Scenario("Openstack-Query-Stack-Resources-2")
+@RequestMapping(value = "/sim/v1/tenantOne/stacks/dummy_id/resources", method = RequestMethod.GET)
+public class QueryResourcesByStackName2 extends AbstractSimulatorScenario {
 
 
     @Override
@@ -19,8 +19,8 @@ public class QueryResourcesByBaseStackName extends AbstractSimulatorScenario {
 
         scenario.variable("stackName", "dummy_id");
 
-        scenario.http().send().response(HttpStatus.OK).header("ContentType", "application/json")
-                .payload(new ClassPathResource("openstack/gr_api/zrdm52emccr01_base_resources.json"));
+        scenario.http().send().response(HttpStatus.OK)
+                .payload(new ClassPathResource("openstack/gr_api/GetStackResources.json"));
 
     }
 
index 10c9593..f6e4c90 100644 (file)
@@ -4,7 +4,7 @@
 
 major=1
 minor=7
-patch=6
+patch=7
 
 base_version=${major}.${minor}.${patch}