Merge "remove unused parameter in methods"
authorRob Daugherty <rd472p@att.com>
Tue, 27 Nov 2018 21:51:26 +0000 (21:51 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 27 Nov 2018 21:51:26 +0000 (21:51 +0000)
35 files changed:
adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java [new file with mode: 0644]
adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java [new file with mode: 0644]
adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/ServiceEndpointNotFoundException.java [new file with mode: 0644]
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java [new file with mode: 0644]
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java
adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java
adapters/mso-adapter-utils/src/test/resources/__files/KeystoneV3Payload.json [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.12.2__AddDomainColumnsCloudIdentity.sql [new file with mode: 0644]
adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
adapters/mso-openstack-adapters/src/test/resources/data.sql
adapters/mso-openstack-adapters/src/test/resources/schema.sql
adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy
bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServerType.java
mso-catalog-db/src/test/resources/data.sql
mso-catalog-db/src/test/resources/schema.sql
packages/docker/src/main/docker/docker-files/scripts/start-app.sh

index 1912cd8..49c80b4 100644 (file)
 
 package org.onap.so.cloud.authentication;
 
+import java.util.Collections;
+
+import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
 import org.onap.so.db.catalog.beans.AuthenticationType;
 import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
 import org.onap.so.utils.CryptoUtils;
 import org.springframework.stereotype.Component;
 
 import com.woorea.openstack.keystone.model.Authentication;
 import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User;
+import com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User.Domain;
+import com.woorea.openstack.keystone.v3.model.Authentication.Scope;
+import com.woorea.openstack.keystone.v3.model.Authentication.Scope.Project;
 
 /**
  * This factory manages all the wrappers associated to authentication types.
@@ -50,4 +58,30 @@ public final class AuthenticationMethodFactory {
                        return new UsernamePassword (cloudIdentity.getMsoId (), CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ()));
                }
        }
+       
+       
+       public final com.woorea.openstack.keystone.v3.model.Authentication getAuthenticationForV3(CloudIdentity cloudIdentity, String tenantId) {
+               Identity identity = new Identity();
+               Password password = new Password();
+               User user = new User();
+               Domain userDomain = new Domain();
+               Scope scope = new Scope();
+               Project project = new Project();
+               Project.Domain projectDomain = new Project.Domain();
+               userDomain.setName(cloudIdentity.getUserDomainName());
+               projectDomain.setName(cloudIdentity.getProjectDomainName());
+               user.setName(cloudIdentity.getMsoId());
+               user.setPassword(CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass()));
+               user.setDomain(userDomain);
+               password.setUser(user);
+               project.setDomain(projectDomain);
+               project.setId(tenantId);
+               scope.setProject(project);
+               identity.setPassword(password);
+               identity.setMethods(Collections.singletonList("password"));
+               com.woorea.openstack.keystone.v3.model.Authentication v3Auth = new com.woorea.openstack.keystone.v3.model.Authentication();
+               v3Auth.setIdentity(identity);
+               v3Auth.setScope(scope);
+               return v3Auth;
+       }
 }
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java
new file mode 100644 (file)
index 0000000..1a221a8
--- /dev/null
@@ -0,0 +1,32 @@
+package org.onap.so.cloud.authentication;
+
+import java.io.Serializable;
+import java.util.Calendar;
+
+public class KeystoneAuthHolder implements Serializable {
+
+       private static final long serialVersionUID = -9073252905181739224L;
+       
+       private String id;
+       private Calendar expiration;
+       private String serviceUrl;
+       
+       public String getId() {
+               return id;
+       }
+       public void setId(String id) {
+               this.id = id;
+       }
+       public Calendar getexpiration() {
+               return expiration;
+       }
+       public void setexpiration(Calendar expiration) {
+               this.expiration = expiration;
+       }
+       public String getServiceUrl() {
+               return serviceUrl;
+       }
+       public void setHeatUrl(String serviceUrl) {
+               this.serviceUrl = serviceUrl;
+       }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java
new file mode 100644 (file)
index 0000000..05364d0
--- /dev/null
@@ -0,0 +1,113 @@
+package org.onap.so.cloud.authentication;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Predicate;
+
+import org.onap.so.config.beans.PoConfig;
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.onap.so.openstack.utils.MsoTenantUtils;
+import org.onap.so.openstack.utils.MsoTenantUtilsFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.woorea.openstack.base.client.OpenStackConnectException;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.base.client.OpenStackResponse;
+import com.woorea.openstack.base.client.OpenStackResponseException;
+import com.woorea.openstack.keystone.v3.Keystone;
+import com.woorea.openstack.keystone.v3.model.Authentication;
+import com.woorea.openstack.keystone.v3.model.Token;
+import com.woorea.openstack.keystone.v3.model.Token.Service;
+
+import net.jodah.failsafe.Failsafe;
+import net.jodah.failsafe.RetryPolicy;
+
+
+@Component
+public class KeystoneV3Authentication {
+
+       @Autowired
+    private AuthenticationMethodFactory authenticationMethodFactory;
+    
+    @Autowired
+    private MsoTenantUtilsFactory tenantUtilsFactory;
+    
+    @Autowired
+       private PoConfig poConfig;
+       
+       public KeystoneAuthHolder getToken(CloudSite cloudSite, String tenantId, String type) throws MsoException {
+               
+               String cloudId = cloudSite.getId();
+        String region = cloudSite.getRegionId();
+
+               CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+               MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
+        String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
+        Keystone keystoneTenantClient = new Keystone (keystoneUrl);
+        Authentication v3Credentials = authenticationMethodFactory.getAuthenticationForV3(cloudIdentity, tenantId);
+
+
+       OpenStackRequest<Token> v3Request = keystoneTenantClient.tokens ()
+                .authenticate(v3Credentials);
+       
+       KeystoneAuthHolder holder = makeRequest(v3Request, type, region);
+
+               return holder;
+       }
+       
+       protected KeystoneAuthHolder makeRequest(OpenStackRequest<Token> v3Request, String type, String region) {
+               
+               OpenStackResponse response = Failsafe.with(createRetryPolicy()).get(() -> {
+                       return v3Request.request();
+               });
+               String id = response.header("X-Subject-Token");
+               Token token = response.getEntity(Token.class);
+               KeystoneAuthHolder result = new KeystoneAuthHolder();
+               result.setId(id);
+               result.setexpiration(token.getExpiresAt());
+               result.setHeatUrl(findEndpointURL(token.getCatalog(), type, region, "public"));
+               return result;
+       }
+       
+       protected RetryPolicy createRetryPolicy() {
+               RetryPolicy policy = new RetryPolicy();
+               List<Predicate<Throwable>> result = new ArrayList<>();
+               result.add(e -> {
+                       return e.getCause() instanceof OpenStackResponseException 
+                                       && Arrays.asList(poConfig.getRetryCodes().split(","))
+                                       .contains(Integer.toString(((OpenStackResponseException)e).getStatus()));
+               });
+               result.add(e -> {
+                       return e.getCause() instanceof OpenStackConnectException;
+               });
+               
+               Predicate<Throwable> pred = result.stream().reduce(Predicate::or).orElse(x -> false);
+
+               policy.retryOn(error -> pred.test(error));
+               
+               policy.withDelay(poConfig.getRetryDelay(), TimeUnit.SECONDS)
+               .withMaxRetries(poConfig.getRetryCount());
+               
+               return policy;
+       }
+       
+       protected String findEndpointURL(List<Service> serviceCatalog, String type, String region, String facing) {
+               for(Service service : serviceCatalog) {
+                       if(type.equals(service.getType())) {
+                               for(Service.Endpoint endpoint : service.getEndpoints()) {
+                                       if(region == null || region.equals(endpoint.getRegion())) {
+                                               if(facing.equals(endpoint.getInterface())) {
+                                                       return endpoint.getUrl();
+                                               }
+                                       }
+                               }
+                       }
+               }
+               throw new ServiceEndpointNotFoundException("endpoint url not found");
+       }
+}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/ServiceEndpointNotFoundException.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/ServiceEndpointNotFoundException.java
new file mode 100644 (file)
index 0000000..3bc57a8
--- /dev/null
@@ -0,0 +1,10 @@
+package org.onap.so.cloud.authentication;
+
+public class ServiceEndpointNotFoundException extends RuntimeException {
+
+       private static final long serialVersionUID = -5347215451284361397L;
+
+       public ServiceEndpointNotFoundException(String message) {
+               super(message);
+       }
+}
index e36d0ff..d87330b 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.so.openstack.utils;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -41,11 +42,15 @@ import org.onap.so.adapters.vdu.VduPlugin;
 import org.onap.so.adapters.vdu.VduStateType;
 import org.onap.so.adapters.vdu.VduStatus;
 import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.cloud.authentication.KeystoneV3Authentication;
+import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException;
 import org.onap.so.db.catalog.beans.CloudIdentity;
 import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
 import org.onap.so.db.catalog.beans.HeatTemplate;
 import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.ServerType;
 import org.onap.so.logger.MessageEnum;
 import org.onap.so.logger.MsoAlarmLogger;
 import org.onap.so.logger.MsoLogger;
@@ -115,7 +120,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
 
     @Autowired
     private MsoTenantUtilsFactory tenantUtilsFactory;
-
+    
+    @Autowired
+    private KeystoneV3Authentication keystoneV3Authentication;
+    
     private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoHeatUtils.class);
 
     // Properties names and variables (with default values)
@@ -875,7 +883,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
      */
     public Heat getHeatClient (CloudSite cloudSite, String tenantId) throws MsoException {
         String cloudId = cloudSite.getId();
-
+        // For DCP/LCP, the region should be the cloudId.
+        String region = cloudSite.getRegionId ();
+        
         // Check first in the cache of previously authorized clients
         String cacheKey = cloudId + ":" + tenantId;
         if (heatClientCache.containsKey (cacheKey)) {
@@ -895,16 +905,58 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
         MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
         String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
         LOGGER.debug("keystoneUrl=" + keystoneUrl);
-        Keystone keystoneTenantClient = new Keystone (keystoneUrl);
-        Access access = null;
-        try {
-               Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
-
-               OpenStackRequest <Access> request = keystoneTenantClient.tokens ()
-                       .authenticate (credentials).withTenantId (tenantId);
-
-            access = executeAndRecordOpenstackRequest (request);
-        } catch (OpenStackResponseException e) {
+        String heatUrl = null;
+        String tokenId = null;
+        Calendar expiration = null;
+           try {
+               if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
+                       Keystone keystoneTenantClient = new Keystone (keystoneUrl);
+                       Access access = null;
+               
+                       Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
+       
+                       OpenStackRequest <Access> request = keystoneTenantClient.tokens ()
+                              .authenticate (credentials).withTenantId (tenantId);
+       
+                   access = executeAndRecordOpenstackRequest (request);
+               
+                       try {
+                               // Isolate trying to printout the region IDs
+                               try {
+                                       LOGGER.debug("access=" + access.toString());
+                                       for (Access.Service service : access.getServiceCatalog()) {
+                                               List<Access.Service.Endpoint> endpoints = service.getEndpoints();
+                                               for (Access.Service.Endpoint endpoint : endpoints) {
+                                                       LOGGER.debug("AIC returned region=" + endpoint.getRegion());
+                                               }
+                                       }
+                               } catch (Exception e) {
+                                       LOGGER.debug("Encountered an error trying to printout Access object returned from AIC. " + e.getMessage());
+                               }
+                           heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public");
+                           LOGGER.debug("heatUrl=" + heatUrl + ", region=" + region);
+                       } catch (RuntimeException e) {
+                           // This comes back for not found (probably an incorrect region ID)
+                           String error = "AIC did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl();
+                           alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
+                           throw new MsoAdapterException (error, e);
+                       }
+                       tokenId = access.getToken ().getId ();
+                       expiration = access.getToken ().getExpires ();
+               } else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
+                       try {
+                               KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "orchestration");
+                               tokenId = holder.getId();
+                               expiration = holder.getexpiration();
+                               heatUrl = holder.getServiceUrl();
+                       } catch (ServiceEndpointNotFoundException e) {
+                               // This comes back for not found (probably an incorrect region ID)
+                           String error = "cloud did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl();
+                           alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
+                           throw new MsoAdapterException (error, e);
+                       }
+               }
+           } catch (OpenStackResponseException e) {
             if (e.getStatus () == 401) {
                 // Authentication error.
                 String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId ();
@@ -922,39 +974,13 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
             // Catch-all
             throw runtimeExceptionToMsoException (e, TOKEN_AUTH);
         }
-
-        // For DCP/LCP, the region should be the cloudId.
-        String region = cloudSite.getRegionId ();
-        String heatUrl = null;
-        try {
-               // Isolate trying to printout the region IDs
-               try {
-                       LOGGER.debug("access=" + access.toString());
-                       for (Access.Service service : access.getServiceCatalog()) {
-                               List<Access.Service.Endpoint> endpoints = service.getEndpoints();
-                               for (Access.Service.Endpoint endpoint : endpoints) {
-                                       LOGGER.debug("AIC returned region=" + endpoint.getRegion());
-                               }
-                       }
-               } catch (Exception e) {
-                       LOGGER.debug("Encountered an error trying to printout Access object returned from AIC. " + e.getMessage());
-               }
-            heatUrl = KeystoneUtils.findEndpointURL (access.getServiceCatalog (), "orchestration", region, "public");
-            LOGGER.debug("heatUrl=" + heatUrl + ", region=" + region);
-        } catch (RuntimeException e) {
-            // This comes back for not found (probably an incorrect region ID)
-            String error = "AIC did not match an orchestration service for: region=" + region + ",cloud=" + cloudIdentity.getIdentityUrl();
-            alarmLogger.sendAlarm ("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
-            throw new MsoAdapterException (error, e);
-        }
-
         Heat heatClient = new Heat (heatUrl);
-        heatClient.token (access.getToken ().getId ());
+        heatClient.token (tokenId);
 
         heatClientCache.put (cacheKey,
                              new HeatCacheEntry (heatUrl,
-                                                 access.getToken ().getId (),
-                                                 access.getToken ().getExpires ()));
+                                                 tokenId,
+                                                 expiration));
         LOGGER.debug ("Caching HEAT Client for " + cacheKey);
 
         return heatClient;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java
new file mode 100644 (file)
index 0000000..da1957f
--- /dev/null
@@ -0,0 +1,41 @@
+package org.onap.so.openstack.utils;
+
+import java.util.Map;
+
+import org.onap.so.db.catalog.beans.CloudIdentity;
+import org.onap.so.openstack.beans.MsoTenant;
+import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
+import org.onap.so.openstack.exceptions.MsoException;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MsoKeystoneV3Utils extends MsoTenantUtils {
+
+       @Override
+       public String createTenant(String tenantName, String cloudSiteId, Map<String, String> metadata, boolean backout)
+                       throws MsoException {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public MsoTenant queryTenant(String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public MsoTenant queryTenantByName(String tenantName, String cloudSiteId)
+                       throws MsoException, MsoCloudSiteNotFound {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public boolean deleteTenant(String tenantId, String cloudSiteId) throws MsoException {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public String getKeystoneUrl(String regionId, CloudIdentity cloudIdentity) throws MsoException {
+               return cloudIdentity.getIdentityUrl();
+       }
+
+}
index a9f0a39..b7676e0 100644 (file)
@@ -22,14 +22,19 @@ package org.onap.so.openstack.utils;
 
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.onap.so.cloud.CloudConfig;
+import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
+import org.onap.so.cloud.authentication.KeystoneAuthHolder;
+import org.onap.so.cloud.authentication.KeystoneV3Authentication;
+import org.onap.so.cloud.authentication.ServiceEndpointNotFoundException;
 import org.onap.so.db.catalog.beans.CloudIdentity;
 import org.onap.so.db.catalog.beans.CloudSite;
-import org.onap.so.cloud.authentication.AuthenticationMethodFactory;
+import org.onap.so.db.catalog.beans.ServerType;
 import org.onap.so.logger.MessageEnum;
 import org.onap.so.logger.MsoAlarmLogger;
 import org.onap.so.logger.MsoLogger;
@@ -78,6 +83,9 @@ public class MsoNeutronUtils extends MsoCommonUtils
        
        @Autowired
        private MsoTenantUtilsFactory tenantUtilsFactory;
+
+       @Autowired
+       private KeystoneV3Authentication keystoneV3Authentication;
        
        private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, MsoNeutronUtils.class);
        
@@ -356,7 +364,8 @@ public class MsoNeutronUtils extends MsoCommonUtils
     private Quantum getNeutronClient(CloudSite cloudSite, String tenantId) throws MsoException
        {
                String cloudId = cloudSite.getId();
-
+               String region = cloudSite.getRegionId();
+               
                // Check first in the cache of previously authorized clients
                String cacheKey = cloudId + ":" + tenantId;
                if (neutronClientCache.containsKey(cacheKey)) {
@@ -378,12 +387,48 @@ public class MsoNeutronUtils extends MsoCommonUtils
                CloudIdentity cloudIdentity = cloudSite.getIdentityService();
                MsoTenantUtils tenantUtils = tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
         final String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
-               Keystone keystoneTenantClient = new Keystone(keystoneUrl);
-               Access access = null;
+               String neutronUrl = null;
+               String tokenId = null;
+               Calendar expiration = null;
                try {
-                       Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
-                       OpenStackRequest<Access> request = keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId);
-                       access = executeAndRecordOpenstackRequest(request);
+               if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
+                               Keystone keystoneTenantClient = new Keystone(keystoneUrl);
+                               Access access = null;
+                               
+                               Authentication credentials = authenticationMethodFactory.getAuthenticationFor(cloudIdentity);
+                               OpenStackRequest<Access> request = keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId);
+                               access = executeAndRecordOpenstackRequest(request);
+                               
+                               
+                               try {
+                                       neutronUrl = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", region, "public");
+                                       if (! neutronUrl.endsWith("/")) {
+                               neutronUrl += "/v2.0/";
+                           }
+                               } catch (RuntimeException e) {
+                                       // This comes back for not found (probably an incorrect region ID)
+                                       String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId();
+                                       alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
+                                       throw new MsoAdapterException (error, e);
+                               }
+                               tokenId = access.getToken().getId();
+                               expiration = access.getToken().getExpires();
+               } else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
+                       try {
+                               KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "network");
+                               tokenId = holder.getId();
+                               expiration = holder.getexpiration();
+                               neutronUrl = holder.getServiceUrl();
+                               if (! neutronUrl.endsWith("/")) {
+                               neutronUrl += "/v2.0/";
+                           }
+                       } catch (ServiceEndpointNotFoundException e) {
+                               // This comes back for not found (probably an incorrect region ID)
+                                       String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId();
+                                       alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
+                                       throw new MsoAdapterException (error, e);
+                       }
+               }
                }
                catch (OpenStackResponseException e) {
                        if (e.getStatus() == 401) {
@@ -408,25 +453,10 @@ public class MsoNeutronUtils extends MsoCommonUtils
                        MsoException me = runtimeExceptionToMsoException(e, "TokenAuth");
                        throw me;
                }
-
-               String region = cloudSite.getRegionId();
-               String neutronUrl = null;
-               try {
-                       neutronUrl = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", region, "public");
-                       if (! neutronUrl.endsWith("/")) {
-                neutronUrl += "/v2.0/";
-            }
-               } catch (RuntimeException e) {
-                       // This comes back for not found (probably an incorrect region ID)
-                       String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId();
-                       alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
-                       throw new MsoAdapterException (error, e);
-               }
-
                Quantum neutronClient = new Quantum(neutronUrl);
-               neutronClient.token(access.getToken().getId());
+               neutronClient.token(tokenId);
 
-               neutronClientCache.put(cacheKey, new NeutronCacheEntry(neutronUrl, access.getToken().getId(), access.getToken().getExpires()));
+               neutronClientCache.put(cacheKey, new NeutronCacheEntry(neutronUrl, tokenId, expiration));
                LOGGER.debug ("Caching Neutron Client for " + cacheKey);
 
                return neutronClient;
index 79934cc..08c98f3 100644 (file)
@@ -36,6 +36,8 @@ public class MsoTenantUtilsFactory {
        protected CloudConfig cloudConfig;
        @Autowired
        protected MsoKeystoneUtils keystoneUtils;
+       @Autowired
+       protected MsoKeystoneV3Utils keystoneV3Utils;
        
        // based on Cloud IdentityServerType returns ORM or KEYSTONE Utils
        public MsoTenantUtils getTenantUtils(String cloudSiteId) throws MsoCloudSiteNotFound {
@@ -50,6 +52,8 @@ public class MsoTenantUtilsFactory {
                MsoTenantUtils tenantU = null;
                if (ServerType.KEYSTONE.equals(serverType)) {
                        tenantU = keystoneUtils;
+               } else if (ServerType.KEYSTONE_V3.equals(serverType)) {
+                       tenantU = keystoneV3Utils;
                }
                return tenantU;
        }
index 95e4352..a5abe75 100644 (file)
 
 package org.onap.so.cloud.authentication;
 
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.so.BaseTest;
+import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
 import org.onap.so.db.catalog.beans.AuthenticationType;
 import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.cloud.authentication.models.RackspaceAuthentication;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.onap.so.utils.CryptoUtils;
 
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.woorea.openstack.keystone.model.Authentication;
 import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
 
@@ -42,10 +46,9 @@ import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
  * only are tested.
  *
  */
-public class AuthenticationMethodTest extends BaseTest {
+public class AuthenticationMethodTest {
 
-       @Autowired
-       private AuthenticationMethodFactory authenticationMethodFactory;
+       private AuthenticationMethodFactory authenticationMethodFactory = new AuthenticationMethodFactory();
        /**
         * 
         */
@@ -99,4 +102,20 @@ public class AuthenticationMethodTest extends BaseTest {
                assertTrue(UsernamePassword.class.equals(auth.getClass()));
        
        }
+       
+       @Test
+       public void getAuthenticationForV3Test() throws JsonParseException, JsonMappingException, IOException {
+               
+               CloudIdentity identity = new CloudIdentity();
+               identity.setMsoId("my-username");
+               identity.setMsoPass(CryptoUtils.encryptCloudConfigPassword("my-password"));
+               identity.setProjectDomainName("test-domain");
+               identity.setUserDomainName("user-domain");
+               ObjectMapper mapper = new ObjectMapper();
+               com.woorea.openstack.keystone.v3.model.Authentication expected = 
+                               mapper.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/__files/KeystoneV3Payload.json"))), com.woorea.openstack.keystone.v3.model.Authentication.class);
+               com.woorea.openstack.keystone.v3.model.Authentication actual = authenticationMethodFactory.getAuthenticationForV3(identity, "project-x");
+               
+               assertThat(actual, sameBeanAs(expected));
+       }
 }
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/KeystoneV3Payload.json b/adapters/mso-adapter-utils/src/test/resources/__files/KeystoneV3Payload.json
new file mode 100644 (file)
index 0000000..dc6588e
--- /dev/null
@@ -0,0 +1,24 @@
+{
+       "identity": {
+               "methods": [
+                       "password"
+               ],
+               "password": {
+                       "user": {
+                               "domain": {
+                                       "name": "user-domain"
+                               },
+                               "name": "my-username",
+                               "password": "my-password"
+                       }
+               }
+       },
+       "scope": {
+               "project": {
+                       "domain": {
+                               "name": "test-domain"
+                       },
+                       "id": "project-x"
+               }
+       }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.12.2__AddDomainColumnsCloudIdentity.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.12.2__AddDomainColumnsCloudIdentity.sql
new file mode 100644 (file)
index 0000000..e2c4dc8
--- /dev/null
@@ -0,0 +1,3 @@
+ALTER TABLE identity_services
+ADD PROJECT_DOMAIN_NAME VARCHAR(255) DEFAULT NULL,
+ADD USER_DOMAIN_NAME VARCHAR(255) DEFAULT NULL;
index b4916bd..4d5105d 100644 (file)
@@ -4,6 +4,8 @@ CREATE TABLE IF NOT EXISTS `identity_services` (
   `IDENTITY_URL` varchar(200) DEFAULT NULL,
   `MSO_ID` varchar(255) DEFAULT NULL,
   `MSO_PASS` varchar(255) DEFAULT NULL,
+  `PROJECT_DOMAIN_NAME` varchar(255) DEFAULT NULL,
+  `USER_DOMAIN_NAME` varchar(255) DEFAULT NULL,
   `ADMIN_TENANT` varchar(50) DEFAULT NULL,
   `MEMBER_ROLE` varchar(50) DEFAULT NULL,
   `TENANT_METADATA` tinyint(1) DEFAULT 0,
@@ -193,7 +195,7 @@ insert into vnf_components(vnf_id, component_type, heat_template_id, heat_enviro
 
 INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08');
 
-INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
+INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `PROJECT_DOMAIN_NAME`, `USER_DOMAIN_NAME`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, NULL, 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
 
 INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
 
index 0103564..77df06b 100644 (file)
@@ -152,7 +152,7 @@ INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION
 
 INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08');
 
-INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm939454', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
+INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `PROJECT_DOMAIN_NAME`, `USER_DOMAIN_NAME`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm939454', '93937EA01B94A10A49279D4572B48369', null, null, 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
 
 INSERT INTO `cloud_sites` (`ID`, `region_id`, `identity_service_id`, `cloud_version`, `clli`, `cloudify_id`, `platform`, `orchestrator`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'mtn13', 'MTN13', '3.0', 'MDT13', 'mtn13', null, 'orchestrator', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
 
index a051417..0c67123 100644 (file)
@@ -788,6 +788,8 @@ CREATE TABLE IF NOT EXISTS `identity_services` (
   `IDENTITY_URL` varchar(200) DEFAULT NULL,
   `MSO_ID` varchar(255) DEFAULT NULL,
   `MSO_PASS` varchar(255) DEFAULT NULL,
+  `PROJECT_DOMAIN_NAME` varchar(255) DEFAULT NULL,
+  `USER_DOMAIN_NAME` varchar(255) DEFAULT NULL,
   `ADMIN_TENANT` varchar(50) DEFAULT NULL,
   `MEMBER_ROLE` varchar(50) DEFAULT NULL,
   `TENANT_METADATA` tinyint(1) DEFAULT 0,
index dc6abce..c8ea165 100644 (file)
@@ -201,7 +201,10 @@ public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
                        String error = "Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: "
                                        + operationId;
                        logger.error(error);
-                       throw new MsoRequestsDbException(error,MsoLogger.ErrorCode.BusinessProcesssError);
+//                     throw new MsoRequestsDbException(error,MsoLogger.ErrorCode.BusinessProcesssError);
+                       operStatus = new OperationStatus();
+                       operStatus.setOperationId(operationId);
+                       operStatus.setServiceId(serviceId);
                }
 
                operStatus.setUserId(userId);
index 7c2dd12..103e216 100644 (file)
@@ -365,35 +365,10 @@ public class MSORequestDBImplTest {
                updatedOperationStatus.setReason(reason);
                updatedOperationStatus.setOperationContent(operationContent);
 
-               try {
-            dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation,  userId,
-                     result, operationContent,  progress, reason);
-            fail("Expected MsoRequestsDbException to be thrown");   
-        } catch (Exception e) {
-            assertEquals("Entity not found. Unable to retrieve OperationStatus Object ServiceId: " + serviceId + " operationId: " + operationId,e.getMessage());
-            for(ILoggingEvent logEvent : TestAppender.events)
-                if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor") &&
-                        logEvent.getMarker().getName().equals("ENTRY")
-                        ){
-                    Map<String,String> mdc = logEvent.getMDCPropertyMap();
-                    assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID));
-                    assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
-                    assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
-                    assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
-                    assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
-                    assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
-                }else if(logEvent.getLoggerName().equals("org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor") &&
-                        logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){
-                    Map<String,String> mdc = logEvent.getMDCPropertyMap();
-                    assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
-                    assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID));
-                    assertEquals("500",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE));
-                    assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME));
-                    assertEquals("/services/RequestsDbAdapter",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME));
-                    assertEquals("ERROR",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE));
-                }
-        }              
-               
+               dbAdapter.updateServiceOperationStatus(serviceId, operationId, operation,  userId,
+                    result, operationContent,  progress, reason);              
+               OperationStatus dbOpStatus = operationStatusRepository.findOneByServiceIdAndOperationId(serviceId,operationId);         
+               assertThat(dbOpStatus, sameBeanAs(updatedOperationStatus).ignoring("operateAt").ignoring("finishedAt"));                
        }
        
        @Test 
