diff options
45 files changed, 599 insertions, 228 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java index 1912cd874a..49c80b44b5 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/AuthenticationMethodFactory.java @@ -20,14 +20,22 @@ 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 index 0000000000..1a221a80df --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneAuthHolder.java @@ -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 index 0000000000..05364d0c92 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/KeystoneV3Authentication.java @@ -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 index 0000000000..3bc57a886a --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/authentication/ServiceEndpointNotFoundException.java @@ -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); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index e36d0ff30e..d87330bfd4 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -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 index 0000000000..da1957f36e --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneV3Utils.java @@ -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(); + } + +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index a9f0a39235..b7676e0041 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -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; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java index 79934ccd28..08c98f3167 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtilsFactory.java @@ -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; } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java index 95e4352e05..a5abe75af2 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/AuthenticationMethodTest.java @@ -20,19 +20,23 @@ 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 index 0000000000..dc6588ed36 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/__files/KeystoneV3Payload.json @@ -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 index 0000000000..e2c4dc8d2f --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.12.2__AddDomainColumnsCloudIdentity.sql @@ -0,0 +1,3 @@ +ALTER TABLE identity_services +ADD PROJECT_DOMAIN_NAME VARCHAR(255) DEFAULT NULL, +ADD USER_DOMAIN_NAME VARCHAR(255) DEFAULT NULL; diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql index b4916bd46c..4d5105dec6 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -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'); diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql index 0103564b5b..77df06bb92 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/data.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql @@ -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'); diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index a051417cc1..0c67123f56 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -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, diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java index dc6abce759..c8ea1652f7 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java +++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/MsoRequestsDbAdapterImpl.java @@ -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); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java index 7c2dd1241f..103e216229 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/MSORequestDBImplTest.java @@ -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 diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index d5183ff5bb..f1eab6601b 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -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") diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn index cf284e8ed9..0a067483ff 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn @@ -4,9 +4,9 @@ <bpmn:startEvent id="Start_AssignVnfBB"> <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing> </bpmn:startEvent> - <bpmn:serviceTask id="Task_SDNCAdapterVnfTopologyAssign" name=" SDNC Assign (vnf) " camunda:expression="${SDNCAssignTasks.assignVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn:incoming>SequenceFlow_14mpqit</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_1ks8kmt</bpmn:outgoing> + <bpmn:serviceTask id="Task_SDNCAdapterVnfTopologyAssign" name=" SDNC Create Request (vnf) " camunda:expression="${SDNCAssignTasks.assignVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <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> @@ -16,10 +16,9 @@ <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=" AAI Update (vnf) " camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusAssignedVnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <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=" AAI Create (instance grp) " camunda:expression="${AssignVnf.createInstanceGroups(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -28,11 +27,9 @@ </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> @@ -74,8 +71,19 @@ <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"> @@ -105,22 +113,15 @@ <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" /> @@ -188,38 +189,31 @@ <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"> @@ -228,6 +222,30 @@ <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> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java index 3fb8faa6c8..f675440ead 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java @@ -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(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy index 727cb5cf4e..66479be973 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy @@ -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() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy index b66ba89800..cf781933f6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy @@ -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() diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy index f45e97fa6e..3a20992bdb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy @@ -341,12 +341,11 @@ public class ReplaceVnfInfra extends VnfCmBase { msoLogger.trace('Entered ' + method) try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + boolean isInMaint = aaiValidator.isVNFLocked(vnfId) msoLogger.debug("isInMaint result: " + isInMaint) execution.setVariable('isVnfInMaintenance', isInMaint) @@ -385,12 +384,11 @@ public class ReplaceVnfInfra extends VnfCmBase { execution.setVariable("failedActivity", "AAI") try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId) msoLogger.debug("areLocked result: " + areLocked) execution.setVariable('arePserversLocked', areLocked) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy index 0972ee184e..1a8df1664f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy @@ -285,9 +285,8 @@ public class UpdateVfModuleInfraV2 { System.out.println("*****************************CheckingPserverFlag*************************") String vnfId = (String)execution.getVariable('vnfId') - String uuid = (String)execution.getVariable('moduleUuid') AAIValidatorImpl aaiVI = new AAIValidatorImpl() - boolean flag = aaiVI.isPhysicalServerLocked(vnfId, uuid) + boolean flag = aaiVI.isPhysicalServerLocked(vnfId) } //check to see if the VFFlag is locked @@ -295,9 +294,8 @@ public class UpdateVfModuleInfraV2 { System.out.print("*****************************VfFlagCheck*************************") String vnfId = (String)execution.getVariable('vnfId') - String uuid = (String)execution.getVariable('moduleUuid') AAIValidatorImpl aaiVI = new AAIValidatorImpl() - boolean flag = aaiVI.isVNFLocked(vnfId, uuid) + boolean flag = aaiVI.isVNFLocked(vnfId) } //lock the VF Flag diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy index 4978faf46c..8c1df9b2e7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy @@ -321,12 +321,11 @@ public class UpdateVnfInfra extends VnfCmBase { msoLogger.trace('Entered ' + method) try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + boolean isInMaint = aaiValidator.isVNFLocked(vnfId) msoLogger.debug("isInMaint result: " + isInMaint) execution.setVariable('isVnfInMaintenance', isInMaint) @@ -365,12 +364,11 @@ public class UpdateVnfInfra extends VnfCmBase { execution.setVariable("failedActivity", "AAI") try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId) msoLogger.debug("areLocked result: " + areLocked) execution.setVariable('arePserversLocked', areLocked) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy index fd9d9cc8a3..ae89fa52dd 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfCmBase.groovy @@ -167,12 +167,11 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { msoLogger.trace('Entered ' + method) try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + boolean isInMaint = aaiValidator.isVNFLocked(vnfId) msoLogger.debug("isInMaint result: " + isInMaint) execution.setVariable('isVnfInMaintenance', isInMaint) @@ -355,12 +354,11 @@ public abstract class VnfCmBase extends AbstractServiceTaskProcessor { execution.setVariable("failedActivity", "AAI") try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId) msoLogger.debug("areLocked result: " + areLocked) execution.setVariable('arePserversLocked', areLocked) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy index 8ca2871916..7de3359f51 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy @@ -219,12 +219,11 @@ public class VnfConfigUpdate extends VnfCmBase { msoLogger.trace('Entered ' + method) try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + boolean isInMaint = aaiValidator.isVNFLocked(vnfId) msoLogger.debug("isInMaint result: " + isInMaint) execution.setVariable('isVnfInMaintenance', isInMaint) @@ -262,12 +261,11 @@ public class VnfConfigUpdate extends VnfCmBase { execution.setVariable("failedActivity", "AAI") try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId) msoLogger.debug("areLocked result: " + areLocked) execution.setVariable('arePserversLocked', areLocked) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy index 2c1b66ded5..f6788fb745 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy @@ -240,12 +240,11 @@ public class VnfInPlaceUpdate extends VnfCmBase { msoLogger.trace('Entered ' + method) try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) + boolean isInMaint = aaiValidator.isVNFLocked(vnfId) msoLogger.debug("isInMaint result: " + isInMaint) execution.setVariable('isVnfInMaintenance', isInMaint) @@ -284,12 +283,11 @@ public class VnfInPlaceUpdate extends VnfCmBase { execution.setVariable("failedActivity", "AAI") try { - def transactionLoggingUuid = UUID.randomUUID().toString() AAIRestClientImpl client = new AAIRestClientImpl() AAIValidatorImpl aaiValidator = new AAIValidatorImpl() aaiValidator.setClient(client) def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) + boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId) msoLogger.debug("areLocked result: " + areLocked) execution.setVariable('arePserversLocked', areLocked) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index 7d0927e498..6b89387a82 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -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); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index ec79b2825a..30f38fc2ed 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -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); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index f8a9390398..b30fc932c0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -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, diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java index c96c38dab1..f8b1298dd8 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/data/TestDataSetup.java @@ -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 +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java index dcfc20c3ae..24ae88b98c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java @@ -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 diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java index bb8fca4719..3329842924 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java @@ -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 diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json index 55aa2ef58c..dc2d99216f 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest1Vpn.json @@ -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 diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json index 6977224ffa..61f9496f05 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3AR.json @@ -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 diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json index c72831b79f..a7da6da7cc 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/SniroHoming/SniroManagerRequest3Vpn.json @@ -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 diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java index 831e43841a..52f15c45c4 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientI.java @@ -33,7 +33,7 @@ public interface AAIRestClientI { void updateMaintenceFlagVnfId(String vnfId, boolean inMaint, String transactionLoggingUuid) throws Exception; - GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) throws Exception; + GenericVnf getVnfByName(String vnfId); Optional<Pnf> getPnfByName(String pnfId, String transactionLoggingUuid) throws Exception; diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java index bcc7d8ba16..813421ff80 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClientImpl.java @@ -75,7 +75,7 @@ public class AAIRestClientImpl implements AAIRestClientI { } @Override - public GenericVnf getVnfByName(String vnfId, String transactionLoggingUuid) { + public GenericVnf getVnfByName(String vnfId) { return new AAIResourcesClient(ENDPOINT_VERSION) .get(GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)).orElse(null); } diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidator.java b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java index bf6485a631..18252d548b 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIValidator.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIValidator.java @@ -24,9 +24,9 @@ import java.io.IOException; public interface AAIValidator { - boolean isPhysicalServerLocked(String hostName, String transactionLoggingUuid) throws IOException; + boolean isPhysicalServerLocked(String hostName) throws IOException; - boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws IOException, Exception; + boolean isVNFLocked(String vnfId); }
\ No newline at end of file diff --git a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java index e416da172c..6ece8a2620 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java +++ b/common/src/main/java/org/onap/so/client/aai/AAIValidatorImpl.java @@ -46,7 +46,7 @@ public class AAIValidatorImpl implements AAIValidator { } @Override - public boolean isPhysicalServerLocked(String vnfId, String transactionLoggingUuid) throws IOException { + public boolean isPhysicalServerLocked(String vnfId) throws IOException { List<Pserver> pservers; boolean isLocked = false; pservers = client.getPhysicalServerByVnfId(vnfId); @@ -58,9 +58,9 @@ public class AAIValidatorImpl implements AAIValidator { } @Override - public boolean isVNFLocked(String vnfId, String transactionLoggingUuid) throws Exception { + public boolean isVNFLocked(String vnfId) { boolean isLocked = false; - GenericVnf genericVnf = client.getVnfByName(vnfId, transactionLoggingUuid); + GenericVnf genericVnf = client.getVnfByName(vnfId); if (genericVnf.isInMaint()) isLocked = true; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java index 63c7290065..f32633122d 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIValidatorTest.java @@ -66,28 +66,28 @@ public class AAIValidatorTest { @Test public void test_IsPhysicalServerLocked_True() throws IOException{ when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(true)); - boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); + boolean locked = validator.isPhysicalServerLocked(vnfName); assertEquals(true, locked); } @Test public void test_IsPhysicalServerLocked_False() throws IOException { when(client.getPhysicalServerByVnfId(vnfName)).thenReturn(getPservers(false)); - boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); + boolean locked = validator.isPhysicalServerLocked(vnfName); assertEquals(false, locked); } @Test - public void test_IsVNFLocked_False() throws Exception{ - when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(false)); - boolean locked = validator.isVNFLocked(vnfName, uuid); + public void test_IsVNFLocked_False() { + when(client.getVnfByName(vnfName)).thenReturn(createGenericVnfs(false)); + boolean locked = validator.isVNFLocked(vnfName); assertEquals(false, locked); } @Test - public void test_IsVNFLocked_True() throws Exception{ - when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(true)); - boolean locked = validator.isVNFLocked(vnfName, uuid); + public void test_IsVNFLocked_True() { + when(client.getVnfByName(vnfName)).thenReturn(createGenericVnfs(true)); + boolean locked = validator.isVNFLocked(vnfName); assertEquals(true,locked ); } } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java index b1c81cf8d8..820b47a2db 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudIdentity.java @@ -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 diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServerType.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServerType.java index d8d386db8c..194215325b 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServerType.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServerType.java @@ -21,5 +21,5 @@ package org.onap.so.db.catalog.beans; public enum ServerType { - KEYSTONE, ORM; + KEYSTONE, ORM, KEYSTONE_V3; } diff --git a/mso-catalog-db/src/test/resources/data.sql b/mso-catalog-db/src/test/resources/data.sql index eeb57249b7..14834ea963 100644 --- a/mso-catalog-db/src/test/resources/data.sql +++ b/mso-catalog-db/src/test/resources/data.sql @@ -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'); diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql index 6eaad260ea..b7d0061e65 100644 --- a/mso-catalog-db/src/test/resources/schema.sql +++ b/mso-catalog-db/src/test/resources/schema.sql @@ -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, |