diff options
Diffstat (limited to 'adapters')
85 files changed, 2208 insertions, 2152 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index 093dbb731c..566eef7b2f 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -60,6 +60,16 @@ <dependencies> <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>ch.vorburger.mariaDB4j</groupId> + <artifactId>mariaDB4j</artifactId> + <version>2.2.3</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> <version>${project.version}</version> diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/AuthenticationType.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/AuthenticationType.java deleted file mode 100644 index 7cb2222525..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/AuthenticationType.java +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - -public enum AuthenticationType { - USERNAME_PASSWORD, RACKSPACE_APIKEY; -} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java index ef5f8232e0..5560282fda 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudConfig.java @@ -20,22 +20,16 @@ package org.onap.so.cloud; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; import java.util.Optional; -import javax.annotation.PostConstruct; - -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; /** * JavaBean JSON class for a CloudConfig. This bean maps a JSON-format cloud @@ -52,61 +46,17 @@ import org.apache.commons.lang3.builder.EqualsBuilder; * */ -@Configuration @JsonRootName("cloud_config") -@ConfigurationProperties(prefix="cloud_config") +@Component public class CloudConfig { private static final String CLOUD_SITE_VERSION = "2.5"; private static final String DEFAULT_CLOUD_SITE_ID = "default"; - - @JsonProperty("identity_services") - private Map<String, CloudIdentity> identityServices = new HashMap<>(); - - @JsonProperty("cloud_sites") - private Map <String, CloudSite> cloudSites = new HashMap<>(); - - @JsonProperty("cloudify_managers") - private Map <String, CloudifyManager> cloudifyManagers = new HashMap<>(); - @PostConstruct - private void init() { - for (Entry<String, CloudIdentity> entry : identityServices.entrySet()) { - entry.getValue().setId(entry.getKey()); - } - - for (Entry<String, CloudSite> entry : cloudSites.entrySet()) { - entry.getValue().setId(entry.getKey()); - } - - for (Entry<String, CloudifyManager> entry : cloudifyManagers.entrySet()) { - entry.getValue().setId(entry.getKey()); - } - } - - /** - * Get a map of all identity services that have been loaded. - */ - public Map<String, CloudIdentity> getIdentityServices() { - return identityServices; - } + @Autowired + private CatalogDbClient catalogDbClient; /** - * Get a map of all cloud sites that have been loaded. - */ - public Map<String, CloudSite> getCloudSites() { - return cloudSites; - } - - /** - * Get a Map of all CloudifyManagers that have been loaded. - * @return the Map - */ - public Map<String,CloudifyManager> getCloudifyManagers() { - return cloudifyManagers; - } - - /** * Get a specific CloudSites, based on an ID. The ID is first checked * against the regions, and if no match is found there, then against * individual entries to try and find one with a CLLI that matches the ID @@ -116,39 +66,28 @@ public class CloudConfig { * @return an Optional of CloudSite object. */ public synchronized Optional<CloudSite> getCloudSite(String id) { - if (id == null) { - return Optional.empty(); - } - if (cloudSites.containsKey(id)) { - return Optional.ofNullable(cloudSites.get(id)); - } else { - return getCloudSiteWithClli(id); - } - } - - public String getCloudSiteId(CloudSite cloudSite) { - for(Entry<String, CloudSite> entry : this.getCloudSites().entrySet()){ - if(entry.getValue().equals(cloudSite)) - return entry.getKey(); - } - return null; - } + if (id == null) { + return Optional.empty(); + } + CloudSite cloudSite = catalogDbClient.getCloudSite(id); + if (cloudSite != null) { + return Optional.of(cloudSite); + } else { + return getCloudSiteWithClli(id); + } + } + /** * Get a specific CloudSites, based on a CLLI and (optional) version, which * will be matched against the aic_version field of the CloudSite. * * @param clli * the CLLI to match - * @param version - * the version to match; may be null in which case any version - * matches * @return a CloudSite, or null of no match found */ private Optional<CloudSite> getCloudSiteWithClli(String clli) { - Optional <CloudSite> cloudSiteOptional = cloudSites.values().stream().filter(cs -> - cs.getClli() != null && clli.equals(cs.getClli()) && (CLOUD_SITE_VERSION.equals(cs.getAicVersion()))) - .findAny(); + Optional <CloudSite> cloudSiteOptional = Optional.ofNullable(catalogDbClient.getCloudSiteByClliAndAicVersion(clli,CLOUD_SITE_VERSION)); if (cloudSiteOptional.isPresent()) { return cloudSiteOptional; } else { @@ -157,8 +96,7 @@ public class CloudConfig { } private Optional<CloudSite> getDefaultCloudSite(String clli) { - Optional<CloudSite> cloudSiteOpt = cloudSites.values().stream() - .filter(cs -> cs.getId().equalsIgnoreCase(DEFAULT_CLOUD_SITE_ID)).findAny(); + Optional<CloudSite> cloudSiteOpt = Optional.ofNullable(catalogDbClient.getCloudSite(DEFAULT_CLOUD_SITE_ID)); if (cloudSiteOpt.isPresent()) { CloudSite defaultCloudSite = cloudSiteOpt.get(); CloudSite clone = new CloudSite(defaultCloudSite); @@ -178,7 +116,7 @@ public class CloudConfig { * @return a CloudIdentity, or null of no match found */ public CloudIdentity getIdentityService(String id) { - return identityServices.get(id); + return catalogDbClient.getCloudIdentity(id); } /** @@ -187,30 +125,6 @@ public class CloudConfig { * @return a CloudifyManager, or null of no match found */ public CloudifyManager getCloudifyManager (String id) { - return cloudifyManagers.get(id); - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("identityServices", getIdentityServices()).append("cloudSites", getCloudSites()).toString(); - } - - @Override - public boolean equals(final Object other) { - if (other == null) { - return false; - } - if (!getClass().equals(other.getClass())) { - return false; - } - CloudConfig castOther = (CloudConfig) other; - return new EqualsBuilder().append(getIdentityServices(), castOther.getIdentityServices()) - .append(getCloudSites(), castOther.getCloudSites()).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(1, 31).append(getIdentityServices()).append(getCloudSites()).toHashCode(); + return catalogDbClient.getCloudifyManager(id); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudIdentity.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudIdentity.java deleted file mode 100644 index 188a93025e..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudIdentity.java +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.openpojo.business.annotation.BusinessKey; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import java.util.Comparator; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -/** - * JavaBean JSON class for a CloudIdentity. This bean represents a cloud identity - * service instance (i.e. a DCP node) in the NVP/AIC cloud. It will be loaded via - * CloudConfig object, of which it is a component (a CloudConfig JSON configuration - * file may contain multiple CloudIdentity definitions). - * - * Note that this is only used to access Cloud Configurations loaded from a - * JSON config file, so there are no explicit setters. - * - */ -public class CloudIdentity { - - @JsonProperty - @BusinessKey - private String id; - @JsonProperty("identity_url") - @BusinessKey - private String identityUrl; - @JsonProperty("mso_id") - @BusinessKey - private String msoId; - @JsonProperty("mso_pass") - @BusinessKey - private String msoPass; - @JsonProperty("admin_tenant") - @BusinessKey - private String adminTenant; - @JsonProperty("member_role") - @BusinessKey - private String memberRole; - @JsonProperty("tenant_metadata") - @BusinessKey - private Boolean tenantMetadata; - @JsonProperty("identity_server_type") - @BusinessKey - private ServerType identityServerType; - @JsonProperty("identity_authentication_type") - @BusinessKey - private AuthenticationType identityAuthenticationType; - - public CloudIdentity() {} - - public String getId () { - return id; - } - - public void setId (String id) { - this.id = id; - } - - public String getIdentityUrl() { - return this.identityUrl; - } - public void setIdentityUrl(String url) { - this.identityUrl = url; - } - - public String getMsoId () { - return msoId; - } - - public void setMsoId (String id) { - this.msoId = id; - } - - public String getMsoPass () { - return msoPass; - } - - public void setMsoPass (String pwd) { - this.msoPass = pwd; - } - - public String getAdminTenant () { - return adminTenant; - } - - public void setAdminTenant (String tenant) { - this.adminTenant = tenant; - } - - public String getMemberRole () { - return memberRole; - } - - public void setMemberRole (String role) { - this.memberRole = role; - } - - public Boolean hasTenantMetadata () { - return tenantMetadata; - } - - public void setTenantMetadata (Boolean meta) { - this.tenantMetadata = meta; - } - - public ServerType getIdentityServerType() { - return this.identityServerType; - } - public void setIdentityServerType(ServerType ist) { - this.identityServerType = ist; - } - public String getIdentityServerTypeAsString() { - return this.identityServerType.toString(); - } - /** - * @return the identityAuthenticationType - */ - public AuthenticationType getIdentityAuthenticationType() { - return identityAuthenticationType; - } - - /** - * @param identityAuthenticationType the identityAuthenticationType to set - */ - public void setIdentityAuthenticationType(AuthenticationType identityAuthenticationType) { - this.identityAuthenticationType = identityAuthenticationType; - } - - @Override - public CloudIdentity clone() { - CloudIdentity cloudIdentityCopy = new CloudIdentity(); - - cloudIdentityCopy.id = this.id; - cloudIdentityCopy.identityUrl = this.identityUrl; - cloudIdentityCopy.msoId = this.msoId; - cloudIdentityCopy.msoPass = this.msoPass; - cloudIdentityCopy.adminTenant = this.adminTenant; - cloudIdentityCopy.memberRole = this.memberRole; - cloudIdentityCopy.tenantMetadata = this.tenantMetadata; - cloudIdentityCopy.identityServerType = this.identityServerType; - cloudIdentityCopy.identityAuthenticationType = this.identityAuthenticationType; - - return cloudIdentityCopy; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId()) - .append("identityUrl", getIdentityUrl()).append("msoId", getMsoId()) - .append("adminTenant", getAdminTenant()).append("memberRole", getMemberRole()) - .append("tenantMetadata", hasTenantMetadata()).append("identityServerType", getIdentityServerType()) - .append("identityAuthenticationType", getIdentityAuthenticationType()).toString(); - } - - @Override - public boolean equals(final Object other) { - if (other == null) { - return false; - } - if (!getClass().equals(other.getClass())) { - return false; - } - CloudIdentity castOther = (CloudIdentity) other; - return new EqualsBuilder().append(getId(), castOther.getId()) - .append(getIdentityUrl(), castOther.getIdentityUrl()).append(getMsoId(), castOther.getMsoId()) - .append(getMsoPass(), castOther.getMsoPass()).append(getAdminTenant(), castOther.getAdminTenant()) - .append(getMemberRole(), castOther.getMemberRole()) - .append(hasTenantMetadata(), castOther.hasTenantMetadata()) - .append(getIdentityServerType(), castOther.getIdentityServerType()) - .append(getIdentityAuthenticationType(), castOther.getIdentityAuthenticationType()).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(1, 31).append(getId()).append(getIdentityUrl()).append(getMsoId()) - .append(getMsoPass()).append(getAdminTenant()).append(getMemberRole()).append(hasTenantMetadata()) - .append(getIdentityServerType()).append(getIdentityAuthenticationType()).toHashCode(); - } -}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudSite.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudSite.java deleted file mode 100644 index f38403d0cd..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudSite.java +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - - -import java.util.Comparator; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.openpojo.business.annotation.BusinessKey; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -/** - * JavaBean JSON class for a CloudSite. This bean represents a cloud location - * (i.e. and LCP node) in the NVP/AIC cloud. It will be loaded via CloudConfig - * object, of which it is a component (a CloudConfig JSON configuration file - * will contain multiple CloudSite definitions). - * - * Note that this is only used to access Cloud Configurations loaded from a - * JSON config file, so there are no explicit setters. - * - */ -public class CloudSite { - @JsonProperty - @BusinessKey - private String id; - @JsonProperty("region_id") - @BusinessKey - private String regionId; - @JsonProperty("identity_service_id") - @BusinessKey - private String identityServiceId; - @JsonProperty("aic_version") - @BusinessKey - private String aicVersion; - @JsonProperty("clli") - @BusinessKey - private String clli; - @JsonProperty("cloudify_id") - @BusinessKey - private String cloudifyId; - @JsonProperty("platform") - @BusinessKey - private String platform; - @JsonProperty("orchestrator") - @BusinessKey - private String orchestrator; - - // Derived property (set by CloudConfig loader based on identityServiceId) - private CloudIdentity identityService; - // Derived property (set by CloudConfig loader based on cloudifyId) - private CloudifyManager cloudifyManager; - - public CloudSite() { - - } - - public CloudSite(CloudSite site) { - this.aicVersion = site.getAicVersion(); - this.clli = site.getClli(); - this.cloudifyId = this.getCloudifyId(); - this.cloudifyManager = this.getCloudifyManager(); - this.id = site.getId(); - this.identityService = site.getIdentityService(); - this.identityServiceId = site.getIdentityServiceId(); - this.orchestrator = site.getOrchestrator(); - this.platform = site.getPlatform(); - this.regionId = this.getRegionId(); - } - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRegionId() { - return regionId; - } - - public void setRegionId(String regionId) { - this.regionId = regionId; - } - - public String getIdentityServiceId() { - return identityServiceId; - } - - public void setIdentityServiceId(String identityServiceId) { - this.identityServiceId = identityServiceId; - } - public String getAicVersion() { - return aicVersion; - } - - public void setAicVersion(String aicVersion) { - this.aicVersion = aicVersion; - } - - public String getClli() { - return clli; - } - - public void setClli(String clli) { - this.clli = clli; - } - - public String getCloudifyId() { - return cloudifyId; - } - - public void setCloudifyId (String id) { - this.cloudifyId = id; - } - - public String getPlatform() { - return platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - - public String getOrchestrator() { - return orchestrator; - } - - public void setOrchestrator(String orchestrator) { - this.orchestrator = orchestrator; - } - - public CloudIdentity getIdentityService () { - return identityService; - } - - public void setIdentityService (CloudIdentity identity) { - this.identityService = identity; - } - - public CloudifyManager getCloudifyManager () { - return cloudifyManager; - } - - public void setCloudifyManager (CloudifyManager cloudify) { - this.cloudifyManager = cloudify; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("regionId", getRegionId()) - .append("identityServiceId", getIdentityServiceId()).append("aicVersion", getAicVersion()) - .append("clli", getClli()).append("cloudifyId", getCloudifyId()).append("platform", getPlatform()) - .append("orchestrator", getOrchestrator()).toString(); - } - - @Override - public boolean equals(final Object other) { - if (other == null) { - return false; - } - if (!getClass().equals(other.getClass())) { - return false; - } - CloudSite castOther = (CloudSite) other; - return new EqualsBuilder().append(getRegionId(), castOther.getRegionId()) - .append(getIdentityServiceId(), castOther.getIdentityServiceId()) - .append(getAicVersion(), castOther.getAicVersion()).append(getClli(), castOther.getClli()).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(1, 31).append(getRegionId()).append(getIdentityServiceId()).append(getAicVersion()) - .append(getClli()).toHashCode(); - } -}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudifyManager.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudifyManager.java deleted file mode 100644 index 1bf3f136b0..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/CloudifyManager.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - -import java.security.GeneralSecurityException; -import java.util.Comparator; - -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; -import org.onap.so.utils.CryptoUtils; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.openpojo.business.annotation.BusinessKey; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; - -/** - * JavaBean JSON class for a Cloudify Manager. This bean represents a Cloudify - * node through which TOSCA-based VNFs may be deployed. Each CloudSite in the - * CloudConfig may have a Cloudify Manager for deployments using TOSCA blueprints. - * Cloudify Managers may support multiple Cloud Sites, but each site will have - * at most one Cloudify Manager. - * - * This does not replace the ability to use the CloudSite directly via Openstack. - * - * Note that this is only used to access Cloud Configurations loaded from a - * JSON config file, so there are no explicit setters. - * - * @author JC1348 - */ -public class CloudifyManager { - - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CloudifyManager.class); - - @BusinessKey - @JsonProperty - private String id; - - @BusinessKey - @JsonProperty ("cloudify_url") - private String cloudifyUrl; - - @BusinessKey - @JsonProperty("username") - private String username; - - @BusinessKey - @JsonProperty("password") - private String password; - - @BusinessKey - @JsonProperty("version") - private String version; - - public CloudifyManager() {} - - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - - public String getCloudifyUrl() { - return cloudifyUrl; - } - - public void setCloudifyUrl(String cloudifyUrl) { - this.cloudifyUrl = cloudifyUrl; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public CloudifyManager clone() { - CloudifyManager cloudifyManagerCopy = new CloudifyManager(); - cloudifyManagerCopy.id = this.id; - cloudifyManagerCopy.cloudifyUrl = this.cloudifyUrl; - cloudifyManagerCopy.username = this.username; - cloudifyManagerCopy.password = this.password; - cloudifyManagerCopy.version = this.version; - return cloudifyManagerCopy; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("id", getId()) - .append("cloudifyUrl", getCloudifyUrl()).append("username", getUsername()) - .append("password", getPassword()).append("version", getVersion()).toString(); - } - - @Override - public boolean equals(final Object other) { - if (other == null) { - return false; - } - if (!getClass().equals(other.getClass())) { - return false; - } - CloudifyManager castOther = (CloudifyManager) other; - return new EqualsBuilder().append(getId(), castOther.getId()) - .append(getCloudifyUrl(), castOther.getCloudifyUrl()).append(getUsername(), castOther.getUsername()) - .append(getPassword(), castOther.getPassword()).append(getVersion(), castOther.getVersion()).isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(1, 31).append(getId()).append(getCloudifyUrl()).append(getUsername()) - .append(getPassword()).append(getVersion()).toHashCode(); - } -}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/ServerType.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/ServerType.java deleted file mode 100644 index ac59018c6b..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloud/ServerType.java +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - -public enum ServerType { - KEYSTONE, ORM; -} 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 5c648eb5e3..1912cd874a 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,8 +20,8 @@ package org.onap.so.cloud.authentication; -import org.onap.so.cloud.AuthenticationType; -import org.onap.so.cloud.CloudIdentity; +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; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java index aa8e37f12b..59996fa3d1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java @@ -42,8 +42,8 @@ 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.CloudSite; -import org.onap.so.cloud.CloudifyManager; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.cloudify.base.client.CloudifyBaseException; import org.onap.so.cloudify.base.client.CloudifyClientTokenProvider; import org.onap.so.cloudify.base.client.CloudifyConnectException; @@ -898,7 +898,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{ { CloudifyManager cloudifyConfig = cloudConfig.getCloudifyManager(cloudSite.getCloudifyId()); if (cloudifyConfig == null) { - throw new MsoCloudifyManagerNotFound (cloudConfig.getCloudSiteId(cloudSite)); + throw new MsoCloudifyManagerNotFound (cloudSite.getId()); } // Get a Cloudify client 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 e5ece20cb7..1d5b1a006d 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 @@ -41,8 +41,8 @@ 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.CloudIdentity; -import org.onap.so.cloud.CloudSite; +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; @@ -949,7 +949,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ * @return an authenticated Heat object */ public Heat getHeatClient (CloudSite cloudSite, String tenantId) throws MsoException { - String cloudId = cloudConfig.getCloudSiteId(cloudSite); + String cloudId = cloudSite.getId(); // Check first in the cache of previously authorized clients String cacheKey = cloudId + ":" + tenantId; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java index 0b3f9dfe17..e68a8e764a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java @@ -28,8 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.StackInfo; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java index d3ec74db8d..2f2a457bed 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java @@ -27,8 +27,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.onap.so.cloud.CloudIdentity; -import org.onap.so.cloud.CloudSite; +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.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -92,7 +92,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * <p> * * @param tenantName The tenant name to create - * @param cloudId The cloud identifier (may be a region) in which to create the tenant. + * @param cloudSiteId The cloud identifier (may be a region) in which to create the tenant. * @return the tenant ID of the newly created tenant * @throws MsoTenantAlreadyExists Thrown if the requested tenant already exists * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception @@ -150,7 +150,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { executeAndRecordOpenstackRequest (request); } - if (cloudIdentity.hasTenantMetadata () && metadata != null && !metadata.isEmpty ()) { + if (cloudIdentity.getTenantMetadata () && metadata != null && !metadata.isEmpty ()) { Metadata tenantMetadata = new Metadata (); tenantMetadata.setMetadata (metadata); @@ -221,7 +221,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } Map <String, String> metadata = new HashMap <String, String> (); - if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).hasTenantMetadata ()) { + if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) { OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); Metadata tenantMetadata = executeAndRecordOpenstackRequest (request); if (tenantMetadata != null) { @@ -267,7 +267,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { } Map <String, String> metadata = new HashMap <String, String> (); - if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).hasTenantMetadata ()) { + if (cloudConfig.getIdentityService(cloudSite.getIdentityServiceId()).getTenantMetadata ()) { OpenStackRequest <Metadata> request = keystoneAdminClient.tenants ().showMetadata (tenant.getId ()); Metadata tenantMetadata = executeAndRecordOpenstackRequest (request); if (tenantMetadata != null) { 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 adeb008ad5..18ed94112c 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 @@ -27,8 +27,8 @@ import java.util.List; import java.util.Map; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudIdentity; -import org.onap.so.cloud.CloudSite; +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.logger.MessageEnum; import org.onap.so.logger.MsoAlarmLogger; @@ -42,7 +42,6 @@ import org.onap.so.openstack.exceptions.MsoIOException; import org.onap.so.openstack.exceptions.MsoNetworkAlreadyExists; import org.onap.so.openstack.exceptions.MsoNetworkNotFound; import org.onap.so.openstack.exceptions.MsoOpenstackException; -import org.onap.so.openstack.exceptions.MsoTenantNotFound; import org.onap.so.openstack.mappers.NetworkInfoMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java index 28911bc45c..383409f810 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoTenantUtils.java @@ -24,7 +24,7 @@ package org.onap.so.openstack.utils; import java.util.Map; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.MsoTenant; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; 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 68d0ef2fad..da9f79aa89 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 @@ -21,8 +21,8 @@ package org.onap.so.openstack.utils; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; -import org.onap.so.cloud.ServerType; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java index 36f82e15bd..36a50fd77e 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/BaseTest.java @@ -22,14 +22,30 @@ package org.onap.so; import com.github.tomakehurst.wiremock.client.WireMock; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpStatus; import org.junit.After; +import org.junit.Before; import org.junit.runner.RunWith; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import javax.ws.rs.core.MediaType; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; + @RunWith(SpringRunner.class) @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -43,4 +59,68 @@ public abstract class BaseTest extends TestDataSetup { public void after() { WireMock.reset(); } -} + + protected static String getBody(String body, int port, String urlPath) throws IOException { + return body.replaceAll("port", "http://localhost:" + port + urlPath); + } + + @Before + public void init() throws IOException { + CloudIdentity identity = getCloudIdentity(); + CloudSite cloudSite = getCloudSite(identity); + mockCloud(identity, cloudSite); + } + + private void mockCloud(CloudIdentity identity, CloudSite cloudSite) throws IOException { + stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) + .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) + .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/cloudIdentity/mtn13")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) + .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + } + + private CloudIdentity getCloudIdentity() { + CloudIdentity identity = new CloudIdentity(); + identity.setId("mtn13"); + identity.setMsoId("m93945"); + identity.setMsoPass("93937EA01B94A10A49279D4572B48369"); + identity.setAdminTenant("admin"); + identity.setMemberRole("admin"); + identity.setTenantMetadata(false); + identity.setIdentityUrl("http://localhost:"+wireMockPort+"/v2.0"); + identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD); + identity.setIdentityServerType(ServerType.KEYSTONE); + return identity; + } + + private CloudSite getCloudSite(CloudIdentity identity) { + CloudSite cloudSite = new CloudSite(); + cloudSite.setId("MTN13"); + cloudSite.setCloudVersion("3.0"); + cloudSite.setClli("MDT13"); + cloudSite.setRegionId("mtn13"); + cloudSite.setIdentityService(identity); + return cloudSite; + } + + private static String readFile(String fileName) throws IOException { + try (BufferedReader br = new BufferedReader(new FileReader(fileName))) { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + + while (line != null) { + sb.append(line); + sb.append("\n"); + line = br.readLine(); + } + return sb.toString(); + } + } +}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..d7b30edbe5 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java @@ -0,0 +1,42 @@ +package org.onap.so; + +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +import javax.sql.DataSource; + +@Configuration +@Profile({"test","local"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } +}
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java index 539e7acef0..012805e774 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsRefactorTest.java @@ -21,39 +21,72 @@ package org.onap.so.adapter_utils.tests; +import org.apache.http.HttpHeaders; +import org.apache.http.HttpStatus; +import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.cloud.Application; -import org.onap.so.openstack.utils.MsoCommonUtils; +import org.onap.so.BaseTest; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; +import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.utils.MsoHeatUtils; 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 javax.ws.rs.core.MediaType; +import java.io.IOException; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.junit.Assert.assertEquals; -/** +/**PoConfigTest * This class implements test methods of the MsoHeatUtils * * */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) -@ActiveProfiles("test") -public class MsoHeatUtilsRefactorTest extends MsoCommonUtils { +public class MsoHeatUtilsRefactorTest extends BaseTest { @Autowired private MsoHeatUtils msoHeatUtils; + + @Before + public void init() throws IOException { + CloudIdentity identity = new CloudIdentity(); + + identity.setId("MTN13"); + identity.setMsoId("m93945"); + identity.setMsoPass("93937EA01B94A10A49279D4572B48369"); + identity.setAdminTenant("admin"); + identity.setMemberRole("admin"); + identity.setTenantMetadata(true); + identity.setIdentityUrl("http://localhost:28090/v2.0"); + identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD); + + CloudSite cloudSite = new CloudSite(); + cloudSite.setId("MTN13"); + cloudSite.setCloudVersion("3.0"); + cloudSite.setClli("MDT13"); + cloudSite.setRegionId("MTN13"); + identity.setIdentityServerType(ServerType.KEYSTONE); + cloudSite.setIdentityService(identity); + + + stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) + .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) + .withHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + } @Test - public final void testGetKeystoneUrl() { - try { - String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN"); - assertEquals("http://192.168.170.21:5000/v2.0",keyUrl); - } catch (Exception e) { - - } + public final void testGetKeystoneUrl() throws MsoCloudSiteNotFound { + String keyUrl = msoHeatUtils.getCloudSiteKeystoneUrl("DAN"); + assertEquals("http://localhost:28090/v2.0", keyUrl); } - - } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java index 6d9687216d..50fc17511b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/adapter_utils/tests/MsoHeatUtilsWithUpdateTest.java @@ -23,7 +23,6 @@ package org.onap.so.adapter_utils.tests; import static org.junit.Assert.fail; import static org.mockito.Mockito.when; -import java.security.GeneralSecurityException; import java.util.HashMap; import java.util.Map; @@ -36,9 +35,9 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudIdentity; -import org.onap.so.cloud.CloudSite; -import org.onap.so.cloud.ServerType; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoIOException; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java index 668b1806ac..c6db998b2b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudConfigTest.java @@ -22,86 +22,71 @@ package org.onap.so.cloud; import static org.junit.Assert.*; -import java.util.Map; import java.util.Optional; import org.junit.Test; -import org.junit.runner.RunWith; import org.onap.so.BaseTest; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.openstack.exceptions.MsoException; 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; /** * This class implements test methods of the CloudConfig features. * * */ -public class CloudConfigTest extends BaseTest { +public class CloudConfigTest extends BaseTest{ @Autowired private CloudConfig con; - /** - * This method implements a test for the getCloudSites method. - */ - @Test - public final void testGetCloudSites () { - Map<String,CloudSite> siteMap = con.getCloudSites(); - assertNotNull(siteMap); - - CloudSite site1 = siteMap.get("regionOne"); - - assertEquals ("regionOne", site1.getRegionId()); - assertEquals ("MT_KEYSTONE", site1.getIdentityServiceId()); - assertEquals ("MT2", site1.getClli()); - assertEquals ("2.5", site1.getAicVersion()); - } - - - /** - * This method implements a test for the getIdentityServices method. - * @throws MsoException - */ - @Test - public final void testGetIdentityServices () throws MsoException { - Map<String,CloudIdentity> identityMap = con.getIdentityServices (); - assertNotNull(identityMap); - - CloudIdentity identity1 = identityMap.get("MT_KEYSTONE"); - - assertEquals("john", identity1.getMsoId()); - assertEquals("313DECE408AF7759D442D7B06DD9A6AA", identity1.getMsoPass()); - assertEquals("admin", identity1.getAdminTenant()); - assertEquals("_member_", identity1.getMemberRole()); - assertEquals(false, identity1.hasTenantMetadata()); - assertEquals("http://localhost:"+wireMockPort+"/v2.0", identity1.getIdentityUrl()); - assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType()); - assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType()); - - } - - /** - * This method implements a test for the getCloudSite method. - */ - @Test - public final void testGetDefaultCloudSite () { - Optional<CloudSite> site = con.getCloudSite("NotThere"); - assertTrue(site.isPresent()); - CloudSite site1 = site.get(); - assertEquals ("NotThere", site1.getRegionId()); - assertEquals("MTN6", site1.getClli()); - assertEquals("NotThere", site1.getId()); - assertEquals ("ORDM3", site1.getIdentityServiceId()); - } - - @Test - public void testGetIdentityService() { - CloudIdentity identity = con.getIdentityService("MT_KEYSTONE"); - assertEquals("john", identity.getMsoId()); - assertEquals("MT_KEYSTONE", identity.getId()); - } - + /** + * This method implements a test for the getCloudSite method. + */ + @Test + public final void testGetCloudSite () { + CloudSite site1 = con.getCloudSite("MTN13").get(); + + assertEquals ("mtn13", site1.getRegionId()); + assertEquals ("mtn13", site1.getIdentityServiceId()); + assertEquals ("MDT13", site1.getClli()); + assertEquals ("3.0", site1.getCloudVersion()); + } + + + /** + * This method implements a test for the getIdentityServices method. + * @throws MsoException + */ + @Test + public final void testGetIdentityServices () throws MsoException { + + CloudIdentity identity1 = con.getIdentityService("mtn13"); + + assertEquals("m93945", identity1.getMsoId()); + assertEquals("93937EA01B94A10A49279D4572B48369", identity1.getMsoPass()); + assertEquals("admin", identity1.getAdminTenant()); + assertEquals("admin", identity1.getMemberRole()); + assertTrue(identity1.getIdentityUrl().contains("http://localhost:")); + assertEquals(ServerType.KEYSTONE, identity1.getIdentityServerType()); + assertEquals(AuthenticationType.USERNAME_PASSWORD, identity1.getIdentityAuthenticationType()); + + } + + /** + * This method implements a test for the getCloudSite method. + */ + @Test + public final void testGetDefaultCloudSite () { + Optional<CloudSite> site = con.getCloudSite("NotThere"); + assertTrue(site.isPresent()); + CloudSite site1 = site.get(); + assertEquals ("NotThere", site1.getRegionId()); + assertEquals("MDT13", site1.getClli()); + assertEquals("NotThere", site1.getId()); + } + } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java deleted file mode 100644 index db2ba05bf1..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudIdentityTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.security.GeneralSecurityException; - -import org.junit.Test; -import org.onap.so.utils.CryptoUtils; - -public class CloudIdentityTest { - - private CloudIdentity cloudIdentity = new CloudIdentity(); - private static final String ID = "testId"; - private static final String IDENTITY_URL = "testIdentityUrl"; - private static final String MSO_ID = "testMsoId"; - private static final String MSO_PASS = "testMsoPassword"; - private static final String ADMIN_TENANT = "testAdminTenant"; - private static final String MEMBER_ROLE = "testMemberRole"; - private static final Boolean TENANT_METADATA = true; - - @Test - public final void testCloudIdentity () { - CloudIdentity id = new CloudIdentity (); - id.setAdminTenant ("AdminTenant"); - id.setId ("id"); -// id.setKeystoneUrl ("keystone"); - id.setIdentityUrl ("keystone"); - id.setMemberRole ("member"); - id.setMsoId ("msoId"); - id.setMsoPass (CryptoUtils.encryptCloudConfigPassword("password")); - id.setTenantMetadata (true); - id.setIdentityServerType(null); - id.setIdentityAuthenticationType(null); - - - assertTrue (id.getAdminTenant ().equals ("AdminTenant")); - assertTrue (id.getId ().equals ("id")); -// assertTrue (id.getKeystoneUrl ().equals ("keystone")); - assertTrue (id.getMemberRole ().equals ("member")); - assertTrue (id.getMsoId ().equals ("msoId")); - assertTrue (CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals ("password")); - assertTrue (id.hasTenantMetadata ()); -// assertTrue (id.toString ().contains ("keystone")); - assertTrue(id.toString().contains("null")); - } - - @Test - public final void testEncryption () throws GeneralSecurityException { - String encrypted = CryptoUtils.encryptCloudConfigPassword("password"); - assertTrue (encrypted != null); - assertTrue (!encrypted.equals ("password")); - } - - @Test - public void cloneTest() { - cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT, - MEMBER_ROLE, TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD); - CloudIdentity cloudIdentity2 = cloudIdentity.clone(); - - assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass()); - } - - private CloudIdentity setupCloudIdentity(CloudIdentity obj, String id, String identityUrl, - String msoId, String msoPass, String adminTenant, String memberRole, Boolean tenantMetadata, - ServerType identityServerType, AuthenticationType identityAuthenticationType) { - obj.setId(id); - obj.setIdentityUrl(identityUrl); - obj.setMsoId(msoId); - obj.setMsoPass(msoPass); - obj.setAdminTenant(adminTenant); - obj.setMemberRole(memberRole); - obj.setTenantMetadata(tenantMetadata); - obj.setIdentityServerType(identityServerType); - obj.setIdentityAuthenticationType(identityAuthenticationType); - - return obj; - } -} diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java index 89c15b0deb..096d5dad8b 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudPojoTest.java @@ -21,7 +21,9 @@ package org.onap.so.cloud; import org.junit.Test; -import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.openpojo.rules.ToStringTester; import com.openpojo.reflection.PojoClass; @@ -51,7 +53,6 @@ public class CloudPojoTest { .with(new SetterTester()) .with(new GetterTester()) .with(new ToStringTester()) - .with(new EqualsAndHashCodeTester()) .build(); validator.validate(pojoClass); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java deleted file mode 100644 index 9a660b4d40..0000000000 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/CloudifyManagerTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.cloud; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class CloudifyManagerTest { - - private CloudifyManager cloudifyManager = new CloudifyManager(); - private static final String ID = "testId"; - private static final String CLOUDIFY_URL = "testCloudifyUrl"; - private static final String USERNAME = "testUsername"; - private static final String PASSWORD = "testPassword"; - private static final String VERSION = "testVersion"; - - @Test - public void cloneTest() { - cloudifyManager.setId(ID); - cloudifyManager.setCloudifyUrl(CLOUDIFY_URL); - cloudifyManager.setUsername(USERNAME); - cloudifyManager.setPassword(PASSWORD); - cloudifyManager.setVersion(VERSION); - - CloudifyManager clone = cloudifyManager.clone(); - assertEquals(cloudifyManager, clone); - } -} 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 e1c533757b..d676bcab3a 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 @@ -24,11 +24,11 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.so.BaseTest; import org.onap.so.cloud.Application; -import org.onap.so.cloud.AuthenticationType; -import org.onap.so.cloud.CloudIdentity; +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.openstack.exceptions.MsoException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; @@ -43,10 +43,7 @@ import com.woorea.openstack.keystone.model.authentication.UsernamePassword; * only are tested. * */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) -@ActiveProfiles("test") -public class AuthenticationMethodTest { +public class AuthenticationMethodTest extends BaseTest { @Autowired private AuthenticationMethodFactory authenticationMethodFactory; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java index e75a4aecaf..96202c5122 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloudify/utils/MsoCloudifyUtilsTest2.java @@ -42,13 +42,12 @@ import org.onap.so.adapters.vdu.VduModelInfo; 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.CloudIdentity; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.cloudify.beans.DeploymentInfo; import org.onap.so.cloudify.beans.DeploymentStatus; import org.onap.so.cloudify.v3.client.Cloudify; import org.onap.so.cloudify.v3.model.AzureConfig; -import org.onap.so.cloudify.v3.model.OpenstackConfig; import org.onap.so.openstack.exceptions.MsoException; public class MsoCloudifyUtilsTest2 { diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java index d347dedb4f..f069e9f61f 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/config/PoConfigTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.so.BaseTest; import org.onap.so.cloud.Application; import org.onap.so.config.beans.PoConfig; import org.springframework.beans.factory.annotation.Autowired; @@ -31,10 +32,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) -@ActiveProfiles("test") -public class PoConfigTest { +public class PoConfigTest extends BaseTest { @Autowired diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java index 4adf6bf5be..b675f4814d 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/HeatCacheEntryTest.java @@ -30,7 +30,7 @@ import java.util.GregorianCalendar; import org.junit.Test; import org.onap.so.BaseTest; -public class HeatCacheEntryTest extends BaseTest { +public class HeatCacheEntryTest { private static final String HEAT_URL = "testHeatUrl"; private static final String TOKEN = "testToken"; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java index 3a652042b7..8626e7d177 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/NeutronCacheEntryTest.java @@ -29,7 +29,7 @@ import java.util.GregorianCalendar; import org.junit.Test; import org.onap.so.BaseTest; -public class NeutronCacheEntryTest extends BaseTest { +public class NeutronCacheEntryTest { private static final String NEUTRON_URL = "testNeutronUrl"; private static final String TOKEN = "testToken"; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java index 522a261fdd..94715f1599 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/beans/OpenstackBeansPojoTest.java @@ -30,7 +30,7 @@ import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; -public class OpenstackBeansPojoTest extends BaseTest { +public class OpenstackBeansPojoTest { @Test public void pojoStructure() { test(PojoClassFactory.getPojoClass(VnfRollback.class)); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 6bcb209125..b304cba93f 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -47,6 +47,10 @@ import org.onap.so.adapters.vdu.VduInstance; import org.onap.so.adapters.vdu.VduModelInfo; import org.onap.so.adapters.vdu.VduStateType; import org.onap.so.adapters.vdu.VduStatus; +import org.onap.so.cloud.CloudConfig; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.openstack.beans.HeatStatus; +import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoException; import org.springframework.beans.factory.annotation.Autowired; @@ -67,7 +71,7 @@ public class MsoHeatUtilsTest extends BaseTest{ expected.setStatus(status); CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("regionOne"); + cloudInfo.setCloudSiteId("MTN13"); cloudInfo.setTenantId("tenantId"); VduModelInfo vduModel = new VduModelInfo(); vduModel.setModelCustomizationUUID("blueprintId"); @@ -111,7 +115,7 @@ public class MsoHeatUtilsTest extends BaseTest{ expected.setStatus(status); CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("regionOne"); + cloudInfo.setCloudSiteId("mtn13"); cloudInfo.setTenantId("tenantId"); String instanceId = "instanceId"; @@ -138,7 +142,7 @@ public class MsoHeatUtilsTest extends BaseTest{ expected.setStatus(status); CloudInfo cloudInfo = new CloudInfo(); - cloudInfo.setCloudSiteId("regionOne"); + cloudInfo.setCloudSiteId("mtn13"); cloudInfo.setTenantId("tenantId"); String instanceId = "instanceId"; diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java index c252f61e7f..1a8f4fb098 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdateTest.java @@ -25,7 +25,6 @@ import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.isA; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import java.io.File; @@ -39,13 +38,12 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.Spy; import org.mockito.runners.MockitoJUnitRunner; import org.onap.so.TestDataSetup; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoException; @@ -55,10 +53,7 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.heat.Heat; -import com.woorea.openstack.heat.StackResource; -import com.woorea.openstack.heat.StackResource.UpdateStack; import com.woorea.openstack.heat.model.Stack; -import com.woorea.openstack.heat.model.UpdateStackParam; @RunWith(MockitoJUnitRunner.class) public class MsoHeatUtilsWithUpdateTest extends TestDataSetup { @@ -95,7 +90,7 @@ public class MsoHeatUtilsWithUpdateTest extends TestDataSetup { @Test public void updateStackTest() throws MsoException, JsonParseException, JsonMappingException, IOException { - CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class); + CloudSite cloudSite = new CloudSite(); Heat heatClient = new Heat("endpoint"); Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class); Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class); @@ -120,7 +115,7 @@ public class MsoHeatUtilsWithUpdateTest extends TestDataSetup { public void updateStackWithEnvironmentTest() throws JsonParseException, JsonMappingException, IOException, MsoException { String environmentString = "environmentString"; - CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class); + CloudSite cloudSite = new CloudSite(); Heat heatClient = new Heat("endpoint"); Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class); Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class); @@ -147,7 +142,7 @@ public class MsoHeatUtilsWithUpdateTest extends TestDataSetup { Map<String, Object> files = new HashMap<>(); files.put("file1", new Object()); - CloudSite cloudSite = mapper.readValue(new File(RESOURCE_PATH + "CloudSite.json"), CloudSite.class); + CloudSite cloudSite = new CloudSite(); Heat heatClient = new Heat("endpoint"); Stack heatStack = mapper.readValue(new File(RESOURCE_PATH + "HeatStack.json"), Stack.class); Stack updateStack = mapper.readValue(new File(RESOURCE_PATH + "UpdateStack.json"), Stack.class); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java index 706427e985..92f7738c62 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoKeystoneUtilsTest.java @@ -48,7 +48,7 @@ public class MsoKeystoneUtilsTest extends BaseTest { StubOpenStack.mockOpenStackGetUserById("john"); StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM"); - String response = msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true); + String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true); Assert.assertEquals("tenantId", response); } @@ -59,7 +59,7 @@ public class MsoKeystoneUtilsTest extends BaseTest { StubOpenStack.mockOpenStackGetUserByName("john"); StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM"); - String response = msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true); + String response = msoKeystoneUtils.createTenant("tenant", "MTN13", new HashMap<>(), true); Assert.assertEquals("tenantId", response); } @@ -70,14 +70,14 @@ public class MsoKeystoneUtilsTest extends BaseTest { StubOpenStack.mockOpenStackPostTenantWithBodyFile_200(); StubOpenStack.mockOpenStackGetUserByName_500("john"); StubOpenStack.mockOpenStackGetRoles_200("OS-KSADM"); - msoKeystoneUtils.createTenant("tenant", "regionOne", new HashMap<>(), true); + msoKeystoneUtils.createTenant("tenant", "Test", new HashMap<>(), true); } @Test public void queryTenantTest() throws Exception { StubOpenStack.mockOpenStackGetTenantById("tenantId"); - MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "regionOne"); + MsoTenant msoTenant = msoKeystoneUtils.queryTenant("tenantId", "MTN13"); Assert.assertEquals("testingTenantName", msoTenant.getTenantName()); } @@ -86,7 +86,7 @@ public class MsoKeystoneUtilsTest extends BaseTest { public void queryTenantByNameTest() throws Exception { StubOpenStack.mockOpenStackGetTenantByName("tenant"); - MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "regionOne"); + MsoTenant msoTenant = msoKeystoneUtils.queryTenantByName("tenant", "MTN13"); Assert.assertEquals("testingTenantName", msoTenant.getTenantName()); } @@ -95,7 +95,7 @@ public class MsoKeystoneUtilsTest extends BaseTest { public void deleteTenantTest() throws Exception { StubOpenStack.mockOpenStackGetTenantById("tenantId"); StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId"); - boolean result = msoKeystoneUtils.deleteTenant("tenantId", "regionOne"); + boolean result = msoKeystoneUtils.deleteTenant("tenantId", "MTN13"); Assert.assertTrue(result); } @@ -104,7 +104,7 @@ public class MsoKeystoneUtilsTest extends BaseTest { public void deleteTenantByNameTest() throws Exception { StubOpenStack.mockOpenStackGetTenantByName("tenant"); StubOpenStack.mockOpenStackDeleteTenantById_200("tenantId"); - boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "regionOne"); + boolean result = msoKeystoneUtils.deleteTenantByName("tenant", "MTN13"); Assert.assertTrue(result); } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java index 9f8b51a3b7..0442d4d635 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoNeutronUtilsTest.java @@ -50,14 +50,14 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void createNetworkTest_OpenStackBaseException() throws Exception { expectedException.expect(MsoException.class); - msoNeutronUtils.createNetwork("regionOne", "tenantId", + msoNeutronUtils.createNetwork("MTN13", "tenantId", MsoNeutronUtils.NetworkType.PROVIDER,"networkName", "PROVIDER", vlans); } @Test public void createNetworkTest_NetworkTypeAsMultiProvider() throws Exception { StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json"); - NetworkInfo networkInfo = msoNeutronUtils.createNetwork("regionOne", "tenantId", + NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId", MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"networkName","PROVIDER", vlans); Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId()); @@ -66,7 +66,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void createNetworkTest() throws Exception { StubOpenStack.mockOpenstackPostNetwork("OpenstackCreateNeutronNetworkResponse.json"); - NetworkInfo networkInfo = msoNeutronUtils.createNetwork("regionOne", "tenantId", + NetworkInfo networkInfo = msoNeutronUtils.createNetwork("MTN13", "tenantId", MsoNeutronUtils.NetworkType.PROVIDER,"networkName","PROVIDER", vlans); Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId()); @@ -75,14 +75,14 @@ public class MsoNeutronUtilsTest extends BaseTest{ @Test public void queryNetworkTest() throws Exception { StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); - NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne"); + NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); Assert.assertEquals("net1",networkInfo.getName()); } @Test public void queryNetworkTest_404() throws Exception { - NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne"); + NetworkInfo networkInfo = msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); Assert.assertNull(networkInfo); } @@ -90,7 +90,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ public void queryNetworkTest_500() throws Exception { expectedException.expect(MsoException.class); StubOpenStack.mockOpenStackGetNeutronNetwork_500("43173f6a-d699-414b-888f-ab243dda6dfe"); - msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne"); + msoNeutronUtils.queryNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); } @@ -98,7 +98,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ public void deleteNetworkkTest() throws Exception { StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); StubOpenStack.mockOpenStackDeleteNeutronNetwork("43173f6a-d699-414b-888f-ab243dda6dfe"); - Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","regionOne"); + Boolean result = msoNeutronUtils.deleteNetwork("43173f6a-d699-414b-888f-ab243dda6dfe", "tenantId","MTN13"); Assert.assertTrue(result); } @@ -107,7 +107,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ public void updateNetworkTest() throws Exception { StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); - NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("regionOne", "tenantId", + NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId", "43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.PROVIDER,"PROVIDER", vlans); Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId()); @@ -117,7 +117,7 @@ public class MsoNeutronUtilsTest extends BaseTest{ public void updateNetworkTest_NetworkTypeAsMultiProvider() throws Exception { StubOpenStack.mockOpenStackGetNeutronNetwork("GetNeutronNetwork.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); StubOpenStack.mockOpenstackPutNetwork("OpenstackCreateNeutronNetworkResponse.json", "43173f6a-d699-414b-888f-ab243dda6dfe"); - NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("regionOne", "tenantId", + NetworkInfo networkInfo = msoNeutronUtils.updateNetwork("MTN13", "tenantId", "43173f6a-d699-414b-888f-ab243dda6dfe",MsoNeutronUtils.NetworkType.MULTI_PROVIDER,"PROVIDER", vlans); Assert.assertEquals("2a4017ef-31ff-496a-9294-e96ecc3bc9c9",networkInfo.getId()); diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json index 7153f8b672..f1c08cc093 100644 --- a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json +++ b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json @@ -12,7 +12,7 @@ "name": null, "endpoints": [ { - "region": "regionOne", + "region": "mtn13", "publicURL": "port", "internalURL": null, "adminURL": null @@ -25,7 +25,7 @@ "name": null, "endpoints": [ { - "region": "regionOne", + "region": "mtn13", "publicURL": "port", "internalURL": null, "adminURL": null @@ -38,7 +38,7 @@ "name": null, "endpoints": [ { - "region": "regionOne", + "region": "mtn13", "publicURL": "port", "internalURL": null, "adminURL": null diff --git a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml index b584088587..f9467d3c12 100644 --- a/adapters/mso-adapter-utils/src/test/resources/application-test.yaml +++ b/adapters/mso-adapter-utils/src/test/resources/application-test.yaml @@ -1,12 +1,5 @@ # will be used as entry in DB to say SITE OFF/ON for healthcheck # MSO Properties go here -mso: - catalog: - db: - spring: - endpoint: "http://localhost:" - db: - auth: Basic YnBlbDptc28tZGItMTUwNyE= cloud_config: identity_services: MT_KEYSTONE: @@ -48,3 +41,51 @@ adapters: orm_url_replace_with_this: "7080" quota_value: "10" set_default_quota: "false" + +server-port: 8080 +ssl-enable: false +tomcat: + max-threads: 50 +mso: + logPath: logs + catalog: + db: + spring: + endpoint: http://localhost:${wiremock.server.port} + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + site-name: localDevEnv + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 +spring: + datasource: + url: jdbc:mariadb://localhost:3307/catalogdb + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + +mariaDB4j: + dataDir: + port: 3307 + databaseName: catalogdb + + +#Actuator +management: + endpoints: + enabled-by-default: false + endpoint: + info: + enabled: true
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/resources/data.sql b/adapters/mso-adapter-utils/src/test/resources/data.sql new file mode 100644 index 0000000000..5e0e558291 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/resources/data.sql @@ -0,0 +1,3 @@ +INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `CREATION_TIMESTAMP`, `UPDATE_TIMESTAMP`) VALUES ('mtn13', 'http://localhost:28090/v2.0', 'm93945', '93937EA01B94A10A49279D4572B48369', NULL, '2018-07-17 14:05:08', '2018-07-17 14:05:08'); + +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');
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java index 6b0d901cb4..63ef8e6dd0 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java @@ -24,13 +24,12 @@ package org.onap.so.adapters.catalogdb.catalogrest; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; - -import org.onap.so.logger.MsoLogger; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; public abstract class CatalogQuery { - protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogQuery.class); + protected static Logger logger = LoggerFactory.getLogger(CatalogQuery.class); private static final boolean IS_EMBED = true; public abstract String JSON2(boolean isArray, boolean isEmbed); @@ -48,21 +47,20 @@ public abstract class CatalogQuery { } protected String setTemplate(String template, Map<String, String> valueMap) { - LOGGER.debug("CatalogQuery setTemplate"); StringBuffer result = new StringBuffer(); String pattern = "<.*>"; Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(template); - LOGGER.debug("CatalogQuery template:" + template); + logger.debug("CatalogQuery template: {}", template); while (m.find()) { String key = template.substring(m.start() + 1, m.end() - 1); - LOGGER.debug("CatalogQuery key:" + key + " contains key? " + valueMap.containsKey(key)); + logger.debug("CatalogQuery key: {} contains key? {}", key , valueMap.containsKey(key)); m.appendReplacement(result, valueMap.getOrDefault(key, "\"TBD\"")); } m.appendTail(result); - LOGGER.debug("CatalogQuery return:" + result.toString()); + logger.debug("CatalogQuery return: {}", result.toString()); return result.toString(); } @@ -76,8 +74,7 @@ public abstract class CatalogQuery { jsonString = mapper.writeValueAsString(this); } catch (Exception e) { - LOGGER.debug("Exception:", e); - LOGGER.debug ("jsonString exception:"+e.getMessage()); + logger.error("Error converting to JSON" , e); jsonString = "invalid"; //throws instead? } return jsonString; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java index 67f337e039..fbaf12b337 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java @@ -27,13 +27,14 @@ import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import org.onap.so.logger.MsoLogger; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; public abstract class CatalogQueryExceptionCommon { private String messageId; - protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogQueryExceptionCommon.class); + protected static Logger logger = LoggerFactory.getLogger(CatalogQueryExceptionCommon.class); public CatalogQueryExceptionCommon() { messageId = null; } public CatalogQueryExceptionCommon(String messageId) { this.messageId = messageId; } @@ -49,7 +50,7 @@ public abstract class CatalogQueryExceptionCommon { jsonString = mapper.writeValueAsString(this); return jsonString; } catch (Exception e) { - LOGGER.debug ("Exception:", e); + logger.error ("Exception:", e); return ""; } } @@ -63,7 +64,7 @@ public abstract class CatalogQueryExceptionCommon { marshaller.marshal(this, bs); return bs.toString(); } catch (Exception e) { - LOGGER.debug ("Exception:", e); + logger.error ("Exception:", e); return ""; } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 2deada5754..3dca6a395c 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -24,19 +24,17 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.xml.bind.annotation.XmlRootElement; - import org.onap.so.db.catalog.beans.AllottedResourceCustomization; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @XmlRootElement(name = "serviceAllottedResources") public class QueryAllottedResourceCustomization extends CatalogQuery { - protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,QueryAllottedResourceCustomization.class); + protected static Logger logger = LoggerFactory.getLogger(QueryAllottedResourceCustomization.class); private List<AllottedResourceCustomization> allottedResourceCustomization; - private final String template = + private static final String TEMPLATE = "\t{\n"+ -// "\t{ \"allottedResource\" : {\n"+ "\t\t\"modelInfo\" : {\n"+ "\t\t\t\"modelName\" : <MODEL_NAME>,\n"+ "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ @@ -55,14 +53,24 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { "\t\t\"nfType\" : <NF_TYPE>,\n"+ "\t\t\"nfRole\" : <NF_ROLE>,\n"+ "\t\t\"nfNamingCode\" : <NF_NAMING_CODE>\n"+ - "\t}"; -// "\t}}"; + "\t}"; - public QueryAllottedResourceCustomization() { super(); allottedResourceCustomization = new ArrayList<>(); } - public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { allottedResourceCustomization = vlist; } + public QueryAllottedResourceCustomization() { + super(); + allottedResourceCustomization = new ArrayList<>(); + } + + public QueryAllottedResourceCustomization(List<AllottedResourceCustomization> vlist) { + allottedResourceCustomization = vlist; + } - public List<AllottedResourceCustomization> getServiceAllottedResources(){ return this.allottedResourceCustomization; } - public void setServiceAllottedResources(List<AllottedResourceCustomization> v) { this.allottedResourceCustomization = v; } + public List<AllottedResourceCustomization> getServiceAllottedResources(){ + return this.allottedResourceCustomization; + } + + public void setServiceAllottedResources(List<AllottedResourceCustomization> v) { + this.allottedResourceCustomization = v; + } @Override public String toString () { @@ -72,7 +80,10 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { int i = 1; for (AllottedResourceCustomization o : allottedResourceCustomization) { sb.append(i).append("\t"); - if (!first) sb.append("\n"); first = false; + if (!first) + sb.append("\n"); + + first = false; sb.append(o); } return sb.toString(); @@ -81,15 +92,20 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { StringBuilder sb = new StringBuilder(); - if (!isEmbed && isArray) sb.append("{ "); - if (isArray) sb.append("\"serviceAllottedResources\": ["); + if (!isEmbed && isArray) + sb.append("{ "); + if (isArray) + sb.append("\"serviceAllottedResources\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; if (this.allottedResourceCustomization != null) { for (AllottedResourceCustomization o : allottedResourceCustomization) { - if (first) sb.append("\n"); first = false; + if (first) + sb.append("\n"); + + first = false; boolean arNull = o.getAllottedResource() == null ? true : false; @@ -110,13 +126,19 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_NAME", o.getProvidingServiceModelName()); - sb.append(sep).append(this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; } } - if (!first) sb.append("\n"); - if (isArray) sb.append("]"); - if (!isEmbed && isArray) sb.append("}"); + if (!first) + sb.append("\n"); + + if (isArray) + sb.append("]"); + + if (!isEmbed && isArray) + sb.append("}"); + return sb.toString(); } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java index e0d187500e..8670b78e15 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java @@ -23,7 +23,8 @@ import java.util.HashMap; import java.util.Map; import org.onap.so.db.catalog.beans.Recipe; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -38,6 +39,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; * @version ONAP Beijing Release 2018-02-28 */ public class QueryResourceRecipe extends CatalogQuery{ + protected static Logger logger = LoggerFactory.getLogger(QueryResourceRecipe.class); private Recipe resourceRecipe; @@ -66,8 +68,7 @@ public class QueryResourceRecipe extends CatalogQuery{ try { jsonStr = mapper.writeValueAsString(valueMap); } catch(JsonProcessingException e) { - - e.printStackTrace(); + logger.error("Error creating JSON", e); } return jsonStr; } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java index d49f8965fb..c7ae137759 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java @@ -35,13 +35,7 @@ import org.onap.so.db.catalog.beans.ToscaCsar; */ public class QueryServiceCsar extends CatalogQuery{ - private ToscaCsar toscaCsar; - - public QueryServiceCsar(ToscaCsar toscaCsar){ - this.toscaCsar = toscaCsar; - } - - private final String template = + private static final String TEMPLATE = "\t{\n"+ "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"+ "\t\t\"name\" : <NAME>,\n"+ @@ -51,9 +45,14 @@ public class QueryServiceCsar extends CatalogQuery{ "\t\t\"description\" : <DESCRIPTION>\n"+ "\t}"; + private ToscaCsar toscaCsar; + + public QueryServiceCsar(ToscaCsar toscaCsar){ + this.toscaCsar = toscaCsar; + } + @Override public String toString() { - return toscaCsar.toString(); } @@ -66,7 +65,7 @@ public class QueryServiceCsar extends CatalogQuery{ put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum()); put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl()); put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription()); - return this.setTemplate(template, valueMap); + return this.setTemplate(TEMPLATE, valueMap); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java index 12ba4c0598..b89c6275d4 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java @@ -32,7 +32,7 @@ import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder; public class QueryServiceMacroHolder extends CatalogQuery { private ServiceMacroHolder serviceMacroHolder; private static final String LINE_BEGINNING = "(?m)^"; - private static final String template = + private static final String TEMPLATE = "{ \"serviceResources\" : {\n"+ "\t\"modelInfo\" : {\n"+ "\t\t\"modelName\" : <SERVICE_MODEL_NAME>,\n"+ @@ -90,7 +90,7 @@ public class QueryServiceMacroHolder extends CatalogQuery { subitem = new QueryAllottedResourceCustomization(service.getAllottedCustomizations()).JSON2(true, true); valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll(LINE_BEGINNING, "\t")); - buf.append(this.setTemplate(template, valueMap)); + buf.append(this.setTemplate(TEMPLATE, valueMap)); return buf.toString(); } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java index b213d33af0..4afc24ea10 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java @@ -29,14 +29,15 @@ import javax.xml.bind.annotation.XmlRootElement; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @XmlRootElement(name = "serviceNetworks") public class QueryServiceNetworks extends CatalogQuery { - protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,QueryServiceNetworks.class); + protected static Logger logger = LoggerFactory.getLogger(QueryServiceNetworks.class); private List<NetworkResourceCustomization> serviceNetworks; - private final String template = + private static final String TEMPLATE = "\t{\n"+ -// "\t{ \"networkResource\" : {\n"+ "\t\t\"modelInfo\" : {\n"+ "\t\t\t\"modelName\" : <MODEL_NAME>,\n"+ "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ @@ -51,16 +52,19 @@ public class QueryServiceNetworks extends CatalogQuery { "\t\t\"networkRole\" : <NETWORK_ROLE>,\n"+ "\t\t\"networkScope\" : <NETWORK_SCOPE>\n"+ "\t}"; -// "\t}}"; - public QueryServiceNetworks() { super(); serviceNetworks = new ArrayList<>(); } + public QueryServiceNetworks() { + super(); + serviceNetworks = new ArrayList<>(); + } + public QueryServiceNetworks(List<NetworkResourceCustomization> vlist) { - LOGGER.debug ("QueryServiceNetworks:"); + logger.debug ("QueryServiceNetworks:"); serviceNetworks = new ArrayList<>(); for (NetworkResourceCustomization o : vlist) { - LOGGER.debug (o.toString()); + if(logger.isDebugEnabled()) + logger.debug (o.toString()); serviceNetworks.add(o); - LOGGER.debug ("-------------------"); } } @@ -75,7 +79,9 @@ public class QueryServiceNetworks extends CatalogQuery { int i = 1; for (NetworkResourceCustomization o : serviceNetworks) { sb.append(i).append("\t"); - if (!first) sb.append("\n"); first = false; + if (!first) + sb.append("\n"); + first = false; sb.append(o); } return sb.toString(); @@ -84,15 +90,19 @@ public class QueryServiceNetworks extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { StringBuilder sb = new StringBuilder(); - if (!isEmbed && isArray) sb.append("{ "); - if (isArray) sb.append("\"serviceNetworks\": ["); + if (!isEmbed && isArray) + sb.append("{ "); + if (isArray) + sb.append("\"serviceNetworks\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (NetworkResourceCustomization o : serviceNetworks) { - if (first) sb.append("\n"); first = false; + if (first) + sb.append("\n"); + first = false; boolean nrNull = o.getNetworkResource() == null ? true : false; put(valueMap, "MODEL_NAME", nrNull ? null : o.getNetworkResource().getModelName()); put(valueMap, "MODEL_UUID", nrNull ? null : o.getNetworkResource().getModelUUID()); @@ -106,12 +116,15 @@ public class QueryServiceNetworks extends CatalogQuery { put(valueMap, "NETWORK_SCOPE", o.getNetworkScope()); put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology()); - sb.append(sep).append(this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; } - if (!first) sb.append("\n"); - if (isArray) sb.append("]"); - if (!isEmbed && isArray) sb.append("}"); + if (!first) + sb.append("\n"); + if (isArray) + sb.append("]"); + if (!isEmbed && isArray) + sb.append("}"); return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index ff52daf880..82b6aa2aeb 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -29,11 +29,15 @@ import java.util.Map; import javax.xml.bind.annotation.XmlRootElement; import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @XmlRootElement(name = "serviceVnfs") public class QueryServiceVnfs extends CatalogQuery { + protected static Logger logger = LoggerFactory.getLogger(QueryServiceVnfs.class); + private List<VnfResourceCustomization> serviceVnfs; - private final String template = + private static final String TEMPLATE = "\n"+ "\t{ \"modelInfo\" : {\n"+ "\t\t\"modelName\" : <MODEL_NAME>,\n"+ @@ -52,15 +56,17 @@ public class QueryServiceVnfs extends CatalogQuery { "<_VFMODULES_>\n" + "\t}"; - public QueryServiceVnfs() { super(); serviceVnfs = new ArrayList<>(); } - public QueryServiceVnfs(List<VnfResourceCustomization> vlist) { - LOGGER.debug ("QueryServiceVnfs:"); + public QueryServiceVnfs() { + super(); + serviceVnfs = new ArrayList<>(); + } + + public QueryServiceVnfs(List<VnfResourceCustomization> vlist) { serviceVnfs = new ArrayList<>(); for (VnfResourceCustomization o : vlist) { - LOGGER.debug ("-- o is a serviceVnfs ----"); - LOGGER.debug (o.toString()); - serviceVnfs.add(o); - LOGGER.debug ("-------------------"); + if(logger.isDebugEnabled()) + logger.debug (o.toString()); + serviceVnfs.add(o); } } @@ -75,7 +81,9 @@ public class QueryServiceVnfs extends CatalogQuery { int i = 1; for (VnfResourceCustomization o : serviceVnfs) { sb.append(i).append("\t"); - if (!first) sb.append("\n"); first = false; + if (!first) + sb.append("\n"); + first = false; sb.append(o); } return sb.toString(); @@ -84,14 +92,18 @@ public class QueryServiceVnfs extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { StringBuilder sb = new StringBuilder(); - if (!isEmbed && isArray) sb.append("{ "); - if (isArray) sb.append("\"serviceVnfs\": ["); + if (!isEmbed && isArray) + sb.append("{ "); + if (isArray) + sb.append("\"serviceVnfs\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VnfResourceCustomization o : serviceVnfs) { - if (first) sb.append("\n"); first = false; + if (first) + sb.append("\n"); + first = false; boolean vrNull = o.getVnfResources() == null ? true : false; @@ -111,12 +123,15 @@ public class QueryServiceVnfs extends CatalogQuery { String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true); valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); - sb.append(sep).append(this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; } - if (!first) sb.append("\n"); - if (isArray) sb.append("]"); - if (!isEmbed && isArray) sb.append("}"); + if (!first) + sb.append("\n"); + if (isArray) + sb.append("]"); + if (!isEmbed && isArray) + sb.append("}"); return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java index e5fa14376b..3680c59dca 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java @@ -33,9 +33,8 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; @XmlRootElement(name = "vfModules") public class QueryVfModule extends CatalogQuery { private List<VfModuleCustomization> vfModules; - private final String template = + private static final String TEMPLATE = "\t{\n"+ -// "\t{ \"vfModule\" : { \n"+ "\t\t\"modelInfo\" : { \n"+ "\t\t\t\"modelName\" : <MODEL_NAME>,\n"+ "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"+ @@ -48,20 +47,21 @@ public class QueryVfModule extends CatalogQuery { "\t\t\"initialCount\" : <INITIAL_COUNT>,\n"+ "\t\t\"hasVolumeGroup\" : <HAS_VOLUME_GROUP>\n"+ "\t}"; -// "\t}}"; - public QueryVfModule() { super(); vfModules = new ArrayList<>(); } - public QueryVfModule(List<VfModuleCustomization> vlist) { - LOGGER.debug ("QueryVfModule:"); - vfModules = new ArrayList<>(); - if (vlist != null) { - for (VfModuleCustomization o : vlist) { - LOGGER.debug ("-- o is a vfModules ----"); - LOGGER.debug (o.toString()); - vfModules.add(o); - LOGGER.debug ("-------------------"); - } + public QueryVfModule() { + super(); + vfModules = new ArrayList<>(); } + + public QueryVfModule(List<VfModuleCustomization> vlist) { + vfModules = new ArrayList<>(); + if (vlist != null) { + for (VfModuleCustomization o : vlist) { + if(logger.isDebugEnabled()) + logger.debug (o.toString()); + vfModules.add(o); + } + } } public List<VfModuleCustomization> getVfModule(){ return this.vfModules; } @@ -75,7 +75,9 @@ public class QueryVfModule extends CatalogQuery { int i = 1; for (VfModuleCustomization o : vfModules) { sb.append(i).append("\t"); - if (!first) sb.append("\n"); first = false; + if (!first) + sb.append("\n"); + first = false; sb.append(o); } return sb.toString(); @@ -84,14 +86,18 @@ public class QueryVfModule extends CatalogQuery { @Override public String JSON2(boolean isArray, boolean isEmbed) { StringBuilder sb = new StringBuilder(); - if (!isEmbed && isArray) sb.append("{ "); - if (isArray) sb.append("\"vfModules\": ["); + if (!isEmbed && isArray) + sb.append("{ "); + if (isArray) + sb.append("\"vfModules\": ["); Map<String, String> valueMap = new HashMap<>(); String sep = ""; boolean first = true; for (VfModuleCustomization o : vfModules) { - if (first) sb.append("\n"); first = false; + if (first) + sb.append("\n"); + first = false; boolean vfNull = o.getVfModule() == null ? true : false; boolean hasVolumeGroup = false; @@ -110,12 +116,15 @@ public class QueryVfModule extends CatalogQuery { put(valueMap, "INITIAL_COUNT", o.getInitialCount()); put(valueMap, "HAS_VOLUME_GROUP", new Boolean(hasVolumeGroup)); - sb.append(sep).append(this.setTemplate(template, valueMap)); + sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; } - if (!first) sb.append("\n"); - if (isArray) sb.append("]"); - if (!isEmbed && isArray) sb.append("}"); + if (!first) + sb.append("\n"); + if (isArray) + sb.append("]"); + if (!isEmbed && isArray) + sb.append("}"); return sb.toString(); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index 0eeaa6a72c..a69e66cc69 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -49,7 +49,7 @@ We might be able to derive it's value from the current vnf-type (using the "midd min and initial counts can be 0. max can be null to indicate no maximum. Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table. -*/ + */ import java.util.ArrayList; import java.util.List; @@ -101,6 +101,8 @@ import org.onap.so.db.catalog.data.repository.VnfResourceRepository; import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -113,488 +115,481 @@ import org.springframework.transaction.annotation.Transactional; @Path("/{version: v[0-9]+}") @Component public class CatalogDbAdapterRest { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogDbAdapterRest.class); - private static final boolean IS_ARRAY = true; - - @Autowired - private VnfCustomizationRepository vnfCustomizationRepo; - - @Autowired - private ServiceRepository serviceRepo; - - @Autowired - private NetworkResourceCustomizationRepository networkCustomizationRepo; - - @Autowired - private NetworkResourceRepository networkResourceRepo; - - @Autowired - private AllottedResourceCustomizationRepository allottedCustomizationRepo; - - @Autowired - private ToscaCsarRepository toscaCsarRepo; - - @Autowired - private VFModuleRepository vfModuleRepo; - - @Autowired - private VnfRecipeRepository vnfRecipeRepo; - - @Autowired - private NetworkRecipeRepository networkRecipeRepo; - - @Autowired - private ArRecipeRepository arRecipeRepo; - - @Autowired - private VnfResourceRepository vnfResourceRepo; - - @Autowired - private AllottedResourceRepository arResourceRepo; - - private static final String NO_MATCHING_PARAMETERS = "no matching parameters"; - - public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) { - return Response - .status(respStatus) - //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {}) - .entity(qryResp.toJsonString(version, isArray)) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - } - - @GET - @Path("vnfResources/{vnfModelCustomizationUuid}") - @Transactional( readOnly = true) - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public Response serviceVnfs ( - @PathParam("version") String version, - @PathParam("vnfModelCustomizationUuid") String vnfUuid - ) { - return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null); - } - - @GET - @Path("serviceVnfs") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional( readOnly = true) - public Response serviceVnfs( - @PathParam("version") String version, - @QueryParam("vnfModelCustomizationUuid") String vnfUuid, - @QueryParam("serviceModelUuid") String smUuid, - @QueryParam("serviceModelInvariantUuid") String smiUuid, - @QueryParam("serviceModelVersion") String smVer, - @QueryParam("serviceModelName") String smName - ) { - return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName); - } - - public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName) { - QueryServiceVnfs qryResp = null; - int respStatus = HttpStatus.SC_OK; - List<VnfResourceCustomization> ret = new ArrayList<>(); - Service service = null; - try { - if (vnfUuid != null && !"".equals(vnfUuid)) - ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid); - else if (serviceModelUUID != null && !"".equals(serviceModelUUID)) - service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID); - else if (smiUuid != null && !"".equals(smiUuid)) - if (smVer != null && !"".equals(smVer)) - service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer,smiUuid); - else - service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid); - else if (smName != null && !"".equals(smName)) { - if (smVer != null && !"".equals(smVer)) - service = serviceRepo.findByModelNameAndModelVersion(smName, smVer); - else - service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName); - } - else { - throw(new Exception(NO_MATCHING_PARAMETERS)); - } - - if (service == null && ret.isEmpty()) { - respStatus = HttpStatus.SC_NOT_FOUND; - qryResp = new QueryServiceVnfs(); - }else if( service == null && !ret.isEmpty()){ - qryResp = new QueryServiceVnfs(ret); - } else if (service != null) { - qryResp = new QueryServiceVnfs(service.getVnfCustomizations()); - } - LOGGER.debug ("serviceVnfs qryResp="+ qryResp); - return respond(version, respStatus, isArray, qryResp); - } catch (Exception e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, "", "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) {}) - .build(); - } - } - - @GET - @Path("networkResources/{networkModelCustomizationUuid}") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional( readOnly = true) - public Response serviceNetworks ( - @PathParam("version") String version, - @PathParam("networkModelCustomizationUuid") String nUuid - ) { - return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null); - } - - @GET - @Path("serviceNetworks") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional( readOnly = true) - public Response serviceNetworks ( - @PathParam("version") String version, - @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid, - @QueryParam("networkType") String networkType, - @QueryParam("networkModelName") String networkModelName, - @QueryParam("serviceModelUuid") String serviceModelUuid, - @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid, - @QueryParam("serviceModelVersion") String serviceModelVersion, - @QueryParam("networkModelVersion") String networkModelVersion - ) { - if (networkModelName != null && !"".equals(networkModelName)) { - networkType = networkModelName; - } - return serviceNetworksImpl (version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid, serviceModelInvariantUuid, serviceModelVersion); - } - - public Response serviceNetworksImpl (String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) { - QueryServiceNetworks qryResp; - int respStatus = HttpStatus.SC_OK; - String uuid = ""; - List<NetworkResourceCustomization> ret = new ArrayList<>(); - Service service = null; - - try{ - if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) { - uuid = networkModelCustomizationUuid; - ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid); - }else if (networkType != null && !"".equals(networkType)) { - uuid = networkType; - NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType); - if(networkResources != null) - ret=networkResources.getNetworkResourceCustomization(); - } - else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) { - uuid = serviceModelInvariantUuid; - if (serviceModelVersion != null && !"".equals(serviceModelVersion)) { - service = serviceRepo.findByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid); - } - else { - service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); - } - }else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) { - uuid = serviceModelUuid; - service = serviceRepo.findOneByModelUUID(serviceModelUuid); - } - else { - throw(new Exception(NO_MATCHING_PARAMETERS)); - } - - if(service != null) - ret = service.getNetworkCustomizations(); - - if (ret == null || ret.isEmpty()) { - LOGGER.debug ("serviceNetworks not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - qryResp = new QueryServiceNetworks(); - } else { - LOGGER.debug ("serviceNetworks found"); - qryResp = new QueryServiceNetworks(ret); - LOGGER.debug ("serviceNetworks qryResp="+ qryResp); - } - LOGGER.debug ("Query serviceNetworks exit"); - return respond(version, respStatus, isArray, qryResp); - } catch (Exception e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) {}) - .build(); - } - } - - @GET - @Path("serviceResources") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional(readOnly = true) - public Response serviceResources( - @PathParam("version") String version, - @QueryParam("serviceModelUuid") String modelUUID, - @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID, - @QueryParam("serviceModelVersion") String modelVersion) { - QueryServiceMacroHolder qryResp; - int respStatus = HttpStatus.SC_OK; - String uuid = ""; - ServiceMacroHolder ret = new ServiceMacroHolder(); - - try{ - if (modelUUID != null && !"".equals(modelUUID)) { - uuid = modelUUID; - LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid); - Service serv =serviceRepo.findOneByModelUUID(uuid); - ret.setService(serv); - } - else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) { - uuid = modelInvariantUUID; - if (modelVersion != null && !"".equals(modelVersion)) { - LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ modelVersion); - Service serv = serviceRepo.findByModelVersionAndModelInvariantUUID(modelVersion, uuid); - ret.setService(serv); - } - else { - LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid); - Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); - ret.setService(serv); - } - } - else { - throw(new Exception(NO_MATCHING_PARAMETERS)); - } - - if (ret.getService() == null) { - LOGGER.debug ("serviceMacroHolder not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - qryResp = new QueryServiceMacroHolder(); - } else { - LOGGER.debug ("serviceMacroHolder found"); - qryResp = new QueryServiceMacroHolder(ret); - LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp); - } - LOGGER.debug ("Query serviceMacroHolder exit"); - return respond(version, respStatus, IS_ARRAY, qryResp); - } catch (Exception e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp){} ) - .build(); - } - } - - - @GET - @Path("allottedResources/{arModelCustomizationUuid}") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional( readOnly = true) - public Response serviceAllottedResources ( - @PathParam("version") String version, - @PathParam("arModelCustomizationUuid") String aUuid - ) { - return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null); - } - - @GET - @Path("serviceAllottedResources") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional( readOnly = true) - public Response serviceAllottedResources( - @PathParam("version") String version, - @QueryParam("serviceModelUuid") String smUuid, - @QueryParam("serviceModelInvariantUuid") String smiUuid, - @QueryParam("serviceModelVersion") String smVer, - @QueryParam("arModelCustomizationUuid") String aUuid - ) { - return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer); - } - - public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) { - QueryAllottedResourceCustomization qryResp; - int respStatus = HttpStatus.SC_OK; - String uuid = ""; - List<AllottedResourceCustomization> ret = new ArrayList<>(); - Service service = null; - try{ - if (smUuid != null && !"".equals(smUuid)) { - uuid = smUuid; - service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid); - } - else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) { - uuid = serviceModelInvariantUuid; - if (smVer != null && !"".equals(smVer)) { - service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer, uuid); - } - else { - service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); - } - } - else if (aUuid != null && !"".equals(aUuid)) { - uuid = aUuid; - ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid); - } - else { - throw(new Exception(NO_MATCHING_PARAMETERS)); - } - - if(service != null) - ret=service.getAllottedCustomizations(); - - if (ret == null || ret.isEmpty()) { - LOGGER.debug ("AllottedResourceCustomization not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - qryResp = new QueryAllottedResourceCustomization(); - } else { - qryResp = new QueryAllottedResourceCustomization(ret); - LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp); - } - return respond(version, respStatus, isArray, qryResp); - } catch (Exception e) { - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) {}) - .build(); - } - } - - @GET - @Path("vfModules") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - @Transactional( readOnly = true) - public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) { - QueryVfModule qryResp; - int respStatus = HttpStatus.SC_OK; - List<VfModuleCustomization> ret = null; - try{ - if(vfModuleModelName != null && !"".equals(vfModuleModelName)){ - VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName); - if(vfModule != null) - ret = vfModule.getVfModuleCustomization(); - }else{ - throw(new Exception(NO_MATCHING_PARAMETERS)); - } - - if(ret == null || ret.isEmpty()){ - LOGGER.debug ("vfModules not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - qryResp = new QueryVfModule(); - }else{ - qryResp = new QueryVfModule(ret); - LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false)); - } - return Response - .status(respStatus) - .entity(qryResp.JSON2(false, false)) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - }catch(Exception e){ - LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) {}) - .build(); - } - } - /** - * Get the tosca csar info from catalog - * <br> - * - * @param smUuid service model uuid - * @return the tosca csar information of the serivce. - * @since ONAP Beijing Release - */ - @GET - @Path("serviceToscaCsar") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) { - int respStatus = HttpStatus.SC_OK; - String entity = ""; - try { - if (smUuid != null && !"".equals(smUuid)) { - LOGGER.debug("Query Csar by service model uuid: " + smUuid); - ToscaCsar toscaCsar = toscaCsarRepo.findOne(smUuid); - if (toscaCsar != null) { - QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar); - entity = serviceCsar.JSON2(false, false); - } else { - respStatus = HttpStatus.SC_NOT_FOUND; - } - } else { - throw (new Exception("Incoming parameter is null or blank")); - } - LOGGER.debug("Query Csar exit"); - return Response - .status(respStatus) - .entity(entity) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - } catch (Exception e) { - LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar", - MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), - CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) { - }) - .build(); - } - } - - /** - * Get the resource recipe info from catalog - * <br> - * - * @param rmUuid resource model uuid - * @return the recipe information of the resource. - * @since ONAP Beijing Release - */ - @GET - @Path("resourceRecipe") - @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) { - int respStatus = HttpStatus.SC_OK; - String entity = ""; - try { - if (rmUuid != null && !"".equals(rmUuid)) { - LOGGER.debug("Query recipe by resource model uuid: " + rmUuid); - //check vnf and network and ar, the resource could be any resource. - VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid); - Recipe recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vnf.getModelName(), action); - if (null == recipe) { - NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); - recipe = networkRecipeRepo.findByModelNameAndAction(nResource.getModelName(), action); - } - if (null == recipe) { - AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid); - recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action); - } - if (recipe != null) { - QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); - entity = resourceRecipe.JSON2(false, false); - } else { - respStatus = HttpStatus.SC_NOT_FOUND; - } - } else { - throw (new Exception("Incoming parameter is null or blank")); - } - LOGGER.debug("Query recipe exit"); - return Response - .status(respStatus) - .entity(entity) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - } catch (Exception e) { - LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe", - MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e); - CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), - CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<CatalogQueryException>(excResp) { - }) - .build(); - } - } + protected static Logger logger = LoggerFactory.getLogger(CatalogDbAdapterRest.class); + private static final boolean IS_ARRAY = true; + + @Autowired + private VnfCustomizationRepository vnfCustomizationRepo; + + @Autowired + private ServiceRepository serviceRepo; + + @Autowired + private NetworkResourceCustomizationRepository networkCustomizationRepo; + + @Autowired + private NetworkResourceRepository networkResourceRepo; + + @Autowired + private AllottedResourceCustomizationRepository allottedCustomizationRepo; + + @Autowired + private ToscaCsarRepository toscaCsarRepo; + + @Autowired + private VFModuleRepository vfModuleRepo; + + @Autowired + private VnfRecipeRepository vnfRecipeRepo; + + @Autowired + private NetworkRecipeRepository networkRecipeRepo; + + @Autowired + private ArRecipeRepository arRecipeRepo; + + @Autowired + private VnfResourceRepository vnfResourceRepo; + + @Autowired + private AllottedResourceRepository arResourceRepo; + + private static final String NO_MATCHING_PARAMETERS = "no matching parameters"; + + public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) { + return Response + .status(respStatus) + //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {}) + .entity(qryResp.toJsonString(version, isArray)) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } + + @GET + @Path("vnfResources/{vnfModelCustomizationUuid}") + @Transactional( readOnly = true) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceVnfs ( + @PathParam("version") String version, + @PathParam("vnfModelCustomizationUuid") String vnfUuid + ) { + return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null); + } + + @GET + @Path("serviceVnfs") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional( readOnly = true) + public Response serviceVnfs( + @PathParam("version") String version, + @QueryParam("vnfModelCustomizationUuid") String vnfUuid, + @QueryParam("serviceModelUuid") String smUuid, + @QueryParam("serviceModelInvariantUuid") String smiUuid, + @QueryParam("serviceModelVersion") String smVer, + @QueryParam("serviceModelName") String smName + ) { + return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName); + } + + public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName) { + QueryServiceVnfs qryResp = null; + int respStatus = HttpStatus.SC_OK; + List<VnfResourceCustomization> ret = new ArrayList<>(); + Service service = null; + try { + if (vnfUuid != null && !"".equals(vnfUuid)) + ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid); + else if (serviceModelUUID != null && !"".equals(serviceModelUUID)) + service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID); + else if (smiUuid != null && !"".equals(smiUuid)) + if (smVer != null && !"".equals(smVer)) + service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer,smiUuid); + else + service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid); + else if (smName != null && !"".equals(smName)) { + if (smVer != null && !"".equals(smVer)) + service = serviceRepo.findByModelNameAndModelVersion(smName, smVer); + else + service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName); + } + else { + throw(new Exception(NO_MATCHING_PARAMETERS)); + } + + if (service == null && ret.isEmpty()) { + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryServiceVnfs(); + }else if( service == null && !ret.isEmpty()){ + qryResp = new QueryServiceVnfs(ret); + } else if (service != null) { + qryResp = new QueryServiceVnfs(service.getVnfCustomizations()); + } + logger.debug ("serviceVnfs qryResp= {}", qryResp); + return respond(version, respStatus, isArray, qryResp); + } catch (Exception e) { + logger.error("Exception - queryServiceVnfs", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + + @GET + @Path("networkResources/{networkModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional( readOnly = true) + public Response serviceNetworks ( + @PathParam("version") String version, + @PathParam("networkModelCustomizationUuid") String nUuid + ) { + return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null); + } + + @GET + @Path("serviceNetworks") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional( readOnly = true) + public Response serviceNetworks ( + @PathParam("version") String version, + @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid, + @QueryParam("networkType") String networkType, + @QueryParam("networkModelName") String networkModelName, + @QueryParam("serviceModelUuid") String serviceModelUuid, + @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid, + @QueryParam("serviceModelVersion") String serviceModelVersion, + @QueryParam("networkModelVersion") String networkModelVersion + ) { + if (networkModelName != null && !"".equals(networkModelName)) { + networkType = networkModelName; + } + return serviceNetworksImpl (version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid, serviceModelInvariantUuid, serviceModelVersion); + } + + public Response serviceNetworksImpl (String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) { + QueryServiceNetworks qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + List<NetworkResourceCustomization> ret = new ArrayList<>(); + Service service = null; + + try{ + if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) { + uuid = networkModelCustomizationUuid; + ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid); + }else if (networkType != null && !"".equals(networkType)) { + uuid = networkType; + NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType); + if(networkResources != null) + ret=networkResources.getNetworkResourceCustomization(); + } + else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) { + uuid = serviceModelInvariantUuid; + if (serviceModelVersion != null && !"".equals(serviceModelVersion)) { + service = serviceRepo.findByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid); + } + else { + service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); + } + }else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) { + uuid = serviceModelUuid; + service = serviceRepo.findOneByModelUUID(serviceModelUuid); + } + else { + throw(new Exception(NO_MATCHING_PARAMETERS)); + } + + if(service != null) + ret = service.getNetworkCustomizations(); + + if (ret == null || ret.isEmpty()) { + logger.debug ("serviceNetworks not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryServiceNetworks(); + } else { + qryResp = new QueryServiceNetworks(ret); + logger.debug ("serviceNetworks found qryResp= {}", qryResp); + } + return respond(version, respStatus, isArray, qryResp); + } catch (Exception e) { + logger.error ("Exception - queryServiceNetworks", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + + @GET + @Path("serviceResources") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional(readOnly = true) + public Response serviceResources( + @PathParam("version") String version, + @QueryParam("serviceModelUuid") String modelUUID, + @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID, + @QueryParam("serviceModelVersion") String modelVersion) { + QueryServiceMacroHolder qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + ServiceMacroHolder ret = new ServiceMacroHolder(); + + try{ + if (modelUUID != null && !"".equals(modelUUID)) { + uuid = modelUUID; + logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: {}" , uuid); + Service serv =serviceRepo.findOneByModelUUID(uuid); + ret.setService(serv); + } + else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) { + uuid = modelInvariantUUID; + if (modelVersion != null && !"".equals(modelVersion)) { + logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}",uuid, modelVersion); + Service serv = serviceRepo.findByModelVersionAndModelInvariantUUID(modelVersion, uuid); + ret.setService(serv); + } + else { + logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: {}" , uuid); + Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); + ret.setService(serv); + } + } + else { + throw(new Exception(NO_MATCHING_PARAMETERS)); + } + + if (ret.getService() == null) { + logger.debug ("serviceMacroHolder not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryServiceMacroHolder(); + } else { + qryResp = new QueryServiceMacroHolder(ret); + logger.debug ("serviceMacroHolder qryResp= {}", qryResp); + } + return respond(version, respStatus, IS_ARRAY, qryResp); + } catch (Exception e) { + logger.error ("Exception - queryServiceMacroHolder", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp){} ) + .build(); + } + } + + + @GET + @Path("allottedResources/{arModelCustomizationUuid}") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional( readOnly = true) + public Response serviceAllottedResources ( + @PathParam("version") String version, + @PathParam("arModelCustomizationUuid") String aUuid + ) { + return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null); + } + + @GET + @Path("serviceAllottedResources") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional( readOnly = true) + public Response serviceAllottedResources( + @PathParam("version") String version, + @QueryParam("serviceModelUuid") String smUuid, + @QueryParam("serviceModelInvariantUuid") String smiUuid, + @QueryParam("serviceModelVersion") String smVer, + @QueryParam("arModelCustomizationUuid") String aUuid + ) { + return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer); + } + + public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) { + QueryAllottedResourceCustomization qryResp; + int respStatus = HttpStatus.SC_OK; + String uuid = ""; + List<AllottedResourceCustomization> ret = new ArrayList<>(); + Service service = null; + try{ + if (smUuid != null && !"".equals(smUuid)) { + uuid = smUuid; + service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid); + } + else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) { + uuid = serviceModelInvariantUuid; + if (smVer != null && !"".equals(smVer)) { + service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer, uuid); + } + else { + service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid); + } + } + else if (aUuid != null && !"".equals(aUuid)) { + uuid = aUuid; + ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid); + } + else { + throw(new Exception(NO_MATCHING_PARAMETERS)); + } + + if(service != null) + ret=service.getAllottedCustomizations(); + + if (ret == null || ret.isEmpty()) { + logger.debug ("AllottedResourceCustomization not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryAllottedResourceCustomization(); + } else { + qryResp = new QueryAllottedResourceCustomization(ret); + logger.debug ("AllottedResourceCustomization qryResp= {}", qryResp); + } + return respond(version, respStatus, isArray, qryResp); + } catch (Exception e) { + logger.error ("Exception - queryAllottedResourceCustomization", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + + @GET + @Path("vfModules") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Transactional( readOnly = true) + public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) { + QueryVfModule qryResp; + int respStatus = HttpStatus.SC_OK; + List<VfModuleCustomization> ret = null; + try{ + if(vfModuleModelName != null && !"".equals(vfModuleModelName)){ + VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName); + if(vfModule != null) + ret = vfModule.getVfModuleCustomization(); + }else{ + throw(new Exception(NO_MATCHING_PARAMETERS)); + } + + if(ret == null || ret.isEmpty()){ + logger.debug ("vfModules not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + qryResp = new QueryVfModule(); + }else{ + qryResp = new QueryVfModule(ret); + if(logger.isDebugEnabled()) + logger.debug ("vfModules tojsonstring is: {}", qryResp.JSON2(false, false)); + } + return Response + .status(respStatus) + .entity(qryResp.JSON2(false, false)) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + }catch(Exception e){ + logger.error ("Exception during query VfModules by vfModuleModuleName: ", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}) + .build(); + } + } + /** + * Get the tosca csar info from catalog + * <br> + * + * @param smUuid service model uuid + * @return the tosca csar information of the serivce. + * @since ONAP Beijing Release + */ + @GET + @Path("serviceToscaCsar") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) { + int respStatus = HttpStatus.SC_OK; + String entity = ""; + try { + if (smUuid != null && !"".equals(smUuid)) { + logger.debug("Query Csar by service model uuid: {}",smUuid); + ToscaCsar toscaCsar = toscaCsarRepo.findOne(smUuid); + if (toscaCsar != null) { + QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar); + entity = serviceCsar.JSON2(false, false); + } else { + respStatus = HttpStatus.SC_NOT_FOUND; + } + } else { + throw (new Exception("Incoming parameter is null or blank")); + } + return Response + .status(respStatus) + .entity(entity) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } catch (Exception e) { + logger.error("Exception during query csar by service model uuid: ", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) { + }) + .build(); + } + } + + /** + * Get the resource recipe info from catalog + * <br> + * + * @param rmUuid resource model uuid + * @return the recipe information of the resource. + * @since ONAP Beijing Release + */ + @GET + @Path("resourceRecipe") + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) { + int respStatus = HttpStatus.SC_OK; + String entity = ""; + try { + if (rmUuid != null && !"".equals(rmUuid)) { + logger.debug("Query recipe by resource model uuid: {}", rmUuid); + //check vnf and network and ar, the resource could be any resource. + VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid); + Recipe recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vnf.getModelName(), action); + if (null == recipe) { + NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid); + recipe = networkRecipeRepo.findByModelNameAndAction(nResource.getModelName(), action); + } + if (null == recipe) { + AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid); + recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action); + } + if (recipe != null) { + QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe); + entity = resourceRecipe.JSON2(false, false); + } else { + respStatus = HttpStatus.SC_NOT_FOUND; + } + } else { + throw new Exception("Incoming parameter is null or blank"); + } + return Response + .status(respStatus) + .entity(entity) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .build(); + } catch (Exception e) { + logger.error("Exception during query recipe by resource model uuid: ", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) { + }) + .build(); + } + } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java deleted file mode 100644 index 8f75008aef..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -/** - * - */ -/** - * - * - */ - -package org.onap.so.adapters.catalogdb.rest; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql new file mode 100644 index 0000000000..5c9e5aae9f --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1.1__Initial_Recipe_Setup.sql @@ -0,0 +1,92 @@ +SET FOREIGN_KEY_CHECKS=0; +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (1,'CONTRAIL_BASIC','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (2,'CONTRAIL_BASIC','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (3,'CONTRAIL_BASIC','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (4,'CONTRAIL_SHARED','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (5,'CONTRAIL_SHARED','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (6,'CONTRAIL_SHARED','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (7,'CONTRAIL_EXTERNAL','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (8,'CONTRAIL_EXTERNAL','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (9,'CONTRAIL_EXTERNAL','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (10,'CONTRAIL30_BASIC','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (11,'CONTRAIL30_BASIC','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (12,'CONTRAIL30_BASIC','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (13,'CONTRAIL30_MPSCE','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (14,'CONTRAIL30_MPSCE','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (15,'CONTRAIL30_MPSCE','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (16,'VID_DEFAULT','createInstance','VID_DEFAULT recipe to create network if no custom BPMN flow is found','/mso/async/services/CreateNetworkInstance',NULL,180,NULL,'2017-10-05 18:52:03','1.0'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (17,'VID_DEFAULT','updateInstance','VID_DEFAULT recipe to update network if no custom BPMN flow is found','/mso/async/services/UpdateNetworkInstance',NULL,180,NULL,'2017-10-05 18:52:03','1.0'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (18,'VID_DEFAULT','deleteInstance','VID_DEFAULT recipe to delete network if no custom BPMN flow is found','/mso/async/services/DeleteNetworkInstance',NULL,180,NULL,'2017-10-05 18:52:03','1.0'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (19,'CONTRAIL30_L2NODHCP','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (20,'CONTRAIL30_L2NODHCP','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (21,'CONTRAIL30_L2NODHCP','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (22,'CONTRAIL30_GNDIRECT','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (23,'CONTRAIL30_GNDIRECT','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (24,'CONTRAIL30_GNDIRECT','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (25,'SDNC_DEFAULT','createInstance','E2E DEFAULT recipe to create network if no custom BPMN flow is found','/mso/async/services/CreateSDNCNetworkResource',NULL,180,NULL,'2017-04-19 18:52:19','1.0'); +INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (26,'SDNC_DEFAULT','deleteInstance','E2E DEFAULT recipe to delete network if no custom BPMN flow is found','/mso/async/services/DeleteSDNCNetworkResource',NULL,180,NULL,'2017-04-19 18:52:19','1.0'); + +INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('48cc36cc-a9fe-11e7-8b4b-0242ac120002','VID_DEFAULT','48cd56c8-a9fe-11e7-8b4b-0242ac120002','1.0','Default service for VID to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-05 18:52:03',NULL); +INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('48cc3acd-a9fe-11e7-8b4b-0242ac120002','*','48ce2256-a9fe-11e7-8b4b-0242ac120002','1.0','Default service to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-05 18:52:03',NULL); + +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (1,'createInstance','1','VID_DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc36cc-a9fe-11e7-8b4b-0242ac120002'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (2,'deleteInstance','1','VID_DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc36cc-a9fe-11e7-8b4b-0242ac120002'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (3,'createInstance','1','DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (4,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); + +-- +-- Custom Reciepe for the VoLTE service added temporarily +-- + +INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('dfcd7471-16c7-444e-8268-d4c50d90593a','UUI_DEFAULT','dfcd7471-16c7-444e-8268-d4c50d90593a','1.0','Default service for UUI to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-23 18:52:03',NULL); +INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('f2e1dc69-c8ef-47e9-8b64-966cc87f2110','*','f2e1dc69-c8ef-47e9-8b64-966cc87f2110','1.0','Default service to use for infra APIH orchestration','2018-01-19 18:52:03',NULL); + +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (11,'createInstance','1','Custom recipe to create E2E service-instance if no custom BPMN flow is found','/mso/async/services/CreateCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (12,'deleteInstance','1','Custom recipe to delete E2E service-instance if no custom BPMN flow is found','/mso/async/services/DeleteCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); + +-- Recipe for E2E service update (R2 just support adding/deleting network service) +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (15,'updateInstance','1','Custom recipe to update E2E service-instance if no custom BPMN flow is found','/mso/async/services/UpdateCustomE2EServiceInstance',NULL,180,NULL,'2018-03-05 10:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (16,'scaleInstance','1','Custom recipe to scale E2E service-instance if no custom BPMN flow is found','/mso/async/services/ScaleCustomE2EServiceInstance',NULL,180,NULL,'2018-05-15 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); + +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (13,'createInstance','1','DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','f2e1dc69-c8ef-47e9-8b64-966cc87f2110'); +INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (14,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','f2e1dc69-c8ef-47e9-8b64-966cc87f2110'); + +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (1,'*','VOLUME_GROUP',NULL,'CREATE',NULL,'1','Recipe Match All for','/mso/async/services/createCinderVolumeV1',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (2,'*','VOLUME_GROUP',NULL,'DELETE',NULL,'1','Recipe Match All for','/mso/async/services/deleteCinderVolumeV1',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (3,'*','VOLUME_GROUP',NULL,'UPDATE',NULL,'1','Recipe Match All for','/mso/async/services/updateCinderVolumeV1',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (4,NULL,'VOLUME_GROUP',NULL,'CREATE_VF_MODULE_VOL',NULL,'1','Recipe Match All for','/mso/async/services/CreateVfModuleVolume',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (5,NULL,'VOLUME_GROUP',NULL,'DELETE_VF_MODULE_VOL',NULL,'1','Recipe Match All for','/mso/async/services/DeleteVfModuleVolume',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (6,NULL,'VOLUME_GROUP',NULL,'UPDATE_VF_MODULE_VOL',NULL,'1','Recipe Match All for','/mso/async/services/UpdateVfModuleVolume',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (7,NULL,'volumeGroup','VID_DEFAULT','createInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/CreateVfModuleVolumeInfraV1',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (8,NULL,'volumeGroup','VID_DEFAULT','deleteInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/DeleteVfModuleVolumeInfraV1',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (9,NULL,'volumeGroup','VID_DEFAULT','updateInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/UpdateVfModuleVolumeInfraV1',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (10,NULL,'vfModule','VID_DEFAULT','createInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/CreateVfModuleInfra',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (11,NULL,'vfModule','VID_DEFAULT','deleteInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/DeleteVfModuleInfra',null,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (12,NULL,'vfModule','VID_DEFAULT','updateInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/UpdateVfModuleInfra',null,180,'2017-10-05 18:52:03'); + +-- +-- Default Reciepe for the VNF componnets added start #SO-334, to unblock the VNF operations +-- + +INSERT INTO `vnf_components_recipe` (`VNF_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`,`VNF_COMPONENT_TYPE`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`) VALUES (NULL,'POLICY_DEFAULT','createInstance','1','Recipe Match POLICY_DEFAULT for VF Modules if no custom flow exists','/mso/async/services/CreateVfModuleInfra','vfModule',NULL,180,NULL); +INSERT INTO `vnf_components_recipe` (`VNF_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`,`VNF_COMPONENT_TYPE`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`) VALUES (NULL,'POLICY_DEFAULT','updateInstance','1','Recipe Match POLICY_DEFAULT for VF Modules if no custom flow exists','/mso/async/services/UpdateVfModuleInfra','vfModule',NULL,180,NULL); +INSERT INTO `vnf_components_recipe` (`VNF_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`,`VNF_COMPONENT_TYPE`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`) VALUES (NULL,'POLICY_DEFAULT','deleteInstance','1','Recipe Match POLICY_DEFAULT for VF Modules if no custom flow exists','/mso/async/services/DeleteVfModuleInfra','vfModule',NULL,180,NULL); +-- +-- Default Reciepe for the VNF componnets added End +-- + +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (1,NULL,'CREATE',NULL,'1','*','Recipe Match All for VNFs if no custom flow exists','/mso/workflow/services/CreateGenericVNFV1',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (2,NULL,'DELETE',NULL,'1','*','Recipe Match All for VNFs if no custom flow exists','/mso/async/services//deleteGenericVNFV1',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (3,NULL,'UPDATE',NULL,'1','*','Recipe Match All for VNFs if no custom flow exists','/mso/workflow/services/updateGenericVNFV1',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (4,'*','CREATE_VF_MODULE',NULL,'1',NULL,'Recipe Match All for VNFs if no custom flow exists','/mso/async/services/CreateVfModule',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (5,'*','DELETE_VF_MODULE',NULL,'1',NULL,'Recipe Match All for VNFs if no custom flow exists','/mso/async/services/DeleteVfModule',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (6,'*','UPDATE_VF_MODULE',NULL,'1',NULL,'Recipe Match All for VNFs if no custom flow exists','/mso/async/services/UpdateVfModule',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (7,NULL,'createInstance',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to create VNF if no custom BPMN flow is found','/mso/async/services/CreateVnfInfra',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (8,NULL,'deleteInstance',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to delete VNF if no custom BPMN flow is found','/mso/async/services/DeleteVnfInfra',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (9,NULL,'createInstance',NULL,'1','RESOURCE_NS_DEFAULT','NS default recipe to create network service if no custom BPMN flow is found','/mso/async/services/CreateVFCNetworkService',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (10,NULL,'deleteInstance',NULL,'1','RESOURCE_NS_DEFAULT','NS default recipe to delete network service if no custom BPMN flow is found','/mso/async/services/DeleteVFCNetworkService',NULL,180,'2017-10-05 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (11,NULL,'createInstance',NULL,'1','NS_DEFAULT','default custom E2E recipe to create NS if no custom BPMN flow is found','/mso/async/services/CreateVFCNSResource',NULL,180,'2018-04-18 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (12,NULL,'deleteInstance',NULL,'1','NS_DEFAULT','default custom E2E recipe to delete NS if no custom BPMN flow is found','/mso/async/services/DeleteVFCNSResource',NULL,180,'2018-04-18 18:52:03'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (13,NULL,'inPlaceSoftwareUpdate',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to update VNF software if no custom BPMN flow is found','/mso/async/services/VnfInPlaceUpdate',NULL,180,'2018-05-23 11:00:00'); +INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (14,NULL,'applyUpdatedConfig',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to apply updated VNF config if no custom BPMN flow is found','/mso/async/services/VnfConfigUpdate',NULL,180,'2018-05-23 11:00:00'); +SET FOREIGN_KEY_CHECKS=1; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1810.1__AddModelAndModelRecipe.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.0__AddModelAndModelRecipe.sql index 0042888117..0042888117 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V1810.1__AddModelAndModelRecipe.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.0__AddModelAndModelRecipe.sql diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.1__AddCloudConfig.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.1__AddCloudConfig.sql new file mode 100644 index 0000000000..1028aa61b1 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.1__AddCloudConfig.sql @@ -0,0 +1,47 @@ + +CREATE TABLE IF NOT EXISTS `identity_services` ( + `ID` varchar(50) NOT NULL, + `IDENTITY_URL` varchar(200) DEFAULT NULL, + `MSO_ID` varchar(255) DEFAULT NULL, + `MSO_PASS` varchar(255) DEFAULT NULL, + `ADMIN_TENANT` varchar(50) DEFAULT NULL, + `MEMBER_ROLE` varchar(50) DEFAULT NULL, + `TENANT_METADATA` tinyint(1) DEFAULT 0, + `IDENTITY_SERVER_TYPE` varchar(50) DEFAULT NULL, + `IDENTITY_AUTHENTICATION_TYPE` varchar(50) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`) +) ; + + +CREATE TABLE IF NOT EXISTS `cloudify_managers` ( + `ID` varchar(50) NOT NULL, + `CLOUDIFY_URL` varchar(200) DEFAULT NULL, + `USERNAME` varchar(255) DEFAULT NULL, + `PASSWORD` varchar(255) DEFAULT NULL, + `VERSION` varchar(20) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`) +) ; + + +CREATE TABLE IF NOT EXISTS `cloud_sites` ( + `ID` varchar(50) NOT NULL, + `REGION_ID` varchar(11) DEFAULT NULL, + `IDENTITY_SERVICE_ID` varchar(50) DEFAULT NULL, + `CLOUD_VERSION` varchar(20) DEFAULT NULL, + `CLLI` varchar(11) DEFAULT NULL, + `CLOUDIFY_ID` varchar(50) DEFAULT NULL, + `PLATFORM` varchar(50) DEFAULT NULL, + `ORCHESTRATOR` varchar(50) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`), + KEY `FK_cloud_sites_identity_services` (`IDENTITY_SERVICE_ID`), + CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`) +) ;
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql new file mode 100644 index 0000000000..b3d8b98176 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.2__ScaleOutRecipe.sql @@ -0,0 +1,5 @@ +use catalogdb; + +INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID) +VALUES +('vfModule', 'scaleOut', '1', 'Gr api recipe to scale out vfModule', '/mso/async/services/WorkflowActionBB', '180', 'GR-API-DEFAULT'); diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/afterMigrate.sql deleted file mode 100644 index b03c0996b0..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/afterMigrate.sql +++ /dev/null @@ -1,166 +0,0 @@ -# INSERT INTO `heat_template` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `TIMEOUT_MINUTES`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','Contrail30-l2nodhcp','1',NULL,'heat_template_version: 2015-04-30\n\ndescription:\n HOT template that creates a Contrail Virtual Network with L2NODHCP\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n shared:\n type: boolean\n description: Shared amongst tenants\n default: False\n external:\n type: boolean\n description: router_external for the VirtualNetwork\n default: False\n route_targets:\n type: comma_delimited_list\n description: Network route-targets (RT)\n default: \"\"\n subnet_list:\n type: json\n description: Network subnets\n default: []\n policy_refs:\n type: comma_delimited_list\n description: Policies referenced by Network\n default: \"\"\n policy_refsdata:\n type: json\n description: Policies referenced by Network\n default: []\n route_table_refs:\n type: comma_delimited_list\n description: Route Tables referenced by Network\n default: \"\"\n virtual_network_properties_allow_transit:\n type: boolean\n description: allow_transit for the VirtualNetwork\n default: True\n virtual_network_properties_forwarding_mode:\n type: string\n description: forwarding_mode for the VirtualNetwork\n default: l2\n virtual_network_properties_rpf:\n type: string\n description: rpf for the VirtualNetwork\n default: disable\n flood_unknown_unicast:\n type: boolean\n description: flood_unknown_unicast for the VirtualNetwork\n default: True\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n networkIpam:\n type: OS::ContrailV2::NetworkIpam\n properties:\n name: { get_param: network_name }\n\n network:\n type: OS::ContrailV2::VirtualNetwork\n properties:\n name: { get_param: network_name }\n is_shared: {get_param: shared}\n router_external: { get_param: external }\n route_target_list:\n {\n route_target_list_route_target: { get_param: route_targets }\n }\n network_ipam_refs: [{ get_resource: networkIpam }]\n network_ipam_refs_data:\n [\n {\n network_ipam_refs_data_ipam_subnets: { get_param: subnet_list }\n }\n ]\n network_policy_refs: { get_param: policy_refs }\n network_policy_refs_data: { get_param: policy_refsdata }\n route_table_refs: { get_param: route_table_refs }\n flood_unknown_unicast: { get_param: flood_unknown_unicast } \n virtual_network_properties:\n {\n virtual_network_properties_allow_transit: { get_param: virtual_network_properties_allow_transit },\n virtual_network_properties_forwarding_mode: { get_param: virtual_network_properties_forwarding_mode },\n virtual_network_properties_rpf: { get_param: virtual_network_properties_rpf },\n }\n',10,'MANUAL RECORD','2017-10-05 18:52:03'); -# -# INSERT INTO `heat_template` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `TIMEOUT_MINUTES`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','Contrail30-gndirect','1',NULL,'heat_template_version: 2015-04-30\n\ndescription:\n HOT template that creates a Contrail Virtual Network for GNDIRECT\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n shared:\n type: boolean\n description: Shared amongst tenants\n default: False\n external:\n type: boolean\n description: router_external for the VirtualNetwork\n default: False\n route_targets:\n type: comma_delimited_list\n description: Network route-targets (RT)\n default: \"\"\n subnet_list:\n type: json\n description: Network subnets\n default: []\n policy_refs:\n type: comma_delimited_list\n description: Policies referenced by Network\n default: \"\"\n policy_refsdata:\n type: json\n description: Policies referenced by Network\n default: []\n route_table_refs:\n type: comma_delimited_list\n description: Route Tables referenced by Network\n default: \"\"\n virtual_network_properties_rpf:\n type: string\n description: rpf for the VirtualNetwork\n default: disable\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n networkIpam:\n type: OS::ContrailV2::NetworkIpam\n properties:\n name: { get_param: network_name }\n\n network:\n type: OS::ContrailV2::VirtualNetwork\n properties:\n name: { get_param: network_name }\n is_shared: {get_param: shared}\n router_external: { get_param: external }\n route_target_list:\n {\n route_target_list_route_target: { get_param: route_targets }\n }\n network_ipam_refs: [{ get_resource: networkIpam }]\n network_ipam_refs_data:\n [\n {\n network_ipam_refs_data_ipam_subnets: { get_param: subnet_list }\n }\n ]\n network_policy_refs: { get_param: policy_refs }\n network_policy_refs_data: { get_param: policy_refsdata }\n route_table_refs: { get_param: route_table_refs }\n virtual_network_properties:\n {\n virtual_network_properties_rpf: { get_param: virtual_network_properties_rpf }\n }\n',10,'MANUAL RECORD','2017-10-05 18:52:03'); -# -# INSERT INTO `heat_template` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`BODY`,`TIMEOUT_MINUTES`,`DESCRIPTION`,`CREATION_TIMESTAMP`,`ARTIFACT_CHECKSUM`) VALUES ('efee1d84-b8ec-11e7-abc4-cec278b6b50a','Generic NeutronNet','1','heat_template_version: 2013-05-23\n\ndescription:\n HOT template that creates a Generic Neutron Network\n\nparameters:\n network_name:\n type: string\n description: Name of direct network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_name:\n type: string\n description: Name of subnet network (e.g. core, dmz)\n default: ECOMPNetwork\n network_subnet_cidr:\n type: string\n description: CIDR of subnet network (e.g. core, dmz)\n default: 10.0.0.0/16\n\noutputs:\n network_id:\n description: Openstack network identifier\n value: { get_resource: network }\n network_fqdn:\n description: Openstack network identifier\n value: {list_join: [\':\', { get_attr: [network, fq_name] } ] }\n\nresources:\n network:\n type: OS::Neutron::Net\n properties:\n name: {get_param: network_name }\n\n subnet:\n type: OS::Neutron::Subnet\n properties:\n name: { get_param: network_subnet_name }\n network_id: { get_resource: network }\n cidr: { get_param: network_subnet_cidr }\n enable_dhcp: false\n',10,'Generic Neutron Template','2017-10-26 14:44:00', 'MANUAL RECORD'); -# -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','external','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','flood_unknown_unicast','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','network_name','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','policy_refs','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','policy_refsdata','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','route_table_refs','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','route_targets','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','shared','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','virtual_network_properties_allow_transit','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','virtual_network_properties_forwarding_mode','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c198-a9fe-11e7-8b4b-0242ac120002','virtual_network_properties_rpf','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','external','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','network_name','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','policy_refs','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','policy_refsdata','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','route_table_refs','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','route_targets','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','shared','\0','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('4885c7a1-a9fe-11e7-8b4b-0242ac120002','virtual_network_properties_rpf','\0','string',NULL); -# -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (1,'CONTRAIL_BASIC','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (2,'CONTRAIL_BASIC','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (3,'CONTRAIL_BASIC','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (4,'CONTRAIL_SHARED','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (5,'CONTRAIL_SHARED','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (6,'CONTRAIL_SHARED','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (7,'CONTRAIL_EXTERNAL','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (8,'CONTRAIL_EXTERNAL','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (9,'CONTRAIL_EXTERNAL','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (10,'CONTRAIL30_BASIC','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (11,'CONTRAIL30_BASIC','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (12,'CONTRAIL30_BASIC','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (13,'CONTRAIL30_MPSCE','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (14,'CONTRAIL30_MPSCE','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (15,'CONTRAIL30_MPSCE','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (16,'VID_DEFAULT','createInstance','VID_DEFAULT recipe to create network if no custom BPMN flow is found','/mso/async/services/CreateNetworkInstance',NULL,180,NULL,'2017-10-05 18:52:03','1.0'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (17,'VID_DEFAULT','updateInstance','VID_DEFAULT recipe to update network if no custom BPMN flow is found','/mso/async/services/UpdateNetworkInstance',NULL,180,NULL,'2017-10-05 18:52:03','1.0'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (18,'VID_DEFAULT','deleteInstance','VID_DEFAULT recipe to delete network if no custom BPMN flow is found','/mso/async/services/DeleteNetworkInstance',NULL,180,NULL,'2017-10-05 18:52:03','1.0'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (19,'CONTRAIL30_L2NODHCP','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (20,'CONTRAIL30_L2NODHCP','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (21,'CONTRAIL30_L2NODHCP','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (22,'CONTRAIL30_GNDIRECT','CREATE',NULL,'/mso/async/services/CreateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (23,'CONTRAIL30_GNDIRECT','UPDATE',NULL,'/mso/async/services/UpdateNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (24,'CONTRAIL30_GNDIRECT','DELETE',NULL,'/mso/async/services/DeleteNetworkV2',NULL,180,NULL,'2017-10-05 18:52:03','1'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (25,'SDNC_DEFAULT','createInstance','E2E DEFAULT recipe to create network if no custom BPMN flow is found','/mso/async/services/CreateSDNCNetworkResource',NULL,180,NULL,'2017-04-19 18:52:19','1.0'); -# INSERT INTO `network_recipe` (`id`, `MODEL_NAME`, `ACTION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `NETWORK_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`, `CREATION_TIMESTAMP`, `VERSION_STR`) VALUES (26,'SDNC_DEFAULT','deleteInstance','E2E DEFAULT recipe to delete network if no custom BPMN flow is found','/mso/async/services/DeleteSDNCNetworkResource',NULL,180,NULL,'2017-04-19 18:52:19','1.0'); -# -# INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('48cc36cc-a9fe-11e7-8b4b-0242ac120002','VID_DEFAULT','48cd56c8-a9fe-11e7-8b4b-0242ac120002','1.0','Default service for VID to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-05 18:52:03',NULL); -# INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('48cc3acd-a9fe-11e7-8b4b-0242ac120002','*','48ce2256-a9fe-11e7-8b4b-0242ac120002','1.0','Default service to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-05 18:52:03',NULL); -# -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (1,'createInstance','1','VID_DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc36cc-a9fe-11e7-8b4b-0242ac120002'); -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (2,'deleteInstance','1','VID_DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc36cc-a9fe-11e7-8b4b-0242ac120002'); -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (3,'createInstance','1','DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (4,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','48cc3acd-a9fe-11e7-8b4b-0242ac120002'); -# -# -- -# -- Custom Reciepe for the VoLTE service added temporarily -# -- -# -# INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('dfcd7471-16c7-444e-8268-d4c50d90593a','UUI_DEFAULT','dfcd7471-16c7-444e-8268-d4c50d90593a','1.0','Default service for UUI to use for infra APIH orchestration1707MIGRATED1707MIGRATED','2017-10-23 18:52:03',NULL); -# INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('f2e1dc69-c8ef-47e9-8b64-966cc87f2110','*','f2e1dc69-c8ef-47e9-8b64-966cc87f2110','1.0','Default service to use for infra APIH orchestration','2018-01-19 18:52:03',NULL); -# -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (11,'createInstance','1','Custom recipe to create E2E service-instance if no custom BPMN flow is found','/mso/async/services/CreateCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (12,'deleteInstance','1','Custom recipe to delete E2E service-instance if no custom BPMN flow is found','/mso/async/services/DeleteCustomE2EServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); -# -# -- Recipe for E2E service update (R2 just support adding/deleting network service) -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (15,'updateInstance','1','Custom recipe to update E2E service-instance if no custom BPMN flow is found','/mso/async/services/UpdateCustomE2EServiceInstance',NULL,180,NULL,'2018-03-05 10:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (16,'scaleInstance','1','Custom recipe to scale E2E service-instance if no custom BPMN flow is found','/mso/async/services/ScaleCustomE2EServiceInstance',NULL,180,NULL,'2018-05-15 18:52:03','dfcd7471-16c7-444e-8268-d4c50d90593a'); -# -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (13,'createInstance','1','DEFAULT recipe to create service-instance if no custom BPMN flow is found','/mso/async/services/CreateGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','f2e1dc69-c8ef-47e9-8b64-966cc87f2110'); -# INSERT INTO `service_recipe` (`id`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `SERVICE_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TIMEOUT_INTERIM`, `CREATION_TIMESTAMP`, `SERVICE_MODEL_UUID`) VALUES (14,'deleteInstance','1','DEFAULT recipe to delete service-instance if no custom BPMN flow is found','/mso/async/services/DeleteGenericALaCarteServiceInstance',NULL,180,NULL,'2017-10-05 18:52:03','f2e1dc69-c8ef-47e9-8b64-966cc87f2110'); -# -# INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`, `AIC_VERSION_MIN`, `AIC_VERSION_MAX`) VALUES ('CONTRAIL30_GNDIRECT','4885c7a1-a9fe-11e7-8b4b-0242ac120002','3.0',NULL); -# INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`, `AIC_VERSION_MIN`, `AIC_VERSION_MAX`) VALUES ('CONTRAIL30_L2NODHCP','4885c198-a9fe-11e7-8b4b-0242ac120002','3.0',NULL); -# INSERT INTO `temp_network_heat_template_lookup` (`NETWORK_RESOURCE_MODEL_NAME`, `HEAT_TEMPLATE_ARTIFACT_UUID`,`AIC_VERSION_MIN` , `AIC_VERSION_MAX` ) VALUES ('Generic NeutronNet','efee1d84-b8ec-11e7-abc4-cec278b6b50a','2.0','NULL'); -# -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (1,'*','VOLUME_GROUP',NULL,'CREATE',NULL,'1','Recipe Match All for','/mso/async/services/createCinderVolumeV1',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (2,'*','VOLUME_GROUP',NULL,'DELETE',NULL,'1','Recipe Match All for','/mso/async/services/deleteCinderVolumeV1',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (3,'*','VOLUME_GROUP',NULL,'UPDATE',NULL,'1','Recipe Match All for','/mso/async/services/updateCinderVolumeV1',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (4,NULL,'VOLUME_GROUP',NULL,'CREATE_VF_MODULE_VOL',NULL,'1','Recipe Match All for','/mso/async/services/CreateVfModuleVolume',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (5,NULL,'VOLUME_GROUP',NULL,'DELETE_VF_MODULE_VOL',NULL,'1','Recipe Match All for','/mso/async/services/DeleteVfModuleVolume',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (6,NULL,'VOLUME_GROUP',NULL,'UPDATE_VF_MODULE_VOL',NULL,'1','Recipe Match All for','/mso/async/services/UpdateVfModuleVolume',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (7,NULL,'volumeGroup','VID_DEFAULT','createInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/CreateVfModuleVolumeInfraV1',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (8,NULL,'volumeGroup','VID_DEFAULT','deleteInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/DeleteVfModuleVolumeInfraV1',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (9,NULL,'volumeGroup','VID_DEFAULT','updateInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/UpdateVfModuleVolumeInfraV1',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (10,NULL,'vfModule','VID_DEFAULT','createInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/CreateVfModuleInfra',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (11,NULL,'vfModule','VID_DEFAULT','deleteInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/DeleteVfModuleInfra',null,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_components_recipe` (`id`, `VNF_TYPE`, `VNF_COMPONENT_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `SERVICE_TYPE`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (12,NULL,'vfModule','VID_DEFAULT','updateInstance',NULL,'1','VID_DEFAULT recipe t','/mso/async/services/UpdateVfModuleInfra',null,180,'2017-10-05 18:52:03'); -# -# -- -# -- Default Reciepe for the VNF componnets added start #SO-334, to unblock the VNF operations -# -- -# -# INSERT INTO `vnf_components_recipe` (`VNF_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`,`VNF_COMPONENT_TYPE`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`) VALUES (NULL,'POLICY_DEFAULT','createInstance','1','Recipe Match POLICY_DEFAULT for VF Modules if no custom flow exists','/mso/async/services/CreateVfModuleInfra','vfModule',NULL,180,NULL); -# INSERT INTO `vnf_components_recipe` (`VNF_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`,`VNF_COMPONENT_TYPE`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`) VALUES (NULL,'POLICY_DEFAULT','updateInstance','1','Recipe Match POLICY_DEFAULT for VF Modules if no custom flow exists','/mso/async/services/UpdateVfModuleInfra','vfModule',NULL,180,NULL); -# INSERT INTO `vnf_components_recipe` (`VNF_TYPE`, `VF_MODULE_MODEL_UUID`, `ACTION`, `VERSION`, `DESCRIPTION`, `ORCHESTRATION_URI`,`VNF_COMPONENT_TYPE`, `VNF_COMPONENT_PARAM_XSD`, `RECIPE_TIMEOUT`, `SERVICE_TYPE`) VALUES (NULL,'POLICY_DEFAULT','deleteInstance','1','Recipe Match POLICY_DEFAULT for VF Modules if no custom flow exists','/mso/async/services/DeleteVfModuleInfra','vfModule',NULL,180,NULL); -# -- -# -- Default Reciepe for the VNF componnets added End -# -- -# -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (1,NULL,'CREATE',NULL,'1','*','Recipe Match All for VNFs if no custom flow exists','/mso/workflow/services/CreateGenericVNFV1',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (2,NULL,'DELETE',NULL,'1','*','Recipe Match All for VNFs if no custom flow exists','/mso/async/services//deleteGenericVNFV1',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (3,NULL,'UPDATE',NULL,'1','*','Recipe Match All for VNFs if no custom flow exists','/mso/workflow/services/updateGenericVNFV1',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (4,'*','CREATE_VF_MODULE',NULL,'1',NULL,'Recipe Match All for VNFs if no custom flow exists','/mso/async/services/CreateVfModule',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (5,'*','DELETE_VF_MODULE',NULL,'1',NULL,'Recipe Match All for VNFs if no custom flow exists','/mso/async/services/DeleteVfModule',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (6,'*','UPDATE_VF_MODULE',NULL,'1',NULL,'Recipe Match All for VNFs if no custom flow exists','/mso/async/services/UpdateVfModule',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (7,NULL,'createInstance',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to create VNF if no custom BPMN flow is found','/mso/async/services/CreateVnfInfra',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (8,NULL,'deleteInstance',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to delete VNF if no custom BPMN flow is found','/mso/async/services/DeleteVnfInfra',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (9,NULL,'createInstance',NULL,'1','RESOURCE_NS_DEFAULT','NS default recipe to create network service if no custom BPMN flow is found','/mso/async/services/CreateVFCNetworkService',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (10,NULL,'deleteInstance',NULL,'1','RESOURCE_NS_DEFAULT','NS default recipe to delete network service if no custom BPMN flow is found','/mso/async/services/DeleteVFCNetworkService',NULL,180,'2017-10-05 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (11,NULL,'createInstance',NULL,'1','NS_DEFAULT','default custom E2E recipe to create NS if no custom BPMN flow is found','/mso/async/services/CreateVFCNSResource',NULL,180,'2018-04-18 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (12,NULL,'deleteInstance',NULL,'1','NS_DEFAULT','default custom E2E recipe to delete NS if no custom BPMN flow is found','/mso/async/services/DeleteVFCNSResource',NULL,180,'2018-04-18 18:52:03'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (13,NULL,'inPlaceSoftwareUpdate',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to update VNF software if no custom BPMN flow is found','/mso/async/services/VnfInPlaceUpdate',NULL,180,'2018-05-23 11:00:00'); -# INSERT INTO `vnf_recipe` (`id`, `VF_MODULE_ID`, `ACTION`, `SERVICE_TYPE`, `VERSION_STR`, `VNF_TYPE`, `DESCRIPTION`, `ORCHESTRATION_URI`, `VNF_PARAM_XSD`, `RECIPE_TIMEOUT`, `CREATION_TIMESTAMP`) VALUES (14,NULL,'applyUpdatedConfig',NULL,'1','VID_DEFAULT','VID_DEFAULT recipe to apply updated VNF config if no custom BPMN flow is found','/mso/async/services/VnfConfigUpdate',NULL,180,'2018-05-23 11:00:00'); -# -# -- -# -- Start Former create_mso_db-demo-vfw.sql -# -- -# -# INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('EnvArtifact-UUID3','base_vfw.env','1.0','base_vfw ENV file','parameters:\n vfw_image_name: Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)\n vfw_flavor_name: 4 GB General Purpose v1\n public_net_id: 00000000-0000-0000-0000-000000000000\n unprotected_private_net_id: zdfw1fwl01_unprotected\n protected_private_net_id: zdfw1fwl01_protected\n ecomp_private_net_id: oam_ecomp\n unprotected_private_net_cidr: 192.168.10.0/24\n protected_private_net_cidr: 192.168.20.0/24\n ecomp_private_net_cidr: 192.168.9.0/24\n vfw_private_ip_0: 192.168.10.100\n vfw_private_ip_1: 192.168.20.100\n vfw_private_ip_2: 192.168.9.100\n vpg_private_ip_0: 192.168.10.200\n vpg_private_ip_1: 192.168.9.200\n vsn_private_ip_0: 192.168.20.250\n vsn_private_ip_1: 192.168.9.250\n vfw_name_0: zdfw1fwl01fwl01\n vpg_name_0: zdfw1fwl01pgn01\n vsn_name_0: zdfw1fwl01snk01\n vnf_id: vFirewall_demo_app\n vf_module_id: vFirewall\n webserver_ip: 162.242.237.182\n dcae_collector_ip: 192.168.9.1\n key_name: vfw_key\n pub_key: INSERT YOUR PUBLIC KEY HERE','MANUAL RECORD','2016-11-14 13:04:07'); -# -# INSERT INTO `heat_template` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION`, `BODY`, `TIMEOUT_MINUTES`, `ARTIFACT_CHECKSUM`, `CREATION_TIMESTAMP`) VALUES ('Artifact-UUID3','base_vfw.yaml','1.0','Base VFW Heat','heat_template_version: 2013-05-23\n\ndescription: Heat template to deploy vFirewall demo app for OpenECOMP\n\nparameters:\n vfw_image_name:\n type: string\n label: Image name or ID\n description: Image to be used for compute instance\n vfw_flavor_name:\n type: string\n label: Flavor\n description: Type of instance (flavor) to be used\n public_net_id:\n type: string\n label: Public network name or ID\n description: Public network that enables remote connection to VNF\n unprotected_private_net_id:\n type: string\n label: Unprotected private network name or ID\n description: Private network that connects vPacketGenerator with vFirewall\n protected_private_net_id:\n type: string\n label: Protected private network name or ID\n description: Private network that connects vFirewall with vSink\n ecomp_private_net_id:\n type: string\n label: ECOMP management network name or ID\n description: Private network that connects ECOMP component and the VNF\n unprotected_private_net_cidr:\n type: string\n label: Unprotected private network CIDR\n description: The CIDR of the unprotected private network\n protected_private_net_cidr:\n type: string\n label: Protected private network CIDR\n description: The CIDR of the protected private network\n ecomp_private_net_cidr:\n type: string\n label: ECOMP private network CIDR\n description: The CIDR of the protected private network\n vfw_private_ip_0:\n type: string\n label: vFirewall private IP address towards the unprotected network\n description: Private IP address that is assigned to the vFirewall to communicate with the vPacketGenerator\n vfw_private_ip_1:\n type: string\n label: vFirewall private IP address towards the protected network\n description: Private IP address that is assigned to the vFirewall to communicate with the vSink\n vfw_private_ip_2:\n type: string\n label: vFirewall private IP address towards the ECOMP management network\n description: Private IP address that is assigned to the vFirewall to communicate with ECOMP components\n vpg_private_ip_0:\n type: string\n label: vPacketGenerator private IP address towards the unprotected network\n description: Private IP address that is assigned to the vPacketGenerator to communicate with the vFirewall\n vpg_private_ip_1:\n type: string\n label: vPacketGenerator private IP address towards the ECOMP management network\n description: Private IP address that is assigned to the vPacketGenerator to communicate with ECOMP components\n vsn_private_ip_0:\n type: string\n label: vSink private IP address towards the protected network\n description: Private IP address that is assigned to the vSink to communicate with the vFirewall\n vsn_private_ip_1:\n type: string\n label: vSink private IP address towards the ECOMP management network\n description: Private IP address that is assigned to the vSink to communicate with ECOMP components\n vfw_name_0:\n type: string\n label: vFirewall name\n description: Name of the vFirewall\n vpg_name_0:\n type: string\n label: vPacketGenerator name\n description: Name of the vPacketGenerator\n vsn_name_0:\n type: string\n label: vSink name\n description: Name of the vSink\n vnf_id:\n type: string\n label: VNF ID\n description: The VNF ID is provided by ECOMP\n vf_module_id:\n type: string\n label: vFirewall module ID\n description: The vFirewall Module ID is provided by ECOMP\n webserver_ip:\n type: string\n label: Webserver IP address\n description: IP address of the webserver that hosts the source code and binaries\n dcae_collector_ip:\n type: string\n label: DCAE collector IP address\n description: IP address of the DCAE collector\n key_name:\n type: string\n label: Key pair name\n description: Public/Private key pair name\n pub_key:\n type: string\n label: Public key\n description: Public key to be installed on the compute instance\n\nresources:\n my_keypair:\n type: OS::Nova::KeyPair\n properties:\n name: { get_param: key_name }\n public_key: { get_param: pub_key }\n save_private_key: false\n\n unprotected_private_network:\n type: OS::Neutron::Net\n properties:\n name: { get_param: unprotected_private_net_id }\n\n protected_private_network:\n type: OS::Neutron::Net\n properties:\n name: { get_param: protected_private_net_id }\n\n unprotected_private_subnet:\n type: OS::Neutron::Subnet\n properties:\n network_id: { get_resource: unprotected_private_network }\n cidr: { get_param: unprotected_private_net_cidr }\n\n protected_private_subnet:\n type: OS::Neutron::Subnet\n properties:\n network_id: { get_resource: protected_private_network }\n cidr: { get_param: protected_private_net_cidr }\n\n vfw_0:\n type: OS::Nova::Server\n properties:\n image: { get_param: vfw_image_name }\n flavor: { get_param: vfw_flavor_name }\n name: { get_param: vfw_name_0 }\n key_name: { get_resource: my_keypair }\n networks:\n - network: { get_param: public_net_id }\n - port: { get_resource: vfw_private_0_port }\n - port: { get_resource: vfw_private_1_port }\n - port: { get_resource: vfw_private_2_port }\n metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\n user_data_format: RAW\n user_data:\n str_replace:\n params:\n __webserver__: { get_param: webserver_ip }\n __dcae_collector_ip__ : { get_param: dcae_collector_ip }\n template: |\n #!/bin/bash\n\n WEBSERVER_IP=__webserver__\n DCAE_COLLECTOR_IP=__dcae_collector_ip__\n\n mkdir /opt/config\n cd /opt\n wget http://$WEBSERVER_IP/demo_repo/v_firewall_init.sh\n wget http://$WEBSERVER_IP/demo_repo/vfirewall.sh\n chmod +x v_firewall_init.sh\n chmod +x vfirewall.sh\n echo $WEBSERVER_IP > config/webserver_ip.txt\n echo $DCAE_COLLECTOR_IP > config/dcae_collector_ip.txt\n echo \"no\" > config/install.txt\n mv vfirewall.sh /etc/init.d\n sudo update-rc.d vfirewall.sh defaults\n ./v_firewall_init.sh\n\n vfw_private_0_port:\n type: OS::Neutron::Port\n properties:\n network: { get_resource: unprotected_private_network }\n fixed_ips: [{\"subnet\": { get_resource: unprotected_private_subnet }, \"ip_address\": { get_param: vfw_private_ip_0 }}]\n\n vfw_private_1_port:\n type: OS::Neutron::Port\n properties:\n network: { get_resource: protected_private_network }\n fixed_ips: [{\"subnet\": { get_resource: protected_private_subnet }, \"ip_address\": { get_param: vfw_private_ip_1 }}]\n\n vfw_private_2_port:\n type: OS::Neutron::Port\n properties:\n network: { get_param: ecomp_private_net_id }\n fixed_ips: [{\"subnet\": { get_param: ecomp_private_net_id }, \"ip_address\": { get_param: vfw_private_ip_2 }}]\n\n vpg_0:\n type: OS::Nova::Server\n properties:\n image: { get_param: vfw_image_name }\n flavor: { get_param: vfw_flavor_name }\n name: { get_param: vpg_name_0 }\n key_name: { get_resource: my_keypair }\n networks:\n - network: { get_param: public_net_id }\n - port: { get_resource: vpg_private_0_port }\n - port: { get_resource: vpg_private_1_port }\n metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\n user_data_format: RAW\n user_data:\n str_replace:\n params:\n __webserver__: { get_param: webserver_ip }\n __fw_ipaddr__: { get_param: vfw_private_ip_0 }\n __protected_net_cidr__: { get_param: protected_private_net_cidr }\n __sink_ipaddr__: { get_param: vsn_private_ip_0 }\n template: |\n #!/bin/bash\n\n WEBSERVER_IP=__webserver__\n FW_IPADDR=__fw_ipaddr__\n PROTECTED_NET_CIDR=__protected_net_cidr__\n SINK_IPADDR=__sink_ipaddr__\n\n mkdir /opt/config\n cd /opt\n wget http://$WEBSERVER_IP/demo_repo/v_packetgen_init.sh\n wget http://$WEBSERVER_IP/demo_repo/vpacketgen.sh\n chmod +x v_packetgen_init.sh\n chmod +x vpacketgen.sh\n echo $WEBSERVER_IP > config/webserver_ip.txt\n echo $FW_IPADDR > config/fw_ipaddr.txt\n echo $PROTECTED_NET_CIDR > config/protected_net_cidr.txt\n echo $SINK_IPADDR > config/sink_ipaddr.txt\n echo \"no\" > config/install.txt\n mv vpacketgen.sh /etc/init.d\n sudo update-rc.d vpacketgen.sh defaults\n ./v_packetgen_init.sh\n\n vpg_private_0_port:\n type: OS::Neutron::Port\n properties:\n network: { get_resource: unprotected_private_network }\n fixed_ips: [{\"subnet\": { get_resource: unprotected_private_subnet }, \"ip_address\": { get_param: vpg_private_ip_0 }}]\n\n vpg_private_1_port:\n type: OS::Neutron::Port\n properties:\n network: { get_param: ecomp_private_net_id }\n fixed_ips: [{\"subnet\": { get_param: ecomp_private_net_id }, \"ip_address\": { get_param: vpg_private_ip_1 }}]\n\n vsn_0:\n type: OS::Nova::Server\n properties:\n image: { get_param: vfw_image_name }\n flavor: { get_param: vfw_flavor_name }\n name: { get_param: vsn_name_0 }\n key_name: { get_resource: my_keypair }\n networks:\n - network: { get_param: public_net_id }\n - port: { get_resource: vsn_private_0_port }\n - port: { get_resource: vsn_private_1_port }\n metadata: {vnf_id: { get_param: vnf_id }, vf_module_id: { get_param: vf_module_id }}\n user_data_format: RAW\n user_data:\n str_replace:\n params:\n __webserver__: { get_param: webserver_ip }\n __protected_net_gw__: { get_param: vfw_private_ip_1 }\n __unprotected_net__: { get_param: unprotected_private_net_cidr }\n template: |\n #!/bin/bash\n\n WEBSERVER_IP=__webserver__\n PROTECTED_NET_GW=__protected_net_gw__\n UNPROTECTED_NET=__unprotected_net__\n UNPROTECTED_NET=$(echo $UNPROTECTED_NET | cut -d\'/\' -f1)\n\n mkdir /opt/config\n cd /opt\n wget http://$WEBSERVER_IP/demo_repo/v_sink_init.sh\n wget http://$WEBSERVER_IP/demo_repo/vsink.sh\n chmod +x v_sink_init.sh\n chmod +x vsink.sh\n echo $PROTECTED_NET_GW > config/protected_net_gw.txt\n echo $UNPROTECTED_NET > config/unprotected_net.txt\n echo \"no\" > config/install.txt\n mv vsink.sh /etc/init.d\n sudo update-rc.d vsink.sh defaults\n ./v_sink_init.sh\n\n vsn_private_0_port:\n type: OS::Neutron::Port\n properties:\n network: { get_resource: protected_private_network }\n fixed_ips: [{\"subnet\": { get_resource: protected_private_subnet }, \"ip_address\": { get_param: vsn_private_ip_0 }}]\n\n vsn_private_1_port:\n type: OS::Neutron::Port\n properties:\n network: { get_param: ecomp_private_net_id }\n fixed_ips: [{\"subnet\": { get_param: ecomp_private_net_id }, \"ip_address\": { get_param: vsn_private_ip_1 }}]\n \n',300,'MANUAL RECORD','2016-11-14 13:04:07'); -# -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','dcae_collector_ip','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','ecomp_private_net_cidr','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','ecomp_private_net_id','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','key_name','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','protected_private_net_cidr','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','protected_private_net_id','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','public_net_id','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','pub_key','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','unprotected_private_net_cidr','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','unprotected_private_net_id','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vfw_flavor_name','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vfw_image_name','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vfw_name_0','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vfw_private_ip_0','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vfw_private_ip_1','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vfw_private_ip_2','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vf_module_id','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vnf_id','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vpg_name_0','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vpg_private_ip_0','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vpg_private_ip_1','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vsn_name_0','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vsn_private_ip_0','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','vsn_private_ip_1','','string',NULL); -# INSERT INTO `heat_template_params` (`HEAT_TEMPLATE_ARTIFACT_UUID`, `PARAM_NAME`, `IS_REQUIRED`, `PARAM_TYPE`, `PARAM_ALIAS`) VALUES ('Artifact-UUID3','webserver_ip','','string',NULL); -# -# INSERT INTO `service` (`MODEL_UUID`, `MODEL_NAME`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `TOSCA_CSAR_ARTIFACT_UUID`) VALUES ('2e34774e-715e-4fd5-bd09-7b654622f35i','vfw-service','585822c7-4027-4f84-ba50-e9248606f112','1.0','VFW service','2016-11-14 13:04:07',NULL); -# -# INSERT INTO `vf_module` (`MODEL_UUID`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `MODEL_NAME`, `DESCRIPTION`, `IS_BASE`, `HEAT_TEMPLATE_ARTIFACT_UUID`, `VOL_HEAT_TEMPLATE_ARTIFACT_UUID`, `CREATION_TIMESTAMP`, `VNF_RESOURCE_MODEL_UUID`) VALUES ('1e34774e-715e-4fd5-bd08-7b654622f33f.VF_RI1_VFW::module-1::module-1.group','585822c7-4027-4f84-ba50-e9248606f134','1.0','VF_RI1_VFW::module-1',NULL,1,'Artifact-UUID3',NULL,'2016-11-14 13:04:07','685822c7-4027-4f84-ba50-e9248606f132'); -# -# INSERT INTO `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`, `LABEL`, `INITIAL_COUNT`, `MIN_INSTANCES`, `MAX_INSTANCES`, `AVAILABILITY_ZONE_COUNT`, `HEAT_ENVIRONMENT_ARTIFACT_UUID`, `VOL_ENVIRONMENT_ARTIFACT_UUID`, `CREATION_TIMESTAMP`, `VF_MODULE_MODEL_UUID`) VALUES ('5aa23938-a9fe-11e7-8b4b-0242ac120002',NULL,1,0,NULL,NULL,'EnvArtifact-UUID3',NULL,'2017-10-05 18:52:03','1e34774e-715e-4fd5-bd08-7b654622f33f.VF_RI1_VFW::module-1::module-1.group'); -# -# INSERT INTO `vnf_res_custom_to_vf_module_custom` (`VNF_RESOURCE_CUST_MODEL_CUSTOMIZATION_UUID`, `VF_MODULE_CUST_MODEL_CUSTOMIZATION_UUID`, `CREATION_TIMESTAMP`) VALUES ('5a9bd247-a9fe-11e7-8b4b-0242ac120002','5aa23938-a9fe-11e7-8b4b-0242ac120002','2017-10-05 18:52:03'); -# -# INSERT INTO `vnf_resource` (`ORCHESTRATION_MODE`, `DESCRIPTION`, `CREATION_TIMESTAMP`, `MODEL_UUID`, `AIC_VERSION_MIN`, `AIC_VERSION_MAX`, `MODEL_INVARIANT_UUID`, `MODEL_VERSION`, `MODEL_NAME`, `TOSCA_NODE_TYPE`, `HEAT_TEMPLATE_ARTIFACT_UUID`) VALUES ('HEAT','VFW service1707MIGRATED','2016-11-14 13:04:07','685822c7-4027-4f84-ba50-e9248606f132',NULL,NULL,'585822c7-4027-4f84-ba50-e9248606f113','1.0','VFWResource',NULL,NULL); -# -# INSERT INTO `vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`, `MODEL_INSTANCE_NAME`, `MIN_INSTANCES`, `MAX_INSTANCES`, `AVAILABILITY_ZONE_MAX_COUNT`, `NF_TYPE`, `NF_ROLE`, `NF_FUNCTION`, `NF_NAMING_CODE`, `CREATION_TIMESTAMP`, `VNF_RESOURCE_MODEL_UUID`) VALUES ('5a9bd247-a9fe-11e7-8b4b-0242ac120002','VFWResource-1',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2017-10-05 18:52:03','685822c7-4027-4f84-ba50-e9248606f132'); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index f3315b57eb..c3159f0e3b 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -58,7 +58,6 @@ import ch.qos.logback.classic.spi.ILoggingEvent; @RunWith(SpringRunner.class) @SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") - public class CatalogDBRestTest { private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules"; @@ -748,32 +747,45 @@ public class CatalogDBRestTest { @Test public void testGetVFModulesBadQueryParam() throws JSONException, IOException { - TestAppender.events.clear(); - HttpEntity<String> entity = new HttpEntity<String>(null, headers); - headers.set("Accept", MediaType.APPLICATION_JSON); - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)) - .queryParam("ADASD", "NEUTRON_BASIC"); - - ResponseEntity<String> response = restTemplate.exchange( - builder.toUriString(), - HttpMethod.GET, entity, String.class); - - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value()); - JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); - - - ILoggingEvent logEvent = TestAppender.events.get(0); - Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(MsoLogger.BEGINTIME)); - assertNotNull(mdc.get(MsoLogger.ENDTIME)); - assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); - assertNotNull(mdc.get(MsoLogger.TIMER)); - assertEquals("500",mdc.get(MsoLogger.RESPONSECODE)); - assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); - assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME)); - assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE)); - assertNotNull(mdc.get(MsoLogger.RESPONSEDESC)); + TestAppender.events.clear(); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)) + .queryParam("ADASD", "NEUTRON_BASIC"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); + + + for(ILoggingEvent logEvent : TestAppender.events) + if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && + logEvent.getMarker().getName().equals("ENTRY") + ){ + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE)); + }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && + logEvent.getMarker().getName().equals("EXIT")){ + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.ENDTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.INVOCATION_ID)); + assertEquals("500",mdc.get(MsoLogger.RESPONSECODE)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE)); + assertNotNull(mdc.get(MsoLogger.RESPONSEDESC)); + } } private String createURLWithPort(String uri) { diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java new file mode 100644 index 0000000000..9ed61b33a3 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb.catalogrest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import java.net.URI; +import java.util.List; + +import javax.transaction.Transactional; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.BuildingBlockDetail; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; +import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; +import org.onap.so.db.catalog.beans.ServerType; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.MsoLogger; +import org.onap.so.logging.jaxrs.filter.jersey.SpringClientFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.util.UriComponentsBuilder; +import uk.co.blackpepper.bowman.Client; +import uk.co.blackpepper.bowman.ClientFactory; +import uk.co.blackpepper.bowman.Configuration; +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class CloudConfigTest { + + protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); + + protected HttpHeaders headers = new HttpHeaders(); + + @LocalServerPort + private int port; + + @Test + @Transactional + public void createCloudSiteRest_TEST() { + headers.set("Accept", MediaType.APPLICATION_JSON); + headers.set("Content-Type",MediaType.APPLICATION_JSON); + + CloudSite cloudSite = new CloudSite(); + cloudSite.setId("MTN6"); + cloudSite.setClli("TESTCLLI"); + cloudSite.setRegionId("regionId"); + cloudSite.setCloudVersion("VERSION"); + cloudSite.setPlatform("PLATFORM"); + + CloudIdentity cloudIdentity = new CloudIdentity(); + cloudIdentity.setId("RANDOMID"); + cloudIdentity.setIdentityUrl("URL"); + cloudIdentity.setMsoId("MSO_ID"); + cloudIdentity.setMsoPass("MSO_PASS"); + cloudIdentity.setAdminTenant("ADMIN_TENANT"); + cloudIdentity.setMemberRole("ROLE"); + cloudIdentity.setIdentityServerType(ServerType.KEYSTONE); + cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY); + cloudSite.setIdentityService(cloudIdentity); + String uri = "/cloudSite"; + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri); + HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers); + ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), + HttpMethod.POST, request, String.class); + assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value()); + + builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri +"/" + cloudSite.getId()); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + ResponseEntity<CloudSite> actualCloudSite = restTemplate.exchange(builder.toUriString(),HttpMethod.GET, entity, CloudSite.class); + + assertEquals(Response.Status.OK.getStatusCode(), actualCloudSite.getStatusCode().value()); + assertThat(actualCloudSite.getBody(), sameBeanAs(cloudSite).ignoring("created").ignoring("updated") + .ignoring("identityService.created").ignoring("identityService.updated")); + + } + +} 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 1b71d16e57..4106e8ac6d 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 @@ -1,4 +1,54 @@ +CREATE TABLE IF NOT EXISTS `identity_services` ( + `ID` varchar(50) NOT NULL, + `IDENTITY_URL` varchar(200) DEFAULT NULL, + `MSO_ID` varchar(255) DEFAULT NULL, + `MSO_PASS` varchar(255) DEFAULT NULL, + `ADMIN_TENANT` varchar(50) DEFAULT NULL, + `MEMBER_ROLE` varchar(50) DEFAULT NULL, + `TENANT_METADATA` tinyint(1) DEFAULT 0, + `IDENTITY_SERVER_TYPE` varchar(50) DEFAULT NULL, + `IDENTITY_AUTHENTICATION_TYPE` varchar(50) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`) +) ; + + + +CREATE TABLE IF NOT EXISTS `cloudify_managers` ( + `ID` varchar(50) NOT NULL, + `CLOUDIFY_URL` varchar(200) DEFAULT NULL, + `USERNAME` varchar(255) DEFAULT NULL, + `PASSWORD` varchar(255) DEFAULT NULL, + `VERSION` varchar(20) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`) +) ; + + + + +CREATE TABLE IF NOT EXISTS `cloud_sites` ( + `ID` varchar(50) NOT NULL, + `REGION_ID` varchar(11) DEFAULT NULL, + `IDENTITY_SERVICE_ID` varchar(50) DEFAULT NULL, + `CLOUD_VERSION` varchar(20) DEFAULT NULL, + `CLLI` varchar(11) DEFAULT NULL, + `CLOUDIFY_ID` varchar(50) DEFAULT NULL, + `PLATFORM` varchar(50) DEFAULT NULL, + `ORCHESTRATOR` varchar(50) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`), + KEY `FK_cloud_sites_identity_services` (`IDENTITY_SERVICE_ID`), + CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`) +) ; + insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values ('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43'); @@ -29,9 +79,6 @@ insert into collection_resource_instance_group_customization(COLLECTION_RESOURCE insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values ('5df8b6de-2083-11e7-93ae-92361f002672', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '2.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', null, 'NA', 'NA', 'Luna', 'Oxygen'); -insert into service_recipe(id, action, version_str, description, orchestration_uri, service_param_xsd, recipe_timeout, service_timeout_interim, creation_timestamp, service_model_uuid) values -('1', 'createInstance', '1', 'MSOTADevInfra aLaCarte', '/mso/async/services/CreateGenericALaCarteServiceInstance', null, '180', '0', '2017-04-14 19:18:20', '5df8b6de-2083-11e7-93ae-92361f002671'); - insert into heat_template(artifact_uuid, name, version, description, body, timeout_minutes, artifact_checksum, creation_timestamp) values ('ff874603-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'), ('ff87482f-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'), @@ -134,65 +181,5 @@ insert into allotted_resource_customization_to_service(service_model_uuid, resou ('5df8b6de-2083-11e7-93ae-92361f002671', '367a8ba9-057a-4506-b106-fbae818597c6' ), ('5df8b6de-2083-11e7-93ae-92361f002672', '367a8ba9-057a-4506-b106-fbae818597c6'); - - -insert into vnf_recipe(id, nf_role, action, service_type, version_str, description, orchestration_uri, vnf_param_xsd, recipe_timeout, creation_timestamp, vf_module_id) values -('61', '*', 'CREATE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/workflow/services/CreateGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), -('63', '*', 'DELETE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/deleteGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), -('65', '*', 'UPDATE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/workflow/services/updateGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), -('67', '*', 'CREATE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/CreateVfModule', '', '180', '2016-06-03 10:14:10', '*'), -('69', '*', 'DELETE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/DeleteVfModule', '', '180', '2016-06-03 10:14:10', '*'), -('71', '*', 'UPDATE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/UpdateVfModule', '', '180', '2016-06-03 10:14:10', '*'), -('77', 'VID_DEFAULT', 'createInstance', '', '1', 'VID_DEFAULT recipe to create VNF if no custom BPMN flow is found', '/mso/async/services/CreateVnfInfra', '', '180', '2016-09-14 19:18:20', ''), -('78', 'VID_DEFAULT', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete VNF if no custom BPMN flow is found', '/mso/async/services/DeleteVnfInfra', '', '180', '2016-09-14 19:18:20', ''), -('81', 'VID_DEFAULT', 'updateInstance', '', '1', 'VID_DEFAULT update', '/mso/async/services/UpdateVnfInfra', '', '180', '2017-07-28 18:19:39', ''), -('85', 'VID_DEFAULT', 'replaceInstance', '', '1', 'VID_DEFAULT replace', '/mso/async/services/ReplaceVnfInfra', '', '180', '2017-07-28 18:19:45', ''), -('10000', 'VID_DEFAULT', 'inPlaceSoftwareUpdate', '', '1', 'VID_DEFAULT inPlaceSoftwareUpdate', '/mso/async/services/VnfInPlaceUpdate', '', '180', '2017-10-25 18:19:45', ''), -('10001', 'VID_DEFAULT', 'applyUpdatedConfig', '', '1', 'VID_DEFAULT applyUpdatedConfig', '/mso/async/services/VnfConfigUpdate', '', '180', '2017-10-25 18:19:45', ''); - - insert into vnf_components(vnf_id, component_type, heat_template_id, heat_environment_id, creation_timestamp) values ('13961', 'VOLUME', '13843', '13961', '2016-05-19 20:22:02'); - -insert into vnf_components_recipe(id, vnf_type, vnf_component_type, action, service_type, version, description, orchestration_uri, vnf_component_param_xsd, recipe_timeout, creation_timestamp, vf_module_model_uuid) values -('5', '*', 'VOLUME_GROUP', 'CREATE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/createCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), -('7', '*', 'VOLUME_GROUP', 'DELETE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/deleteCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), -('9', '*', 'VOLUME_GROUP', 'UPDATE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/updateCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), -('13', '', 'VOLUME_GROUP', 'DELETE_VF_MODULE_VOL', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/DeleteVfModuleVolume', '', '180', '2016-06-03 10:15:11', '*'), -('15', '', 'VOLUME_GROUP', 'UPDATE_VF_MODULE_VOL', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/UpdateVfModuleVolume', '', '180', '2016-06-03 10:15:11', '*'), -('16', '', 'volumeGroup', 'createInstance', '', '1', 'VID_DEFAULT recipe to create volume-group if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('17', '', 'volumeGroup', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete volume-group if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('18', '', 'volumeGroup', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update volume-group if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('19', '', 'vfModule', 'createInstance', '', '1', 'VID_DEFAULT recipe to create vf-module if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('20', '', 'vfModule', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete vf-module if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('21', '', 'vfModule', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update vf-module if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), -('25', '', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT'); - -insert into network_recipe(id, model_name, action, description, orchestration_uri, network_param_xsd, recipe_timeout, service_type, creation_timestamp, version_str) values -('1', 'CONTRAIL_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('2', 'CONTRAIL_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('3', 'CONTRAIL_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('4', 'CONTRAIL_SHARED', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('5', 'CONTRAIL_SHARED', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('6', 'CONTRAIL_SHARED', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('7', 'CONTRAIL_EXTERNAL', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('8', 'CONTRAIL_EXTERNAL', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('9', 'CONTRAIL_EXTERNAL', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), -('10', 'CONTRAIL30_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), -('11', 'CONTRAIL30_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), -('12', 'CONTRAIL30_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), -('13', 'NEUTRON_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-06-01 19:54:51', '1'), -('17', 'VID_DEFAULT', 'createInstance', 'VID_DEFAULT recipe to create network if no custom BPMN flow is found', '/mso/async/services/CreateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), -('18', 'VID_DEFAULT', 'updateInstance', 'VID_DEFAULT recipe to update network if no custom BPMN flow is found', '/mso/async/services/UpdateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), -('19', 'VID_DEFAULT', 'deleteInstance', 'VID_DEFAULT recipe to delete network if no custom BPMN flow is found', '/mso/async/services/DeleteNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), -('124', 'CONTRAIL30_MPSCE', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), -('126', 'CONTRAIL30_MPSCE', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), -('128', 'CONTRAIL30_MPSCE', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), -('141', 'CONTRAIL30_L2NODHCP', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), -('144', 'CONTRAIL30_L2NODHCP', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), -('147', 'CONTRAIL30_L2NODHCP', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), -('169', 'CONTRAIL30_GNDIRECT', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), -('172', 'CONTRAIL30_GNDIRECT', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), -('175', 'CONTRAIL30_GNDIRECT', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), -('176', 'NEUTRON_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-09-22 18:47:31', '1'), -('177', 'NEUTRON_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-09-22 18:47:31', '1'); diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml index aceeda408b..715cef8db1 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml +++ b/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml @@ -1,12 +1,18 @@ <configuration> - + <property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}"/> + <property name="p_lvl" value="%level"/> + <property name="p_log" value="%logger"/> + <property name="p_mdc" value="%replace(%replace(%mdc){'\t','\\\\t'}){'\n', '\\\\n'}"/> + <property name="p_msg" value="%replace(%replace(%msg){'\t', '\\\\t'}){'\n','\\\\n'}"/> + <property name="p_exc" value="%replace(%replace(%rootException){'\t', '\\\\t'}){'\n','\\\\n'}"/> + <property name="p_mak" value="%replace(%replace(%marker){'\t', '\\\\t'}){'\n','\\\\n'}"/> + <property name="p_thr" value="%thread"/> + <property name="pattern" value="%nopexception${p_tim}\t${p_thr}\t${p_lvl}\t${p_log}\t${p_mdc}\t${p_msg}\t${p_exc}\t${p_mak}\t%n"/> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> - <pattern>%d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level - %logger{1024} - %msg%n - </pattern> + <pattern>${pattern}</pattern> </encoder> </appender> @@ -27,6 +33,7 @@ <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> <appender-ref ref="STDOUT" /> + <appender-ref ref="test" /> </logger> <logger name="org.flywaydb" level="DEBUG" additivity="false"> @@ -38,12 +45,10 @@ <appender-ref ref="STDOUT" /> </logger> - <logger name="AUDIT" level="info" additivity="true"> - <appender-ref ref="test" /> - </logger> <root level="WARN"> <appender-ref ref="STDOUT" /> + <appender-ref ref="test" /> </root> diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 5f5da85a88..01c1df304e 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -194,17 +194,17 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>3.1.11</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.webjars</groupId> @@ -218,6 +218,10 @@ <scope>test</scope> </dependency> <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </dependency> + <dependency> <groupId>janino</groupId> <artifactId>janino</artifactId> <version>2.5.15</version> @@ -264,5 +268,9 @@ <version>1.2.4.RELEASE</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.flywaydb</groupId> + <artifactId>flyway-core</artifactId> + </dependency> </dependencies> </project> diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java new file mode 100644 index 0000000000..0309c88dac --- /dev/null +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/CloudConfig.java @@ -0,0 +1,67 @@ +package db.migration; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * @deprecated + * This class is introduced as deprecated as its only purpose is for migration of cloud config data. It shouldnt be used elsewhere. + */ + +@Deprecated +@JsonIgnoreProperties(ignoreUnknown = true) +public class CloudConfig { + @JsonProperty("identity_services") + private Map<String, CloudIdentity> identityServices = new HashMap<>(); + + @JsonProperty("cloud_sites") + private Map<String, CloudSite> cloudSites = new HashMap<>(); + + @JsonProperty("cloudify_managers") + private Map<String, CloudifyManager> cloudifyManagers = new HashMap<>(); + + + public Map<String, CloudIdentity> getIdentityServices() { + return identityServices; + } + + public void setIdentityServices(Map<String, CloudIdentity> identityServices) { + this.identityServices = identityServices; + } + + public Map<String, CloudSite> getCloudSites() { + return cloudSites; + } + + public void setCloudSites(Map<String, CloudSite> cloudSites) { + this.cloudSites = cloudSites; + } + + public Map<String, CloudifyManager> getCloudifyManagers() { + return cloudifyManagers; + } + + public void setCloudifyManagers(Map<String, CloudifyManager> cloudifyManagers) { + this.cloudifyManagers = cloudifyManagers; + } + + public void populateId(){ + for (Map.Entry<String, CloudIdentity> entry : identityServices.entrySet()) { + entry.getValue().setId(entry.getKey()); + } + + for (Map.Entry <String, CloudSite> entry : cloudSites.entrySet()) { + entry.getValue().setId(entry.getKey()); + } + + for (Map.Entry<String, CloudifyManager> entry : cloudifyManagers.entrySet()) { + entry.getValue().setId(entry.getKey()); + } + } +} diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java new file mode 100644 index 0000000000..fd2ec179dc --- /dev/null +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/R__CloudConfigMigration.java @@ -0,0 +1,167 @@ +package db.migration; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import org.flywaydb.core.api.MigrationVersion; +import org.flywaydb.core.api.migration.MigrationChecksumProvider; +import org.flywaydb.core.api.migration.MigrationInfoProvider; +import org.flywaydb.core.api.migration.jdbc.JdbcMigration; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.CloudifyManager; +import org.onap.so.logger.MsoLogger; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Collection; + +/** + * Performs migration using JDBC Connection from the cloud config provided in the environment (application-{profile}.yaml) and persist data (when not already present) to the catalod database. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class R__CloudConfigMigration implements JdbcMigration , MigrationInfoProvider, MigrationChecksumProvider { + public static final String FLYWAY = "FLYWAY"; + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, R__CloudConfigMigration.class); + @JsonProperty("cloud_config") + private CloudConfig cloudConfig; + + @Override + public void migrate(Connection connection) throws Exception { + LOGGER.debug("Starting migration for CloudConfig"); + CloudConfig cloudConfig = loadCloudConfig(); + if(cloudConfig == null){ + LOGGER.debug("No CloudConfig defined in :"+getApplicationYamlName()+" exiting."); + }else{ + migrateCloudIdentity(cloudConfig.getIdentityServices().values(), connection); + migrateCloudSite(cloudConfig.getCloudSites().values(), connection); + migrateCloudifyManagers(cloudConfig.getCloudifyManagers().values(), connection); + } + } + + public CloudConfig getCloudConfig() { + return cloudConfig; + } + + public void setCloudConfig(CloudConfig cloudConfig) { + this.cloudConfig = cloudConfig; + } + + private CloudConfig loadCloudConfig() throws Exception { + ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); + R__CloudConfigMigration cloudConfigMigration = mapper.readValue(R__CloudConfigMigration.class + .getResourceAsStream(getApplicationYamlName()), R__CloudConfigMigration.class); + CloudConfig cloudConfig = cloudConfigMigration.getCloudConfig(); + if(cloudConfig != null){ + cloudConfig.populateId(); + } + + return cloudConfig; + } + + private String getApplicationYamlName() { + String profile = System.getProperty("spring.profiles.active") == null ? "" : "-" + System.getProperty("spring.profiles.active"); + return "/application" + profile + ".yaml"; + } + + private void migrateCloudIdentity(Collection<CloudIdentity> entities, Connection connection) throws Exception { + LOGGER.debug("Starting migration for CloudConfig-->IdentityService"); + String insert = "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`) " + + "VALUES (?,?,?,?,?,?,?,?,?,?);"; + PreparedStatement ps = connection.prepareStatement(insert); + try (Statement stmt = connection.createStatement()) { + for (CloudIdentity cloudIdentity : entities) { + try (ResultSet rows = stmt.executeQuery("Select count(1) from identity_services where id='" + cloudIdentity.getId() + "'")) { + int count = 0; + while (rows.next()) { + count = rows.getInt(1); + } + if (count == 0) { + ps.setString(1, cloudIdentity.getId()); + ps.setString(2, cloudIdentity.getIdentityUrl()); + ps.setString(3, cloudIdentity.getMsoId()); + ps.setString(4, cloudIdentity.getMsoPass()); + ps.setString(5, cloudIdentity.getAdminTenant()); + ps.setString(6, cloudIdentity.getMemberRole()); + ps.setBoolean(7, cloudIdentity.getTenantMetadata()); + ps.setString(8, cloudIdentity.getIdentityServerType() != null ? cloudIdentity.getIdentityServerType().name() : null); + ps.setString(9, cloudIdentity.getIdentityAuthenticationType() != null ? cloudIdentity.getIdentityAuthenticationType().name() : null); + ps.setString(10, FLYWAY); + ps.executeUpdate(); + } + } + } + } + } + + private void migrateCloudSite(Collection<CloudSite> entities, Connection connection) throws Exception { + LOGGER.debug("Starting migration for CloudConfig-->CloudSite"); + String insert = "INSERT INTO `cloud_sites` (`ID`, `REGION_ID`, `IDENTITY_SERVICE_ID`, `CLOUD_VERSION`, `CLLI`, `CLOUDIFY_ID`, `PLATFORM`, `ORCHESTRATOR`, `LAST_UPDATED_BY`) " + + "VALUES (?,?,?,?,?,?,?,?,?);"; + PreparedStatement ps = connection.prepareStatement(insert); + try (Statement stmt = connection.createStatement()) { + for (CloudSite cloudSite : entities) { + try (ResultSet rows = stmt.executeQuery("Select count(1) from cloud_sites where id='" + cloudSite.getId() + "'")) { + int count = 0; + while (rows.next()) { + count = rows.getInt(1); + } + if (count == 0) { + ps.setString(1, cloudSite.getId()); + ps.setString(2, cloudSite.getRegionId()); + ps.setString(3, cloudSite.getIdentityServiceId()); + ps.setString(4, cloudSite.getCloudVersion()); + ps.setString(5, cloudSite.getClli()); + ps.setString(6, cloudSite.getCloudifyId()); + ps.setString(7, cloudSite.getPlatform()); + ps.setString(8, cloudSite.getOrchestrator()); + ps.setString(9, FLYWAY); + ps.executeUpdate(); + } + } + } + } + } + + private void migrateCloudifyManagers(Collection<CloudifyManager> entities, Connection connection) throws Exception { + String insert = "INSERT INTO `cloudify_managers` (`ID`, `CLOUDIFY_URL`, `USERNAME`, `PASSWORD`, `VERSION`, `LAST_UPDATED_BY`)" + + " VALUES (?,?,?,?,?,?);"; + PreparedStatement ps = connection.prepareStatement(insert); + try (Statement stmt = connection.createStatement()) { + for (CloudifyManager cloudifyManager : entities) { + try (ResultSet rows = stmt.executeQuery("Select count(1) from cloudify_managers where id='" + cloudifyManager.getId() + "'")) { + int count = 0; + while (rows.next()) { + count = rows.getInt(1); + } + if (count == 0) { + ps.setString(1, cloudifyManager.getId()); + ps.setString(2, cloudifyManager.getCloudifyUrl()); + ps.setString(3, cloudifyManager.getUsername()); + ps.setString(4, cloudifyManager.getPassword()); + ps.setString(5, cloudifyManager.getVersion()); + ps.setString(6, FLYWAY); + ps.executeUpdate(); + } + } + } + } + } + + public MigrationVersion getVersion() { + return null; + } + + public String getDescription() { + return "R_CloudConfigMigration"; + } + + public Integer getChecksum() { + return Math.toIntExact(System.currentTimeMillis() / 1000); + } +} + diff --git a/adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java b/adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java new file mode 100644 index 0000000000..6530b7ba7c --- /dev/null +++ b/adapters/mso-openstack-adapters/src/main/java/db/migration/V4_2__DummyMigration.java @@ -0,0 +1,12 @@ +package db.migration; + +import org.flywaydb.core.api.migration.jdbc.JdbcMigration; + +import java.sql.Connection; + +public class V4_2__DummyMigration implements JdbcMigration { + @Override + public void migrate(Connection connection) throws Exception { + + } +} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index f5a05b7333..e5a8d3faa1 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -36,7 +36,7 @@ import org.onap.so.adapters.network.beans.ContrailSubnet; import org.onap.so.adapters.network.exceptions.NetworkException; import org.onap.so.adapters.network.mappers.ContrailSubnetMapper; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.HeatTemplate; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; @@ -1167,7 +1167,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } MavenLikeVersioning aicV = new MavenLikeVersioning(); - aicV.setVersion(cloudSite.getAicVersion()); + aicV.setVersion(cloudSite.getCloudVersion()); if ((aicV.isMoreRecentThan(networkResource.getAicVersionMin()) || aicV .isTheSameVersion(networkResource.getAicVersionMin())) // aic // >= @@ -1181,13 +1181,13 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { + networkResource.getAicVersionMin() + " VersionMax:" + networkResource.getAicVersionMax() + " supported on Cloud:" + cloudSiteId - + " with AIC_Version:" + cloudSite.getAicVersion()); + + " with AIC_Version:" + cloudSite.getCloudVersion()); } else { String error = "Network Type:" + networkType + " Version_Min:" + networkResource.getAicVersionMin() + " Version_Max:" + networkResource.getAicVersionMax() + " not supported on Cloud:" + cloudSiteId - + " with AIC_Version:" + cloudSite.getAicVersion(); + + " with AIC_Version:" + cloudSite.getCloudVersion(); LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Network Type not supported on Cloud"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java index d67a4b684c..02aa0843ae 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java @@ -34,8 +34,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @SpringBootApplication(scanBasePackages = { "org.onap.so" }) @EnableAsync @EnableJpaRepositories({ "org.onap.so.db.catalog.data.repository", - "org.onap.so.db.request.data.repository" }) -@EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans" }) + "org.onap.so.db.request.data.repository"}) +@EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans"}) public class MsoOpenstackAdaptersApplication { @Value("${mso.async.core-pool-size}") diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java index ef66d6876c..37a84c1a56 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tenant/MsoTenantAdapter.java @@ -50,7 +50,7 @@ public interface MsoTenantAdapter @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="tenantId", mode=Mode.OUT) Holder<String> tenantId, @WebParam(name="rollback", mode=Mode.OUT) Holder<TenantRollback> rollback ) - throws TenantException, TenantAlreadyExists; + throws TenantException; @WebMethod public void queryTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId, diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 8a55e0717e..29d8f297bf 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -39,7 +39,7 @@ import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.adapters.vnf.exceptions.VnfNotFound; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.HeatFiles; import org.onap.so.db.catalog.beans.HeatTemplate; @@ -859,7 +859,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (this.cloudConfig != null) { Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId); if (cloudSiteOpt.isPresent()) { - aicV.setVersion(cloudSiteOpt.get().getAicVersion()); + aicV.setVersion(cloudSiteOpt.get().getCloudVersion()); // Add code to handle unexpected values in here boolean moreThanMin = true; boolean equalToMin = true; @@ -878,10 +878,10 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (!doNotTest) { if ((moreThanMin || equalToMin) // aic >= min && (equalToMax || !(moreThanMax))) { //aic <= max - LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getAicVersion()); + LOGGER.debug("VNF Resource " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion()); } else { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getAicVersion(); + String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + minVersionVnf + " VersionMax:" + maxVersionVnf + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSiteOpt.get().getCloudVersion(); LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); @@ -1606,7 +1606,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { if (this.cloudConfig != null) { Optional<CloudSite> cloudSiteOpt = this.cloudConfig.getCloudSite(cloudSiteId); if (cloudSiteOpt.isPresent()) { - aicV.setVersion(cloudSiteOpt.get().getAicVersion()); + aicV.setVersion(cloudSiteOpt.get().getCloudVersion()); boolean moreThanMin = true; boolean equalToMin = true; boolean moreThanMax = true; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java index 0266e87523..1cf65cb6fc 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java @@ -34,7 +34,7 @@ import javax.xml.ws.Holder; import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.cloudify.beans.DeploymentInfo; import org.onap.so.cloudify.beans.DeploymentStatus; import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound; @@ -663,7 +663,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } CloudSite cloudSite = cloudSiteOp.get(); MavenLikeVersioning aicV = new MavenLikeVersioning(); - aicV.setVersion(cloudSite.getAicVersion()); + aicV.setVersion(cloudSite.getCloudVersion()); String vnfMin = vnfResource.getAicVersionMin(); String vnfMax = vnfResource.getAicVersionMax(); @@ -672,7 +672,7 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getAicVersion(); + String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java index 0a7b30f9ca..b440f7d521 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java @@ -59,7 +59,7 @@ import org.onap.so.adapters.vdu.mapper.VfModuleCustomizationToVduMapper; import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.cloudify.utils.MsoCloudifyUtils; import org.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.HeatTemplate; @@ -705,7 +705,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { } CloudSite cloudSite = cloudSiteOp.get(); MavenLikeVersioning aicV = new MavenLikeVersioning(); - aicV.setVersion(cloudSite.getAicVersion()); + aicV.setVersion(cloudSite.getCloudVersion()); String vnfMin = vnfResource.getAicVersionMin(); String vnfMax = vnfResource.getAicVersionMax(); @@ -714,7 +714,7 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) { // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getAicVersion(); + String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); LOGGER.error(MessageEnum.RA_CONFIG_EXC, error, "OpenStack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - setVersion"); LOGGER.debug(error); throw new VnfException(error, MsoExceptionCategory.USERDATA); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java index 876aae8a37..4da026f454 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java @@ -23,7 +23,7 @@ package org.onap.so.adapters.vnf; import java.util.Optional; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudSite; +import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml index fa6078689e..469744d2de 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application-local.yaml @@ -114,21 +114,7 @@ spring: management: context-path: /manage -cloud_config: - identity_services: - MTN13: - identity_url: "http://localhost:5000/v2.0" - mso_id: "m93945" - mso_pass: "93937EA01B94A10A49279D4572B48369" - admin_tenant: "admin" - member_role: "admin" - tenant_metadata: true - identity_server_type: "KEYSTONE" - identity_authentication_type: "USERNAME_PASSWORD" - cloud_sites: - mtn13: - region_id: "mtn13" - clli: "MDT13" - aic_version: "3.0" - identity_service_id: "MTN13" +flyway: + outOfOrder: true + ignoreMissingMigrations: true diff --git a/adapters/mso-openstack-adapters/src/main/resources/application.yaml b/adapters/mso-openstack-adapters/src/main/resources/application.yaml index faca1a3056..4a4c83e4a5 100644 --- a/adapters/mso-openstack-adapters/src/main/resources/application.yaml +++ b/adapters/mso-openstack-adapters/src/main/resources/application.yaml @@ -38,3 +38,7 @@ spring: #Actuator management: context-path: /manage + +flyway: + outOfOrder: true + ignoreMissingMigrations: true
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java new file mode 100644 index 0000000000..b29e1f57a7 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/db/migration/CloudConfigMigrationTest.java @@ -0,0 +1,107 @@ +package db.migration; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.adapters.vnf.BaseRestTestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; + +public class CloudConfigMigrationTest extends BaseRestTestUtils { + + @Qualifier("dataSource") + @Autowired + DataSource dataSource; + + R__CloudConfigMigration cloudConfigMigration; + + @Before + public void setup() { + cloudConfigMigration = new R__CloudConfigMigration(); + } + + @Test + public void testMigrate() throws Exception { + System.setProperty("spring.profiles.active", "test"); + cloudConfigMigration.migrate(dataSource.getConnection()); + assertMigratedIdentityServiceData(); + assertMigratedCloudSiteData(); + assertMigratedCloudManagerData(); + } + + @Test + public void testMigrateNoData() throws Exception { + System.setProperty("spring.profiles.active", "nomigrate"); + int identityCount = getDataCount("identity_services"); + int cloudSiteCount = getDataCount("cloud_sites"); + int cloudManagerCount = getDataCount("cloudify_managers"); + + cloudConfigMigration.migrate(dataSource.getConnection()); + + Assert.assertEquals(identityCount, getDataCount("identity_services")); + Assert.assertEquals(cloudSiteCount, getDataCount("cloud_sites")); + Assert.assertEquals(cloudManagerCount, getDataCount("cloudify_managers")); + } + + + private int getDataCount(String tableName) throws Exception { + try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select count(1) from " + tableName)) { + while (rs.next()) { + return rs.getInt(1); + } + } + return 0; + } + + private void assertMigratedIdentityServiceData() throws Exception { + try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from identity_services where id='MTKEYSTONE'")) { + boolean dataAvailable = false; + while (rs.next()) { + dataAvailable = true; + Assert.assertEquals("MTKEYSTONE", rs.getString("id")); + Assert.assertEquals("http://localhost:5000/v2.0", rs.getString("identity_url")); + Assert.assertEquals("john", rs.getString("mso_id")); + Assert.assertEquals("313DECE408AF7759D442D7B06DD9A6AA", rs.getString("mso_pass")); + Assert.assertEquals("admin", rs.getString("admin_tenant")); + Assert.assertEquals("_member_", rs.getString("member_role")); + Assert.assertEquals("KEYSTONE", rs.getString("identity_server_type")); + Assert.assertEquals("USERNAME_PASSWORD", rs.getString("identity_authentication_type")); + } + Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable); + } + } + + private void assertMigratedCloudSiteData() throws Exception { + try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloud_sites where id='regionOne'")) { + boolean dataAvailable = false; + while (rs.next()) { + dataAvailable = true; + Assert.assertEquals("regionOne", rs.getString("id")); + Assert.assertEquals("regionOne", rs.getString("region_id")); + Assert.assertEquals("MT2", rs.getString("clli")); + Assert.assertEquals("2.5", rs.getString("cloud_version")); + Assert.assertEquals("MTKEYSTONE", rs.getString("identity_service_id")); + } + Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable); + } + } + + private void assertMigratedCloudManagerData() throws Exception { + try (Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from cloudify_managers where id='manager'")) { + boolean dataAvailable = false; + while (rs.next()) { + dataAvailable = true; + Assert.assertEquals("http://localhost:8080", rs.getString("cloudify_url")); + Assert.assertEquals("user", rs.getString("username")); + Assert.assertEquals("password", rs.getString("password")); + Assert.assertEquals("2.0", rs.getString("version")); + } + Assert.assertTrue("Expected data in identity_services table post migration but didnt find any!!!", dataAvailable); + } + } +} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java index acfe6568af..ea21687bc5 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tenant/TenantAdapterRestTest.java @@ -75,7 +75,7 @@ public class TenantAdapterRestTest extends BaseRestTestUtils { cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateTenantRequest request = new CreateTenantRequest(); - String cloudSiteId = "mtn13"; + String cloudSiteId = "MTN13"; String requestId = "62265093-277d-4388-9ba6-449838ade586"; String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; String tenantName = "testingTenantName"; @@ -127,7 +127,7 @@ public class TenantAdapterRestTest extends BaseRestTestUtils { cloudConfig.getIdentityService("MTN13").setIdentityUrl("http://localhost:" + wireMockPort + "/v2.0"); CreateTenantRequest request = new CreateTenantRequest(); - String cloudSiteId = "mtn13"; + String cloudSiteId = "MTN13"; String requestId = "62265093-277d-4388-9ba6-449838ade586"; String serviceInstanceId = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; String tenantName = "testingTenantName"; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java new file mode 100644 index 0000000000..c982f8beb1 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java @@ -0,0 +1,146 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Nokia + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vdu.mapper; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.common.collect.Lists; +import java.util.List; +import org.junit.Test; +import org.onap.so.adapters.vdu.VduArtifact; +import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; +import org.onap.so.adapters.vdu.VduModelInfo; +import org.onap.so.db.catalog.beans.HeatEnvironment; +import org.onap.so.db.catalog.beans.HeatFiles; +import org.onap.so.db.catalog.beans.HeatTemplate; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.beans.VfModuleCustomization; + +public class VfModuleCustomizationToVduMapperTest { + + private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; + private static final String HEAT_ENV_NAME = "heatEnvName"; + private static final String HEAT_ENV_CONTENT = "heatEnvContent"; + private static final String MODULE_HEAT_TEMPLATE_NAME = "moduleHeatTemplateName"; + private static final String MODULE_HEAT_TEMPLATE_BODY = "moduleHeatTemplateBody"; + private static final String NESTED_TEMPLATE_NAME = "nestedTemplateName"; + private static final String NESTED_TEMPLATE_BODY = "nestedTemplateBody"; + private static final int TIMEOUT_IN_MIN = 66; + private static final String VF_MODULE_MODEL_INVARIANT_UUID = "vfModuleModelInvariantUUID"; + private static final String CLOUD_FILE_NAME = "cloudFileName"; + private static final String CLOUD_FILE_BODY = "cloudFileBody"; + + + @Test + public void mapVfModuleCustomizationToVdu_successful() { + // GIVEN + VfModuleCustomization vfModuleCustomization = createVfModuleCustomization(); + vfModuleCustomization.setHeatEnvironment(createHeatEnvironment(HEAT_ENV_NAME, HEAT_ENV_CONTENT)); + VfModule vfModule = createVfModule(); + vfModule.setModuleHeatTemplate(createHeatTemplate( + MODULE_HEAT_TEMPLATE_NAME, MODULE_HEAT_TEMPLATE_BODY, + NESTED_TEMPLATE_NAME, NESTED_TEMPLATE_BODY)); + vfModuleCustomization.setVfModule(vfModule); + + // WHEN + VduModelInfo vduModelInfo = new VfModuleCustomizationToVduMapper() + .mapVfModuleCustomizationToVdu(vfModuleCustomization); + + // THEN + assertThat(vduModelInfo.getModelCustomizationUUID()).isEqualTo(MODEL_CUSTOMIZATION_UUID); + assertThat(vduModelInfo.getTimeoutMinutes()).isEqualTo(TIMEOUT_IN_MIN); + assertThat(vduModelInfo.getArtifacts()).containsExactlyElementsOf(createExpectedVduArtifacts()); + } + + @Test + public void mapVfModuleCustVolumeToVdu_successful() { + // GIVEN + VfModuleCustomization vfModuleCustomization = createVfModuleCustomization(); + vfModuleCustomization.setVolumeHeatEnv(createHeatEnvironment(HEAT_ENV_NAME, HEAT_ENV_CONTENT)); + VfModule vfModule = createVfModule(); + vfModule.setVolumeHeatTemplate(createHeatTemplate( + MODULE_HEAT_TEMPLATE_NAME, MODULE_HEAT_TEMPLATE_BODY, + NESTED_TEMPLATE_NAME, NESTED_TEMPLATE_BODY)); + vfModuleCustomization.setVfModule(vfModule); + + // WHEN + VduModelInfo vduModelInfo = new VfModuleCustomizationToVduMapper() + .mapVfModuleCustVolumeToVdu(vfModuleCustomization); + + // THEN + assertThat(vduModelInfo.getModelCustomizationUUID()).isEqualTo(MODEL_CUSTOMIZATION_UUID); + assertThat(vduModelInfo.getTimeoutMinutes()).isEqualTo(TIMEOUT_IN_MIN); + assertThat(vduModelInfo.getArtifacts()).containsExactlyElementsOf(createExpectedVduArtifacts()); + } + + private VfModuleCustomization createVfModuleCustomization() { + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vfModuleCustomization; + } + + private HeatEnvironment createHeatEnvironment(String volHeatEnvName, String volHeatEnvContent) { + HeatEnvironment heatEnvironment = new HeatEnvironment(); + heatEnvironment.setName(volHeatEnvName); + heatEnvironment.setEnvironment(volHeatEnvContent); + return heatEnvironment; + } + + private VfModule createVfModule() { + VfModule vfModule = new VfModule(); + vfModule.setModelInvariantUUID(VF_MODULE_MODEL_INVARIANT_UUID); + vfModule.setHeatFiles(createHeatFiles(CLOUD_FILE_NAME, CLOUD_FILE_BODY)); + return vfModule; + } + + private List<HeatFiles> createHeatFiles(String fileName, String fileBody) { + HeatFiles heatFiles = new HeatFiles(); + heatFiles.setFileName(fileName); + heatFiles.setFileBody(fileBody); + return Lists.newArrayList(heatFiles); + } + + private HeatTemplate createHeatTemplate(String moduleHeatTemplateName, String moduleHeatTemplateBody, + String childTemplateName, String childTemplateBody) { + HeatTemplate heatTemplate = new HeatTemplate(); + heatTemplate.setTemplateName(moduleHeatTemplateName); + heatTemplate.setTemplateBody(moduleHeatTemplateBody); + heatTemplate.setTimeoutMinutes(TIMEOUT_IN_MIN); + heatTemplate.setChildTemplates(createChildHeatTemplate(childTemplateName, childTemplateBody)); + return heatTemplate; + } + + private List<HeatTemplate> createChildHeatTemplate(String moduleHeatTemplateName, String moduleHeatTemplateBody) { + HeatTemplate heatTemplate = new HeatTemplate(); + heatTemplate.setTemplateName(moduleHeatTemplateName); + heatTemplate.setTemplateBody(moduleHeatTemplateBody); + return Lists.newArrayList(heatTemplate); + } + + private List<VduArtifact> createExpectedVduArtifacts() { + return Lists.newArrayList( + new VduArtifact(MODULE_HEAT_TEMPLATE_NAME, MODULE_HEAT_TEMPLATE_BODY.getBytes(), + ArtifactType.MAIN_TEMPLATE), + new VduArtifact(NESTED_TEMPLATE_NAME, NESTED_TEMPLATE_BODY.getBytes(), ArtifactType.NESTED_TEMPLATE), + new VduArtifact(CLOUD_FILE_NAME, CLOUD_FILE_BODY.getBytes(), ArtifactType.TEXT_FILE), + new VduArtifact(HEAT_ENV_NAME, HEAT_ENV_CONTENT.getBytes(), ArtifactType.ENVIRONMENT)); + } +} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java index a2faaaff78..d2b6d4f633 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/BaseRestTestUtils.java @@ -24,10 +24,15 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.openstack.MsoOpenstackAdaptersApplication; +import org.onap.so.db.catalog.beans.AuthenticationType; +import org.onap.so.db.catalog.beans.CloudIdentity; +import org.onap.so.db.catalog.beans.CloudSite; +import org.onap.so.db.catalog.beans.ServerType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; @@ -36,16 +41,20 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.http.HttpHeaders; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; +import javax.ws.rs.core.MediaType; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.reset; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; @RunWith(SpringRunner.class) @SpringBootTest(classes = MsoOpenstackAdaptersApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -63,6 +72,9 @@ public class BaseRestTestUtils { @LocalServerPort private int port; + + public ObjectMapper mapper; + protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{ ObjectMapper mapper = new ObjectMapper(); @@ -87,10 +99,53 @@ public class BaseRestTestUtils { return sb.toString(); } } - + + /*** + * Before each test execution, updating IdentityUrl port value to the ramdom wireMockPort + * Since URL will be used as a rest call and required to be mocked in unit tests + */ @Before - public void setUp(){ + public void setUp() throws Exception { reset(); + mapper = new ObjectMapper(); + + CloudIdentity identity = new CloudIdentity(); + identity.setId("MTN13"); + identity.setMsoId("m93945"); + identity.setMsoPass("93937EA01B94A10A49279D4572B48369"); + identity.setAdminTenant("admin"); + identity.setMemberRole("admin"); + identity.setTenantMetadata(new Boolean(true)); + identity.setIdentityUrl("http://localhost:"+wireMockPort+"/v2.0"); + identity.setIdentityAuthenticationType(AuthenticationType.USERNAME_PASSWORD); + + CloudSite cloudSite = new CloudSite(); + cloudSite.setId("MTN13"); + cloudSite.setCloudVersion("3.0"); + cloudSite.setClli("MDT13"); + cloudSite.setRegionId("mtn13"); + cloudSite.setOrchestrator("orchestrator" + + ""); + identity.setIdentityServerType(ServerType.KEYSTONE); + cloudSite.setIdentityService(identity); + + + stubFor(get(urlPathEqualTo("/cloudSite/MTN13")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) + .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/cloudSite/default")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(cloudSite),wireMockPort, "")) + .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + stubFor(get(urlPathEqualTo("/cloudIdentity/MTN13")).willReturn(aResponse() + .withBody(getBody(mapper.writeValueAsString(identity),wireMockPort, "")) + .withHeader(org.apache.http.HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON) + .withStatus(HttpStatus.SC_OK))); + } + + protected static String getBody(String body, int port, String urlPath) throws IOException { + return body.replaceAll("port", "http://localhost:" + port + urlPath); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java index 0ce3683a1e..005586e3ad 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java @@ -81,9 +81,10 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"; @Before - public void before() { + public void before() throws Exception { MockitoAnnotations.initMocks(this); WireMock.reset(); + setUp(); } @Test @@ -105,7 +106,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { Map<String, String> map = new HashMap<>(); map.put("key1", "value1"); - instance.createVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", + instance.createVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", "88a6ca3ee0394ade9403f075db23167e", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); @@ -510,7 +511,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { vfModuleCustomization.getVfModule().getModuleHeatTemplate().setParameters(new HashSet<>()); Map<String, String> map = new HashMap<>(); map.put("key1", "value1"); - instance.updateVfModule("mtn13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", + instance.updateVfModule("MTN13", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", vnfName, "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", "vfModuleStackId", "b4ea86b4-253f-11e7-93ae-92361f002671", map, msoRequest, new Holder<Map<String, String>>(), new Holder<VnfRollback>()); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java index 6f2c6cf86d..6674c7171f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java @@ -22,14 +22,13 @@ package org.onap.so.adapters.vnf; import org.apache.http.HttpStatus; -import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.onap.so.adapters.vnf.exceptions.VnfException; import org.onap.so.cloud.CloudConfig; -import org.onap.so.cloud.CloudifyManager; +import org.onap.so.db.catalog.beans.CloudifyManager; import org.onap.so.entity.MsoRequest; import org.onap.so.openstack.beans.VnfRollback; import org.springframework.beans.factory.annotation.Autowired; @@ -38,11 +37,7 @@ import javax.xml.ws.Holder; import java.util.HashMap; import java.util.Map; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; +import static com.github.tomakehurst.wiremock.client.WireMock.*; public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { @@ -56,23 +51,18 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { private CloudConfig cloudConfig; @Before - public void before(){ + public void before() throws Exception { super.setUp(); CloudifyManager cloudifyManager = new CloudifyManager(); cloudifyManager.setId("mtn13"); cloudifyManager.setCloudifyUrl("http://localhost:"+wireMockPort+"/v2.0"); cloudifyManager.setUsername("m93945"); cloudifyManager.setPassword("93937EA01B94A10A49279D4572B48369"); - cloudConfig.getCloudifyManagers().put("mtn13",cloudifyManager); } - @After - public void after(){ - cloudConfig.getCloudifyManagers().clear(); - } - - @Test - public void queryVnfNullPointerExceptionTest() throws Exception { + @Test + public void queryVnfExceptionTest() throws Exception { + reset(); expectedException.expect(VnfException.class); MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345"); diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json index 934e075220..b78f700fd9 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Created.json @@ -1,11 +1,11 @@ { "createTenantResponse": { - "cloudSiteId": "mtn13", + "cloudSiteId": "MTN13", "tenantId": "tenantId", "tenantCreated": true, "tenantRollback": { "tenantId": "tenantId", - "cloudId": "mtn13", + "cloudId": "MTN13", "tenantCreated": true, "msoRequest": { "requestId": "62265093-277d-4388-9ba6-449838ade586", diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json index 6f81ebcd36..977aa542b3 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateTenantResponse_Exists.json @@ -1,10 +1,10 @@ { "createTenantResponse": { - "cloudSiteId": "mtn13", + "cloudSiteId": "MTN13", "tenantId": "tenantId", "tenantCreated": false, "tenantRollback": { - "cloudId": "mtn13", + "cloudId": "MTN13", "tenantCreated": false, "msoRequest": { "requestId": "62265093-277d-4388-9ba6-449838ade586", diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml new file mode 100644 index 0000000000..c508b6e2d6 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/application-nomigrate.yaml @@ -0,0 +1,122 @@ +# will be used as entry in DB to say SITE OFF/ON for healthcheck +# MSO Properties go here +org: + onap: + so: + adapters: + default_keystone_url_version: /v2.0 + default_keystone_reg_ex: "/[vV][0-9]" + vnf: + bpelauth: 481E6A95CE97E393A53363750D5E1E75 + checkRequiredParameters: true + addGetFilesOnVolumeReq: false + sockettimeout: 30 + connecttimeout: 30 + retrycount: 5 + retryinterval: -15 + retrylist: 408,429,500,502,503,504,900 + network: + bpelauth: 481E6A95CE97E393A53363750D5E1E75 + sockettimeout: 5 + connecttimeout: 5 + retrycount: 5 + retryinterval: -15 + retrylist: 408,429,500,502,503,504,900 + tenant: + default_x_aic_orm_client_string: ONAP-SO + default_keystone_url_version: /v2.0 + default_keystone_reg_ex: "/[vV][0-9]" + default_tenant_description: ECOMP Tenant + default_region_type: single + default_user_role: admin + default_success_status_string: Success + default_no_regions_status_string: no regions + default_orm_request_path: /v1/orm/customers/ + default_orm_url_replace_this: 8080 + default_orm_url_replace_with_this: 7080 + default_quota_value: 10 + set_default_quota: false + valet: + base_url: http://localhost:${wiremock.server.port} + base_path: /api/valet/placement/v1/ + valet_auth: +ecomp: + mso: + adapters: + po: + retryCodes: 504 + retryDelay: 5 + retryCount: 3 + vnf: + heat: + create: + pollInterval: 15 + delete: + pollTimeout: 7500 + pollInterval: 15 + network: + heat: + create: + pollInterval: 15 + delete: + pollTimeout: 300 + pollInterval: 15 + +server-port: 8080 +ssl-enable: false +tomcat: + max-threads: 50 +mso: + logPath: logs + catalog: + db: + spring: + endpoint: http://localhost:${wiremock.server.port} + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + site-name: localDevEnv + async: + core-pool-size: 50 + max-pool-size: 50 + queue-capacity: 500 +spring: + datasource: + url: jdbc:mariadb://localhost:3307/catalogdb + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + initialization-mode: never + jpa: + generate-ddl: false + show-sql: false + hibernate: + ddl-auto: none + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5InnoDBDialect + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: MSO-Client + +mariaDB4j: + dataDir: + port: 3307 + databaseName: catalogdb + + +#Actuator +management: + endpoints: + enabled-by-default: false + endpoint: + info: + enabled: true + +flyway: + baseline-on-migrate: true + outOfOrder: true + ignoreMissingMigrations: true
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 97eecc2423..d15978357a 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -71,7 +71,7 @@ mso: catalog: db: spring: - endpoint: "http://localhost:" + endpoint: http://localhost:${wiremock.server.port} db: auth: Basic YnBlbDptc28tZGItMTUwNyE= site-name: localDevEnv @@ -118,13 +118,13 @@ management: cloud_config: identity_services: - MTN13: - identity_url: "http://localhost:${wiremock.server.port}/v2.0" - mso_id: "m93945" - mso_pass: "93937EA01B94A10A49279D4572B48369" + MTKEYSTONE: + identity_url: "http://localhost:5000/v2.0" + mso_id: "john" + mso_pass: "313DECE408AF7759D442D7B06DD9A6AA" admin_tenant: "admin" - member_role: "admin" - tenant_metadata: true + member_role: "_member_" + tenant_metadata: false identity_server_type: "KEYSTONE" identity_authentication_type: "USERNAME_PASSWORD" cloud_sites: @@ -135,3 +135,20 @@ cloud_config: identity_service_id: "MTN13" orchestrator: "orchestrator" cloudify_id: "mtn13" + regionOne: + region_id: "regionOne" + clli: "MT2" + aic_version: "2.5" + identity_service_id: "MTKEYSTONE" + cloudify_managers: + manager: + cloudify_url: "http://localhost:8080" + username: "user" + password: "password" + version: "2.0" + + +flyway: + baseline-on-migrate: true + outOfOrder: true + ignoreMissingMigrations: true
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql index 5fabec6c8a..d16ca4528c 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/data.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql @@ -136,7 +136,11 @@ INSERT INTO `heat_environment` (`ARTIFACT_UUID`, `NAME`, `VERSION`, `DESCRIPTION INSERT INTO `vf_module_customization` (`MODEL_CUSTOMIZATION_UUID`, `LABEL`, `INITIAL_COUNT`, `MIN_INSTANCES`, `MAX_INSTANCES`, `AVAILABILITY_ZONE_COUNT`, `HEAT_ENVIRONMENT_ARTIFACT_UUID`, `VOL_ENVIRONMENT_ARTIFACT_UUID`, `CREATION_TIMESTAMP`, `VF_MODULE_MODEL_UUID`) VALUES ('9b339a61-69ca-465f-86b8-1c72c582b8e8', 'base_vmme', 1, 1, 1, NULL, 'f4a21b58-5654-4cf6-9c50-de42004fe2b4', '3375f64b-4709-4802-8713-7a164763f9cd', '2018-05-13 12:12:09', '207fe0dc-4c89-4e5d-9a78-345e99ef7fbe'); +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 `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 d24d16d577..a051417cc1 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -781,4 +781,53 @@ create table if not exists model ( PRIMARY KEY (`ID`), CONSTRAINT uk1_model UNIQUE (`MODEL_TYPE`, `MODEL_VERSION_ID`), FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=latin1;
\ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `identity_services` ( + `ID` varchar(50) NOT NULL, + `IDENTITY_URL` varchar(200) DEFAULT NULL, + `MSO_ID` varchar(255) DEFAULT NULL, + `MSO_PASS` varchar(255) DEFAULT NULL, + `ADMIN_TENANT` varchar(50) DEFAULT NULL, + `MEMBER_ROLE` varchar(50) DEFAULT NULL, + `TENANT_METADATA` tinyint(1) DEFAULT 0, + `IDENTITY_SERVER_TYPE` varchar(50) DEFAULT NULL, + `IDENTITY_AUTHENTICATION_TYPE` varchar(50) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`) +) ; + + + +CREATE TABLE IF NOT EXISTS `cloudify_managers` ( + `ID` varchar(50) NOT NULL, + `CLOUDIFY_URL` varchar(200) DEFAULT NULL, + `USERNAME` varchar(255) DEFAULT NULL, + `PASSWORD` varchar(255) DEFAULT NULL, + `VERSION` varchar(20) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`) +) ; + + + +CREATE TABLE IF NOT EXISTS `cloud_sites` ( + `ID` varchar(50) NOT NULL, + `REGION_ID` varchar(11) DEFAULT NULL, + `IDENTITY_SERVICE_ID` varchar(50) DEFAULT NULL, + `CLOUD_VERSION` varchar(20) DEFAULT NULL, + `CLLI` varchar(11) DEFAULT NULL, + `CLOUDIFY_ID` varchar(50) DEFAULT NULL, + `PLATFORM` varchar(50) DEFAULT NULL, + `ORCHESTRATOR` varchar(50) DEFAULT NULL, + `LAST_UPDATED_BY` varchar(120) DEFAULT NULL, + `CREATION_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + `UPDATE_TIMESTAMP` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`ID`), + KEY `FK_cloud_sites_identity_services` (`IDENTITY_SERVICE_ID`), + CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`) +) ;
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index 175e7fbd19..934e2a544f 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -35,17 +35,17 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>3.1.11</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -118,17 +118,17 @@ <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-simple</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> </dependencies> <executions> @@ -213,7 +213,7 @@ cxf-java2ws-plugin </artifactId> <versionRange> - [3.1.12,) + [3.2.5,) </versionRange> <goals> <goal>java2ws</goal> diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index 7a051990bf..0337c2613e 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -121,17 +121,17 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>3.1.11</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index 9392db2a2a..d416c8e1e2 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -70,17 +70,17 @@ <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> - <version>3.1.12</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-service-description-swagger</artifactId> - <version>3.1.11</version> + <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/adapters/mso-vnf-adapter/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java b/adapters/mso-vnf-adapter/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java deleted file mode 100644 index c3d9cca0e9..0000000000 --- a/adapters/mso-vnf-adapter/src/test/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapperTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.vdu.mapper; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.adapters.vdu.VduArtifact; -import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.db.catalog.CatalogDatabase; -import org.onap.so.db.catalog.beans.HeatEnvironment; -import org.onap.so.db.catalog.beans.HeatFiles; -import org.onap.so.db.catalog.beans.HeatTemplate; -import org.onap.so.db.catalog.beans.VfModule; -import org.onap.so.db.catalog.beans.VfModuleCustomization; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({CatalogDatabase.class}) -public class VfModuleCustomizationToVduMapperTest { - - private static final String HEAT_TEMPLATE_ARTIFACT_UUID = "testHeatTemplate"; - private static final String VF_MODULE_MODEL_UUID = "vfModuleUuid"; - private static final String HEAT_ENV_ARTIFACT_UUID = "heatEnvArtifactUuid"; - private static final String MAIN_TEMPLATE_NAME = "testTempName"; - private static final String MAIN_TEMPLATE_BODY = "testTempBody"; - private static final String NESTED_TEMPLATE_KEY = "testKey"; - private static final String NESTED_TEMPLATE_VALUE = "nestedTemplateTest"; - private static final String HEAT_FILE_NAME = "heatFileName"; - private static final String HEAT_FILE_BODY = "heatFileBodyTest"; - private static final String HEAT_ENV_NAME = "heatEnvName"; - private static final String HEAT_ENV = "heatEnv"; - private static final String VOL_HEAT_TEMPLATE_ARTIFACT = "volEnvArtifact"; - private static final String VOL_ENV_ARTIFACT_UUID = "volEnvArtifactUuid"; - - private VfModuleCustomizationToVduMapper testedObject; - private CatalogDatabase catalogDatabaseMock; - - @Before - public void init() { - PowerMockito.mockStatic(CatalogDatabase.class); - catalogDatabaseMock = mock(CatalogDatabase.class); - testedObject = new VfModuleCustomizationToVduMapper(); - PowerMockito.when(CatalogDatabase.getInstance()).thenReturn(catalogDatabaseMock); - when(catalogDatabaseMock.getNestedTemplates(HEAT_TEMPLATE_ARTIFACT_UUID)).thenReturn(createNestedTemplates()); - when(catalogDatabaseMock.getHeatFilesForVfModule(VF_MODULE_MODEL_UUID)).thenReturn(createHeatFileMap()); - } - - @Test - public void mapVfModuleCustomizationToVdu_successful() { - when(catalogDatabaseMock.getHeatTemplateByArtifactUuid(HEAT_TEMPLATE_ARTIFACT_UUID)) - .thenReturn(createHeatTemplate()); - when(catalogDatabaseMock.getHeatEnvironmentByArtifactUuid(HEAT_ENV_ARTIFACT_UUID)) - .thenReturn(createHeatEnvironment()); - VduModelInfo result = testedObject.mapVfModuleCustomizationToVdu(createVfModuleCustomization()); - assertThat(result.getArtifacts()).containsExactly(createExpectedResultArray()); - } - - @Test - public void mapVfModuleCustVolumeToVdu_successful() { - when(catalogDatabaseMock.getHeatTemplateByArtifactUuid(VOL_HEAT_TEMPLATE_ARTIFACT)) - .thenReturn(createHeatTemplate()); - when(catalogDatabaseMock.getHeatEnvironmentByArtifactUuid(VOL_ENV_ARTIFACT_UUID)) - .thenReturn(createHeatEnvironment()); - VduModelInfo result = testedObject.mapVfModuleCustVolumeToVdu(createVfModuleCustomization()); - assertThat(result.getArtifacts()).containsExactly(createExpectedResultArray()); - } - - private VfModuleCustomization createVfModuleCustomization() { - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - VfModule vfModule = new VfModule(); - vfModule.setHeatTemplateArtifactUUId(HEAT_TEMPLATE_ARTIFACT_UUID); - vfModule.setVolHeatTemplateArtifactUUId(VOL_HEAT_TEMPLATE_ARTIFACT); - vfModuleCustomization.setVfModule(vfModule); - vfModuleCustomization.setVfModuleModelUuid(VF_MODULE_MODEL_UUID); - vfModuleCustomization.setHeatEnvironmentArtifactUuid(HEAT_ENV_ARTIFACT_UUID); - vfModuleCustomization.setVolEnvironmentArtifactUuid(VOL_ENV_ARTIFACT_UUID); - return vfModuleCustomization; - } - - private HeatTemplate createHeatTemplate() { - HeatTemplate heatTemplate = new HeatTemplate(); - heatTemplate.setTemplateName(MAIN_TEMPLATE_NAME); - heatTemplate.setTemplateBody(MAIN_TEMPLATE_BODY); - heatTemplate.setArtifactUuid(HEAT_TEMPLATE_ARTIFACT_UUID); - return heatTemplate; - } - - private Map<String, Object> createNestedTemplates() { - Map<String, Object> map = new HashMap<>(); - map.put(NESTED_TEMPLATE_KEY, NESTED_TEMPLATE_VALUE); - return map; - } - - private Map<String, HeatFiles> createHeatFileMap() { - HeatFiles heatFiles = new HeatFiles(); - heatFiles.setFileName(HEAT_FILE_NAME); - heatFiles.setFileBody(HEAT_FILE_BODY); - Map<String, HeatFiles> map = new HashMap<>(); - map.put("heatFileKey", heatFiles); - return map; - } - - private HeatEnvironment createHeatEnvironment() { - HeatEnvironment heatEnvironment = new HeatEnvironment(); - heatEnvironment.setName(HEAT_ENV_NAME); - heatEnvironment.setEnvironment(HEAT_ENV); - return heatEnvironment; - } - - - private VduArtifact[] createExpectedResultArray() { - VduArtifact[] vduArtifactsArray = new VduArtifact[4]; - vduArtifactsArray[0] = new VduArtifact(MAIN_TEMPLATE_NAME, MAIN_TEMPLATE_BODY.getBytes(), - ArtifactType.MAIN_TEMPLATE); - vduArtifactsArray[1] = new VduArtifact(NESTED_TEMPLATE_KEY, NESTED_TEMPLATE_VALUE.getBytes(), - ArtifactType.NESTED_TEMPLATE); - vduArtifactsArray[2] = createVduArtifact(HEAT_FILE_NAME, HEAT_FILE_BODY, ArtifactType.TEXT_FILE); - vduArtifactsArray[3] = createVduArtifact(HEAT_ENV_NAME, HEAT_ENV, ArtifactType.ENVIRONMENT); - return vduArtifactsArray; - } - - private VduArtifact createVduArtifact(String name, String content, ArtifactType artifactType) { - VduArtifact vduArtifact = new VduArtifact(); - vduArtifact.setName(name); - vduArtifact.setContent(content.getBytes()); - vduArtifact.setType(artifactType); - return vduArtifact; - } - -} |