index d5183ff..f1eab66 100644 (file)
@@ -982,22 +982,7 @@ class CatalogDbUtils {
                                                vfModuleModelJson.put("modelInfo", vfModuleModelInfo)
                                                String vfModuleType = jsonUtils.getJsonValueForKey(vfModule, "type")
                                                vfModuleModelJson.put("vfModuleType", vfModuleType)
-                                               switch(catalogUtilsVersion) {
-                                                       case "v1":
-                                                       //TODO this does not work, isBase is not a integer.
-                                                               Integer isBase = jsonUtils.getJsonIntValueForKey(vfModule, "isBase")
-                                                               if (isBase.intValue() == 1) {
-                                                                       vfModuleModelJson.put("isBase", "true")
-                                                               }
-                                                               else {
-                                                                       vfModuleModelJson.put("isBase", "false")
-                                                               }
-                                                               break
-                                                       default:
-                                                               boolean isBase = jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase")
-                                                               vfModuleModelJson.put("isBase", isBase)
-                                                               break
-                                               }
+                                               vfModuleModelJson.put("isBase", jsonUtils.getJsonBooleanValueForKey(vfModule, "isBase"))
                                                String vfModuleLabel = jsonUtils.getJsonValueForKey(vfModule, "label")
                                                vfModuleModelJson.put("vfModuleLabel", vfModuleLabel)
                                                Integer initialCount = jsonUtils.getJsonIntValueForKey(vfModule, "initialCount")
index cf284e8..0a06748 100644 (file)
@@ -4,9 +4,9 @@
     <bpmn:startEvent id="Start_AssignVnfBB">
       <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing>
     </bpmn:startEvent>
-    <bpmn:serviceTask id="Task_SDNCAdapterVnfTopologyAssign" name="&#10;SDNC &#10;Assign&#10;(vnf)&#10;" camunda:expression="${SDNCAssignTasks.assignVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
-      <bpmn:incoming>SequenceFlow_14mpqit</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_1ks8kmt</bpmn:outgoing>
+    <bpmn:serviceTask id="Task_SDNCAdapterVnfTopologyAssign" name="&#10;SDNC &#10;Create Request&#10;(vnf)&#10;" camunda:expression="${SDNCAssignTasks.assignVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+      <bpmn:incoming>SequenceFlow_1samncw</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1qkhm79</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:endEvent id="End_AssignVnfBB">
       <bpmn:incoming>SequenceFlow_0csh9dc</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_1jwsja5</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_AssignVnfBB" targetRef="Task_CreateVnf" />
-    <bpmn:sequenceFlow id="SequenceFlow_1ks8kmt" sourceRef="Task_SDNCAdapterVnfTopologyAssign" targetRef="Task_UpdateVnfOrchestrationStatusAssigned" />
     <bpmn:sequenceFlow id="SequenceFlow_0csh9dc" sourceRef="Task_UpdateVnfOrchestrationStatusAssigned" targetRef="End_AssignVnfBB" />
     <bpmn:serviceTask id="Task_UpdateVnfOrchestrationStatusAssigned" name="&#10;AAI&#10;Update&#10;(vnf)&#10;" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusAssignedVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
-      <bpmn:incoming>SequenceFlow_1ks8kmt</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1vw20wu</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0csh9dc</bpmn:outgoing>
     </bpmn:serviceTask>
     <bpmn:serviceTask id="Task_createInstanceGroups" name="&#10;AAI&#10;Create&#10;(instance grp)&#10;" camunda:expression="${AssignVnf.createInstanceGroups(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
     </bpmn:serviceTask>
     <bpmn:sequenceFlow id="SequenceFlow_1jwsja5" sourceRef="Task_CreateVnf" targetRef="Task_createPlatform" />
     <bpmn:sequenceFlow id="SequenceFlow_1nle8kc" sourceRef="Task_createInstanceGroups" targetRef="ExclusiveGateway_02tchpp" />
-    <bpmn:sequenceFlow id="SequenceFlow_11jum90" name="no" sourceRef="ExclusiveGateway_02tchpp" targetRef="ExclusiveGateway_1blf52g">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("callHoming") == false}]]></bpmn:conditionExpression>
-    </bpmn:sequenceFlow>
+    <bpmn:sequenceFlow id="SequenceFlow_11jum90" name="no" sourceRef="ExclusiveGateway_02tchpp" targetRef="ExclusiveGateway_1blf52g" />
     <bpmn:sequenceFlow id="SequenceFlow_1uiok7v" name="yes" sourceRef="ExclusiveGateway_02tchpp" targetRef="Task_callHoming">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("callHoming") == true}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("callHoming")}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="SequenceFlow_0v8d14a" sourceRef="Task_callHoming" targetRef="ExclusiveGateway_1blf52g" />
     <bpmn:callActivity id="Task_callHoming" name="Call Homing" calledElement="HomingBB">
@@ -40,6 +37,7 @@
         <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" />
         <camunda:in source="mso-request-id" target="mso-request-id" />
         <camunda:out source="generalBuildingBlock" target="gBBInput" />
+        <camunda:out source="WorkflowException" target="WorkflowException" />
       </bpmn:extensionElements>
       <bpmn:incoming>SequenceFlow_1uiok7v</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0v8d14a</bpmn:outgoing>
@@ -65,8 +63,7 @@
       </bpmn:endEvent>
       <bpmn:sequenceFlow id="SequenceFlow_1i52a7x" sourceRef="StartEvent_1c3cyuv" targetRef="EndEvent_1bywujf" />
     </bpmn:subProcess>
-    <bpmn:sequenceFlow id="SequenceFlow_14mpqit" sourceRef="ExclusiveGateway_1blf52g" targetRef="Task_SDNCAdapterVnfTopologyAssign" />
-    <bpmn:inclusiveGateway id="ExclusiveGateway_02tchpp" name="Call Homing?">
+    <bpmn:inclusiveGateway id="ExclusiveGateway_02tchpp" name="Call Homing?" default="SequenceFlow_11jum90">
       <bpmn:incoming>SequenceFlow_1nle8kc</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_11jum90</bpmn:outgoing>
       <bpmn:outgoing>SequenceFlow_1uiok7v</bpmn:outgoing>
     <bpmn:inclusiveGateway id="ExclusiveGateway_1blf52g">
       <bpmn:incoming>SequenceFlow_11jum90</bpmn:incoming>
       <bpmn:incoming>SequenceFlow_0v8d14a</bpmn:incoming>
-      <bpmn:outgoing>SequenceFlow_14mpqit</bpmn:outgoing>
+      <bpmn:outgoing>SequenceFlow_1samncw</bpmn:outgoing>
     </bpmn:inclusiveGateway>
+    <bpmn:callActivity id="CallActivity_sdncAssign" name="SDNC Assign (vnf)" calledElement="SDNCHandler">
+      <bpmn:extensionElements>
+        <camunda:in source="SDNCRequest" target="SDNCRequest" />
+        <camunda:out source="SDNCResponse" target="SDNCResponse" />
+      </bpmn:extensionElements>
+      <bpmn:incoming>SequenceFlow_1qkhm79</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1vw20wu</bpmn:outgoing>
+    </bpmn:callActivity>
+    <bpmn:sequenceFlow id="SequenceFlow_1samncw" sourceRef="ExclusiveGateway_1blf52g" targetRef="Task_SDNCAdapterVnfTopologyAssign" />
+    <bpmn:sequenceFlow id="SequenceFlow_1qkhm79" sourceRef="Task_SDNCAdapterVnfTopologyAssign" targetRef="CallActivity_sdncAssign" />
+    <bpmn:sequenceFlow id="SequenceFlow_1vw20wu" sourceRef="CallActivity_sdncAssign" targetRef="Task_UpdateVnfOrchestrationStatusAssigned" />
   </bpmn:process>
   <bpmn:error id="Error_0rgauy1" name="gDelegateError" errorCode="7000" />
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
@@ -90,9 +98,9 @@
         <dc:Bounds x="930" y="94" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_1h93h9d_di" bpmnElement="End_AssignVnfBB">
-        <dc:Bounds x="1229" y="116" width="36" height="36" />
+        <dc:Bounds x="1323" y="116" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="1238" y="156" width="18" height="12" />
+          <dc:Bounds x="1296" y="156" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_1r380lg_di" bpmnElement="Task_CreateVnf">
           <dc:Bounds x="83" y="113" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_1ks8kmt_di" bpmnElement="SequenceFlow_1ks8kmt">
-        <di:waypoint xsi:type="dc:Point" x="1030" y="134" />
-        <di:waypoint xsi:type="dc:Point" x="1056" y="134" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="998" y="113" width="90" height="12" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0csh9dc_di" bpmnElement="SequenceFlow_0csh9dc">
-        <di:waypoint xsi:type="dc:Point" x="1156" y="134" />
-        <di:waypoint xsi:type="dc:Point" x="1229" y="134" />
+        <di:waypoint xsi:type="dc:Point" x="1303" y="134" />
+        <di:waypoint xsi:type="dc:Point" x="1323" y="134" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="1147.5" y="113" width="90" height="12" />
+          <dc:Bounds x="1268" y="113" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="ServiceTask_0s6d1be_di" bpmnElement="Task_UpdateVnfOrchestrationStatusAssigned">
-        <dc:Bounds x="1056" y="94" width="100" height="80" />
+        <dc:Bounds x="1203" y="94" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ServiceTask_0wjy7za_di" bpmnElement="Task_createInstanceGroups">
         <dc:Bounds x="534" y="94" width="100" height="80" />
         <dc:Bounds x="404" y="94" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="SubProcess_19596dp_di" bpmnElement="SubProcess_19596dp" isExpanded="true">
-        <dc:Bounds x="249" y="267" width="231" height="135" />
+        <dc:Bounds x="673" y="239" width="231" height="135" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="StartEvent_1c3cyuv_di" bpmnElement="StartEvent_1c3cyuv">
-        <dc:Bounds x="286" y="323" width="36" height="36" />
+        <dc:Bounds x="710" y="295" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="259" y="359" width="0" height="12" />
+          <dc:Bounds x="638" y="331" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="EndEvent_1bywujf_di" bpmnElement="EndEvent_1bywujf">
-        <dc:Bounds x="422" y="323" width="36" height="36" />
+        <dc:Bounds x="846" y="295" width="36" height="36" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="395" y="359" width="0" height="12" />
+          <dc:Bounds x="774" y="331" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_1i52a7x_di" bpmnElement="SequenceFlow_1i52a7x">
-        <di:waypoint xsi:type="dc:Point" x="322" y="341" />
-        <di:waypoint xsi:type="dc:Point" x="422" y="341" />
+        <di:waypoint xsi:type="dc:Point" x="746" y="313" />
+        <di:waypoint xsi:type="dc:Point" x="846" y="313" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="372" y="320" width="0" height="12" />
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge id="SequenceFlow_14mpqit_di" bpmnElement="SequenceFlow_14mpqit">
-        <di:waypoint xsi:type="dc:Point" x="899" y="134" />
-        <di:waypoint xsi:type="dc:Point" x="930" y="134" />
-        <bpmndi:BPMNLabel>
-          <dc:Bounds x="914.5" y="113" width="0" height="12" />
+          <dc:Bounds x="751" y="292" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="InclusiveGateway_0x0c3kk_di" bpmnElement="ExclusiveGateway_02tchpp">
         <dc:Bounds x="679" y="109" width="50" height="50" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="731" y="128" width="67" height="13" />
+          <dc:Bounds x="732" y="128" width="64" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="InclusiveGateway_0ijggth_di" bpmnElement="ExclusiveGateway_1blf52g">
           <dc:Bounds x="896" y="163" width="0" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape id="CallActivity_12uxg1m_di" bpmnElement="CallActivity_sdncAssign">
+        <dc:Bounds x="1060" y="94" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1samncw_di" bpmnElement="SequenceFlow_1samncw">
+        <di:waypoint xsi:type="dc:Point" x="899" y="134" />
+        <di:waypoint xsi:type="dc:Point" x="930" y="134" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="914.5" y="113" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1qkhm79_di" bpmnElement="SequenceFlow_1qkhm79">
+        <di:waypoint xsi:type="dc:Point" x="1030" y="134" />
+        <di:waypoint xsi:type="dc:Point" x="1060" y="134" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1045" y="113" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge id="SequenceFlow_1vw20wu_di" bpmnElement="SequenceFlow_1vw20wu">
+        <di:waypoint xsi:type="dc:Point" x="1160" y="134" />
+        <di:waypoint xsi:type="dc:Point" x="1203" y="134" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="1181.5" y="113" width="0" height="12" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>
index 3fb8faa..f675440 100644 (file)
@@ -35,11 +35,11 @@ public class AssignVnfBBTest extends BaseBPMNTest {
        @Test
        public void sunnyDayAssignVnfBBTest() throws InterruptedException, IOException {
                variables.put("callHoming", true);
-               mockSubprocess("ReceiveWorkflowMessage", "Mocked ReceiveWorkflowMessage", "GenericStub");
+               mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
                ProcessInstance pi = runtimeService.startProcessInstanceByKey("AssignVnfBB", variables);
                assertThat(pi).isNotNull();
                assertThat(pi).isStarted().hasPassedInOrder("Start_AssignVnfBB", "Task_CreateVnf", "Task_createPlatform", "Task_createLineOfBusiness", "Task_createInstanceGroups",
-                               "Task_callHoming", "Task_SDNCAdapterVnfTopologyAssign", "Task_UpdateVnfOrchestrationStatusAssigned",
+                               "Task_callHoming", "Task_SDNCAdapterVnfTopologyAssign","CallActivity_sdncAssign", "Task_UpdateVnfOrchestrationStatusAssigned",
                                "End_AssignVnfBB");
                assertThat(pi).isEnded();
        }
index 727cb5c..66479be 100644 (file)
@@ -145,7 +145,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
             String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
             String source = execution.getVariable("source")
             String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId")
-            ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+            ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
             String serviceType = resourceInputObj.getServiceType()
             String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid()
             String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid()
@@ -339,7 +339,7 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
     }
 
     public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
-        ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+        ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
         String operType = resourceInputObj.getOperationType()
         String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
         String serviceInstanceId = resourceInputObj.getServiceInstanceId()
index b66ba89..cf78193 100644 (file)
@@ -171,7 +171,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
             String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
             String source = execution.getVariable("source")
             String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId")
-            ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+            ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
             String serviceType = resourceInputObj.getServiceType()
             String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid()
             String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid()
@@ -371,7 +371,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
     }
 
     public void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) {
-        ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+        ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
         String operType = resourceInputObj.getOperationType()
         String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
         String serviceInstanceId = resourceInputObj.getServiceInstanceId()
@@ -404,7 +404,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
     }
 
     public void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) {
-        ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+        ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
         String operType = resourceInputObj.getOperationType()
         String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
         String serviceInstanceId = resourceInputObj.getServiceInstanceId()
index 7d0927e..6b89387 100644 (file)
@@ -247,6 +247,9 @@ public class SniroHomingV2 {
                        if(modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0){ //temp solution
                                info.put("serviceName", modelInfo.getServiceType());
                        }
+                       if(modelInfo.getServiceRole() != null){
+                               info.put("serviceRole", modelInfo.getServiceRole());
+                       }
                        info.put("modelInfo", buildModelInfo(serviceInstance.getModelInfoServiceInstance()));
                }else{
                        throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + MODEL_VERSION_ID + ", " + MODEL_INVARIANT_ID);
index ec79b28..30f38fc 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.so.bpmn.infrastructure.sdnc.tasks;
 
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
@@ -38,6 +39,8 @@ import org.onap.so.client.orchestration.SDNCNetworkResources;
 import org.onap.so.client.orchestration.SDNCServiceInstanceResources;
 import org.onap.so.client.orchestration.SDNCVfModuleResources;
 import org.onap.so.client.orchestration.SDNCVnfResources;
+import org.onap.so.client.sdnc.beans.SDNCRequest;
+import org.onap.so.client.sdnc.endpoint.SDNCTopology;
 import org.onap.so.logger.MsoLogger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -79,8 +82,11 @@ public class SDNCAssignTasks {
                        GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
                        Customer customer = gBBInput.getCustomer();
                        CloudRegion cloudRegion = gBBInput.getCloudRegion();
-                       String response = sdncVnfResources.assignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, Boolean.TRUE.equals(vnf.isCallHoming()));
-                       execution.setVariable("SDNCResponse", response);
+                       GenericResourceApiVnfOperationInformation req = sdncVnfResources.assignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, Boolean.TRUE.equals(vnf.isCallHoming()));
+                       SDNCRequest sdncRequest = new SDNCRequest();
+                       sdncRequest.setSDNCPayload(req);
+                       sdncRequest.setTopology(SDNCTopology.VNF);
+                       execution.setVariable("SDNCRequest", sdncRequest);
                } catch (Exception ex) {
                        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
                }
index f8a9390..b30fc93 100644 (file)
@@ -48,12 +48,11 @@ public class SDNCVnfResources {
        @Autowired
        private SDNCClient sdncClient;
        
-       public String assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
+       public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
                        CloudRegion cloudRegion, RequestContext requestContext, boolean homing)
                        throws MapperException, BadResponseException {
-               GenericResourceApiVnfOperationInformation sdncReq = sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
+               return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION,
                                SDNCSvcAction.ASSIGN,GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, cloudRegion, requestContext, homing);
-               return sdncClient.post(sdncReq, SDNCTopology.VNF);
        }
 
        public String activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, Customer customer,
index c96c38d..f8b1298 100644 (file)
@@ -306,6 +306,7 @@ public class TestDataSetup{
                modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
                modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
                modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
+               modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
                serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
 
                serviceInstance.setProject(buildProject());
@@ -381,6 +382,24 @@ public class TestDataSetup{
 
                collection.setInstanceGroup(instanceGroup);
 
+
+               return instanceGroup;
+       }
+
+       public InstanceGroup setInstanceGroupVnf() {
+               InstanceGroup instanceGroup = buildInstanceGroup();
+
+               ServiceInstance serviceInstance = null;
+
+               try {
+                       serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
+               } catch(BBObjectNotFoundException e) {
+                       serviceInstance = setServiceInstance();
+               }
+
+               serviceInstance.getInstanceGroups().add(instanceGroup);
+               lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
+
                return instanceGroup;
        }
 
@@ -700,4 +719,4 @@ public class TestDataSetup{
         subnet.setNeutronSubnetId("testNeutronSubnetId");
                return subnet;
        }
-}
\ No newline at end of file
+}
index dcfc20c..24ae88b 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.onap.so.bpmn.infrastructure.sdnc.tasks;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
@@ -34,6 +35,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentMatchers;
 import org.mockito.InjectMocks;
+import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation;
 import org.onap.so.bpmn.BaseTaskTest;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
@@ -46,6 +48,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
 import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.sdnc.beans.SDNCRequest;
+import org.onap.so.client.sdnc.endpoint.SDNCTopology;
 
 
 public class SDNCAssignTasksTest extends BaseTaskTest{
@@ -102,13 +106,14 @@ public class SDNCAssignTasksTest extends BaseTaskTest{
 
        @Test
        public void assignVnfTest() throws Exception {
-               doReturn("response").when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
+               doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
 
                execution.setVariable("generalBuildingBlock", gBBInput);
                sdncAssignTasks.assignVnf(execution);
 
                verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance,customer, cloudRegion, requestContext, false);
-               assertTrue(execution.getVariable("SDNCResponse").equals("response"));
+               SDNCRequest sdncRequest = execution.getVariable("SDNCRequest");
+               assertEquals(SDNCTopology.VNF,sdncRequest.getTopology());
        }
 
        @Test
index bb8fca4..3329842 100644 (file)
@@ -88,11 +88,10 @@ public class SDNCVnfResourcesTest  extends TestDataSetup{
        @Test
        public void assignVnfTest() throws MapperException, BadResponseException {
                doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
-               doReturn("test").when(MOCK_sdncClient).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
                
                sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false);
                
-               verify(MOCK_sdncClient, times(1)).post(isA(GenericResourceApiVnfOperationInformation.class), eq(SDNCTopology.VNF));
+               verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class),isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), anyBoolean());
        }
        
        @Test
index 55aa2ef..dc2d992 100644 (file)
@@ -1,6 +1,6 @@
 {
   "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800},
-  "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
+  "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceRole":"testServiceRole1","serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
   "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}},
   "licenseInfo" : {"licenseDemands":[]}
 }
\ No newline at end of file
index 6977224..61f9496 100644 (file)
@@ -1,6 +1,6 @@
 {
   "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800},
-  "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
+  "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceRole":"testServiceRole1","serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
   "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testAllottedModelName1","modelVersionId":"testAllottedModelUuid1","modelVersion":"testAllottedModelVersion1","modelInvariantId":"testAllottedModelInvariantUuid1"},"resourceModuleName":"testAllottedModelInstanceName1","serviceResourceId":"testAllottedResourceId1"},{"resourceModelInfo":{"modelName":"testAllottedModelName2","modelVersionId":"testAllottedModelUuid2","modelVersion":"testAllottedModelVersion2","modelInvariantId":"testAllottedModelInvariantUuid2"},"resourceModuleName":"testAllottedModelInstanceName2","serviceResourceId":"testAllottedResourceId2"},{"resourceModelInfo":{"modelName":"testAllottedModelName3","modelVersionId":"testAllottedModelUuid3","modelVersion":"testAllottedModelVersion3","modelInvariantId":"testAllottedModelInvariantUuid3"},"resourceModuleName":"testAllottedModelInstanceName3","serviceResourceId":"testAllottedResourceId3"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}},
   "licenseInfo" : {"licenseDemands":[]}
 }
\ No newline at end of file
index c72831b..a7da6da 100644 (file)
@@ -1,6 +1,6 @@
 {
   "requestInfo" : {"sourceId":"mso","requestType":"create","requestId":"testRequestId","callbackUrl":"http://localhost:28080/mso/WorkflowMesssage/SNIROResponse/testRequestId","transactionId":"testRequestId","timeout":1800},
-  "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
+  "serviceInfo" : {"modelInfo":{"modelName":"testModelName1","modelVersionId":"testModelUUID1","modelVersion":"testModelVersion1","modelInvariantId":"testModelInvariantUUID1"},"serviceRole":"testServiceRole1","serviceInstanceId":"testServiceInstanceId1","serviceName":"testServiceType1"},
   "placementInfo" : {"subscriberInfo":{"subscriberName":"testCustomerName","globalSubscriberId":"testCustomerId"},"placementDemands":[{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"},{"resourceModelInfo":{"modelName":"testProxyModelName1","modelVersionId":"testProxyModelUuid1","modelVersion":"testProxyModelVersion1","modelInvariantId":"testProxyModelInvariantUuid1"},"resourceModuleName":"testProxyInstanceName1","serviceResourceId":"testProxyId1"},{"resourceModelInfo":{"modelName":"testProxyModelName2","modelVersionId":"testProxyModelUuid2","modelVersion":"testProxyModelVersion2","modelInvariantId":"testProxyModelInvariantUuid2"},"requiredCandidates":[{"candidateType":{"name":"vnfId"},"candidates":["testVnfId"]}],"resourceModuleName":"testProxyInstanceName2","serviceResourceId":"testProxyId2"}],"requestParameters":{"aLaCarte":false,"subscriptionServiceType":"iptollfree"}},
   "licenseInfo" : {"licenseDemands":[]}
 }
\ No newline at end of file
index b1c81cf..820b47a 100644 (file)
@@ -70,6 +70,16 @@ public class CloudIdentity {
     @Column(name = "MSO_PASS")
     private String msoPass;
     
+    @JsonProperty("project_domain_name")
+    @BusinessKey
+    @Column(name = "PROJECT_DOMAIN_NAME")
+    private String projectDomainName;
+    
+    @JsonProperty("user_domain_name")
+    @BusinessKey
+    @Column(name = "USER_DOMAIN_NAME")
+    private String userDomainName;
+    
     @JsonProperty("admin_tenant")
     @BusinessKey
     @Column(name = "ADMIN_TENANT")
@@ -224,6 +234,21 @@ public class CloudIdentity {
                this.identityAuthenticationType = identityAuthenticationType;
        }
 
+       public String getProjectDomainName() {
+               return projectDomainName;
+       }
+       
+       public void setProjectDomainName(String projectDomainName) {
+               this.projectDomainName = projectDomainName;
+       }
+       
+       public String getUserDomainName() {
+               return userDomainName;
+       }
+       
+       public void setUserDomainName(String userDomainName) {
+               this.userDomainName = userDomainName;
+       }
        @Override
        public CloudIdentity clone() {
                CloudIdentity cloudIdentityCopy = new CloudIdentity();
@@ -237,6 +262,8 @@ public class CloudIdentity {
                cloudIdentityCopy.tenantMetadata = this.tenantMetadata;
                cloudIdentityCopy.identityServerType = this.identityServerType;
                cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType;
+               cloudIdentityCopy.projectDomainName = this.projectDomainName;
+               cloudIdentityCopy.userDomainName = this.userDomainName;
 
                return cloudIdentityCopy;
        }
@@ -245,6 +272,7 @@ public class CloudIdentity {
        public String toString() {
                return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId())
                                .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId())
+                               .append("projectDomain", getProjectDomainName()).append("userDomain", getUserDomainName())
                                .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole())
                                .append("tenantMetadata", getTenantMetadata()).append("identityServerType", getIdentityServerType())
                                .append("identityAuthenticationType", getIdentityAuthenticationType()).toString();
@@ -262,6 +290,7 @@ public class CloudIdentity {
                return new EqualsBuilder().append(getId(), castOther.getId())
                                .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId())
                                .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant())
+                               .append(getProjectDomainName(), castOther.getProjectDomainName()).append(getUserDomainName(), castOther.getUserDomainName())
                                .append(getMemberRole(), castOther.getMemberRole())
                                .append(getTenantMetadata(), castOther.getTenantMetadata())
                                .append(getIdentityServerType(), castOther.getIdentityServerType())
@@ -271,7 +300,7 @@ public class CloudIdentity {
        @Override
        public int hashCode() {
                return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId())
-                               .append(getMsoPass()).append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
+                               .append(getMsoPass()).append(getProjectDomainName()).append(getUserDomainName()).append(getAdminTenant()).append(getMemberRole()).append(getTenantMetadata())
                                .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode();
        }
 }
\ No newline at end of file
index eeb5724..14834ea 100644 (file)
@@ -657,7 +657,7 @@ VALUES
 
 INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, 'MSO_USER', '2018-07-17 14:05:08', '2018-07-17 14:05:08');
 
-INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
+INSERT INTO `identity_services` (`ID`, `IDENTITY_URL`, `MSO_ID`, `MSO_PASS`, `PROJECT_DOMAIN_NAME`, `USER_DOMAIN_NAME`, `ADMIN_TENANT`, `MEMBER_ROLE`, `TENANT_METADATA`, `IDENTITY_SERVER_TYPE`, `IDENTITY_AUTHENTICATION_TYPE`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('MTN13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, NULL, 'admin', 'admin', 1, 'KEYSTONE', 'USERNAME_PASSWORD', 'MSO_USER', '2018-07-17 14:02:33', '2018-07-17 14:02:33');
 
 INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'mtn13', 'MTN13', '2.5', 'MDT13', 'mtn13', NULL, 'orchestrator', 'MSO_USER', '2018-07-17 14:06:28', '2018-07-17 14:06:28');
 
index 6eaad26..b7d0061 100644 (file)
@@ -837,6 +837,8 @@ CREATE TABLE IF NOT EXISTS `identity_services` (
   `IDENTITY_URL` varchar(200) DEFAULT NULL,
   `MSO_ID` varchar(255) DEFAULT NULL,
   `MSO_PASS` varchar(255) DEFAULT NULL,
+  `PROJECT_DOMAIN_NAME` varchar(255) DEFAULT NULL,
+  `USER_DOMAIN_NAME` varchar(255) DEFAULT NULL,
   `ADMIN_TENANT` varchar(50) DEFAULT NULL,
   `MEMBER_ROLE` varchar(50) DEFAULT NULL,
   `TENANT_METADATA` tinyint(1) DEFAULT 0,
index 143b1cf..cb5586d 100644 (file)
@@ -77,7 +77,7 @@ if [ ! -z "${TRUSTSTORE}" ]; then
        jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}"
 fi
 
-jvmargs="${JVM_ARGS} -Djava.security.egd=file:/dev/./urandom -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}"
+jvmargs="${JVM_ARGS} -Djava.security.egd=file:/dev/./urandom -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.additional-location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}"
 
 echo "JVM Arguments: ${jvmargs}"