diff options
172 files changed, 4699 insertions, 2771 deletions
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 75a8ca0593..16639d9166 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 @@ -127,12 +127,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { // Properties names and variables (with default values) protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - private String deletePollTimeoutProp = "org.onap.so.adapters.po.pollTimeout"; private String pollingMultiplierProp = "org.onap.so.adapters.po.pollMultiplier"; protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15"; - private static final String DELETE_POLL_INTERVAL_DEFAULT = "15"; private static final String POLLING_MULTIPLIER_DEFAULT = "60"; private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -177,7 +174,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception. */ - @SuppressWarnings("unchecked") public StackInfo createStack(String cloudSiteId, String cloudOwner, String tenantId, String stackName, VduModelInfo vduModel, String heatTemplate, Map<String, ?> stackInputs, boolean pollForCompletion, int timeoutMinutes, String environment, Map<String, Object> nestedTemplates, Map<String, Object> heatFiles, @@ -848,7 +844,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { * Boolean if any of the conversions should fail, we will default to adding it to the inputs as a string - see if * Openstack can handle it. Also, will remove any params that are extra. Any aliases will be converted to their * appropriate name (anyone use this feature?) - * + * * @param inputs - the Map<String, String> of the inputs received on the request * @param template the HeatTemplate object - this is so we can also verify if the param is valid for this template * @return HashMap<String, Object> of the inputs, cleaned and converted diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/DeleteVfModuleRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/DeleteVfModuleRequest.java index 6a979d754b..7e10bb3801 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/DeleteVfModuleRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/DeleteVfModuleRequest.java @@ -7,9 +7,9 @@ * 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. @@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; @XmlRootElement(name = "deleteVfModuleRequest") public class DeleteVfModuleRequest extends VfRequestCommon implements Serializable { /** - * + * */ private static final long serialVersionUID = -8504083539107392561L; private String cloudSiteId; @@ -39,6 +39,7 @@ public class DeleteVfModuleRequest extends VfRequestCommon implements Serializab private String vnfId; private String vfModuleId; private String vfModuleStackId; + private String modelCustomizationUuid; private MsoRequest msoRequest = new MsoRequest(); @@ -94,6 +95,14 @@ public class DeleteVfModuleRequest extends VfRequestCommon implements Serializab this.vfModuleStackId = vfModuleStackId; } + public String getModelCustomizationUuid() { + return modelCustomizationUuid; + } + + public void setModelCustomizationUuid(String modelCustomizationUuid) { + this.modelCustomizationUuid = modelCustomizationUuid; + } + public MsoRequest getMsoRequest() { return msoRequest; } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java index e5b51f72c9..1ad4238ade 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java @@ -28,7 +28,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication(scanBasePackages = {"org.onap.so.adapters.catalogdb", "org.onap.so.db.catalog.client", "org.onap.so.logging.jaxrs.filter", "org.onap.so.logging.spring.interceptor", "org.onap.so.client", - "org.onap.so.configuration", "org.onap.so.db", "org.onap.logging.filter", "org.onap.so.logger"}) + "org.onap.so.configuration", "org.onap.so.db", "org.onap.logging.filter", + "org.onap.so.logger, org.onap.so.security"}) @EnableJpaRepositories("org.onap.so.db.catalog.data.repository") @EntityScan("org.onap.so.db.catalog.beans") @EnableScheduling diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/SoCadiFilter.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/SoCadiFilter.java deleted file mode 100644 index e7e360d444..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.adapters.catalogdb; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java deleted file mode 100644 index 8cadb00f8f..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() - .httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} 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 edec48dc95..a98778bf5d 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 @@ -21,6 +21,7 @@ package org.onap.so.adapters.catalogdb.catalogrest; +import java.io.IOException; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -95,4 +96,17 @@ public abstract class CatalogQuery { return smartToJSON(); } + + protected boolean isJSONValid(String jsonInString) { + try { + if (jsonInString == null) { + return false; + } + ObjectMapper mapper = new ObjectMapper(); + mapper.readValue(jsonInString, String.class); + return true; + } catch (IOException e) { + return false; + } + } } 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 c1acc319f7..afcb2d5761 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 @@ -123,7 +123,10 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUUID()); put(valueMap, "PROVIDING_SERVICE_MODEL_NAME", o.getProvidingServiceModelName()); - put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + + if (isJSONValid(o.getResourceInput())) { + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + } sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; 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 5573b23a8d..129718241c 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 @@ -116,7 +116,10 @@ public class QueryServiceNetworks extends CatalogQuery { put(valueMap, "NETWORK_ROLE", o.getNetworkRole()); put(valueMap, "NETWORK_SCOPE", o.getNetworkScope()); put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology()); - put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + + if (isJSONValid(o.getResourceInput())) { + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + } sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; 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 0b8de60a81..d6e7415a77 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 @@ -23,6 +23,7 @@ package org.onap.so.adapters.catalogdb.catalogrest; /* should be called QueryVnfResource.java */ +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -32,6 +33,7 @@ import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.databind.ObjectMapper; @XmlRootElement(name = "serviceVnfs") public class QueryServiceVnfs extends CatalogQuery { @@ -120,7 +122,9 @@ public class QueryServiceVnfs extends CatalogQuery { put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode()); put(valueMap, "VNFC_INSTANCE_GROUP_ORDER", o.getVnfcInstanceGroupOrder()); put(valueMap, "MULTI_STEP_DESIGN", o.getMultiStageDesign()); - put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + if (isJSONValid(o.getResourceInput())) { + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + } String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true); valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t")); @@ -142,4 +146,5 @@ public class QueryServiceVnfs extends CatalogQuery { sb.append("}"); return sb.toString(); } + } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java index dc73fe904d..24c07d6d3e 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java @@ -20,12 +20,12 @@ package org.onap.so.adapters.catalogdb.catalogrest; -import org.onap.so.db.catalog.beans.VnfcCustomization; -import javax.xml.bind.annotation.XmlRootElement; 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.VnfcCustomization; @XmlRootElement(name = "vnfcs") public class QueryVnfcs extends CatalogQuery { @@ -105,8 +105,10 @@ public class QueryVnfcs extends CatalogQuery { put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantUUID()); put(valueMap, "MODEL_VERSION", o.getModelVersion()); put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID()); - put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + if (isJSONValid(o.getResourceInput())) { + put(valueMap, "RESOURCE_INPUT", o.getResourceInput()); + } sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap)); sep = ",\n"; } diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index 9527986f52..f5c7cd65c2 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -29,7 +29,8 @@ INSERT INTO northbound_request_ref_lookup(MACRO_ACTION, ACTION, REQUEST_SCOPE, I ('VFModule-Replace-Retain-Assignments', 'replaceInstanceRetainAssignments', 'VfModule', true,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Create', 'createInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), ('NetworkCollection-Macro-Delete', 'deleteInstance', 'NetworkCollection', false,true, '7','7', 'DEFAULT', '*'), -('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'); +('VFModule-ScaleOut', 'scaleOut', 'VfModule', true, true, '7','7', 'DEFAULT', '*'), +('VNF-InPlaceUpdate', 'inPlaceSoftwareUpdate', 'Vnf', true, true, '7','7', 'DEFAULT', '*'); INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID) VALUES @@ -176,7 +177,26 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VFModule-Replace-Retain-Assignments', '10', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), ('VFModule-Replace-Retain-Assignments', '11', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), ('VFModule-Replace-Retain-Assignments', '12', 'ChangeModelVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), -('VFModule-Replace-Retain-Assignments', '13', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')); +('VFModule-Replace-Retain-Assignments', '13', 'ChangeModelServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Replace-Retain-Assignments' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '1', 'VNFCheckPserversLockedFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '2', 'VNFCheckInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '3', 'VNFSetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '4', 'VNFCheckClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '5', 'VNFSetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '6', 'VNFLockActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '7', 'VNFUpgradePreCheckActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '8', 'VNFQuiesceTrafficActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '9', 'VNFStopActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '10', 'VNFSnapShotActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '11', 'VNFStartActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '12', 'VNFUpgradeBackupActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '13', 'VNFUpgradeSoftwareActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '14', 'VNFUpgradePostCheckActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '15', 'VNFResumeTrafficActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '16', 'VNFUnlockActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '17', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')), +('VNF-InPlaceUpdate', '18', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-InPlaceUpdate' and CLOUD_OWNER = 'DEFAULT')); + INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) @@ -849,3 +869,7 @@ UPDATE rainy_day_handler_macro SET SERVICE_ROLE = '*' WHERE SERVICE_ROLE IS null INSERT INTO vnf_components_recipe (VNF_TYPE, VNF_COMPONENT_TYPE, ACTION, VERSION, ORCHESTRATION_URI, RECIPE_TIMEOUT) VALUES (NULL, 'vfModule', 'replaceInstanceRetainAssignments', '1', '/mso/async/services/WorkflowActionBB', 180); + +UPDATE vnf_recipe +SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB' +WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'inPlaceSoftwareUpdate'; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql index 137f73cf65..42df1adf13 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql @@ -202,4 +202,6 @@ INSERT INTO `workflow` (`ARTIFACT_UUID`,`ARTIFACT_NAME`,`NAME`,`OPERATION_NAME`, VALUES ('9d45cd30-1a89-4993-87c1-6dd09c1696cf','VFModule-ScaleOut','VNF Scale Out','ScaleOut',1.0,'native static workflow to support ScaleOut','vfModule','native'), ('da6478e4-ea33-3346-ac12-ab121284a333','VnfInPlaceUpdate.bpmn','VnfInPlaceUpdate','inPlaceSoftwareUpdate',1.0,'native static workflow to support inPlaceSoftwareUpdate','vnf','native'), -('fdb3ac48-70f9-4584-bd92-253bdbdec1e1','VnfConfigUpdate.bpmn','VnfConfigUpdate','applyConfigModify',1.0,'native static workflow to support applyConfigModify','vnf','native'); +('fdb3ac48-70f9-4584-bd92-253bdbdec1e1','VnfConfigUpdate.bpmn','VnfConfigUpdate','applyConfigModify',1.0,'native static workflow to support applyConfigModify','vnf','native'), +('b2fd5627-55e4-4f4f-8064-9e6f443e9152','DummyPnfWorkflow','Dummy Pnf Workflow','DummyPnfWorkflow',1.0,'Dummy Pnf Workflow to test custom Pnf workflow','pnf','native'); + diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java new file mode 100644 index 0000000000..b71808b2c8 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfTest.java @@ -0,0 +1,36 @@ +package org.onap.so.adapters.catalogdb.catalogrest; + +import static org.junit.Assert.assertEquals; +import org.json.JSONException; +import org.junit.Test; + + +public class QueryServiceVnfTest extends QueryServiceVnfs { + + private QueryServiceVnfs queryServiceVnf = new QueryServiceVnfs(); + + private final String invalidJSON = + "\"{\\\\\\\"nf_function\\\\\\\":\\\\\\\"DO_STUFF\\\\\\\",\\\"_image_name\\\\\\\":\\\\\\\"test_image\\\""; + + private final String validJSON = "\"{\"nf_function\":\"DO_STUFF\",\"image_name\":\"test_image\"}"; + + @Test + public void test_IsValidJsonTrue() throws JSONException { + boolean isValidJson = queryServiceVnf.isJSONValid(validJSON); + assertEquals(true, isValidJson); + } + + @Test + public void test_IsValidJsonFalse() throws JSONException { + boolean isValidJson = queryServiceVnf.isJSONValid(invalidJSON); + assertEquals(false, isValidJson); + } + + @Test + public void test_IsValidJsonNull() throws JSONException { + boolean isValidJson = queryServiceVnf.isJSONValid(null); + assertEquals(false, isValidJson); + } + + +} 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 97c715b44e..ef04ee9c13 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 @@ -1017,7 +1017,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Retrieve the Network Resource definition NetworkResource networkResource = null; - if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) { if (!commonUtils.isNullOrEmpty(networkType)) { networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType); @@ -1030,10 +1029,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } + int timeoutMinutes = 118; String mode = ""; if (networkResource != null) { logger.debug(LOG_DEBUG_MSG, networkResource.toString()); mode = networkResource.getOrchestrationMode(); + networkResource.getHeatTemplate().getTimeoutMinutes(); + HeatTemplate heat = networkResource.getHeatTemplate(); + if (heat != null && heat.getTimeoutMinutes() != null) { + if (heat.getTimeoutMinutes() < 118) { + timeoutMinutes = heat.getTimeoutMinutes(); + } + } } if (NEUTRON_MODE.equals(mode)) { @@ -1048,7 +1055,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } else { try { - heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, 120); + heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); networkDeleted.value = true; } catch (MsoException me) { me.addContext("DeleteNetwork"); @@ -1381,7 +1388,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { * make these optional + " ip_version: %ipversion%\n" + " enable_dhcp: %enabledhcp%\n" + * " gateway_ip: %gatewayip%\n" + " allocation_pools:\n" + " - start: %poolstart%\n" + * " end: %poolend%\n"; - * + * */ String outputTempl = " subnet_id_%subnetId%:\n" + " description: Openstack subnet identifier\n" diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/SecurityFilters.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/SecurityFilters.java deleted file mode 100644 index cbe619e8a0..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/SecurityFilters.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 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.openstack; - -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; - -@Configuration -@Profile("aaf") -public class SecurityFilters { - - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/SoCadiFilter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/SoCadiFilter.java deleted file mode 100644 index d9901b75ed..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.adapters.openstack; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/WebSecurityConfigImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/WebSecurityConfigImpl.java deleted file mode 100644 index ddae887103..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.openstack; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() - .httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java index 39a380d2cf..0074dca03c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java @@ -123,6 +123,7 @@ public interface MsoVnfAdapter { @WebParam(name = "vfName") @XmlElement(required = true) String vfName, @WebParam(name = "vnfId") @XmlElement(required = true) String vnfId, @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId, + @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, @WebParam(name = "request") MsoRequest msoRequest, @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs) throws VnfException; 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 fcb2d7c2bb..4b908004df 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 @@ -1137,7 +1137,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { @Override public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId, - String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { + String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest, + Holder<Map<String, String>> outputs) throws VnfException { Map<String, Object> stackOutputs; try { stackOutputs = msoHeatUtils.queryStackForOutputs(cloudSiteId, cloudOwner, tenantId, vnfName); @@ -1166,8 +1167,32 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { msoRequest, failRequestOnValetFailure); } + int timeoutMinutes = 118; + VfModule vf = null; + VfModuleCustomization vfmc = null; + if (modelCustomizationUuid != null) { + vfmc = vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid); + if (vfmc != null) { + vf = vfmc.getVfModule(); + } + if (vf != null) { + logger.trace("Found vfModuleCust entry {}", vfmc.toString()); + HeatTemplate heat = vf.getModuleHeatTemplate(); + if (heat != null && heat.getTimeoutMinutes() != null) { + if (heat.getTimeoutMinutes() < 118) { + timeoutMinutes = heat.getTimeoutMinutes(); + } + } + + } else { + logger.debug( + "Unable to find vfModuleCust with modelCustomizationUuid={} . Using default timeout for polling", + modelCustomizationUuid); + } + } + try { - msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, 118); + msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes); } catch (MsoException me) { me.addContext(DELETE_VNF); // Failed to query the Stack due to an openstack exception. 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 d35c34a937..abaf881ba5 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 @@ -1082,7 +1082,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { } public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId, - String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { + String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest, + Holder<Map<String, String>> outputs) throws VnfException { logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); // 1702 capture the output parameters on a delete 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 561b21250f..b1f4055b3b 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 @@ -1073,7 +1073,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, String vnfId, - String aaiVfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { + String aaiVfModuleId, String modelCustomizationUuid, MsoRequest msoRequest, + Holder<Map<String, String>> outputs) throws VnfException { logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java index 58899b7f48..0fb11ebbf3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java @@ -179,8 +179,8 @@ public class VnfAdapterRest { Holder<Map<String, String>> outputs = new Holder<>(); if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) { vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(), - outputs); + req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), + req.getModelCustomizationUuid(), req.getMsoRequest(), outputs); } response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java index 0e70c6be53..fcb570f3f5 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java @@ -195,8 +195,8 @@ public class VnfAdapterRestV2 { // Support different Adapter Implementations MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite); adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(), - outputs); + req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), + req.getModelCustomizationUuid(), req.getMsoRequest(), outputs); } response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, req.getMessageId(), outputs.value); 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 01726acd54..a058378425 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 @@ -7,9 +7,9 @@ * 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. @@ -485,7 +485,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils { MsoRequest msoRequest = getMsoRequest(); try { instance.deleteVfModule("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, + "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", null, msoRequest, new Holder<Map<String, String>>()); } catch (Exception e) { 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 e7ef9d9348..45504fcab5 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 @@ -8,9 +8,9 @@ * 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. @@ -67,30 +67,30 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { * msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); Holder<Map<String, String>> outputs = * new Holder<>(); instance.queryVnf("siteid", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new * Holder<>(), new Holder<>(), outputs); - * + * * assertTrue(outputs.value.isEmpty()); } */ /* * @Test public void queryVnfTest() throws Exception { - * - * + * + * * MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345"); * msoRequest.setServiceInstanceId("12345"); * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")) * .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK))); - * + * * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")) * .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }") * .withStatus(HttpStatus.SC_OK))); - * + * * wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse() * .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ") * .withStatus(HttpStatus.SC_OK))); - * + * * instance.queryVnf("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new Holder<>(), new * Holder<>(), new Holder<>()); - * + * * } */ @@ -102,7 +102,7 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { msoRequest.setServiceInstanceId("12345"); instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157", - "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>()); + "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>()); } @Test @@ -126,7 +126,7 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK))); instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157", - "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>()); + "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>()); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 0ac30cb75c..3bf784c50b 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -211,7 +211,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { .willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT))); instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157", - "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>()); + "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>()); } @Test diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java index ede25c5dbe..a68efbe130 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java @@ -134,8 +134,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { expectedException.expect(VnfException.class); MsoRequest msoRequest = getMsoRequest(); msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, - new Holder<Map<String, String>>()); + "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", + msoRequest, new Holder<Map<String, String>>()); } @Test @@ -152,8 +152,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); MsoRequest msoRequest = getMsoRequest(); msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, - new Holder<Map<String, String>>()); + "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", + msoRequest, new Holder<Map<String, String>>()); } private MsoRequest getMsoRequest() { diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java deleted file mode 100644 index 6cd7462299..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.requestsdb; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info", "/services") - .permitAll().antMatchers("/**") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/SoCadiFilter.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/SoCadiFilter.java deleted file mode 100644 index 5e6ced077b..0000000000 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.adapters.requestsdb.application; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SoCadiFilter.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SoCadiFilter.java deleted file mode 100644 index 1e5647097c..0000000000 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.adapters.sdnc; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/WebSecurityConfigImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/WebSecurityConfigImpl.java deleted file mode 100644 index 4d922a4cd0..0000000000 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.sdnc; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info", "/services") - .permitAll().antMatchers("/**") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} diff --git a/adapters/mso-ve-vnfm-adapter/pom.xml b/adapters/mso-ve-vnfm-adapter/pom.xml new file mode 100644 index 0000000000..02abd600f8 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/pom.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-ve-vnfm-adapter</artifactId> + <packaging>jar</packaging> + + <name>mso-ve-vnfm-adapter</name> + <description>Ve-Vnfm (SOL002) Adapter</description> + + <properties> + <java.version>1.8</java.version> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-vnfm-adapter-ext-clients</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + +</project> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SecurityFilters.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java index 0cf63b9605..c4ca5f1fe1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SecurityFilters.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java @@ -1,15 +1,15 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO + * SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 Samsung. 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. @@ -18,24 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.apihandlerinfra; +package org.onap.so.adapters.vevnfm; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; -@Configuration -@Profile("aaf") -public class SecurityFilters { +@SpringBootApplication +public class Application { - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; + public static void main(String... args) { + SpringApplication.run(Application.class, args); } } diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java new file mode 100644 index 0000000000..2e5a00ad02 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2019 Samsung. 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.vevnfm.controller; + +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class NotificationController { + + private static final Logger logger = LoggerFactory.getLogger(NotificationController.class); + + @PostMapping("${notification.url}") + public ResponseEntity receiveNotification(@RequestBody final VnfLcmOperationOccurrenceNotification notification) { + logger.info("Notification received {}", notification); + return ResponseEntity.ok().build(); + } +} diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml new file mode 100644 index 0000000000..30b3955821 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# Copyright © 2019 Samsung. +# 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. + +notification: + url: /lcm/v1/vnf/instances/notifications + +spring: + http: + converters: + preferred-json-mapper: gson diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java new file mode 100644 index 0000000000..c8d2a6bf90 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2019 Samsung. 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.vevnfm.controller; + +import org.junit.Test; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import static org.junit.Assert.assertEquals; + +public class NotificationControllerTest { + + private final NotificationController controller = new NotificationController(); + + @Test + public void testReceiveNotification() { + final VnfLcmOperationOccurrenceNotification notification = new VnfLcmOperationOccurrenceNotification(); + final ResponseEntity response = controller.receiveNotification(notification); + assertEquals(HttpStatus.OK, response.getStatusCode()); + } +} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/SoCadiFilter.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/SoCadiFilter.java deleted file mode 100644 index 89526d4cda..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.adapters.vfc; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java deleted file mode 100644 index 28ac311b4e..0000000000 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vfc; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info", "/services") - .permitAll().antMatchers("/**") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/SoCadiFilter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/SoCadiFilter.java deleted file mode 100644 index aefb36c6bb..0000000000 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.adapters.vnfmadapter; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/SecurityFilters.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java index 3876d77a80..4f3bbe6c5b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/SecurityFilters.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicWebSecurityConfigurerAdapter.java @@ -2,7 +2,9 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,22 +22,32 @@ package org.onap.so.adapters.vnfmadapter; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; +import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@EnableWebSecurity @Configuration -@Profile("aaf") -public class SecurityFilters { - - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; +public class VnfmBasicWebSecurityConfigurerAdapter extends SoBasicWebSecurityConfigurerAdapter { + + @Value("${server.ssl.client-auth:none}") + private String clientAuth; + + @Override + protected void configure(final HttpSecurity http) throws Exception { + if (("need").equalsIgnoreCase(clientAuth)) { + http.csrf().disable().authorizeRequests().anyRequest().permitAll(); + } else { + super.configure(http); + } } + } + diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java deleted file mode 100644 index e43efd014a..0000000000 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnfmadapter; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Value("${server.ssl.client-auth:none}") - private String clientAuth; - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - if (("need").equalsIgnoreCase(clientAuth)) { - http.csrf().disable().authorizeRequests().anyRequest().permitAll(); - } else { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")) - .and().httpBasic(); - } - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java index d4063951bd..34fc2645a2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java @@ -54,6 +54,14 @@ public interface EtsiCatalogServiceProvider { Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId); /** + * GET specific VNF package VNFD from ETSI Catalog. + * + * @param vnfPkgId The ID of the VNF Package that you want to query. + * @return The VNF package retrieved from the ETSI Catalog + */ + Optional<byte[]> getVnfPackageVnfd(final String vnfPkgId); + + /** * GET Package Artifact, from VNF Package. * * @param vnfPkgId The ID of the VNF Package from which the artifact will be retrieved. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java index 11a59c2ec8..779cb2a7a6 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java @@ -62,26 +62,9 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide @Override public Optional<byte[]> getVnfPackageContent(final String vnfPkgId) throws EtsiCatalogManagerRequestFailureException { - try { - final ResponseEntity<byte[]> response = httpServiceProvider - .getHttpResponse(etsiCatalogUrlProvider.getVnfPackageContentUrl(vnfPkgId), byte[].class); - logger.info("getVnfPackageContent Request to ETSI Catalog Manager Status Code: {}", - response.getStatusCodeValue()); - if (response.getStatusCode() == HttpStatus.OK) { - return Optional.ofNullable(response.getBody()); - } - } catch (final HttpResouceNotFoundException httpResouceNotFoundException) { - logger.error("Caught HttpResouceNotFoundException", httpResouceNotFoundException); - throw new VnfPkgNotFoundException("No Vnf Package found with vnfPkgId: " + vnfPkgId); - } catch (final RestProcessingException restProcessingException) { - logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(), - restProcessingException); - if (restProcessingException.getStatusCode() == HttpStatus.CONFLICT.value()) { - throw new VnfPkgConflictException("A conflict occurred with the state of the resource,\n" - + "due to the attribute: onboardingState not being set to ONBOARDED."); - } - } - throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred."); + final String vnfRequestUrl = etsiCatalogUrlProvider.getVnfPackageContentUrl(vnfPkgId); + final String vnfRequestName = "getVnfPackageContent"; + return requestVnfElement(vnfPkgId, vnfRequestUrl, vnfRequestName); } @Override @@ -179,4 +162,34 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred."); } } + + @Override + public Optional<byte[]> getVnfPackageVnfd(final String vnfPkgId) { + final String vnfRequestUrl = etsiCatalogUrlProvider.getVnfPackageVnfdUrl(vnfPkgId); + final String vnfRequestName = "getVnfPackageVnfd"; + return requestVnfElement(vnfPkgId, vnfRequestUrl, vnfRequestName); + } + + private Optional<byte[]> requestVnfElement(final String vnfPkgId, final String vnfRequestUrl, + final String vnfRequestName) { + try { + final ResponseEntity<byte[]> response = httpServiceProvider.getHttpResponse(vnfRequestUrl, byte[].class); + logger.info("{} Request to ETSI Catalog Manager Status Code: {}", vnfRequestName, + response.getStatusCodeValue()); + if (response.getStatusCode() == HttpStatus.OK) { + return Optional.ofNullable(response.getBody()); + } + } catch (final HttpResouceNotFoundException httpResouceNotFoundException) { + logger.error("Caught HttpResouceNotFoundException", httpResouceNotFoundException); + throw new VnfPkgNotFoundException("No Vnf Package found with vnfPkgId: " + vnfPkgId); + } catch (final RestProcessingException restProcessingException) { + logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(), + restProcessingException); + if (restProcessingException.getStatusCode() == HttpStatus.CONFLICT.value()) { + throw new VnfPkgConflictException("A conflict occurred with the state of the resource,\n" + + "due to the attribute: onboardingState not being set to ONBOARDED."); + } + } + throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred."); + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java index cc2c7a62a4..8382212d51 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -35,12 +35,8 @@ public class EtsiCatalogUrlProvider { private static final Logger logger = getLogger(EtsiCatalogUrlProvider.class); - @Value("${msb.endpoint:#{\"http://msb_iag.onap:80\"}}") - private String msbEndpoint; - @Value("${msb.catalogServiceUrl:#{null}}") - private String catalogServiceUrl; - @Value("${msb.vnfpkgmServiceUrl:#{\"/api/vnfpkgm/v1\"}}") - private String vnfpkgmServiceUrl; + @Value("${etsi-catalog-manager.vnfpkgm.endpoint}") + private String etsiCatalogManagerEndpoint; public EtsiCatalogUrlProvider() {} @@ -51,7 +47,7 @@ public class EtsiCatalogUrlProvider { * @return the URL for the GET operation */ public String getVnfPackageContentUrl(final String vnfPkgId) { - final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/package_content"; + final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId + "/package_content"; logger.info("getEtsiCatalogVnfPackageContentUrl: {}", url); return url; } @@ -62,7 +58,7 @@ public class EtsiCatalogUrlProvider { * @return the URL for the GET operation */ public String getVnfPackagesUrl() { - final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages"; + final String url = etsiCatalogManagerEndpoint + "/vnf_packages"; logger.info("getEtsiCatalogVnfPackagesEndpoint: {}", url); return url; } @@ -74,7 +70,7 @@ public class EtsiCatalogUrlProvider { * @return the URL for the GET operation */ public String getVnfPackageUrl(final String vnfPkgId) { - final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId; + final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId; logger.info("getEtsiCatalogVnfPackageEndpoint: {}", url); return url; } @@ -87,8 +83,20 @@ public class EtsiCatalogUrlProvider { * @return the URL for the GET operation */ public String getVnfPackageArtifactUrl(final String vnfPkgId, final String artifactPath) { - final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath; + final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath; logger.info("getVnfPackageArtifactUrl: {}", url); return url; } + + /** + * Get the URL for retrieving VNF packages vnfd from ETSI Catalog. + * + * @param vnfPkgId The ID of the VNF Package + * @return the URL for the GET operation + */ + public String getVnfPackageVnfdUrl(final String vnfPkgId) { + final String url = etsiCatalogManagerEndpoint + "/vnf_packages/" + vnfPkgId + "/vnfd"; + logger.info("getEtsiCatalogVnfPackageVnfd: {}", url); + return url; + } } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java index 3f975fbc9c..9d8e29b3f9 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java @@ -103,15 +103,25 @@ public class Sol003PackageManagementController { /** * GET VNFD, from VNF package. Will return a copy of the file representing the VNFD or a ZIP file that contains the * file/multiple files representing the VNFD specified. Section Number: 10.4.4 - * + * * @param vnfPkgId The ID of the VNF Package that you want to retrieve the VNFD from. * @return The VNFD of a VNF Package as a single file or within a ZIP file. Object: byte[] Response Code: 200 OK */ @GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd", produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP, MediaType.APPLICATION_JSON}) - public ResponseEntity<?> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) { - logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd: ", vnfPkgId); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + public ResponseEntity<byte[]> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) { + logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd Endpoint Invoked with VNF Package ID: ", vnfPkgId); + final Optional<byte[]> response = etsiCatalogServiceProvider.getVnfPackageVnfd(vnfPkgId); + if (response.isPresent()) { + logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd Response: ", HttpStatus.OK); + return new ResponseEntity(response.get(), HttpStatus.OK); + } + final String errorMessage = "An error occurred, a null response was received by the\n" + + " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnfd\" \n" + + "endpoint."; + + logger.error(errorMessage); + return new ResponseEntity(buildProblemDetails(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR); } /** diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml index 951d4a3bb9..57dc08f3b5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml @@ -23,7 +23,9 @@ spring: http: converters: preferred-json-mapper: gson - + main: + allow-bean-definition-overriding: true + server: port: 9092 tomcat: diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java index dbc8ef251d..c5194cf27e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java @@ -20,7 +20,10 @@ package org.onap.so.adapters.vnfmadapter.rest; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; @@ -34,17 +37,25 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.*; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Checksum; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.UriLink; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VNFPKGMLinkSerializer; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageArtifactInfo; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo; +import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; @@ -59,8 +70,6 @@ import com.google.gson.Gson; @ActiveProfiles("test") public class Sol003PackageManagementControllerTest { - private static final Logger logger = LoggerFactory.getLogger(Sol003PackageManagementControllerTest.class); - @LocalServerPort private int port; @@ -69,14 +78,11 @@ public class Sol003PackageManagementControllerTest { private RestTemplate testRestTemplate; @Autowired - private Sol003PackageManagementController controller; - - @Autowired private TestRestTemplate restTemplate; private static final String VNF_PACKAGE_ID = "myVnfPackageId"; private static final String ARTIFACT_PATH = "myArtifactPath"; - private static final String MSB_BASE_URL = "http://msb_iag.onap:80/api/vnfpkgm/v1/vnf_packages"; + private static final String MSB_BASE_URL = "http://msb-iag.onap:80/api/vnfpkgm/v1/vnf_packages"; private static final String VNFPKGM_BASE_URL = PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages"; private static final String localhostUrl = "http://localhost:"; private static final String GET_VNF_PACKAGES_URL = ""; @@ -150,12 +156,18 @@ public class Sol003PackageManagementControllerTest { public void testOnGetPackageContent_UnauthorizedClient_Fail() { final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + VNF_PACKAGE_ID + "/package_content"; + + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + + final ResponseEntity<ProblemDetails> responseEntity = restTemplate.exchange(testURL, HttpMethod.GET, request, ProblemDetails.class); assertTrue(responseEntity.getBody() instanceof ProblemDetails); - assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); } @Test @@ -249,12 +261,16 @@ public class Sol003PackageManagementControllerTest { public void testOnGetPackageArtifact_UnauthorizedClient_Fail() { final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH; + + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); final ResponseEntity<ProblemDetails> responseEntity = restTemplate.exchange(testURL, HttpMethod.GET, request, ProblemDetails.class); assertNotNull(responseEntity.getBody()); - assertEquals(HttpStatus.UNAUTHORIZED, responseEntity.getStatusCode()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); } @Test @@ -470,9 +486,99 @@ public class Sol003PackageManagementControllerTest { // The below test method is here to improve code coverage and provide a foundation for writing future tests @Test - public void testGetVnfd_Not_Implemented() { + public void testGetPackageVnfd_ValidArray_Success() { + final byte[] responseArray = buildByteArrayWithRandomData(10); + + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess(responseArray, MediaType.APPLICATION_OCTET_STREAM)); + + final String testURL = + "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + VNF_PACKAGE_ID + "/vnfd"; + final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); + final ResponseEntity<byte[]> responseEntity = + restTemplate.withBasicAuth("test", "test").exchange(testURL, HttpMethod.GET, request, byte[].class); + + assertEquals(byte[].class, responseEntity.getBody().getClass()); + assertArrayEquals(responseEntity.getBody(), responseArray); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageVnfd_Conflict_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.CONFLICT)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.CONFLICT, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageVnfd_NotFound_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageVnfd_UnauthorizedClient_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageVnfd_InternalServerError_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageVnfd_BadRequest_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.BAD_REQUEST)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testOnGetPackageVnfd_UnauthorizedServer_InternalError_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); + + assertTrue(responseEntity.getBody() instanceof ProblemDetails); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); + } + + @Test + public void testGetPackageVnfd_SuccessResponseFromServerWithNullPackage_Fail() { + mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + .andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); + + final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); + + assertEquals(ProblemDetails.class, responseEntity.getBody().getClass()); + assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); } // Simply returns a byte array filled with random data, for use in the tests. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java index 8fc27c5943..ed1880035a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003SubscriptionManagementControllerTest.java @@ -34,14 +34,13 @@ public class Sol003SubscriptionManagementControllerTest { @Autowired @Qualifier(CONFIGURABLE_REST_TEMPLATE) private RestTemplate testRestTemplate; - private MockRestServiceServer mockRestServer; @Autowired private Sol003SubscriptionManagementController controller; @Before public void setUp() throws Exception { - mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build(); + MockRestServiceServer.bindTo(testRestTemplate).build(); } @Test diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java index e408a326f2..fca50ea6f2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java @@ -39,6 +39,7 @@ import java.util.Optional; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -259,6 +260,7 @@ public class VnfmAdapterControllerTest { } @Test + @Ignore public void createVnf_UnauthorizedUser_Returns401() throws Exception { final TestRestTemplate restTemplateWrongPassword = new TestRestTemplate("test", "wrongPassword"); final Tenant tenant = new Tenant().cloudOwner(CLOUD_OWNER).regionName(REGION).tenantId(TENANT_ID); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml index 8cf8b51b9f..ae66464f29 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml @@ -20,6 +20,8 @@ spring: - username: vnfm password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' role: BPEL-Client + main: + allow-bean-definition-overriding: true mso: key: 07a7159d3bf51a0e53be7a8f89699be7 @@ -52,3 +54,7 @@ management: prometheus: enabled: true # Whether exporting of metrics to Prometheus is enabled. step: 1m # Step size (i.e. reporting frequency) to use. + +etsi-catalog-manager: + vnfpkgm: + endpoint: http://msb-iag.onap:80/api/vnfpkgm/v1 diff --git a/adapters/pom.xml b/adapters/pom.xml index bd7bebafa0..b96c3744c3 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -22,6 +22,8 @@ <module>mso-vfc-adapter</module> <module>mso-openstack-adapters</module> <module>mso-vnfm-adapter</module> + <module>mso-ve-vnfm-adapter</module> + <module>so-appc-orchestrator</module> </modules> <dependencies> diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml new file mode 100644 index 0000000000..717bcee3fc --- /dev/null +++ b/adapters/so-appc-orchestrator/pom.xml @@ -0,0 +1,221 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <groupId>org.onap.so.adapters</groupId> + <artifactId>so-appc-orchestrator</artifactId> + <packaging>jar</packaging> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + <appc.client.version>1.6.0-SNAPSHOT</appc.client.version> + </properties> + <name>so-appc-orchestrator</name> + <description>MSO APPC-C Orchestrator</description> + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${springboot.version}</version> + <configuration> + <mainClass>org.onap.so.adapters.appc.orchestrator.AppcOrchestratorApplication</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>extract-docker-file</id> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>fabric8-maven-plugin</artifactId> + <executions> + <execution> + <id>start</id> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.3</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <fork>true</fork> + <compilerArgs> + <arg>-parameters</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <goals> + <goal>test</goal> + </goals> + <configuration> + <includes> + <include>**/AllTestsTestSuite.java</include> + </includes> + <parallel>suites</parallel> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <!--This plugin's configuration is used to store Eclipse m2e settings + only. It has no influence on the Maven build itself. --> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId> + org.jvnet.jax-ws-commons + </groupId> + <artifactId> + jaxws-maven-plugin + </artifactId> + <versionRange> + [2.3,) + </versionRange> + <goals> + <goal>wsgen</goal> + </goals> + </pluginExecutionFilter> + <action> + <ignore> + </ignore> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + </plugins> + </pluginManagement> + <finalName>${project.artifactId}-${project.version}</finalName> + </build> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-core</artifactId> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-registry-prometheus</artifactId> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-external-task-client</artifactId> + <version>1.1.1</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>MSOCommonBPMN</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapter-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- Test Dependencies --> + <dependency> + <groupId>pl.pragmatists</groupId> + <artifactId>JUnitParams</artifactId> + <version>1.0.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +</project> diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/SecurityFilters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/AppcOrchestratorApplication.java index 319d79e0fb..258c95ac89 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/SecurityFilters.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/AppcOrchestratorApplication.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * 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. @@ -18,24 +18,29 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vfc; +package org.onap.so.adapters.appc.orchestrator; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; -@Configuration -@Profile("aaf") -public class SecurityFilters { +/** + * @since Version 1.0 + * + */ + +@SpringBootApplication(scanBasePackages = {"org.onap"}) +public class AppcOrchestratorApplication { + + private static final String LOGS_DIR = "logs_dir"; + + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/appcorch/"); + } + } - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; + public static void main(String... args) { + SpringApplication.run(AppcOrchestratorApplication.class, args); + setLogsDir(); } } diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallback.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallback.java new file mode 100644 index 0000000000..1f73000299 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallback.java @@ -0,0 +1,84 @@ +/*- + * ============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.appc.orchestrator.client; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ApplicationControllerCallback<T> implements ResponseHandler<T> { + + private static final Logger logger = LoggerFactory.getLogger(ApplicationControllerCallback.class); + + private final ExternalTask externalTask; + private final ExternalTaskService externalTaskService; + private final ApplicationControllerSupport appCSupport; + + public ApplicationControllerCallback(ExternalTask externalTask, ExternalTaskService externalTaskService, + ApplicationControllerSupport appCSupport) { + this.externalTask = externalTask; + this.externalTaskService = externalTaskService; + this.appCSupport = appCSupport; + } + + @Override + public void onResponse(T response) { + logger.info("ON RESPONSE IN CALLBACK"); + + Status status = appCSupport.getStatusFromGenericResponse(response); + + logger.info("Status code is: " + status.getCode()); + logger.info("Status message is: " + status.getMessage()); + + if (appCSupport.getFinalityOf(status)) { + logger.debug("Obtained final status, complete the task"); + completeExternalTask(externalTask, externalTaskService, status); + } else { + logger.debug("Intermediate status, continue the task"); + } + } + + @Override + public void onException(AppcClientException exception) { + + logger.info("ON EXCEPTION IN CALLBACK"); + logger.info("Exception from APPC: " + exception.getMessage()); + Status exceptionStatus = appCSupport.buildStatusFromAppcException(exception); + completeExternalTask(externalTask, externalTaskService, exceptionStatus); + } + + private void completeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService, + Status status) { + + if (appCSupport.getCategoryOf(status).equals(StatusCategory.NORMAL)) { + externalTaskService.complete(externalTask); + logger.debug("The External Task Id: {} Successful", externalTask.getId()); + } else { + logger.debug("The External Task Id: {} Failed", externalTask.getId()); + externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", status.getMessage()); + } + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java new file mode 100644 index 0000000000..20093be6a4 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -0,0 +1,244 @@ +/*- + * ============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.appc.orchestrator.client; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.time.Instant; +import java.util.Optional; +import java.util.Properties; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; +import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; +import org.onap.appc.client.lcm.api.ApplicationContext; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Action; +import org.onap.appc.client.lcm.model.ActionIdentifiers; +import org.onap.appc.client.lcm.model.CommonHeader; +import org.onap.appc.client.lcm.model.Flags; +import org.onap.appc.client.lcm.model.Flags.Force; +import org.onap.appc.client.lcm.model.Flags.Mode; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; +import org.onap.appc.client.lcm.model.Payload; +import org.onap.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.model.ZULU; + +@Component +public class ApplicationControllerClient { + + @Autowired + public Environment env; + + public static final String DEFAULT_CONTROLLER_TYPE = "APPC"; + + private static final String CLIENT_NAME = "MSO"; + + private static final String API_VER = "2.00"; + private static final String ORIGINATOR_ID = "MSO"; + private static final int FLAGS_TTL = 65000; + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerClient.class); + + @Autowired + private ApplicationControllerSupport appCSupport; + + // APPC gave us an API where the controllerType is configured in the + // client object, which is not what we asked for. We asked for an API + // in which the client would have additional methods that could take + // the controllerType as a parameter, so that we would not need to + // maintain multiple client objects. This map should be removed when + // the (hopefully short-term) controllerType becomes obsolete. + + private String controllerType = DEFAULT_CONTROLLER_TYPE; + + private static ConcurrentHashMap<String, LifeCycleManagerStateful> appCClients = new ConcurrentHashMap<>(); + + /** + * Creates an ApplicationControllerClient for the specified controller type. + * + * @param controllerType the controller type: "appc" or "sdnc". + */ + public void setControllerType(String controllerType) { + if (controllerType == null) { + controllerType = DEFAULT_CONTROLLER_TYPE; + } + this.controllerType = controllerType.toUpperCase(); + } + + /** + * Gets the controller type. + * + * @return the controllertype + */ + public String getControllerType() { + return controllerType; + } + + /** + * Returns the AppC client object associated with this ApplicationControllerClient. AppC client objects are shared + * objects. One is created if it does not exist. + * + * @return the client object, or null if creation failed + */ + public LifeCycleManagerStateful getAppCClient() { + return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k)); + } + + protected LifeCycleManagerStateful createAppCClient(String controllerType) { + + try { + if (controllerType == null) { + controllerType = DEFAULT_CONTROLLER_TYPE; + } + controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); + } catch (AppcClientException e) { + logger.error("Error in getting LifeCycleManagerStateful: {}", e.getMessage(), e); + // This null value will cause NullPointerException when used later. + // Error handling could certainly be improved here. + return null; + } + } + + public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, + Optional<String> request, String controllerType, ApplicationControllerCallback listener) + throws ApplicationControllerOrchestratorException { + this.setControllerType(controllerType); + Status status; + ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); + actionIdentifiers.setVnfId(vnfId); + if (vserverId.isPresent()) { + actionIdentifiers.setVserverId(vserverId.get()); + } + Payload payload = null; + if (request.isPresent()) { + payload = new Payload(request.get()); + + } + status = runCommand(action, actionIdentifiers, payload, requestId, listener); + if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { + throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); + } else { + return status; + } + } + + + public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, + org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener) + throws ApplicationControllerOrchestratorException { + Status status; + Object requestObject; + requestObject = createRequest(action, actionIdentifiers, payload, requestID); + appCSupport.logLCMMessage(requestObject); + LifeCycleManagerStateful client = getAppCClient(); + Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true); + try { + Object response = lcmMethod.invoke(client, requestObject, listener); + if (response != null) { + return appCSupport.getStatusFromGenericResponse(response); + } else { + return new Status(); + } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(String.format("%s : %s", "Unable to invoke action", action.toString()), e); + } + } + + protected Properties getLCMProperties() { + return getLCMProperties("appc"); + } + + protected Properties getLCMProperties(String controllerType) { + Properties properties = new Properties(); + + properties.put("topic.read", this.env.getProperty("appc.client.topic.read.name")); + properties.put("topic.write", this.env.getProperty("appc.client.topic.write")); + properties.put("SDNC-topic.read", this.env.getProperty("appc.client.topic.sdnc.read")); + properties.put("SDNC-topic.write", this.env.getProperty("appc.client.topic.sdnc.write")); + properties.put("topic.read.timeout", this.env.getProperty("appc.client.topic.read.timeout")); + properties.put("client.response.timeout", this.env.getProperty("appc.client.response.timeout")); + properties.put("poolMembers", this.env.getProperty("appc.client.poolMembers")); + properties.put("controllerType", controllerType); + properties.put("client.key", this.env.getProperty("appc.client.key")); + properties.put("client.secret", this.env.getProperty("appc.client.secret")); + properties.put("client.name", CLIENT_NAME); + properties.put("service", this.env.getProperty("appc.client.service")); + return properties; + } + + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + Object requestObject = appCSupport.getInput(action.name()); + + + try { + CommonHeader commonHeader = buildCommonHeader(requestId); + requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, + commonHeader); + requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); + requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class) + .invoke(requestObject, identifier); + if (payload != null) { + logger.info("payload in RunCommand: " + payload.getValue()); + requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload); + } + } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + logger.error("Error building Appc request", e); + } + return requestObject; + } + + private CommonHeader buildCommonHeader(String requestId) { + CommonHeader commonHeader = new CommonHeader(); + commonHeader.setApiVer(API_VER); + commonHeader.setOriginatorId(ORIGINATOR_ID); + commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); + commonHeader.setSubRequestId(UUID.randomUUID().toString()); + Flags flags = new Flags(); + String flagsMode = "NORMAL"; + Mode mode = Mode.valueOf(flagsMode); + flags.setMode(mode); + String flagsForce = "FALSE"; + Force force = Force.valueOf(flagsForce); + flags.setForce(force); + flags.setTtl(FLAGS_TTL); + commonHeader.setFlags(flags); + Instant timestamp = Instant.now(); + ZULU zulu = new ZULU(timestamp.toString()); + commonHeader.setTimestamp(zulu); + return commonHeader; + } + + public Flags createRequestFlags() { + Flags flags = new Flags(); + flags.setTtl(6000); + return flags; + } +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SecurityFilters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerOrchestratorException.java index c615440ff6..cc980a489d 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SecurityFilters.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerOrchestratorException.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * 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. @@ -18,24 +18,20 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.sdnc; +package org.onap.so.adapters.appc.orchestrator.client; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; -@Configuration -@Profile("aaf") -public class SecurityFilters { +public class ApplicationControllerOrchestratorException extends Exception { - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; + private static final long serialVersionUID = 2594894543585595494L; + private final int appcCode; + + public ApplicationControllerOrchestratorException(String message, int code) { + super(message); + appcCode = code; + } + + public int getAppcCode() { + return appcCode; } } diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java new file mode 100644 index 0000000000..90ab24cb86 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupport.java @@ -0,0 +1,207 @@ +/*- + * ============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.appc.orchestrator.client; + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.onap.appc.client.lcm.api.LifeCycleManagerStateful; +import org.onap.appc.client.lcm.api.ResponseHandler; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Status; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; + + +@Component +public class ApplicationControllerSupport { + + private static final int ACCEPT_SERIES = 100; + private static final int ERROR_SERIES = 200; + private static final int REJECT_SERIES = 300; + private static final int SUCCESS_SERIES = 400; + private static final int SUCCESS_STATUS = SUCCESS_SERIES; + private static final int PARTIAL_SERIES = 500; + private static final int PARTIAL_SUCCESS_STATUS = PARTIAL_SERIES; + private static final int PARTIAL_FAILURE_STATUS = PARTIAL_SERIES + 1; + + private static Logger logger = LoggerFactory.getLogger(ApplicationControllerSupport.class); + private String lcmModelPackage = "org.onap.appc.client.lcm.model"; + + /** + * @param action + * @return + * @throws ClassNotFoundException + * @throws InstantiationException + * @throws IllegalAccessException + */ + public Object getInput(String action) { + try { + return getInputClass(action).newInstance(); + } catch (IllegalAccessException | InstantiationException e) { + throw new RuntimeException( + String.format("%s : %s", "Unable to instantiate viable LCM Kit input class for action", action), e); + } + } + + /** + * @param action + * @return + * @throws ClassNotFoundException + */ + public Method getAPIMethod(String action, LifeCycleManagerStateful lcmStateful, boolean async) { + Method[] methods = lcmStateful.getClass().getMethods(); + for (Method method : methods) { + if (method.getName().equalsIgnoreCase(action)) { + Class<?>[] methodParameterTypes = method.getParameterTypes(); + if (methodParameterTypes.length > 0) { + if (getInputClass(action).equals(methodParameterTypes[0])) { + if (async) { + if (methodParameterTypes.length == 2 + && ResponseHandler.class.isAssignableFrom(methodParameterTypes[1])) { + return method; + } + } else if (methodParameterTypes.length == 1) { + return method; + } + } + } + } + } + throw new RuntimeException(String.format("%s : %s, async=%b", + "Unable to derive viable LCM Kit API method for action", action, async)); + } + + public Status getStatusFromGenericResponse(Object response) { + Method statusReader = getBeanPropertyMethodFor(response.getClass(), "status", false); + if (statusReader != null) { + try { + return (Status) statusReader.invoke(response); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + logger.error("Unable to obtain status from LCM Kit response", e); + } + } + return new Status(); + } + + public StatusCategory getCategoryOf(Status status) { + int codeSeries = status.getCode() - (status.getCode() % 100); + switch (codeSeries) { + case ACCEPT_SERIES: + return StatusCategory.NORMAL; + case ERROR_SERIES: + case REJECT_SERIES: + return StatusCategory.ERROR; + case SUCCESS_SERIES: + return status.getCode() == SUCCESS_STATUS ? StatusCategory.NORMAL : StatusCategory.ERROR; + case PARTIAL_SERIES: + switch (status.getCode()) { + case PARTIAL_SUCCESS_STATUS: + return StatusCategory.NORMAL; + case PARTIAL_FAILURE_STATUS: + return StatusCategory.ERROR; + default: + return StatusCategory.WARNING; + } + default: + return StatusCategory.WARNING; + } + } + + public boolean getFinalityOf(Status status) { + int codeSeries = status.getCode() - (status.getCode() % 100); + switch (codeSeries) { + case ACCEPT_SERIES: + case PARTIAL_SERIES: + return false; + case ERROR_SERIES: + case REJECT_SERIES: + case SUCCESS_SERIES: + return true; + default: + return true; + } + } + + private Method getBeanPropertyMethodFor(Class<?> clazz, String propertyName, boolean isWriter) { + BeanInfo beanInfo; + try { + beanInfo = Introspector.getBeanInfo(clazz, Object.class); + } catch (IntrospectionException e) { + throw new RuntimeException( + String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", + clazz.getName(), propertyName, isWriter), + e); + } + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { + if (propertyDescriptor.getName().equals(propertyName)) { + return isWriter ? propertyDescriptor.getWriteMethod() : propertyDescriptor.getReadMethod(); + } + } + throw new RuntimeException( + String.format("Unable to produce bean property method for class : %s, property : %s, writer=%b", + clazz.getName(), propertyName, isWriter)); + } + + /** + * @param action + * @return + * @throws ClassNotFoundException + */ + private Class<?> getInputClass(String action) { + try { + return Class.forName(lcmModelPackage + '.' + action + "Input"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(String.format("%s : %s using package : %s", + "Unable to identify viable LCM Kit input class for action", action, lcmModelPackage), e); + } + } + + + public void logLCMMessage(Object message) { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(Include.NON_NULL); + ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter(); + String inputAsJSON; + try { + inputAsJSON = writer.writeValueAsString(message); + logger.info("LCM Kit input message follows: {}", inputAsJSON); + } catch (JsonProcessingException e) { + logger.error("Error in logging LCM Message", e); + } + } + + public Status buildStatusFromAppcException(AppcClientException exception) { + Status exceptionStatus = new Status(); + exceptionStatus.setCode(200); + exceptionStatus.setMessage("Exception on APPC request: " + exception.getMessage()); + return exceptionStatus; + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/StatusCategory.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/StatusCategory.java new file mode 100644 index 0000000000..27160ef981 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/StatusCategory.java @@ -0,0 +1,16 @@ +package org.onap.so.adapters.appc.orchestrator.client; + +public enum StatusCategory { + NORMAL("normal"), WARNING("warning"), ERROR("error"); + + private final String category; + + private StatusCategory(final String category) { + this.category = category; + } + + @Override + public String toString() { + return category; + } +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java new file mode 100644 index 0000000000..b065e9a0c3 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/ConfigurationParameters.java @@ -0,0 +1,53 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ConfigurationParameters { + + @JsonProperty("vnf_name") + private String vnfName; + @JsonProperty("book_name") + private String bookName; + @JsonProperty("node_list") + private String nodeList; + @JsonProperty("file_parameter_content") + private String fileParameterContent; + + + @JsonProperty("vnf_name") + public String getVnfName() { + return vnfName; + } + + @JsonProperty("vnf_name") + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public String getNodeList() { + return nodeList; + } + + public void setNodeList(String nodeList) { + this.nodeList = nodeList; + } + + public String getFileParameterContent() { + return fileParameterContent; + } + + public void setFileParameterContent(String fileParameterContent) { + this.fileParameterContent = fileParameterContent; + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Identity.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Identity.java new file mode 100644 index 0000000000..912441ad9a --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Identity.java @@ -0,0 +1,24 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"identity-url"}) +public class Identity { + + @JsonProperty("identity-url") + private String identityUrl; + + @JsonProperty("identity-url") + public String getIdentityUrl() { + return identityUrl; + } + + @JsonProperty("identity-url") + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Parameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Parameters.java new file mode 100644 index 0000000000..9b0385bd7a --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/Parameters.java @@ -0,0 +1,99 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"vm-id", "identity-url", "old_software_version", "new_software_version", "operations_timeout", + "request-parameters", "configuration-parameters"}) +public class Parameters { + + @JsonProperty("vm-id") + private String vmId; + @JsonProperty("identity-url") + private String identityUrl; + @JsonProperty("operations_timeout") + private String operationsTimeout; + @JsonProperty("existing_software_version") + private String existingSoftwareVersion; + @JsonProperty("new_software_version") + private String newSoftwareVersion; + @JsonProperty("request-parameters") + private RequestParameters requestParameters; + @JsonProperty("configuration-parameters") + private ConfigurationParameters configurationParameters; + + @JsonProperty("request-parameters") + public RequestParameters getRequestParameters() { + return requestParameters; + } + + @JsonProperty("request-parameters") + public void setRequestParameters(RequestParameters requestParameters) { + this.requestParameters = requestParameters; + } + + @JsonProperty("configuration-parameters") + public ConfigurationParameters getConfigurationParameters() { + return configurationParameters; + } + + @JsonProperty("configuration-parameters") + public void setConfigurationParameters(ConfigurationParameters configurationParameters) { + this.configurationParameters = configurationParameters; + } + + @JsonProperty("vm-id") + public String getVmId() { + return vmId; + } + + @JsonProperty("vm-id") + public void setVmId(String vmId) { + this.vmId = vmId; + } + + @JsonProperty("identity-url") + public String getIdentityUrl() { + return identityUrl; + } + + @JsonProperty("identity-url") + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; + } + + @JsonProperty("operations_timeout") + public String getOperationsTimeout() { + return operationsTimeout; + } + + @JsonProperty("operations_timeout") + public void setOperationsTimeout(String operationsTimeout) { + this.operationsTimeout = operationsTimeout; + } + + @JsonProperty("existing_software_version") + public String getExistingSoftwareVersion() { + return existingSoftwareVersion; + } + + @JsonProperty("existing_software_version") + public void setExistingSoftwareVersion(String existingSoftwareVersion) { + this.existingSoftwareVersion = existingSoftwareVersion; + } + + @JsonProperty("new_software_version") + public String getNewSoftwareVersion() { + return newSoftwareVersion; + } + + @JsonProperty("new_software_version") + public void setNewSoftwareVersion(String newSoftwareVersion) { + this.newSoftwareVersion = newSoftwareVersion; + } + + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/RequestParameters.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/RequestParameters.java new file mode 100644 index 0000000000..ddc0a0ea3d --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/beans/RequestParameters.java @@ -0,0 +1,59 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RequestParameters { + + @JsonProperty("vnf-host-ip-address") + private String vnfHostIpAddress; + @JsonProperty("vf-module-id") + private String vfModuleId; + @JsonProperty("vnf-name") + private String vnfName; + @JsonProperty("host-ip-address") + private String hostIpAddress; + + public String getVnfHostIpAddress() { + return vnfHostIpAddress; + } + + public void setVnfHostIpAddress(String vnfHostIpAddress) { + this.vnfHostIpAddress = vnfHostIpAddress; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public void setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getHostIpAddress() { + return hostIpAddress; + } + + public void setHostIpAddress(String hostIpAddress) { + this.hostIpAddress = hostIpAddress; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("RequestParametersConfigScaleOut{"); + sb.append("vnf-host-ip-address=").append(vnfHostIpAddress); + sb.append(", vf-module-id='").append(vfModuleId); + sb.append('}'); + return sb.toString(); + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java new file mode 100644 index 0000000000..181d114cc0 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java @@ -0,0 +1,50 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.externaltasks.logging.AuditMDCSetup; +import org.onap.so.utils.ExternalTaskUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.onap.appc.client.lcm.model.Status; + +@Component +public class ApplicationControllerTask extends ExternalTaskUtils { + + private static final Logger logger = LoggerFactory.getLogger(ApplicationControllerTask.class); + + @Autowired + public Environment env; + + @Autowired + public ApplicationControllerTaskImpl applicationControllerTaskImpl; + + @Autowired + public ApplicationControllerSupport applicationControllerSupport; + + @Autowired + private AuditMDCSetup mdcSetup; + + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { + mdcSetup.setupMDC(externalTask); + ApplicationControllerTaskRequest request = externalTask.getVariable("appcOrchestratorRequest"); + String msoRequestId = externalTask.getVariable("mso-request-id"); + logger.debug("Starting External Task for RequestId: {} ", msoRequestId); + Status status = null; + ApplicationControllerCallback listener = + new ApplicationControllerCallback(externalTask, externalTaskService, applicationControllerSupport); + + try { + status = applicationControllerTaskImpl.execute(msoRequestId, request, listener); + } catch (Exception e) { + logger.error("Error while calling appc", e.getMessage()); + } + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java new file mode 100644 index 0000000000..a174ccb05a --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -0,0 +1,112 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import java.util.Optional; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.Identity; +import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.fasterxml.jackson.core.JsonProcessingException; + +@Component +public class ApplicationControllerTaskImpl { + + @Autowired + private ApplicationControllerClient appcClient; + + public Status execute(String msoRequestId, ApplicationControllerTaskRequest request, + ApplicationControllerCallback listener) + throws JsonProcessingException, ApplicationControllerOrchestratorException { + Status status = null; + GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider(); + Optional<String> payload = Optional.empty(); + String vmId = null; + Optional<String> vserverId = Optional.empty(); + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + + switch (request.getAction()) { + case HealthCheck: + RequestParameters requestParams = new RequestParameters(); + requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); + parameters.setRequestParameters(requestParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case ResumeTraffic: + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case Start: + case Stop: + Identity identity = new Identity(); + identity.setIdentityUrl(request.getIdentityUrl()); + payload = Optional.of((mapper.getMapper().writeValueAsString(identity))); + break; + case Unlock: + case Lock: + break; + case QuiesceTraffic: + parameters.setOperationsTimeout(request.getOperationsTimeout()); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case DistributeTraffic: + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case DistributeTrafficCheck: + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case ConfigModify: + case ConfigScaleOut: + break; + case UpgradePreCheck: + case UpgradePostCheck: + case UpgradeSoftware: + case UpgradeBackup: + parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion()); + parameters.setNewSoftwareVersion(request.getNewSoftwareVersion()); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + break; + case ActionStatus: + break; + case Snapshot: + ApplicationControllerVm applicationControllerVm = + request.getApplicationControllerVnf().getApplicationControllerVm(); + if (applicationControllerVm != null) { + vmId = request.getApplicationControllerVnf().getApplicationControllerVm().getVmId(); + parameters.setVmId(vmId); + payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + vserverId = Optional + .of(request.getApplicationControllerVnf().getApplicationControllerVm().getVserverId()); + } + default: + // errorMessage = "Unable to idenify Action request for AppCClient"; + break; + } + + status = appcClient.vnfCommand(request.getAction(), msoRequestId, + request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), + listener); + + return status; + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskService.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskService.java new file mode 100644 index 0000000000..2a33124eac --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskService.java @@ -0,0 +1,31 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import javax.annotation.PostConstruct; +import org.onap.so.utils.ExternalTaskServiceUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +@Profile("!test") +public class ApplicationControllerTaskService { + + @Autowired + public Environment env; + + @Autowired + private ApplicationControllerTask appcOrchestrator; + + @Autowired + private ExternalTaskServiceUtils externalTaskServiceUtils; + + @PostConstruct + public void appcOrchestrator() throws Exception { + for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { + externalTaskServiceUtils.createExternalTaskClient().subscribe("AppcService").lockDuration(604800000) + .handler(appcOrchestrator::executeExternalTask).open(); + } + } + +} diff --git a/adapters/so-appc-orchestrator/src/main/resources/application.yaml b/adapters/so-appc-orchestrator/src/main/resources/application.yaml new file mode 100644 index 0000000000..c0c5962ea2 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/main/resources/application.yaml @@ -0,0 +1,18 @@ +server: + port: 8080 + tomcat: + max-threads: 50 + +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use.
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/SecurityFilters.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java index 040723501b..fe965b4444 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/SecurityFilters.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/TestApplication.java @@ -1,8 +1,9 @@ +package org.onap.so; /*- * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * 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. @@ -18,24 +19,25 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.catalogdb; -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; -@Configuration -@Profile("aaf") -public class SecurityFilters { +@SpringBootApplication +@Profile("test") +@ComponentScan(basePackages = {"org.onap.so"}, + excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)}) +public class TestApplication { + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; } } diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java new file mode 100644 index 0000000000..90f5a44752 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerCallbackTest.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-2019 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.appc.orchestrator.client; + +import static org.hamcrest.CoreMatchers.any; +import static org.mockito.Mockito.doReturn; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.appc.client.lcm.model.Status; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.ResumeTrafficOutput; + +public class ApplicationControllerCallbackTest { + + @InjectMocks + ApplicationControllerCallback appcTaskCallback; + + @Mock + ApplicationControllerSupport applicationControllerSupport; + + @Mock + ExternalTask mockExternalTask; + + @Mock + ExternalTaskService mockExternalTaskService; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + appcTaskCallback = new ApplicationControllerCallback(mockExternalTask, mockExternalTaskService, + applicationControllerSupport); + } + + @Test + public void onResponse_appcCallback_success_Test() throws Exception { + Status status = new Status(); + status.setCode(400); + ResumeTrafficOutput response = new ResumeTrafficOutput(); + response.setStatus(status); + doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); + doReturn(true).when(applicationControllerSupport).getFinalityOf(status); + doReturn(StatusCategory.NORMAL).when(applicationControllerSupport).getCategoryOf(status); + appcTaskCallback.onResponse(response); + Mockito.verify(mockExternalTaskService).complete(mockExternalTask); + } + + @Test + public void onResponse_appcCallback_intermediateResponse_Test() throws Exception { + Status status = new Status(); + status.setCode(100); + ResumeTrafficOutput response = new ResumeTrafficOutput(); + response.setStatus(status); + doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); + appcTaskCallback.onResponse(response); + Mockito.verifyZeroInteractions(mockExternalTaskService); + } + + @Test + public void onResponse_appcCallback_failure_Test() throws Exception { + String testFailure = "test failure"; + Status status = new Status(); + status.setCode(200); + status.setMessage(testFailure); + ResumeTrafficOutput response = new ResumeTrafficOutput(); + response.setStatus(status); + doReturn(status).when(applicationControllerSupport).getStatusFromGenericResponse(response); + doReturn(true).when(applicationControllerSupport).getFinalityOf(status); + doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status); + appcTaskCallback.onResponse(response); + Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException", testFailure); + } + + @Test + public void onException_appcCallback_failure_Test() throws Exception { + String testFailure = "test failure"; + AppcClientException appcException = new AppcClientException(testFailure); + Status status = new Status(); + status.setCode(200); + String exceptionMessage = "Exception on APPC request: " + testFailure; + status.setMessage(exceptionMessage); + doReturn(status).when(applicationControllerSupport).buildStatusFromAppcException(appcException); + doReturn(StatusCategory.ERROR).when(applicationControllerSupport).getCategoryOf(status); + appcTaskCallback.onException(appcException); + Mockito.verify(mockExternalTaskService).handleBpmnError(mockExternalTask, "MSOWorkflowException", + exceptionMessage); + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java new file mode 100644 index 0000000000..2dd2fd7ac8 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerSupportTest.java @@ -0,0 +1,79 @@ +/*- + * ============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.appc.orchestrator.client; + +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.appc.client.lcm.exceptions.AppcClientException; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; + +@RunWith(JUnitParamsRunner.class) +public class ApplicationControllerSupportTest { + private ApplicationControllerSupport applicationControllerSupport = new ApplicationControllerSupport(); + + public static Object[][] statusesAndCategories() { + return new Object[][] {{100, StatusCategory.NORMAL}, {200, StatusCategory.ERROR}, {300, StatusCategory.ERROR}, + {400, StatusCategory.NORMAL}, {401, StatusCategory.ERROR}, {500, StatusCategory.NORMAL}, + {501, StatusCategory.ERROR}, {502, StatusCategory.WARNING}, {800, StatusCategory.WARNING},}; + } + + public static Object[][] statusesAndFinalities() { + return new Object[][] {{100, false}, {200, true}, {300, true}, {400, true}, {500, false}, {800, true},}; + } + + @Test + @Parameters(method = "statusesAndCategories") + public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception { + // when + StatusCategory detectedCategory = applicationControllerSupport.getCategoryOf(createStatus(code)); + // then + assertThat(detectedCategory).isEqualTo(category); + } + + @Test + @Parameters(method = "statusesAndFinalities") + public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception { + // when + boolean finality = applicationControllerSupport.getFinalityOf(createStatus(code)); + // then + assertThat(finality).isEqualTo(expectedFinality); + } + + @Test + public void buildStatusFromAppcException_Test() { + String errorMessage = "errormessage"; + AppcClientException exception = new AppcClientException(errorMessage); + Status status = applicationControllerSupport.buildStatusFromAppcException(exception); + assertThat(status.getCode() == 200); + assertThat((status.getMessage()).equals(("Exception on APPC request: " + errorMessage))); + } + + private Status createStatus(int code) { + Status status = new Status(); + status.setCode(code); + return status; + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java new file mode 100644 index 0000000000..76b5efacb3 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/client/beans/BeansTest.java @@ -0,0 +1,20 @@ +package org.onap.so.adapters.appc.orchestrator.client.beans; + +import org.junit.Test; +import com.openpojo.reflection.filters.FilterPackageInfo; +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; + +public class BeansTest { + + @Test + public void validateGettersAndSetters() { + Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule()) + .with(new SetterTester(), new GetterTester()).build(); + validator.validate("org.onap.so.adapters.appc.orchestrator.client.beans", new FilterPackageInfo()); + } +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java new file mode 100644 index 0000000000..3eac851f13 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java @@ -0,0 +1,88 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import java.util.List; +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.TestApplication; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.Identity; +import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters; +import org.onap.so.adapters.appc.orchestrator.service.ApplicationControllerTaskImpl; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import org.springframework.beans.factory.annotation.Autowired; +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.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.onap.appc.client.lcm.model.Action; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +@ContextConfiguration +@AutoConfigureWireMock(port = 0) +public class ApplicationControllerTaskImplITTest { + + @Autowired + private ApplicationControllerTaskImpl applicationControllerTaskImpl; + + @Mock + ExternalTask externalTask; + + @Mock + ExternalTaskService externalTaskService; + + @Mock + ApplicationControllerSupport appCSupport; + + ApplicationControllerTaskRequest request; + + ApplicationControllerCallback listener; + + GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider(); + + @Before + public void setup() { + request = new ApplicationControllerTaskRequest(); + request.setBookName("testBookName"); + request.setControllerType("testControllerType"); + request.setFileParameters("testFileParams"); + request.setIdentityUrl("testIdentityUrl"); + request.setNewSoftwareVersion("2.0"); + request.setExistingSoftwareVersion("1.0"); + request.setOperationsTimeout("30"); + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + applicationControllerVnf.setVnfHostIpAddress("100.100"); + applicationControllerVnf.setVnfId("testVnfId"); + applicationControllerVnf.setVnfName("testVnfName"); + request.setApplicationControllerVnf(applicationControllerVnf); + listener = new ApplicationControllerCallback(null, externalTaskService, appCSupport); + } + + + @Test + public void testListener() throws Exception { + request.setAction(Action.QuiesceTraffic); + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + } + +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java new file mode 100644 index 0000000000..640e2dbd6e --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -0,0 +1,236 @@ +package org.onap.so.adapters.appc.orchestrator.service; + +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.appc.client.lcm.model.Status; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerClient; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException; +import org.onap.so.adapters.appc.orchestrator.client.beans.ConfigurationParameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.Identity; +import org.onap.so.adapters.appc.orchestrator.client.beans.Parameters; +import org.onap.so.adapters.appc.orchestrator.client.beans.RequestParameters; +import org.onap.so.adapters.appc.orchestrator.service.ApplicationControllerTaskImpl; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; +import com.fasterxml.jackson.core.JsonProcessingException; +import org.onap.appc.client.lcm.model.Action; + +@RunWith(MockitoJUnitRunner.class) +public class ApplicationControllerTaskImplTest { + + @Mock + ApplicationControllerClient applicationControllerClient; + + @InjectMocks + @Spy + ApplicationControllerTaskImpl applicationControllerTaskImpl; + + ApplicationControllerTaskRequest request; + + ApplicationControllerCallback listener; + + GraphInventoryCommonObjectMapperProvider mapper = new GraphInventoryCommonObjectMapperProvider(); + + @Before + public void setup() { + request = new ApplicationControllerTaskRequest(); + request.setBookName("testBookName"); + request.setControllerType("testControllerType"); + request.setFileParameters("testFileParams"); + request.setIdentityUrl("testIdentityUrl"); + request.setNewSoftwareVersion("2.0"); + request.setExistingSoftwareVersion("1.0"); + request.setOperationsTimeout("30"); + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + applicationControllerVnf.setVnfHostIpAddress("100.100"); + applicationControllerVnf.setVnfId("testVnfId"); + applicationControllerVnf.setVnfName("testVnfName"); + request.setApplicationControllerVnf(applicationControllerVnf); + listener = new ApplicationControllerCallback(null, null, null); + + } + + @Test + public void testExcute_healthCheck() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.HealthCheck); + + Parameters parameters = new Parameters(); + RequestParameters requestParams = new RequestParameters(); + requestParams.setHostIpAddress(request.getApplicationControllerVnf().getVnfHostIpAddress()); + parameters.setRequestParameters(requestParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + + } + + @Test + public void testExcute_resumeTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.ResumeTraffic); + + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_stop() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.Stop); + + Identity identity = new Identity(); + identity.setIdentityUrl(request.getIdentityUrl()); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(identity))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_lock() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.Lock); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), + "testControllerType", listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), + "testControllerType", listener); + } + + @Test + public void testExcute_quiesceTraffic() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.QuiesceTraffic); + + + Parameters parameters = new Parameters(); + parameters.setOperationsTimeout(request.getOperationsTimeout()); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + System.out.println("PAYLOAD is: " + payload.get()); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_distributeTraffic() + throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.DistributeTraffic); + + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_distributeTrafficCheck() + throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.DistributeTrafficCheck); + + Parameters parameters = new Parameters(); + ConfigurationParameters configParams = new ConfigurationParameters(); + configParams.setBookName(request.getBookName()); + configParams.setNodeList(request.getNodeList()); + configParams.setFileParameterContent(request.getFileParameters()); + configParams.setVnfName(request.getApplicationControllerVnf().getVnfName()); + parameters.setConfigurationParameters(configParams); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testExcute_upgradeBackup() throws JsonProcessingException, ApplicationControllerOrchestratorException { + request.setAction(Action.UpgradeBackup); + + Parameters parameters = new Parameters(); + parameters.setExistingSoftwareVersion(request.getExistingSoftwareVersion()); + parameters.setNewSoftwareVersion(request.getNewSoftwareVersion()); + Optional<String> payload = Optional.of((mapper.getMapper().writeValueAsString(parameters))); + + Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener)).thenReturn(new Status()); + + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + + Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", + request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", + listener); + } + + @Test + public void testListener() throws Exception { + request.setAction(Action.QuiesceTraffic); + Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); + } + +} diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java new file mode 100644 index 0000000000..228ee90107 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017-2019 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.appc.orchestrator.service; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import org.camunda.bpm.client.task.ExternalTask; +import org.camunda.bpm.client.task.ExternalTaskService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.so.externaltasks.logging.AuditMDCSetup; +import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.appc.client.lcm.model.Status; + +public class ApplicationControllerTaskTest extends ApplicationControllerTask { + + @InjectMocks + ApplicationControllerTask appcTaskService = new ApplicationControllerTask(); + + @Mock + ApplicationControllerTaskImpl applicationControllerTaskImpl; + + @Mock + ExternalTask mockExternalTask; + + @Mock + ExternalTaskService mockExternalTaskService; + + @Mock + private AuditMDCSetup mdcSetup; + + private ApplicationControllerTaskRequest request = new ApplicationControllerTaskRequest(); + private String msoRequestId = "testRequestId"; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + doNothing().when(mdcSetup).setupMDC(mockExternalTask); + doReturn(request).when(mockExternalTask).getVariable("appcOrchestratorRequest"); + doReturn(msoRequestId).when(mockExternalTask).getVariable("mso-request-id"); + } + + @Test + public void executeExternalTask_appc_success_Test() throws Exception { + Status status = new Status(); + doReturn(status).when(applicationControllerTaskImpl).execute(any(String.class), + any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class)); + appcTaskService.executeExternalTask(mockExternalTask, mockExternalTaskService); + Mockito.verify(applicationControllerTaskImpl).execute(any(String.class), + any(ApplicationControllerTaskRequest.class), any(ApplicationControllerCallback.class)); + } +} diff --git a/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml b/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..eb693a263e --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/resources/application-test.yaml @@ -0,0 +1,17 @@ + +appc: + client: + key: LSl8QKolmKcC0yJR + response: + timeout: '60000' + secret: lgjXraD1HutKxv8jEN6tVouu + poolMembers: localhost:3904,localhost:3904 + service: ueb + topic: + read: + name: APPC-1902-SHDEV-WRITE + timeout: '120000' + write: APPC-1902-SHDEV-READ + sdnc: + read: SDNC-LCM-READ + write: SDNC-LCM-WRITE
\ No newline at end of file diff --git a/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml b/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..8a9e705ca6 --- /dev/null +++ b/adapters/so-appc-orchestrator/src/test/resources/logback-test.xml @@ -0,0 +1,31 @@ +<configuration> + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.onap" level="${so.log.level:-WARN}" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java deleted file mode 100644 index 8722d193fe..0000000000 --- a/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java +++ /dev/null @@ -1,78 +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.asdc; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() - .httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } - -} diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java b/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java index c35e8e34d6..e25de9c3d4 100644 --- a/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java +++ b/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java @@ -31,7 +31,7 @@ import org.springframework.context.annotation.Profile; @SpringBootApplication @Profile("test") -@ComponentScan(basePackages = {"org.onap.so.asdc"}, +@ComponentScan(basePackages = {"org.onap.so.asdc", "org.onap.so.security"}, excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class), @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class), @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class)}) diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java new file mode 100644 index 0000000000..51bc4d7064 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/ServiceModel.java @@ -0,0 +1,32 @@ +package org.onap.so.bpmn.servicedecomposition.entities; + +import org.onap.so.db.catalog.beans.Service; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("serviceModel") +public class ServiceModel { + + @JsonProperty("currentService") + private Service currentService; + @JsonProperty("newService") + private Service newService; + + + public Service getCurrentService() { + return currentService; + } + + public void setCurrentService(Service currentService) { + this.currentService = currentService; + } + + public Service getNewService() { + return newService; + } + + public void setNewService(Service newService) { + this.newService = newService; + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 6b96bc384a..ac66fb1a41 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -46,6 +46,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -72,7 +73,6 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; -import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; @@ -121,9 +121,6 @@ public class BBInputSetup implements JavaDelegate { @Autowired private ExceptionBuilder exceptionUtil; - @Autowired - private RequestsDbClient requestsDbClient; - private ObjectMapper mapper = new ObjectMapper(); public BBInputSetupUtils getBbInputSetupUtils() { @@ -246,31 +243,41 @@ public class BBInputSetup implements JavaDelegate { String bbName = executeBB.getBuildingBlock().getBpmnFlowName(); String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null; + ServiceModel serviceModel = new ServiceModel(); Service service = null; + Service newService = null; boolean isReplace = false; if (serviceInstanceId != null) { aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId); if (aaiServiceInstance != null) { - if (requestAction.equalsIgnoreCase("replaceInstance")) { + if (requestAction.equalsIgnoreCase("replaceInstance") + || requestAction.equalsIgnoreCase("replaceInstanceRetainAssignments")) { RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); if (relatedInstanceList != null) { for (RelatedInstanceList relatedInstList : relatedInstanceList) { RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { - service = bbInputSetupUtils.getCatalogServiceByModelUUID( + newService = bbInputSetupUtils.getCatalogServiceByModelUUID( relatedInstance.getModelInfo().getModelVersionId()); isReplace = true; } } } - } else { - service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); } + + service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + + serviceModel.setNewService(newService); + serviceModel.setCurrentService(service); + if (service == null) { String message = String.format( "Related service instance model not found in MSO CatalogDB: model-version-id=%s", aaiServiceInstance.getModelVersionId()); throw new ServiceModelNotFoundException(message); + } else if (newService == null && isReplace) { + String message = "Related service instance model in Request not found in MSO CatalogDB"; + throw new ServiceModelNotFoundException(message); } } else { String message = String.format("Related service instance from AAI not found: service-instance-id=%s", @@ -280,10 +287,16 @@ public class BBInputSetup implements JavaDelegate { } ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); - serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); - this.populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, executeBB.getBuildingBlock().getKey(), - executeBB.getConfigurationResourceKeys(), isReplace); + if (isReplace) { + serviceInstance.setModelInfoServiceInstance( + this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getNewService())); + } else { + serviceInstance.setModelInfoServiceInstance( + this.mapperLayer.mapCatalogServiceIntoServiceInstance(serviceModel.getCurrentService())); + } + this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, + resourceId, vnfType, executeBB.getBuildingBlock().getKey(), executeBB.getConfigurationResourceKeys(), + isReplace, serviceModel); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); } @@ -301,18 +314,14 @@ public class BBInputSetup implements JavaDelegate { org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); genericVnfs.add(genericVnf); - if (genericVnf != null) { - updateInstanceName(executeBB.getRequestId(), ModelType.vnf, genericVnf.getVnfName()); - } } String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID); - if (instanceGroupId != null) { + if (instanceGroupId != null && !instanceGroupId.isEmpty()) { org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId); InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup); instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); - updateInstanceName(executeBB.getRequestId(), ModelType.instanceGroup, instanceGroup.getInstanceGroupName()); if (serviceInstanceId == null) { Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = @@ -347,10 +356,10 @@ public class BBInputSetup implements JavaDelegate { customer); } - protected void populateObjectsOnAssignAndCreateFlows(String requestId, RequestDetails requestDetails, - Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, - String resourceId, String vnfType, String configurationKey, - ConfigurationResourceKeys configurationResourceKeys, boolean isReplace) throws Exception { + protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType, + String configurationKey, ConfigurationResourceKeys configurationResourceKeys, boolean isReplace, + ServiceModel serviceModel) throws Exception { ModelInfo modelInfo = requestDetails.getModelInfo(); String instanceName = requestDetails.getRequestInfo().getInstanceName(); String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); @@ -366,29 +375,30 @@ public class BBInputSetup implements JavaDelegate { if (modelType.equals(ModelType.network)) { lookupKeyMap.put(ResourceKey.NETWORK_ID, resourceId); - this.populateL3Network(requestId, instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, null); + this.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + null); } else if (modelType.equals(ModelType.vnf)) { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, resourceId); - this.populateGenericVnf(requestId, modelInfo, instanceName, platform, lineOfBusiness, service, bbName, - serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, - applicationId); + this.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, serviceInstance, + lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId, applicationId, + isReplace); } else if (modelType.equals(ModelType.volumeGroup) || (modelType.equals(ModelType.vfModule) && (bbName.equalsIgnoreCase(AssignFlows.VOLUME_GROUP.toString()) || bbName.startsWith(CREATEVOLUME)))) { lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, resourceId); - this.populateVolumeGroup(requestId, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); } else if (modelType.equals(ModelType.vfModule)) { if (bbName.contains("Configuration")) { String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); ModelInfo configurationModelInfo = new ModelInfo(); configurationModelInfo.setModelCustomizationUuid(configurationKey); - populateConfiguration(requestId, configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, + populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, configurationId, instanceName, configurationResourceKeys, requestDetails); } else { lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); - this.populateVfModule(requestId, modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration(), isReplace, + serviceModel); } } else if (modelType.equals(ModelType.instanceGroup)) { lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId); @@ -412,7 +422,7 @@ public class BBInputSetup implements JavaDelegate { // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups } - protected void populateConfiguration(String requestId, ModelInfo modelInfo, Service service, String bbName, + protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String instanceName, ConfigurationResourceKeys configurationResourceKeys, RequestDetails requestDetails) { Configuration configuration = null; @@ -436,13 +446,11 @@ public class BBInputSetup implements JavaDelegate { Vnfc vnfc = getVnfcToConfiguration(configurationResourceKeys.getVnfcName()); configuration.setVnfc(vnfc); this.mapCatalogConfiguration(configuration, modelInfo, service, configurationResourceKeys); - updateInstanceName(requestId, ModelType.configuration, configuration.getConfigurationName()); } else if (configuration != null && bbName.contains("Vrf")) { configuration.setModelInfoConfiguration(mapperLayer.mapCatalogConfigurationToConfiguration( findConfigurationResourceCustomization(modelInfo, service), null)); configuration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType()); configuration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole()); - updateInstanceName(requestId, ModelType.configuration, configuration.getConfigurationName()); } } @@ -517,10 +525,10 @@ public class BBInputSetup implements JavaDelegate { vfModuleCustomizationUUID, cvnfcCustomizationUUID); } - protected void populateVfModule(String requestId, ModelInfo modelInfo, Service service, String bbName, + protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, RelatedInstanceList[] relatedInstanceList, String instanceName, List<Map<String, String>> instanceParams, - CloudConfiguration cloudConfiguration, boolean isReplace) throws Exception { + CloudConfiguration cloudConfiguration, boolean isReplace, ServiceModel serviceModel) throws Exception { String replaceVnfModelCustomizationUUID = null; String vnfModelCustomizationUUID = null; if (relatedInstanceList != null) { @@ -545,8 +553,13 @@ public class BBInputSetup implements JavaDelegate { vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId(); ModelInfo vnfModelInfo = new ModelInfo(); - vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); - this.mapCatalogVnf(tempVnf, vnfModelInfo, service); + if (isReplace) { + vnfModelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + this.mapCatalogVnf(tempVnf, vnfModelInfo, serviceModel.getNewService()); + } else { + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(tempVnf, vnfModelInfo, serviceModel.getCurrentService()); + } Optional<String> volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(tempVnf, modelInfo, cloudConfiguration.getCloudOwner(), cloudConfiguration.getLcpCloudRegionId(), lookupKeyMap); if (volumeGroupIdOp.isPresent()) { @@ -566,24 +579,26 @@ public class BBInputSetup implements JavaDelegate { .getModelCustomizationId(); ModelInfo modelInfoVfModule = new ModelInfo(); modelInfoVfModule.setModelCustomizationId(vfModuleCustId); - if (isReplace) { - mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, replaceVnfModelCustomizationUUID); + if (isReplace && lookupKeyMap.get(ResourceKey.VF_MODULE_ID) != null + && vfModuleTemp.getVfModuleId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.VF_MODULE_ID))) { + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, serviceModel.getNewService(), + replaceVnfModelCustomizationUUID); } else { - mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, service, vnfModelCustomizationUUID); + mapCatalogVfModule(vfModuleTemp, modelInfoVfModule, serviceModel.getCurrentService(), + vnfModelCustomizationUUID); } } if (vfModule == null && bbName.equalsIgnoreCase(AssignFlows.VF_MODULE.toString())) { vfModule = createVfModule(lookupKeyMap, resourceId, instanceName, instanceParams); vnf.getVfModules().add(vfModule); if (isReplace) { - mapCatalogVfModule(vfModule, modelInfo, service, replaceVnfModelCustomizationUUID); + mapCatalogVfModule(vfModule, modelInfo, serviceModel.getNewService(), + replaceVnfModelCustomizationUUID); } else { - mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID); + mapCatalogVfModule(vfModule, modelInfo, serviceModel.getCurrentService(), + vnfModelCustomizationUUID); } } - if (vfModule != null) { - updateInstanceName(requestId, ModelType.vfModule, vfModule.getVfModuleName()); - } } else { logger.debug("Related VNF instance Id not found: {}", lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); throw new Exception("Could not find relevant information for related VNF"); @@ -648,7 +663,7 @@ public class BBInputSetup implements JavaDelegate { return vfModule; } - protected void populateVolumeGroup(String requestId, ModelInfo modelInfo, Service service, String bbName, + protected void populateVolumeGroup(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, RelatedInstanceList[] relatedInstanceList, String instanceName, String vnfType, List<Map<String, String>> instanceParams) throws Exception { @@ -694,7 +709,6 @@ public class BBInputSetup implements JavaDelegate { } if (volumeGroup != null) { mapCatalogVolumeGroup(volumeGroup, modelInfo, service, vnfModelCustomizationUUID); - updateInstanceName(requestId, ModelType.volumeGroup, volumeGroup.getVolumeGroupName()); } } else { logger.debug("Related VNF instance Id not found: {}", lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID)); @@ -748,16 +762,17 @@ public class BBInputSetup implements JavaDelegate { return null; } - protected void populateGenericVnf(String requestId, ModelInfo modelInfo, String instanceName, + protected void populateGenericVnf(ModelInfo modelInfo, String instanceName, org.onap.so.serviceinstancebeans.Platform platform, org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, RelatedInstanceList[] relatedInstanceList, String resourceId, String vnfType, - List<Map<String, String>> instanceParams, String productFamilyId, String applicationId) { + List<Map<String, String>> instanceParams, String productFamilyId, String applicationId, boolean isReplace) { GenericVnf vnf = null; ModelInfo instanceGroupModelInfo = null; String instanceGroupId = null; String generatedVnfType = vnfType; + String replaceVnfModelCustomizationUUID = null; if (generatedVnfType == null || generatedVnfType.isEmpty()) { generatedVnfType = service.getModelName() + "/" + modelInfo.getModelCustomizationName(); } @@ -768,6 +783,9 @@ public class BBInputSetup implements JavaDelegate { instanceGroupModelInfo = relatedInstance.getModelInfo(); instanceGroupId = relatedInstance.getInstanceId(); } + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf) && isReplace) { + replaceVnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + } } } for (GenericVnf vnfTemp : serviceInstance.getVnfs()) { @@ -775,6 +793,12 @@ public class BBInputSetup implements JavaDelegate { && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { String vnfModelCustId = bbInputSetupUtils.getAAIGenericVnf(vnfTemp.getVnfId()).getModelCustomizationId(); + if (isReplace && replaceVnfModelCustomizationUUID != null + && vnfTemp.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + modelInfo.setModelCustomizationUuid(replaceVnfModelCustomizationUUID); + } else { + modelInfo.setModelCustomizationUuid(vnfModelCustId); + } modelInfo.setModelCustomizationUuid(vnfModelCustId); vnf = vnfTemp; break; @@ -793,7 +817,6 @@ public class BBInputSetup implements JavaDelegate { && !instanceGroupInList(vnf, instanceGroupId)) { mapNetworkCollectionInstanceGroup(vnf, instanceGroupId); } - updateInstanceName(requestId, ModelType.vnf, vnf.getVnfName()); } } @@ -885,8 +908,8 @@ public class BBInputSetup implements JavaDelegate { return vnfResourceCustomization; } - protected void populateL3Network(String requestId, String instanceName, ModelInfo modelInfo, Service service, - String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, + protected void populateL3Network(String instanceName, ModelInfo modelInfo, Service service, String bbName, + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, List<Map<String, String>> instanceParams) { L3Network network = null; for (L3Network networkTemp : serviceInstance.getNetworks()) { @@ -903,7 +926,6 @@ public class BBInputSetup implements JavaDelegate { } if (network != null) { mapCatalogNetwork(network, modelInfo, service); - updateInstanceName(requestId, ModelType.network, network.getNetworkName()); } } @@ -963,7 +985,6 @@ public class BBInputSetup implements JavaDelegate { ServiceInstance serviceInstance = this.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()), executeBB.getBuildingBlock().getBpmnFlowName()); - updateInstanceName(executeBB.getRequestId(), ModelType.service, serviceInstance.getServiceInstanceName()); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, customer); } else { @@ -1172,8 +1193,8 @@ public class BBInputSetup implements JavaDelegate { NetworkResourceCustomization networkCust = getNetworkCustomizationByKey(key, service); if (networkCust != null) { networkModelInfo.setModelCustomizationUuid(networkCust.getModelCustomizationUUID()); - this.populateL3Network(executeBB.getRequestId(), null, networkModelInfo, service, bbName, - serviceInstance, lookupKeyMap, networkId, null); + this.populateL3Network(null, networkModelInfo, service, bbName, serviceInstance, lookupKeyMap, + networkId, null); } else { logger.debug("Could not find a network customization with key: {}", key); } @@ -1193,9 +1214,8 @@ public class BBInputSetup implements JavaDelegate { String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); ModelInfo configurationModelInfo = new ModelInfo(); configurationModelInfo.setModelCustomizationUuid(key); - this.populateConfiguration(executeBB.getRequestId(), configurationModelInfo, service, bbName, - serviceInstance, lookupKeyMap, configurationId, null, executeBB.getConfigurationResourceKeys(), - executeBB.getRequestDetails()); + this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, + configurationId, null, executeBB.getConfigurationResourceKeys(), executeBB.getRequestDetails()); } if (executeBB.getWorkflowResourceIds() != null) { this.populateNetworkCollectionAndInstanceGroupAssign(service, bbName, serviceInstance, @@ -1312,7 +1332,6 @@ public class BBInputSetup implements JavaDelegate { ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); - updateInstanceName(executeBB.getRequestId(), ModelType.service, serviceInstance.getServiceInstanceName()); gBB = populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); serviceInstance = gBB.getServiceInstance(); @@ -1451,9 +1470,13 @@ public class BBInputSetup implements JavaDelegate { } String productFamilyId = requestDetails.getRequestInfo().getProductFamilyId(); String applicationId = ""; - this.populateGenericVnf(executeBB.getRequestId(), vnfs.getModelInfo(), vnfs.getInstanceName(), - vnfs.getPlatform(), vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, - vnfId, vnfType, vnfs.getInstanceParams(), productFamilyId, applicationId); + if (vnfs.getApplicationId() != null) { + applicationId = vnfs.getApplicationId(); + } + this.populateGenericVnf(vnfs.getModelInfo(), vnfs.getInstanceName(), vnfs.getPlatform(), + vnfs.getLineOfBusiness(), service, bbName, serviceInstance, lookupKeyMap, null, vnfId, vnfType, + vnfs.getInstanceParams(), productFamilyId, applicationId, false); + } else if (bbName.contains(PNF)) { String pnfId = lookupKeyMap.get(ResourceKey.PNF); resources.getPnfs().stream() @@ -1472,24 +1495,24 @@ public class BBInputSetup implements JavaDelegate { ModelInfo modelInfo = vfModules.getModelInfo(); if (bbName.contains(VOLUME_GROUP)) { String volumeGroupId = lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID); - this.populateVolumeGroup(executeBB.getRequestId(), modelInfo, service, bbName, serviceInstance, - lookupKeyMap, volumeGroupId, null, vfModules.getVolumeGroupInstanceName(), vnfType, - vfModules.getInstanceParams()); + this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, volumeGroupId, null, + vfModules.getVolumeGroupInstanceName(), vnfType, vfModules.getInstanceParams()); } else { String vfModuleId = lookupKeyMap.get(ResourceKey.VF_MODULE_ID); CloudConfiguration cloudConfig = new CloudConfiguration(); cloudConfig.setLcpCloudRegionId(cloudRegion.getLcpCloudRegionId()); cloudConfig.setCloudOwner(cloudRegion.getCloudOwner()); - this.populateVfModule(executeBB.getRequestId(), modelInfo, service, bbName, serviceInstance, - lookupKeyMap, vfModuleId, null, vfModules.getInstanceName(), vfModules.getInstanceParams(), - cloudConfig, false); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, vfModuleId, null, + vfModules.getInstanceName(), vfModules.getInstanceParams(), cloudConfig, false, serviceModel); } } else if (bbName.contains(NETWORK)) { networks = findNetworksByKey(key, resources); String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID); if (networks != null) { - this.populateL3Network(executeBB.getRequestId(), networks.getInstanceName(), networks.getModelInfo(), - service, bbName, serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams()); + this.populateL3Network(networks.getInstanceName(), networks.getModelInfo(), service, bbName, + serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams()); } } else if (bbName.contains("Configuration")) { String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID); @@ -1498,9 +1521,8 @@ public class BBInputSetup implements JavaDelegate { ConfigurationResourceCustomization configurationCust = findConfigurationResourceCustomization(configurationModelInfo, service); if (configurationCust != null) { - this.populateConfiguration(executeBB.getRequestId(), configurationModelInfo, service, bbName, - serviceInstance, lookupKeyMap, configurationId, null, executeBB.getConfigurationResourceKeys(), - executeBB.getRequestDetails()); + this.populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, lookupKeyMap, + configurationId, null, executeBB.getConfigurationResourceKeys(), executeBB.getRequestDetails()); } else { logger.debug("Could not find a configuration customization with key: {}", key); } @@ -2011,25 +2033,4 @@ public class BBInputSetup implements JavaDelegate { } return customer; } - - protected void updateInstanceName(String requestId, ModelType resourceType, String instanceName) { - try { - if (instanceName != null) { - InfraActiveRequests request = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); - if (resourceType.getName(request) == null) { - logger.info("Updating instanceName to: {} in requestDb for requestId: {}", instanceName, requestId); - resourceType.setName(request, instanceName); - requestsDbClient.updateInfraActiveRequests(request); - } - } else { - logger.info("Failed to update instanceName in RequestDb because it was null for requestId: {}", - requestId); - } - } catch (Exception ex) { - logger.error("Unable to update Request db with instanceName for requestId: {} due to error: {}", requestId, - ex.getMessage()); - } - } - - } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 994abda083..ec7b613727 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -276,7 +276,7 @@ public class BBInputSetupUtils { } } - protected InstanceGroup getAAIInstanceGroup(String instanceGroupId) { + public InstanceGroup getAAIInstanceGroup(String instanceGroupId) { return injectionHelper.getAaiClient().get(InstanceGroup.class, AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)).orElse(null); } @@ -549,6 +549,20 @@ public class BBInputSetupUtils { } } + public Optional<VolumeGroup> getRelatedVolumeGroupByIdFromVnf(String vnfId, String volumeGroupId) { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-id", volumeGroupId); + Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri); + VolumeGroup volumeGroup = null; + if (!volumeGroups.isPresent()) { + logger.debug("No VolumeGroups matched by id"); + return Optional.empty(); + } else { + volumeGroup = volumeGroups.get().getVolumeGroup().get(0); + return Optional.of(volumeGroup); + } + } + public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vnfId, String vfModuleId, String volumeGroupName) throws MultipleObjectsFoundException { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java index 5498b5be31..9741d4b6c2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtils.java @@ -24,7 +24,6 @@ package org.onap.so.client.cds; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -51,28 +50,29 @@ import io.grpc.Status; * */ @Component -public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { +public class AbstractCDSProcessingBBUtils { private static final Logger logger = LoggerFactory.getLogger(AbstractCDSProcessingBBUtils.class); private static final String SUCCESS = "Success"; private static final String FAILED = "Failed"; private static final String PROCESSING = "Processing"; + private static final String RESPONSE_PAYLOAD = "CDSResponsePayload"; + private static final String CDS_STATUS = "CDSStatus"; + private static final String EXEC_INPUT = "executionServiceInput"; + /** * indicate exception thrown. */ private static final String EXCEPTION = "Exception"; - - private final AtomicReference<String> cdsResponse = new AtomicReference<>(); - @Autowired private ExceptionBuilder exceptionUtil; /** * Extracting data from execution object and building the ExecutionServiceInput Object - * + * * @param execution DelegateExecution object */ public void constructExecutionServiceInputObject(DelegateExecution execution) { @@ -105,7 +105,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { ExecutionServiceInput.newBuilder().setCommonHeader(commonHeader) .setActionIdentifiers(actionIdentifiers).setPayload(struct.build()).build(); - execution.setVariable("executionServiceInput", executionServiceInput); + execution.setVariable(EXEC_INPUT, executionServiceInput); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -114,7 +114,7 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { /** * get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period - * + * * @param execution DelegateExecution object */ public void sendRequestToCDSClient(DelegateExecution execution) { @@ -127,10 +127,11 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { "No RestProperty.CDSProperties implementation found on classpath, can't create client."); } - ExecutionServiceInput executionServiceInput = - (ExecutionServiceInput) execution.getVariable("executionServiceInput"); + ExecutionServiceInput executionServiceInput = (ExecutionServiceInput) execution.getVariable(EXEC_INPUT); + + CDSResponse cdsResponse = new CDSResponse(); - try (CDSProcessingClient cdsClient = new CDSProcessingClient(this)) { + try (CDSProcessingClient cdsClient = new CDSProcessingClient(new ResponseHandler(cdsResponse))) { CountDownLatch countDownLatch = cdsClient.sendRequest(executionServiceInput); countDownLatch.await(props.getTimeout(), TimeUnit.SECONDS); } catch (InterruptedException ex) { @@ -138,61 +139,82 @@ public class AbstractCDSProcessingBBUtils implements CDSProcessingListener { Thread.currentThread().interrupt(); } - if (cdsResponse != null) { - String cdsResponseStatus = cdsResponse.get(); - execution.setVariable("CDSStatus", cdsResponseStatus); + String cdsResponseStatus = cdsResponse.status; + + /** + * throw CDS failed exception. + */ + if (!cdsResponseStatus.equals(SUCCESS)) { + throw new BadResponseException("CDS call failed with status: " + cdsResponse.status + + " and errorMessage: " + cdsResponse.errorMessage); + } + + execution.setVariable(CDS_STATUS, cdsResponseStatus); - /** - * throw CDS failed exception. - */ - if (cdsResponseStatus != SUCCESS) { - throw new BadResponseException("CDS call failed with status: " + cdsResponseStatus); - } + if (cdsResponse.payload != null) { + String payload = JsonFormat.printer().print(cdsResponse.payload); + execution.setVariable(RESPONSE_PAYLOAD, payload); } + + } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } - /** - * Get Response from CDS Client - * - */ - @Override - public void onMessage(ExecutionServiceOutput message) { - logger.info("Received notification from CDS: {}", message); - EventType eventType = message.getStatus().getEventType(); - - switch (eventType) { - - case EVENT_COMPONENT_FAILURE: - // failed processing with failure - cdsResponse.set(FAILED); - break; - case EVENT_COMPONENT_PROCESSING: - // still processing - cdsResponse.set(PROCESSING); - break; - case EVENT_COMPONENT_EXECUTED: - // done with async processing - cdsResponse.set(SUCCESS); - break; - default: - cdsResponse.set(FAILED); - break; + private class ResponseHandler implements CDSProcessingListener { + + private CDSResponse cdsResponse; + + ResponseHandler(CDSResponse cdsResponse) { + this.cdsResponse = cdsResponse; } - } + /** + * Get Response from CDS Client + */ + @Override + public void onMessage(ExecutionServiceOutput message) { + logger.info("Received notification from CDS: {}", message); + EventType eventType = message.getStatus().getEventType(); + + switch (eventType) { + case EVENT_COMPONENT_PROCESSING: + cdsResponse.status = PROCESSING; + break; + case EVENT_COMPONENT_EXECUTED: + cdsResponse.status = SUCCESS; + break; + default: + cdsResponse.status = FAILED; + cdsResponse.errorMessage = message.getStatus().getErrorMessage(); + break; + } + cdsResponse.payload = message.getPayload(); + } - /** - * On error at CDS, log the error - */ - @Override - public void onError(Throwable t) { - Status status = Status.fromThrowable(t); - logger.error("Failed processing blueprint {}", status, t); - cdsResponse.set(EXCEPTION); + /** + * On error at CDS, log the error + */ + @Override + public void onError(Throwable t) { + Status status = Status.fromThrowable(t); + logger.error("Failed processing blueprint {}", status, t); + cdsResponse.status = EXCEPTION; + } } + private class CDSResponse { + + String status; + String errorMessage; + Struct payload; + + @Override + public String toString() { + return "CDSResponse{" + "status='" + status + '\'' + ", errorMessage='" + errorMessage + '\'' + ", payload=" + + payload + '}'; + } + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java index 7bd2beeb92..dbd5000387 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java @@ -115,6 +115,12 @@ public class ExtractPojosForBBTest extends BaseTest { instanceGroupsPend.add(instanceGroupPend); lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId()); + List<Pnf> pnfsPend = serviceInstancePend.getPnfs(); + Pnf pnfPend = new Pnf(); + pnfPend.setPnfId("abc"); + pnfsPend.add(pnfPend); + lookupKeyMap.put(ResourceKey.PNF, pnfPend.getPnfId()); + customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend); gBBInput.setCustomer(customer); @@ -143,89 +149,49 @@ public class ExtractPojosForBBTest extends BaseTest { InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID); assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId()); + + Pnf extractPnfPend = extractPojos.extractByKey(execution, ResourceKey.PNF); + assertEquals(extractPnfPend.getPnfId(), pnfPend.getPnfId()); } @Test public void siError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - - extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.SERVICE_INSTANCE_ID); } @Test public void vnfError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.GENERIC_VNF_ID); } @Test public void vfModuleError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VF_MODULE_ID); } @Test public void configurationError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.CONFIGURATION_ID); } @Test public void allotedError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.ALLOTTED_RESOURCE_ID); } @Test public void vpnBindingError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VPN_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_ID); } @Test public void vpnBondingLinkError() throws BBObjectNotFoundException { - expectedException.expect(BBObjectNotFoundException.class); - Customer customer = new Customer(); - customer.setServiceSubscription(new ServiceSubscription()); - ServiceInstance serviceInstance = new ServiceInstance(); - customer.getServiceSubscription().getServiceInstances().add(serviceInstance); - gBBInput.setCustomer(customer); - extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID); + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.VPN_BONDING_LINK_ID); + } + + @Test + public void pnfError() throws BBObjectNotFoundException { + assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey.PNF); } @Test @@ -239,4 +205,19 @@ public class ExtractPojosForBBTest extends BaseTest { ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId()); } + + private void assertThrowsBBObjectNotFoundForResource_WhenServiceEmpty(ResourceKey key) + throws BBObjectNotFoundException { + expectedException.expect(BBObjectNotFoundException.class); + setCustomerWithEmptyServiceInstance(); + extractPojos.extractByKey(execution, key); + } + + private void setCustomerWithEmptyServiceInstance() { + Customer customer = new Customer(); + customer.setServiceSubscription(new ServiceSubscription()); + ServiceInstance serviceInstance = new ServiceInstance(); + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + gBBInput.setCustomer(customer); + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 8ee3979386..e0ee918ead 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -79,6 +79,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.entities.ServiceModel; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; @@ -445,6 +446,8 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); String requestAction = "createInstance"; Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); String resourceId = "123"; String vnfType = "vnfType"; @@ -456,9 +459,9 @@ public class BBInputSetupTest { .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), - requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, - false); + doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(false), isA(ServiceModel.class)); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); @@ -470,6 +473,51 @@ public class BBInputSetupTest { } @Test + public void testGetGBBALaCarteNonServiceIsReplace() throws Exception { + GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"), + GeneralBuildingBlock.class); + ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), + ExecuteBuildingBlock.class); + RequestDetails requestDetails = mapper.readValue( + new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + String requestAction = "replaceInstance"; + Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); + ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); + String resourceId = "123"; + String vnfType = "vnfType"; + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); + aaiServiceInstance.setModelVersionId("modelVersionId"); + org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId"); + doReturn(service).when(SPY_bbInputSetupUtils) + .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID("modelUUID"); + doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); + + doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(true), isA(ServiceModel.class)); + doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); + doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, + executeBB, requestAction, null); + + GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, + requestAction, resourceId, vnfType); + + verify(SPY_bbInputSetup, times(1)).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(true), isA(ServiceModel.class)); + + verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); + verify(SPY_bbInputSetupUtils, times(1)).getCatalogServiceByModelUUID("modelUUID"); + + assertThat(actual, sameBeanAs(expected)); + } + + @Test public void testGetGBBALaCarteNonServiceWithoutServiceModelInfo() throws Exception { ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"), ExecuteBuildingBlock.class); @@ -528,6 +576,8 @@ public class BBInputSetupTest { Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); String requestAction = "createInstance"; Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); String resourceId = "123"; ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance(); @@ -539,9 +589,9 @@ public class BBInputSetupTest { .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId()); doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId"); - doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), - requestDetails, service, "bbName", serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, - false); + doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(eq(requestDetails), eq(service), + eq("bbName"), eq(serviceInstance), eq(lookupKeyMap), eq(resourceId), eq(vnfType), eq(null), eq(null), + eq(false), isA(ServiceModel.class)); doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance); doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, @@ -820,6 +870,8 @@ public class BBInputSetupTest { String productFamilyId = "productFamilyId"; String applicationId = "applicationId"; Service service = Mockito.mock(Service.class); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class); RequestDetails requestDetails = Mockito.mock(RequestDetails.class); ModelInfo modelInfo = Mockito.mock(ModelInfo.class); @@ -832,8 +884,8 @@ public class BBInputSetupTest { Mockito.mock(org.onap.so.serviceinstancebeans.LineOfBusiness.class); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); - doNothing().when(SPY_bbInputSetup).populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, - serviceInstance, lookupKeyMap, resourceId, null); + doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, + lookupKeyMap, resourceId, null); doReturn(modelInfo).when(requestDetails).getModelInfo(); doReturn(productFamilyId).when(requestInfo).getProductFamilyId(); doReturn(requestInfo).when(requestDetails).getRequestInfo(); @@ -845,59 +897,59 @@ public class BBInputSetupTest { doReturn(applicationId).when(requestInfo).getApplicationId(); doReturn(ModelType.network).when(modelInfo).getModelType(); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, - serviceInstance, lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, + lookupKeyMap, resourceId, null); assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.vnf).when(modelInfo).getModelType(); resourceId = "vnfId"; - doNothing().when(SPY_bbInputSetup).populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, - lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, - vnfType, null, productFamilyId, applicationId); + doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, + productFamilyId, applicationId, false); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, - lineOfBusiness, service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, - vnfType, null, productFamilyId, applicationId); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, + service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, + productFamilyId, applicationId, false); assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.volumeGroup).when(modelInfo).getModelType(); resourceId = "volumeGroupId"; - doNothing().when(SPY_bbInputSetup).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, + doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId)); doReturn(ModelType.vfModule).when(modelInfo).getModelType(); resourceId = "vfModuleId"; - doNothing().when(SPY_bbInputSetup).populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbName, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false); + doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false, serviceModel); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, + lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, relatedInstanceList, instanceName, null, cloudConfiguration, false, serviceModel); assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId)); String bbNameAssignVolume = AssignFlows.VOLUME_GROUP.toString(); doReturn(ModelType.vfModule).when(modelInfo).getModelType(); resourceId = "vfModuleId"; - doNothing().when(SPY_bbInputSetup).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbNameAssignVolume, - serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); - SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(REQUEST_ID, requestDetails, service, bbNameAssignVolume, - serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(REQUEST_ID, modelInfo, service, bbNameAssignVolume, - serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbNameAssignVolume, serviceInstance, + lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); + SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbNameAssignVolume, + serviceInstance, lookupKeyMap, resourceId, vnfType, null, null, false, serviceModel); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbNameAssignVolume, serviceInstance, + lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId)); } @@ -1178,12 +1230,12 @@ public class BBInputSetupTest { doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId"); - SPY_bbInputSetup.populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); + SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID"); vnf.getVolumeGroups().clear(); - SPY_bbInputSetup.populateVolumeGroup(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); + SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null); verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service, "vnfModelCustomizationUUID"); } @@ -1232,19 +1284,19 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(network, modelInfo, service); - SPY_bbInputSetup.populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, null); lookupKeyMap.put(ResourceKey.NETWORK_ID, null); - SPY_bbInputSetup.populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, null); verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service); instanceName = "networkName2"; L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null); - SPY_bbInputSetup.populateL3Network(REQUEST_ID, instanceName, modelInfo, service, bbName, serviceInstance, - lookupKeyMap, resourceId, null); + SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap, + resourceId, null); verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service); } @@ -1302,15 +1354,15 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); @@ -1321,8 +1373,8 @@ public class BBInputSetupTest { doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId); doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys); } @@ -1387,8 +1439,8 @@ public class BBInputSetupTest { doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service); doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName); - SPY_bbInputSetup.populateConfiguration(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, instanceName, configResourceKeys, requestDetails); + SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + instanceName, configResourceKeys, requestDetails); verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys); } @@ -1433,15 +1485,15 @@ public class BBInputSetupTest { new org.onap.so.db.catalog.beans.InstanceGroup(); doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; @@ -1454,9 +1506,9 @@ public class BBInputSetupTest { lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2"); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -1531,15 +1583,15 @@ public class BBInputSetupTest { new org.onap.so.db.catalog.beans.InstanceGroup(); doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any()); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service); instanceName = "vnfName2"; @@ -1551,9 +1603,9 @@ public class BBInputSetupTest { doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId()); doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service); doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); - SPY_bbInputSetup.populateGenericVnf(REQUEST_ID, modelInfo, instanceName, platform, lineOfBusiness, service, - bbName, serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, - null, requestDetails.getRequestInfo().getProductFamilyId(), applicationId); + SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName, + serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null, + requestDetails.getRequestInfo().getProductFamilyId(), applicationId, false); verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service); verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}"); verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service); @@ -2007,33 +2059,33 @@ public class BBInputSetupTest { executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), any(String.class), isA(ModelInfo.class), + verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString()); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(any(String.class), isA(ModelInfo.class), - any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), + isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), - any(String.class), any(String.class)); + any(String.class), any(String.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), - any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); + verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class), + isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), + isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any(String.class), any()); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + ArgumentMatchers.isNull(), any(String.class), any()); Configuration configuration = new Configuration(); configuration.setConfigurationId("configurationId"); @@ -2043,16 +2095,16 @@ public class BBInputSetupTest { configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); doReturn(configurationCustList).when(service).getConfigurationCustomizations(); configurationCustList.add(configurationCust); - doNothing().when(SPY_bbInputSetup).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB"); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); } @@ -2118,16 +2170,16 @@ public class BBInputSetupTest { ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization(); configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); configurationCustList.add(configurationCust); - doNothing().when(SPY_bbInputSetup).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); executeBB.getBuildingBlock().setBpmnFlowName("AssignVrfConfigurationBB"); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9"); gBB = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateConfiguration(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); + verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + isA(ConfigurationResourceKeys.class), isA(RequestDetails.class)); assertEquals(gBB.getCustomer().getVpnBindings().get(0).getVpnId(), "vpnBindingId"); assertEquals(gBB.getServiceInstance().getNetworks().get(0).getNetworkId(), "localNetworkId"); assertEquals(gBB.getServiceInstance().getNetworks().get(0).getVpnBindings().get(0).getVpnId(), @@ -2290,33 +2342,33 @@ public class BBInputSetupTest { executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), any(String.class), isA(ModelInfo.class), + verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(any(String.class), isA(ModelInfo.class), - any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), + isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), ArgumentMatchers.isNull(), any(String.class), - ArgumentMatchers.isNull(), any(), any(String.class), any()); + ArgumentMatchers.isNull(), any(), any(String.class), any(), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), - any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); + verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class), + isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), + isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any()); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any()); } @Test @@ -2355,33 +2407,33 @@ public class BBInputSetupTest { executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), any(String.class), isA(ModelInfo.class), + verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateGenericVnf(any(String.class), isA(ModelInfo.class), - any(String.class), isA(org.onap.so.serviceinstancebeans.Platform.class), + verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class), + isA(org.onap.so.serviceinstancebeans.Platform.class), isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), - any(String.class), any(String.class)); + any(String.class), any(String.class), Mockito.anyBoolean()); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString()); executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVfModule(any(String.class), isA(ModelInfo.class), isA(Service.class), - any(String.class), isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), - any(), isA(CloudConfiguration.class), Mockito.anyBoolean()); + verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class), + isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), + isA(CloudConfiguration.class), Mockito.anyBoolean(), isA(ServiceModel.class)); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString()); executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8"); SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType); - verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(any(String.class), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), - ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any(String.class), any()); + verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), + ArgumentMatchers.isNull(), any(String.class), any()); } @Test @@ -2459,8 +2511,8 @@ public class BBInputSetupTest { doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID(); networkCustList.add(networkCust); doReturn(networkCustList).when(service).getNetworkCustomizations(); - doNothing().when(SPY_bbInputSetup).populateL3Network(any(String.class), any(), isA(ModelInfo.class), - isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); + doNothing().when(SPY_bbInputSetup).populateL3Network(any(), isA(ModelInfo.class), isA(Service.class), + any(String.class), isA(ServiceInstance.class), any(), any(String.class), any()); executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString()); executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04"); @@ -2947,6 +2999,8 @@ public class BBInputSetupTest { ModelInfo modelInfo = new ModelInfo(); modelInfo.setModelCustomizationId(vfModuleCustomizationId); Service service = new Service(); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(service); String bbName = AssignFlows.VF_MODULE.toString(); ServiceInstance serviceInstance = new ServiceInstance(); GenericVnf vnf = new GenericVnf(); @@ -2985,8 +3039,8 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); - SPY_bbInputSetup.populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false); + SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, false, serviceModel); verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); @@ -2997,6 +3051,84 @@ public class BBInputSetupTest { } @Test + public void testPopulateVfModuleIsReplaceCorrectPopulationOfVfs() throws Exception { + String vnfId = "vnfId"; + String vfModuleId = "vfModuleId"; + String volumeGroupId = "volumeGroupId"; + String vfModuleCustomizationId = "vfModuleCustomizationId"; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationId(vfModuleCustomizationId); + Service currentService = new Service(); + currentService.setModelUUID("currentUUID"); + Service newService = new Service(); + newService.setModelUUID("newUUID"); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(currentService); + serviceModel.setNewService(newService); + String bbName = "ActivateVfModuleBB"; + ServiceInstance serviceInstance = new ServiceInstance(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId(vnfId); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupId(volumeGroupId); + vnf.getVolumeGroups().add(volumeGroup); + serviceInstance.getVnfs().add(vnf); + VfModule vfModule1 = new VfModule(); + vfModule1.setVfModuleId("vfModuleId1"); + VfModule vfModule2 = new VfModule(); + vfModule2.setVfModuleId("vfModuleId2"); + vnf.getVfModules().add(vfModule1); + vnf.getVfModules().add(vfModule2); + Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); + lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId1"); + String resourceId = vfModuleId; + RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1]; + RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList(); + RelatedInstance relatedInstance = new RelatedInstance(); + relatedInstance.setInstanceId(vnfId); + + ModelInfo vnfModelInfo = new ModelInfo(); + vnfModelInfo.setModelCustomizationId("vnfCustomizationId"); + vnfModelInfo.setModelType(ModelType.vnf); + relatedInstance.setModelInfo(vnfModelInfo); + relatedInstanceListObj.setRelatedInstance(relatedInstance); + relatedInstanceList[0] = relatedInstanceListObj; + + String instanceName = "vfModuleName"; + List<Map<String, String>> instanceParams = null; + CloudConfiguration cloudConfiguration = new CloudConfiguration(); + + org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf(); + vnfAAI.setModelCustomizationId("vnfModelCustId"); + org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup(); + volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId); + org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule(); + vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId); + + doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId()); + doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER, + cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId()); + doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class)); + doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), + isA(Service.class)); + doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + isA(Service.class), isA(String.class)); + + SPY_bbInputSetup.populateVfModule(modelInfo, newService, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true, serviceModel); + + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + eq(currentService), eq("vnfModelCustId")); + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), eq(newService), + eq("vnfCustomizationId")); + assertEquals("Lookup Key Map populated with VfModule Id", "vfModuleId1", + lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); + assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, + lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID)); + } + + @Test public void testPopulateVfModuleIsReplace() throws Exception { String vnfId = "vnfId"; String vfModuleId = "vfModuleId"; @@ -3004,7 +3136,13 @@ public class BBInputSetupTest { String vfModuleCustomizationId = "vfModuleCustomizationId"; ModelInfo modelInfo = new ModelInfo(); modelInfo.setModelCustomizationId(vfModuleCustomizationId); - Service service = new Service(); + Service currentService = new Service(); + Service newService = new Service(); + ServiceModel serviceModel = new ServiceModel(); + serviceModel.setCurrentService(currentService); + currentService.setModelUUID("currentUUID"); + serviceModel.setNewService(newService); + currentService.setModelUUID("newUUID"); String bbName = AssignFlows.VF_MODULE.toString(); ServiceInstance serviceInstance = new ServiceInstance(); GenericVnf vnf = new GenericVnf(); @@ -3021,6 +3159,7 @@ public class BBInputSetupTest { vnf.getVfModules().add(vfModule2); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId); + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModuleId); String resourceId = vfModuleId; RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[1]; RelatedInstanceList relatedInstanceListObj = new RelatedInstanceList(); @@ -3054,11 +3193,13 @@ public class BBInputSetupTest { doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class)); - SPY_bbInputSetup.populateVfModule(REQUEST_ID, modelInfo, service, bbName, serviceInstance, lookupKeyMap, - resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true); + SPY_bbInputSetup.populateVfModule(modelInfo, newService, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, instanceParams, cloudConfiguration, true, serviceModel); - verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), - isA(Service.class), isA(String.class)); + verify(SPY_bbInputSetup, times(2)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + eq(serviceModel.getCurrentService()), isA(String.class)); + verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), + eq(serviceModel.getNewService()), isA(String.class)); assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID)); assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, @@ -3082,18 +3223,4 @@ public class BBInputSetupTest { vnfc = SPY_bbInputSetup.getVnfcToConfiguration(vnfcName); Assert.assertNotNull(vnfc); } - - @Test - public void updateInstanceNameTest() { - InfraActiveRequests request = new InfraActiveRequests(); - request.setRequestId(REQUEST_ID); - - when(requestsDbClient.getInfraActiveRequestbyRequestId(REQUEST_ID)).thenReturn(request); - SPY_bbInputSetup.updateInstanceName(REQUEST_ID, ModelType.service, "instanceName"); - - verify(requestsDbClient).updateInfraActiveRequests(request); - assertEquals("instanceName", request.getServiceInstanceName()); - } - - } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java deleted file mode 100644 index bdc1c504f0..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SecurityFilters.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 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.bpmn.infrastructure; - -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; - -@Configuration -@Profile("aaf") -public class SecurityFilters { - - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java deleted file mode 100644 index cb60d5d219..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.bpmn.infrastructure; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java deleted file mode 100644 index bcc38ec9e0..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.bpmn.infrastructure; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", - "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().permitAll(); - } - }; - } -} diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn index 4ea6bb10b1..496fcb1784 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="DistributeTrafficActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskDistributeTraffic" targetRef="DistributeTrafficActivity_End" /> - <bpmn:serviceTask id="TaskDistributeTraffic" name="Distribute Traffic" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionDistributeTraffic"))}"> + <bpmn:serviceTask id="TaskDistributeTraffic" name="Distribute Traffic" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskDistributeTraffic" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"DistributeTraffic")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn index 19a4972187..a5bde79237 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/DistributeTrafficCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="DistributeTrafficCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskDistributeTrafficCheck" targetRef="DistributeTrafficCheckActivity_End" /> - <bpmn:serviceTask id="TaskDistributeTrafficCheck" name="Distribute Traffic Check" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionDistributeTrafficCheck"))}"> + <bpmn:serviceTask id="TaskDistributeTrafficCheck" name="Distribute Traffic Check" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskDistributeTrafficCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"DistributeTrafficCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn index 9ac0f38835..50fc40f450 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckClosedLoopDisabledFlagActivity.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.9.0"> - <bpmn:process id="VNFCheckClosedLoopDisabledFlagActivity" name="VNFCheckClosedLoopDisabledFlagActivity " isExecutable="true"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> + <bpmn:process id="VNFCheckClosedLoopDisabledFlagActivity" name="VNFCheckClosedLoopDisabledFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFCheckClosedLoopDisabledFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_01c8z5u</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn index 8709f399a5..ed6b10feed 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckInMaintFlagActivity.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.9.0"> - <bpmn:process id="VNFCheckInMaintFlagActivity" name="VNFCheckInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFCheckInMaintFlagActivity" name="VNFCheckInMaintFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFCheckInMaintFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0h1gkvd</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn index 9c327a4da9..49777daa02 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFCheckPserversLockedFlagActivity.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.9.0"> - <bpmn:process id="VNFCheckPserversLockedFlagActivity" name="VNFCheckInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFCheckPserversLockedFlagActivity" name="VNFCheckPserversLockedFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFCheckPserversLockedFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0a56huh</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn index 2e97206867..2e66f6c948 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFHealthCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFHealthCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskHealthCheck" targetRef="VNFHealthCheckActivity_End" /> - <bpmn:serviceTask id="TaskHealthCheck" name="VNF Health Check" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionHealthCheck"))}"> + <bpmn:serviceTask id="TaskHealthCheck" name="VNF Health Check" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskHealthCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"HealthCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn index 1aaa920ef8..43f2f4d6d3 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFLockActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFLockActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskLock" targetRef="VNFLockActivity_End" /> - <bpmn:serviceTask id="TaskLock" name="VNF Lock" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionLock"))}"> + <bpmn:serviceTask id="TaskLock" name="VNF Lock" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskLock" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Lock")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn index ac09674884..d0073803e9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFQuiesceTrafficActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFQuiesceTrafficActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskQuiesceTraffic" targetRef="VNFQuiesceTrafficActivity_End" /> - <bpmn:serviceTask id="TaskQuiesceTraffic" name="VNF Quiesce Traffic" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionQuiesceTraffic"))}"> + <bpmn:serviceTask id="TaskQuiesceTraffic" name="VNF Quiesce Traffic" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskQuiesceTraffic" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"QuiesceTraffic")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn index c21072a32a..888ce18467 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFResumeTrafficActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFResumeTrafficActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskResumeTraffic" targetRef="VNFResumeTrafficActivity_End" /> - <bpmn:serviceTask id="TaskResumeTraffic" name="VNF Resume Traffic" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionResumeTraffic"))}"> + <bpmn:serviceTask id="TaskResumeTraffic" name="VNF Resume Traffic" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskResumeTraffic" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"ResumeTraffic")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn index f356634106..c02161eb61 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetClosedLoopDisabledFlagActivity.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.9.0"> - <bpmn:process id="VNFSetClosedLoopDisabledFlagActivity" name="VNFSetClosedLoopDisabledFlagActivity " isExecutable="true"> + <bpmn:process id="VNFSetClosedLoopDisabledFlagActivity" name="VNFSetClosedLoopDisabledFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFSetClosedLoopDisabledFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0pp6ze7</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn index 2bdb1d7533..a0d0cbd5d7 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSetInMaintFlagActivity.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> - <bpmn:process id="VNFSetInMaintFlagActivity" name="VNFSetInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFSetInMaintFlagActivity" name="VNFSetInMaintFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFSetInMaintFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn index 8115f694c2..f7bf835bd9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFSnapShotActivity.bpmn @@ -5,19 +5,44 @@ <bpmn:outgoing>SequenceFlow_06vhbci</bpmn:outgoing> </bpmn:startEvent> <bpmn:endEvent id="VNFSnapShotActivity_End"> - <bpmn:incoming>SequenceFlow_01312aj</bpmn:incoming> + <bpmn:incoming>SequenceFlow_048qlth</bpmn:incoming> + <bpmn:incoming>SequenceFlow_17zvrl5</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFSnapShotActivity_Start" targetRef="TaskPreProcessActivity" /> - <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskSnapShot" targetRef="VNFSnapShotActivity_End" /> - <bpmn:serviceTask id="TaskSnapShot" name="VNF SnapShot" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionSnapshot"))}"> - <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> + <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskSnapShot" targetRef="ExclusiveGateway_0u10l8w" /> + <bpmn:serviceTask id="TaskSnapShot" name="VM SnapShot" camunda:type="external" camunda:topic="AppcService"> + <bpmn:incoming>SequenceFlow_041lqrr</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Snapshot")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskSnapShot" /> + <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="ExclusiveGateway_0ivqnoj" /> + <bpmn:sequenceFlow id="SequenceFlow_041lqrr" sourceRef="TaskPreProcessVM" targetRef="TaskSnapShot" /> + <bpmn:exclusiveGateway id="ExclusiveGateway_0ivqnoj" name="Are there VMs?" default="SequenceFlow_048qlth"> + <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0aachpx</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_048qlth</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_0aachpx" name="yes" sourceRef="ExclusiveGateway_0ivqnoj" targetRef="TaskPreProcessVM"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("vmIdListSize") > 0}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_048qlth" name="no" sourceRef="ExclusiveGateway_0ivqnoj" targetRef="VNFSnapShotActivity_End" /> + <bpmn:serviceTask id="TaskPreProcessVM" name="PreProcess VM" camunda:expression="${AppcOrchestratorPreProcessor.addVmInfoToAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_0aachpx</bpmn:incoming> + <bpmn:incoming>SequenceFlow_12eenwu</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_041lqrr</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:exclusiveGateway id="ExclusiveGateway_0u10l8w" name="Any more VMs?" default="SequenceFlow_17zvrl5"> + <bpmn:incoming>SequenceFlow_01312aj</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17zvrl5</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_12eenwu</bpmn:outgoing> + </bpmn:exclusiveGateway> + <bpmn:sequenceFlow id="SequenceFlow_17zvrl5" name="no" sourceRef="ExclusiveGateway_0u10l8w" targetRef="VNFSnapShotActivity_End" /> + <bpmn:sequenceFlow id="SequenceFlow_12eenwu" name="yes" sourceRef="ExclusiveGateway_0u10l8w" targetRef="TaskPreProcessVM"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("vmIndex") < execution.getVariable("vmIdListSize")}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="VNFSnapShotActivity"> @@ -25,9 +50,9 @@ <dc:Bounds x="173" y="102" width="36" height="36" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_102xlzi_di" bpmnElement="VNFSnapShotActivity_End"> - <dc:Bounds x="561" y="102" width="36" height="36" /> + <dc:Bounds x="1047" y="102" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="579" y="138" width="0" height="0" /> + <dc:Bounds x="1065" y="138" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_06vhbci_di" bpmnElement="SequenceFlow_06vhbci"> @@ -38,25 +63,79 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_01312aj_di" bpmnElement="SequenceFlow_01312aj"> - <di:waypoint xsi:type="dc:Point" x="497" y="120" /> - <di:waypoint xsi:type="dc:Point" x="561" y="120" /> + <di:waypoint xsi:type="dc:Point" x="850" y="120" /> + <di:waypoint xsi:type="dc:Point" x="911" y="120" /> <bpmndi:BPMNLabel> - <dc:Bounds x="529" y="105" width="0" height="0" /> + <dc:Bounds x="881" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_066idx4_di" bpmnElement="TaskSnapShot"> - <dc:Bounds x="397" y="80" width="100" height="80" /> + <dc:Bounds x="750" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0fti66x_di" bpmnElement="TaskPreProcessActivity"> <dc:Bounds x="255" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0cf0riu_di" bpmnElement="SequenceFlow_0cf0riu"> <di:waypoint xsi:type="dc:Point" x="355" y="120" /> - <di:waypoint xsi:type="dc:Point" x="397" y="120" /> + <di:waypoint xsi:type="dc:Point" x="430" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="393" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_041lqrr_di" bpmnElement="SequenceFlow_041lqrr"> + <di:waypoint xsi:type="dc:Point" x="667" y="120" /> + <di:waypoint xsi:type="dc:Point" x="750" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="709" y="105" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ExclusiveGateway_0ivqnoj_di" bpmnElement="ExclusiveGateway_0ivqnoj" isMarkerVisible="true"> + <dc:Bounds x="430" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="417" y="59" width="76" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0aachpx_di" bpmnElement="SequenceFlow_0aachpx"> + <di:waypoint xsi:type="dc:Point" x="480" y="120" /> + <di:waypoint xsi:type="dc:Point" x="567" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="515" y="105" width="18" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_048qlth_di" bpmnElement="SequenceFlow_048qlth"> + <di:waypoint xsi:type="dc:Point" x="455" y="145" /> + <di:waypoint xsi:type="dc:Point" x="455" y="243" /> + <di:waypoint xsi:type="dc:Point" x="1065" y="243" /> + <di:waypoint xsi:type="dc:Point" x="1065" y="138" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="754" y="228" width="12" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_12efz54_di" bpmnElement="TaskPreProcessVM"> + <dc:Bounds x="567" y="80" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ExclusiveGateway_0u10l8w_di" bpmnElement="ExclusiveGateway_0u10l8w" isMarkerVisible="true"> + <dc:Bounds x="911" y="95" width="50" height="50" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="897" y="145" width="78" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_17zvrl5_di" bpmnElement="SequenceFlow_17zvrl5"> + <di:waypoint xsi:type="dc:Point" x="961" y="120" /> + <di:waypoint xsi:type="dc:Point" x="1047" y="120" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="998" y="95" width="12" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_12eenwu_di" bpmnElement="SequenceFlow_12eenwu"> + <di:waypoint xsi:type="dc:Point" x="936" y="95" /> + <di:waypoint xsi:type="dc:Point" x="936" y="-10" /> + <di:waypoint xsi:type="dc:Point" x="617" y="-10" /> + <di:waypoint xsi:type="dc:Point" x="617" y="80" /> <bpmndi:BPMNLabel> - <dc:Bounds x="376" y="105" width="0" height="0" /> + <dc:Bounds x="768" y="-25" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn index f0490a9b61..da1e4a3630 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStartActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFStartActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskStart" targetRef="VNFStartActivity_End" /> - <bpmn:serviceTask id="TaskStart" name="VNF Start" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionStart"))}"> + <bpmn:serviceTask id="TaskStart" name="VNF Start" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskStart" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Start")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn index 0e02295631..93d442eaa5 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFStopActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFStopActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskStop" targetRef="VNFStopActivity_End" /> - <bpmn:serviceTask id="TaskStop" name="VNF Stop" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionStop"))}"> + <bpmn:serviceTask id="TaskStop" name="VNF Stop" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskStop" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Stop")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn index 6d1b68cb7b..ef4162c60e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnlockActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUnlockActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUnlock" targetRef="VNFUnlockActivity_End" /> - <bpmn:serviceTask id="TaskUnlock" name="VNF Unlock" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUnlock"))}"> + <bpmn:serviceTask id="TaskUnlock" name="VNF Unlock" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUnlock" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"Unlock")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn index d70e103009..575e3124fa 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetClosedLoopDisabledFlagActivity.bpmn @@ -44,4 +44,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn index 05d3fcfa27..59eb80c16e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUnsetInMaintFlagActivity.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> - <bpmn:process id="VNFUnsetInMaintFlagActivity" name="VNFUnsetInMaintFlagActivity " isExecutable="true"> + <bpmn:process id="VNFUnsetInMaintFlagActivity" name="VNFUnsetInMaintFlagActivity" isExecutable="true"> <bpmn:startEvent id="VNFUnsetInMaintFlagActivity_Start"> <bpmn:outgoing>SequenceFlow_0zaz9o2</bpmn:outgoing> </bpmn:startEvent> @@ -47,4 +47,4 @@ </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn index dfcf9974ee..1b37867ecf 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeBackupActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradeBackupActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradeBackup" targetRef="VNFUpgradeBackupActivity_End" /> - <bpmn:serviceTask id="TaskUpgradeBackup" name="VNF UpgradeBackup" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradeBackup"))}"> + <bpmn:serviceTask id="TaskUpgradeBackup" name="VNF UpgradeBackup" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradeBackup" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradeBackup")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn index 56c24dabc9..b9c4d89be9 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePostCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradePostCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradePostCheck" targetRef="VNFUpgradePostCheckActivity_End" /> - <bpmn:serviceTask id="TaskUpgradePostCheck" name="VNF Upgrade PostCheck " camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradePostCheck"))}"> + <bpmn:serviceTask id="TaskUpgradePostCheck" name="VNF Upgrade PostCheck " camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradePostCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradePostCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn index 1ec0a18dd5..33886e358d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradePreCheckActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradePreCheckActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradePreCheck" targetRef="VNFUpgradePreCheckActivity_End" /> - <bpmn:serviceTask id="TaskUpgradePreCheck" name="VNF Upgrade PreCheck " camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradePreCheck"))}"> + <bpmn:serviceTask id="TaskUpgradePreCheck" name="VNF Upgrade PreCheck " camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradePreCheck" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradePreCheck")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn index 89481a5640..16df667f6a 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/VNFUpgradeSoftwareActivity.bpmn @@ -9,12 +9,12 @@ </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_06vhbci" sourceRef="VNFUpgradeSoftwareActivity_Start" targetRef="TaskPreProcessActivity" /> <bpmn:sequenceFlow id="SequenceFlow_01312aj" sourceRef="TaskUpgradeSoftware" targetRef="VNFUpgradeSoftwareActivity_End" /> - <bpmn:serviceTask id="TaskUpgradeSoftware" name="VNF Upgrade Software" camunda:expression="${AppcRunTasks.runAppcCommand(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),execution.getVariable("actionUpgradeSoftware"))}"> + <bpmn:serviceTask id="TaskUpgradeSoftware" name="VNF Upgrade Software" camunda:type="external" camunda:topic="AppcService"> <bpmn:incoming>SequenceFlow_0cf0riu</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01312aj</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0cf0riu" sourceRef="TaskPreProcessActivity" targetRef="TaskUpgradeSoftware" /> - <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcRunTasks.preProcessActivity(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:serviceTask id="TaskPreProcessActivity" name="PreProcess Activity" camunda:expression="${AppcOrchestratorPreProcessor.buildAppcTaskRequest(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"UpgradeSoftware")}"> <bpmn:incoming>SequenceFlow_06vhbci</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0cf0riu</bpmn:outgoing> </bpmn:serviceTask> @@ -59,4 +59,4 @@ </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> -</bpmn:definitions> +</bpmn:definitions>
\ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn index f9c5d0cdb3..930f666bf0 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignPnfBB.bpmn @@ -11,8 +11,8 @@ <bpmn:startEvent id="AssignPnf_StartEvent"> <bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing> </bpmn:startEvent> - <bpmn:serviceTask id="CheckAaiForPnfCorrelationId" name="Check AAI for pnf_correlation_id" camunda:delegateExpression="${CheckAaiForPnfCorrelationIdDelegate}"> - <bpmn:incoming>SequenceFlow_02j05kk</bpmn:incoming> + <bpmn:serviceTask id="CheckAaiForPnfCorrelationId" name="Check AAI for pnf_correlation_id" camunda:expression="${CheckAaiForPnfCorrelationId.execute(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming> <bpmn:outgoing>SequenceFlow_081rs5d</bpmn:outgoing> </bpmn:serviceTask> <bpmn:exclusiveGateway id="DoesAaiContainInfoAboutPnf" name="Does AAI contain info about pnf?"> @@ -20,7 +20,7 @@ <bpmn:outgoing>SequenceFlow_0fn5kgz</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_1ewfz8r</bpmn:outgoing> </bpmn:exclusiveGateway> - <bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:delegateExpression="${CreatePnfEntryInAaiDelegate}"> + <bpmn:serviceTask id="CreatePnfEntryInAai" name="Create Pnf entry in AAI" camunda:expression="${CreatePnfEntryInAai.execute(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> <bpmn:incoming>SequenceFlow_0fn5kgz</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing> </bpmn:serviceTask> @@ -36,12 +36,7 @@ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{aaiContainsInfoAboutPnf}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="CreatePnfEntryInAai" targetRef="AaiEntryExists" /> - <bpmn:serviceTask id="CheckInputs" name="Check Inputs" camunda:delegateExpression="${AssignPnfInputsCheckerDelegate}"> - <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_02j05kk</bpmn:outgoing> - </bpmn:serviceTask> - <bpmn:sequenceFlow id="SequenceFlow_02j05kk" sourceRef="CheckInputs" targetRef="CheckAaiForPnfCorrelationId" /> - <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CheckInputs" /> + <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="CheckAaiForPnfCorrelationId" /> <bpmn:textAnnotation id="TextAnnotation_184cxp4"> <bpmn:text>Inputs: - pnfCorrelationId - String @@ -121,16 +116,9 @@ <di:waypoint x="1020" y="287" /> <di:waypoint x="1152" y="287" /> </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ServiceTask_0tv92eb_di" bpmnElement="CheckInputs"> - <dc:Bounds x="400" y="247" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_02j05kk_di" bpmnElement="SequenceFlow_02j05kk"> - <di:waypoint x="500" y="287" /> - <di:waypoint x="640" y="287" /> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1fu9o4x_di" bpmnElement="SequenceFlow_1fu9o4x"> <di:waypoint x="255" y="287" /> - <di:waypoint x="400" y="287" /> + <di:waypoint x="640" y="287" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java index ff987b75d4..5b7fe66f54 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/BaseBPMNTest.java @@ -19,6 +19,7 @@ */ package org.onap.so.bpmn; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -26,6 +27,8 @@ import java.util.Map; import org.camunda.bpm.engine.ExternalTaskService; import org.camunda.bpm.engine.RepositoryService; import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; +import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.extension.mockito.mock.FluentJavaDelegateMock; import org.camunda.bpm.model.bpmn.Bpmn; import org.camunda.bpm.model.bpmn.BpmnModelInstance; @@ -49,6 +52,7 @@ import org.onap.so.bpmn.infrastructure.adapter.network.tasks.NetworkAdapterUpdat import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterCreateTasks; import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterDeleteTasks; import org.onap.so.bpmn.infrastructure.adapter.vnf.tasks.VnfAdapterImpl; +import org.onap.so.bpmn.infrastructure.appc.tasks.AppcOrchestratorPreProcessor; import org.onap.so.bpmn.infrastructure.appc.tasks.AppcRunTasks; import org.onap.so.bpmn.infrastructure.audit.AuditTasks; import org.onap.so.bpmn.infrastructure.flowspecific.tasks.ActivateVfModule; @@ -131,6 +135,9 @@ public abstract class BaseBPMNTest { protected AppcRunTasks appcRunTasks; @MockBean + protected AppcOrchestratorPreProcessor appcOrchestratorPreProcessor; + + @MockBean protected SDNCActivateTasks sdncActivateTasks; @MockBean @@ -299,4 +306,17 @@ public abstract class BaseBPMNTest { mockedSubprocessList.add(repositoryService.createDeployment() .addModelInstance(fileName + ".bpmn", modelInstance).deploy().getId()); } + + protected void processExternalTasks(ProcessInstance pi, String taskName) { + assertThat(pi).isWaitingAt(taskName); + List<LockedExternalTask> tasks = + externalTaskService.fetchAndLock(100, "externalWorkerId").topic("AppcService", 60L * 1000L).execute(); + while (!tasks.isEmpty()) { + for (LockedExternalTask task : tasks) { + externalTaskService.complete(task.getId(), "externalWorkerId"); + } + tasks = externalTaskService.fetchAndLock(100, "externalWorkerId").topic("AppcService", 60L * 1000L) + .execute(); + } + } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java index 8306de4794..dae430e400 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class DistributeTrafficActivityTest extends BaseBPMNTest { @Test public void sunnyDayDistributeTrafficActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskDistributeTraffic"); assertThat(pi).isStarted().hasPassedInOrder("DistributeTrafficActivity_Start", "TaskPreProcessActivity", "TaskDistributeTraffic", "DistributeTrafficActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class DistributeTrafficActivityTest extends BaseBPMNTest { @Test public void rainyDayDistributeTrafficActivity_Test() throws Exception { - variables.put("actionDistributeTraffic", Action.DistributeTraffic); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("DistributeTrafficActivity_Start", "TaskPreProcessActivity", "TaskDistributeTraffic") - .hasNotPassed("DistributeTrafficActivity_End"); + .hasPassedInOrder("DistributeTrafficActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskDistributeTraffic", "DistributeTrafficActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java index 195a1ed809..7c18a20604 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/DistributeTrafficCheckActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class DistributeTrafficCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayDistributeTrafficCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficCheckActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskDistributeTrafficCheck"); assertThat(pi).isStarted().hasPassedInOrder("DistributeTrafficCheckActivity_Start", "TaskPreProcessActivity", "TaskDistributeTrafficCheck", "DistributeTrafficCheckActivity_End"); assertThat(pi).isEnded(); @@ -42,14 +44,12 @@ public class DistributeTrafficCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayDistributeTrafficActivity_Test() throws Exception { - variables.put("actionDistributeTrafficCheck", Action.DistributeTrafficCheck); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("DistributeTrafficCheckActivity", variables); - assertThat(pi) - .isNotNull().isStarted().hasPassedInOrder("DistributeTrafficCheckActivity_Start", - "TaskPreProcessActivity", "TaskDistributeTrafficCheck") - .hasNotPassed("DistributeTrafficCheckActivity_End"); + assertThat(pi).isNotNull().isStarted() + .hasPassedInOrder("DistributeTrafficCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskDistributeTrafficCheck", "DistributeTrafficCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java index c0b0094f20..48104017a5 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java @@ -29,7 +29,6 @@ import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.runtime.Job; import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.task.Task; import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; import org.junit.Test; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java index 0b17e3e099..10040b813c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFHealthCheckActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFHealthCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFHealthCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFHealthCheckActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskHealthCheck"); assertThat(pi).isStarted().hasPassedInOrder("VNFHealthCheckActivity_Start", "TaskPreProcessActivity", "TaskHealthCheck", "VNFHealthCheckActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFHealthCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFHealthCheckActivity_Test() throws Exception { - variables.put("actionHealthCheck", Action.HealthCheck); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFHealthCheckActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFHealthCheckActivity_Start", "TaskPreProcessActivity", "TaskHealthCheck") - .hasNotPassed("VNFHealthCheckActivity_End"); + .hasPassedInOrder("VNFHealthCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskHealthCheck", "VNFHealthCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java index 45cf44848f..a174bbb90c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFLockActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFLockActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFLockActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFLockActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskLock"); assertThat(pi).isStarted().hasPassedInOrder("VNFLockActivity_Start", "TaskPreProcessActivity", "TaskLock", "VNFLockActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFLockActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFLockActivity_Test() throws Exception { - variables.put("actionLock", Action.Lock); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFLockActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFLockActivity_Start", "TaskPreProcessActivity", "TaskLock") - .hasNotPassed("VNFLockActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFLockActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskLock", "VNFLockActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java index fb462bc02f..b1229cdfdf 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFQuiesceTrafficActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFQuiesceTrafficActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFQuiesceTrafficActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFQuiesceTrafficActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskQuiesceTraffic"); assertThat(pi).isStarted().hasPassedInOrder("VNFQuiesceTrafficActivity_Start", "TaskPreProcessActivity", "TaskQuiesceTraffic", "VNFQuiesceTrafficActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFQuiesceTrafficActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFQuiesceTrafficActivity_Test() throws Exception { - variables.put("actionQuiesceTraffic", Action.QuiesceTraffic); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFQuiesceTrafficActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFQuiesceTrafficActivity_Start", "TaskPreProcessActivity", "TaskQuiesceTraffic") - .hasNotPassed("VNFQuiesceTrafficActivity_End"); + .hasPassedInOrder("VNFQuiesceTrafficActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskQuiesceTraffic", "VNFQuiesceTrafficActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java index 61d88a5770..ae61f3c46e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFResumeTrafficActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFResumeTrafficActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFResumeTrafficActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFResumeTrafficActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskResumeTraffic"); assertThat(pi).isStarted().hasPassedInOrder("VNFResumeTrafficActivity_Start", "TaskPreProcessActivity", "TaskResumeTraffic", "VNFResumeTrafficActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFResumeTrafficActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFResumeTrafficActivity_Test() throws Exception { - variables.put("actionResumeTraffic", Action.ResumeTraffic); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFResumeTrafficActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFResumeTrafficActivity_Start", "TaskPreProcessActivity", "TaskResumeTraffic") - .hasNotPassed("VNFResumeTrafficActivity_End"); + .hasPassedInOrder("VNFResumeTrafficActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskResumeTraffic", "VNFResumeTrafficActivity_End"); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java index 001dc70b54..513afd35e5 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSetClosedLoopDisabledFlagActivityTest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; -import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doThrow; import org.camunda.bpm.engine.delegate.BpmnError; diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java index 6f1e076c02..b883f1cb28 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFSnapShotActivityTest.java @@ -28,27 +28,27 @@ import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFSnapShotActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFSnapShotActivity_Test() throws InterruptedException { + variables.put("vmIdListSize", 0); + variables.put("vmIdList", null); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFSnapShotActivity", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted().hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity", - "TaskSnapShot", "VNFSnapShotActivity_End"); + assertThat(pi).isStarted() + .hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity", "VNFSnapShotActivity_End") + .hasNotPassed("TaskSnapShot"); assertThat(pi).isEnded(); } @Test public void rainyDayVNFSnapShotActivity_Test() throws Exception { - variables.put("actionSnapshot", Action.Snapshot); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFSnapShotActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity", "TaskSnapShot") - .hasNotPassed("VNFSnapShotActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFSnapShotActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskSnapShot", "VNFSnapShotActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java index 2163e0b7a8..0a700c5fa1 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStartActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFStartActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFStartActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStartActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskStart"); assertThat(pi).isStarted().hasPassedInOrder("VNFStartActivity_Start", "TaskPreProcessActivity", "TaskStart", "VNFStartActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFStartActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFStartActivity_Test() throws Exception { - variables.put("actionStart", Action.Start); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStartActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFStartActivity_Start", "TaskPreProcessActivity", "TaskStart") - .hasNotPassed("VNFStartActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFStartActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskStart", "VNFStartActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java index 58dfff8bd7..89cc13f0f0 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFStopActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFStopActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFStopActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStopActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskStop"); assertThat(pi).isStarted().hasPassedInOrder("VNFStopActivity_Start", "TaskPreProcessActivity", "TaskStop", "VNFStopActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFStopActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFStopActivity_Test() throws Exception { - variables.put("actionStop", Action.Stop); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFStopActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFStopActivity_Start", "TaskPreProcessActivity", "TaskStop") - .hasNotPassed("VNFStopActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFStopActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskStop", "VNFStopActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java index c5ddd56880..0dbde4b62c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUnlockActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUnlockActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUnlockActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUnlockActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUnlock"); assertThat(pi).isStarted().hasPassedInOrder("VNFUnlockActivity_Start", "TaskPreProcessActivity", "TaskUnlock", "VNFUnlockActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,11 @@ public class VNFUnlockActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUnlockActivity_Test() throws Exception { - variables.put("actionUnlock", Action.Unlock); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUnlockActivity", variables); - assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUnlockActivity_Start", "TaskPreProcessActivity", "TaskUnlock") - .hasNotPassed("VNFUnlockActivity_End"); + assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFUnlockActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUnlock", "VNFUnlockActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java index 4d99147761..2d4a11c17e 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeBackupActivityTest.java @@ -23,18 +23,20 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradeBackupActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradeBackupActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeBackupActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUpgradeBackup"); assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradeBackupActivity_Start", "TaskPreProcessActivity", "TaskUpgradeBackup", "VNFUpgradeBackupActivity_End"); assertThat(pi).isEnded(); @@ -42,14 +44,12 @@ public class VNFUpgradeBackupActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradeBackupActivity_Test() throws Exception { - variables.put("actionUpgradeBackup", Action.UpgradeBackup); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeBackupActivity", variables); assertThat(pi).isNotNull(); - assertThat(pi).isStarted() - .hasPassedInOrder("VNFUpgradeBackupActivity_Start", "TaskPreProcessActivity", "TaskUpgradeBackup") - .hasNotPassed("VNFUpgradeBackupActivity_End"); + assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradeBackupActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradeBackup", "VNFUpgradeBackupActivity_End"); assertThat(pi).isEnded(); } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java index c87cc44f29..dfb6bc1d9c 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePostCheckActivityTest.java @@ -20,20 +20,22 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradePostCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradePostCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePostCheckActivity", variables); + processExternalTasks(pi, "TaskUpgradePostCheck"); assertThat(pi).isNotNull().isStarted().hasPassedInOrder("VNFUpgradePostCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePostCheck", "VNFUpgradePostCheckActivity_End"); @@ -41,14 +43,12 @@ public class VNFUpgradePostCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradePostCheckActivity_Test() throws Exception { - variables.put("actionUpgradePostCheck", Action.UpgradePostCheck); - - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePostCheckActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUpgradePostCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePostCheck") - .hasNotPassed("VNFUpgradePostCheckActivity_End"); + .hasPassedInOrder("VNFUpgradePostCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradePostCheck", "VNFUpgradePostCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java index 79fc43396d..9854bd8860 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradePreCheckActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradePreCheckActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradePreCheckActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePreCheckActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUpgradePreCheck"); assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradePreCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePreCheck", "VNFUpgradePreCheckActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFUpgradePreCheckActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradePreCheckActivity_Test() throws Exception { - variables.put("actionUpgradePreCheck", Action.UpgradePreCheck); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradePreCheckActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUpgradePreCheckActivity_Start", "TaskPreProcessActivity", "TaskUpgradePreCheck") - .hasNotPassed("VNFUpgradePreCheckActivity_End"); + .hasPassedInOrder("VNFUpgradePreCheckActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradePreCheck", "VNFUpgradePreCheckActivity_End"); } } diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java index b550185702..de999e1074 100644 --- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/VNFUpgradeSoftwareActivityTest.java @@ -20,21 +20,23 @@ package org.onap.so.bpmn.infrastructure.bpmn.subprocess; -import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; +import java.util.List; import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.externaltask.LockedExternalTask; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Test; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.BaseBPMNTest; -import org.onap.appc.client.lcm.model.Action; public class VNFUpgradeSoftwareActivityTest extends BaseBPMNTest { @Test public void sunnyDayVNFUpgradeSoftwareActivity_Test() throws InterruptedException { ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeSoftwareActivity", variables); assertThat(pi).isNotNull(); + processExternalTasks(pi, "TaskUpgradeSoftware"); assertThat(pi).isStarted().hasPassedInOrder("VNFUpgradeSoftwareActivity_Start", "TaskPreProcessActivity", "TaskUpgradeSoftware", "VNFUpgradeSoftwareActivity_End"); assertThat(pi).isEnded(); @@ -42,13 +44,12 @@ public class VNFUpgradeSoftwareActivityTest extends BaseBPMNTest { @Test public void rainyDayVNFUpgradeSoftwareActivity_Test() throws Exception { - variables.put("actionUpgradeSoftware", Action.UpgradeSoftware); - doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcRunTasks) - .runAppcCommand(any(BuildingBlockExecution.class), any(Action.class)); + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(appcOrchestratorPreProcessor) + .buildAppcTaskRequest(any(BuildingBlockExecution.class), any(String.class)); ProcessInstance pi = runtimeService.startProcessInstanceByKey("VNFUpgradeSoftwareActivity", variables); assertThat(pi).isNotNull().isStarted() - .hasPassedInOrder("VNFUpgradeSoftwareActivity_Start", "TaskPreProcessActivity", "TaskUpgradeSoftware") - .hasNotPassed("VNFUpgradeSoftwareActivity_End"); + .hasPassedInOrder("VNFUpgradeSoftwareActivity_Start", "TaskPreProcessActivity") + .hasNotPassed("TaskUpgradeSoftware", "VNFUpgradeSoftwareActivity_End"); } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java deleted file mode 100644 index 9176948288..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegate.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.onap.so.bpmn.infrastructure.pnf.delegate; - -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; -import com.google.common.base.Strings; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.so.bpmn.common.scripts.ExceptionUtil; -import org.springframework.stereotype.Component; - -@Component -public class AssignPnfInputsCheckerDelegate implements JavaDelegate { - - public static final String UUID_REGEX = - "(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[1-5]{1}[0-9a-f]{3}-[89ab]{1}[0-9a-f]{3}-[0-9a-f]{12}$"; - - @Override - public void execute(DelegateExecution execution) { - validatePnfCorrelationId(execution); - validatePnfUuid(execution); - } - - private void validatePnfCorrelationId(DelegateExecution execution) { - String pnfCorrelationId = (String) execution.getVariable(PNF_CORRELATION_ID); - if (Strings.isNullOrEmpty(pnfCorrelationId)) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, - "pnfCorrelationId variable not defined"); - } - } - - private void validatePnfUuid(DelegateExecution execution) { - String pnfUuid = (String) execution.getVariable(PNF_UUID); - if (Strings.isNullOrEmpty(pnfUuid)) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid variable not defined"); - } - if (!pnfUuid.matches(UUID_REGEX)) { - new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, "pnfUuid is not a valid UUID"); - } - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java new file mode 100644 index 0000000000..29914252d8 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationId.java @@ -0,0 +1,45 @@ +package org.onap.so.bpmn.infrastructure.pnf.tasks; + +import joptsimple.internal.Strings; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import java.io.IOException; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; + +@Component +public class CheckAaiForPnfCorrelationId extends PnfBaseTasks { + private static final Logger logger = LoggerFactory.getLogger(CheckAaiForPnfCorrelationId.class); + + @Override + public void execute(BuildingBlockExecution execution) { + try { + String pnfCorrelationId = extractPnf(execution).getPnfName(); + checkIfPnfCorrelationIdPresent(execution, pnfCorrelationId); + checkIfPnfExistsInAai(execution, pnfCorrelationId); + } catch (BBObjectNotFoundException e) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); + } + + } + + private void checkIfPnfCorrelationIdPresent(BuildingBlockExecution execution, String pnfCorrelationId) { + if (Strings.isNullOrEmpty(pnfCorrelationId)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 500, PNF_CORRELATION_ID + " is not set"); + } + } + + private void checkIfPnfExistsInAai(BuildingBlockExecution execution, String pnfCorrelationId) { + try { + boolean isEntry = pnfManagement.getEntryFor(pnfCorrelationId).isPresent(); + logger.debug("AAI entry is found for pnf correlation id {}: {}", PNF_CORRELATION_ID, isEntry); + execution.setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry); + } catch (IOException e) { + logger.error("Exception in check AAI for pnf_correlation_id execution", e); + exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java new file mode 100644 index 0000000000..6e86ad619e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAai.java @@ -0,0 +1,34 @@ +package org.onap.so.bpmn.infrastructure.pnf.tasks; + +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class CreatePnfEntryInAai extends PnfBaseTasks { + private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAai.class); + + @Override + public void execute(BuildingBlockExecution execution) throws Exception { + try { + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = extractPnf(execution); + String pnfCorrelationId = pnf.getPnfName(); + pnfManagement.createEntry(pnfCorrelationId, preparePnfForAai(pnf)); + logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", pnfCorrelationId, + pnf.getPnfId()); + } catch (BBObjectNotFoundException e) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); + } + } + + private Pnf preparePnfForAai(org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf) { + Pnf pnfAai = new Pnf(); + pnfAai.setPnfId(pnf.getPnfId()); + pnfAai.setPnfName(pnf.getPnfName()); + return pnfAai; + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java new file mode 100644 index 0000000000..d8e3379afb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfBaseTasks.java @@ -0,0 +1,29 @@ +package org.onap.so.bpmn.infrastructure.pnf.tasks; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.springframework.beans.factory.annotation.Autowired; + +public abstract class PnfBaseTasks { + protected PnfManagement pnfManagement; + @Autowired + protected ExceptionBuilder exceptionUtil; + @Autowired + protected ExtractPojosForBB extractPojosForBB; + + @Autowired + public void setPnfManagement(PnfManagement pnfManagement) { + this.pnfManagement = pnfManagement; + } + + public abstract void execute(BuildingBlockExecution execution) throws Exception; + + protected Pnf extractPnf(BuildingBlockExecution execution) throws BBObjectNotFoundException { + return extractPojosForBB.extractByKey(execution, ResourceKey.PNF); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java deleted file mode 100644 index 58e58464e1..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.bpmn.infrastructure; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@Configuration -@EnableWebSecurity -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Bean - @Profile("test") - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", - "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and().httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - - }; - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java deleted file mode 100644 index a562da490b..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AssignPnfInputsCheckerDelegateTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.onap.so.bpmn.infrastructure.pnf.delegate; - -import org.apache.commons.lang3.StringUtils; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.junit.Before; -import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.DelegateExecutionBuilder; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.RESERVED_UUID; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfInputCheckersTestUtils.VALID_UUID; - -public class AssignPnfInputsCheckerDelegateTest { - - private DelegateExecutionBuilder delegateExecutionBuilder; - private AssignPnfInputsCheckerDelegate testedObject; - private DelegateExecution execution; - - @Before - public void setUp() { - testedObject = new AssignPnfInputsCheckerDelegate(); - delegateExecutionBuilder = new DelegateExecutionBuilder(); - } - - @Test - public void shouldThrowException_whenPnfCorrelationIdNotSet() { - execution = delegateExecutionBuilder.setPnfCorrelationId(null).setPnfUuid(VALID_UUID).build(); - assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class); - } - - @Test - public void shouldThrowException_whenPnfUuidIsNotSet() { - execution = delegateExecutionBuilder.setPnfUuid(null).build(); - assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class); - } - - @Test - public void shouldThrowException_whenPnfUuidIsEmptyString() { - execution = delegateExecutionBuilder.setPnfUuid(StringUtils.EMPTY).build(); - assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class); - } - - @Test - public void shouldThrowException_whenPnfUuidIsReservedUuid() { - execution = delegateExecutionBuilder.setPnfUuid(RESERVED_UUID).build(); - assertThatSutExecutionThrowsExceptionOfInstance(BpmnError.class); - } - - private void assertThatSutExecutionThrowsExceptionOfInstance(Class<?> type) { - assertThatThrownBy(() -> testedObject.execute(execution)).isInstanceOf(type); - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java deleted file mode 100644 index c1c7f06d4e..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfInputCheckersTestUtils.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.onap.so.bpmn.infrastructure.pnf.delegate; - -import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.*; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; -import java.util.UUID; - - -public class PnfInputCheckersTestUtils { - - static final String PNF_ENTRY_NOTIFICATION_TIMEOUT = "P1D"; - static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); - static final String RESERVED_UUID = new UUID(0, 0).toString(); - private static final String DEFAULT_SERVICE_INSTANCE_ID = "da7d07d9-b71c-4128-809d-2ec01c807169"; - private static final String DEFAULT_PNF_CORRELATION_ID = "testPnfCorrelationId"; - - static class DelegateExecutionBuilder { - private String pnfCorrelationId = DEFAULT_PNF_CORRELATION_ID; - private String pnfUuid = VALID_UUID; - private String serviceInstanceId = DEFAULT_SERVICE_INSTANCE_ID; - - public DelegateExecutionBuilder setPnfCorrelationId(String pnfCorrelationId) { - this.pnfCorrelationId = pnfCorrelationId; - return this; - } - - public DelegateExecutionBuilder setPnfUuid(String pnfUuid) { - this.pnfUuid = pnfUuid; - return this; - } - - public DelegateExecutionBuilder setServiceInstanceId(String serviceInstanceId) { - this.serviceInstanceId = serviceInstanceId; - return this; - } - - public DelegateExecution build() { - DelegateExecution execution = new DelegateExecutionFake(); - execution.setVariable("testProcessKey", "testProcessKeyValue"); - execution.setVariable(PNF_CORRELATION_ID, this.pnfCorrelationId); - execution.setVariable(PNF_UUID, this.pnfUuid); - execution.setVariable(SERVICE_INSTANCE_ID, this.serviceInstanceId); - return execution; - } - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java new file mode 100644 index 0000000000..3fa9fbf3b5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CheckAaiForPnfCorrelationIdTest.java @@ -0,0 +1,129 @@ +package org.onap.so.bpmn.infrastructure.pnf.tasks; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.runners.Enclosed; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl; +import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementThrowingException; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.ExceptionBuilder; +import java.io.IOException; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITHOUT_ENTRY; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY; +import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf; + +@RunWith(Enclosed.class) +public class CheckAaiForPnfCorrelationIdTest { + + @RunWith(MockitoJUnitRunner.class) + public static class ConnectionOkTests { + + @Mock + private ExtractPojosForBB extractPojosForBB; + @Mock + private ExceptionBuilder exceptionUtil; + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @InjectMocks + private CheckAaiForPnfCorrelationId task = new CheckAaiForPnfCorrelationId(); + private PnfManagement pnfManagementTest = new PnfManagementTestImpl(); + + @Before + public void setUp() { + task.setPnfManagement(pnfManagementTest); + } + + @Test + public void shouldThrowExceptionWhenPnfCorrelationIdIsNotSet() throws Exception { + // given + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))).thenReturn(preparePnf(null, PNF_UUID)); + BuildingBlockExecution execution = mock(BuildingBlockExecution.class); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(eq(execution), + anyInt(), anyString()); + // when, then + expectedException.expect(BpmnError.class); + task.execute(execution); + verify(exceptionUtil).buildAndThrowWorkflowException(eq(execution), anyInt(), anyString()); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiDoesNotContainInfoAboutPnf() throws Exception { + // given + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))) + .thenReturn(preparePnf(ID_WITHOUT_ENTRY, PNF_UUID)); + BuildingBlockExecution execution = mock(BuildingBlockExecution.class); + // when + task.execute(execution); + // then + verify(execution).setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, false); + } + + @Test + public void shouldSetCorrectVariablesWhenAaiContainsInfoAboutPnfWithoutIp() throws Exception { + // given + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))) + .thenReturn(preparePnf(ID_WITH_ENTRY, PNF_UUID)); + BuildingBlockExecution execution = mock(BuildingBlockExecution.class); + // when + task.execute(execution); + // then + verify(execution).setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, true); + } + } + + @RunWith(MockitoJUnitRunner.class) + public static class NoConnectionTests { + + @Mock + private ExtractPojosForBB extractPojosForBB; + @Mock + private ExceptionBuilder exceptionUtil; + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @InjectMocks + private CheckAaiForPnfCorrelationId task = new CheckAaiForPnfCorrelationId(); + private PnfManagement pnfManagementTest = new PnfManagementThrowingException(); + + @Before + public void setUp() throws Exception { + task.setPnfManagement(pnfManagementTest); + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))) + .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID)); + } + + @Test + public void shouldThrowExceptionWhenIoExceptionOnConnectionToAai() { + // given + BuildingBlockExecution execution = mock(BuildingBlockExecution.class); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(eq(execution), + anyInt(), any(IOException.class)); + // when, then + expectedException.expect(BpmnError.class); + task.execute(execution); + verify(exceptionUtil).buildAndThrowWorkflowException(eq(execution), anyInt(), any(IOException.class)); + } + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java new file mode 100644 index 0000000000..ed8dd82efb --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/CreatePnfEntryInAaiTest.java @@ -0,0 +1,50 @@ +package org.onap.so.bpmn.infrastructure.pnf.tasks; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_CORRELATION_ID; +import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.PNF_UUID; +import static org.onap.so.bpmn.infrastructure.pnf.tasks.PnfTasksUtils.preparePnf; + +@RunWith(MockitoJUnitRunner.class) +public class CreatePnfEntryInAaiTest { + + @Mock + private ExtractPojosForBB extractPojosForBB; + @InjectMocks + private CreatePnfEntryInAai task = new CreatePnfEntryInAai(); + private PnfManagementTestImpl pnfManagementTest = new PnfManagementTestImpl(); + + @Before + public void setUp() throws Exception { + task.setPnfManagement(pnfManagementTest); + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.PNF))) + .thenReturn(preparePnf(PNF_CORRELATION_ID, PNF_UUID)); + } + + @Test + public void shouldSetPnfIdAndPnfName() throws Exception { + // when + task.execute(mock(BuildingBlockExecution.class)); + // then + Pnf createdEntry = pnfManagementTest.getCreated().get(PNF_CORRELATION_ID); + assertThat(createdEntry.getPnfId()).isEqualTo(PNF_UUID); + assertThat(createdEntry.getPnfName()).isEqualTo(PNF_CORRELATION_ID); + assertThat(createdEntry.isInMaint()).isNull(); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java new file mode 100644 index 0000000000..49fe96c3d9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/tasks/PnfTasksUtils.java @@ -0,0 +1,17 @@ +package org.onap.so.bpmn.infrastructure.pnf.tasks; + +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; +import java.util.UUID; + +public class PnfTasksUtils { + static final String PNF_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); + static final String PNF_CORRELATION_ID = "testPnfCorrelationId"; + + public static Pnf preparePnf(String pnfName, String pnfUuid) { + Pnf pnf = new Pnf(); + pnf.setPnfName(pnfName); + pnf.setPnfId(pnfUuid); + return pnf; + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java index 1add5e6d24..997d20036f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java @@ -35,6 +35,8 @@ import org.springframework.stereotype.Component; @Component public class AAIFlagTasks { + private static final Logger logger = LoggerFactory.getLogger(AAIFlagTasks.class); + @Autowired private AAIVnfResources aaiVnfResources; @@ -107,7 +109,7 @@ public class AAIFlagTasks { String vnfId = vnf.getVnfId(); inPserversLocked = aaiVnfResources.checkVnfPserversLockedFlag(vnfId); } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + logger.warn("Exception on checking pservers: " + ex.getMessage()); } if (inPserversLocked) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF PServers in Locked in A&AI"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java new file mode 100644 index 0000000000..4b967c7bc4 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -0,0 +1,189 @@ +package org.onap.so.bpmn.infrastructure.appc.tasks; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.onap.aai.domain.yang.Vserver; +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVm; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.Relationships; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.AAIVnfResources; +import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class AppcOrchestratorPreProcessor { + private static final Logger logger = LoggerFactory.getLogger(AppcOrchestratorPreProcessor.class); + public static final String CONTROLLER_TYPE_DEFAULT = "APPC"; + + @Autowired + private ExceptionBuilder exceptionUtil; + @Autowired + private ExtractPojosForBB extractPojosForBB; + @Autowired + private CatalogDbClient catalogDbClient; + @Autowired + private AAIVnfResources aaiVnfResources; + + public void buildAppcTaskRequest(BuildingBlockExecution execution, String actionName) { + try { + Action action = Action.valueOf(actionName); + ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest(); + appcTaskRequest.setAction(action); + GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + GenericVnf vnf = null; + try { + vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); + } catch (BBObjectNotFoundException e) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "No valid VNF exists"); + } + String vnfId = null; + String vnfName = null; + String vnfType = null; + String vnfHostIpAddress = null; + + if (vnf != null) { + vnfId = vnf.getVnfId(); + vnfName = vnf.getVnfName(); + vnfType = vnf.getVnfType(); + vnfHostIpAddress = vnf.getIpv4OamAddress(); + } + String msoRequestId = gBBInput.getRequestContext().getMsoRequestId(); + + String aicIdentity = execution.getVariable("aicIdentity"); + String identityUrl = execution.getVariable("identityUrl"); + appcTaskRequest.setIdentityUrl(identityUrl); + + if (gBBInput.getRequestContext().getRequestParameters() != null) { + String payload = gBBInput.getRequestContext().getRequestParameters().getPayload(); + if (payload == null) { + payload = ""; + } + String existingSoftwareVersion = JsonUtils.getJsonValue(payload, "existing-software-version"); + appcTaskRequest.setExistingSoftwareVersion(existingSoftwareVersion); + String newSoftwareVersion = JsonUtils.getJsonValue(payload, "new-software-version"); + appcTaskRequest.setNewSoftwareVersion(newSoftwareVersion); + String operationsTimeout = JsonUtils.getJsonValue(payload, "operations-timeout"); + appcTaskRequest.setOperationsTimeout(operationsTimeout); + } + + ControllerSelectionReference controllerSelectionReference = catalogDbClient + .getControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, action.toString()); + String controllerType = null; + if (controllerSelectionReference != null) { + controllerType = controllerSelectionReference.getControllerName(); + } else { + controllerType = CONTROLLER_TYPE_DEFAULT; + } + appcTaskRequest.setControllerType(controllerType); + + execution.setVariable("vmIdList", null); + execution.setVariable("vserverIdList", null); + execution.setVariable("vmIndex", 0); + execution.setVariable("vmIdListSize", 0); + + String vfModuleId = null; + VfModule vfModule = null; + try { + vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + } catch (BBObjectNotFoundException e) { + } + if (vfModule != null) { + vfModuleId = vfModule.getVfModuleId(); + } + if (action.equals(Action.Snapshot)) { + try { + getVserversForAppc(execution, vnf); + } catch (Exception e) { + logger.warn("Unable to retrieve vservers for vnf: " + vnfId); + } + } + + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + applicationControllerVnf.setVnfHostIpAddress(vnfHostIpAddress); + applicationControllerVnf.setVnfId(vnfId); + applicationControllerVnf.setVnfName(vnfName); + appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + } catch (Exception e) { + logger.error("Error building ApplicationControllerTaskRequest Object", e); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); + } + } + + public void addVmInfoToAppcTaskRequest(BuildingBlockExecution execution) { + try { + ApplicationControllerTaskRequest appcTaskRequest = + (ApplicationControllerTaskRequest) execution.getVariable("appcOrchestratorRequest"); + ArrayList<String> vmIdList = execution.getVariable("vmIdList"); + ArrayList<String> vserverIdList = execution.getVariable("vserverIdList"); + Integer vmIndex = (Integer) execution.getVariable("vmIndex"); + + if (vmIdList != null && !vmIdList.isEmpty() && vserverIdList != null && !vserverIdList.isEmpty()) { + execution.setVariable("vmIdListSize", vmIdList.size()); + if (vmIndex < vmIdList.size()) { + ApplicationControllerVm applicationControllerVm = new ApplicationControllerVm(); + applicationControllerVm.setVmId(vmIdList.get(vmIndex)); + applicationControllerVm.setVserverId(vserverIdList.get(vmIndex)); + if (appcTaskRequest.getApplicationControllerVnf() == null) { + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + } + appcTaskRequest.getApplicationControllerVnf().setApplicationControllerVm(applicationControllerVm); + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + vmIndex++; + execution.setVariable("vmIndex", vmIndex); + } + } + } catch (Exception e) { + logger.error("Error adding VM info to ApplicationControllerTaskRequest Object", e); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); + } + } + + protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception { + AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); + + if (aaiRW != null && aaiRW.getRelationships().isPresent()) { + Relationships relationships = aaiRW.getRelationships().get(); + if (relationships != null) { + List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER); + ArrayList<String> vserverIds = new ArrayList<String>(); + ArrayList<String> vserverSelfLinks = new ArrayList<String>(); + for (AAIResourceUri j : vserverUris) { + String vserverId = j.getURIKeys().get("vserver-id"); + vserverIds.add(vserverId); + Optional<Vserver> oVserver = aaiVnfResources.getVserver(j); + if (oVserver.isPresent()) { + Vserver vserver = oVserver.get(); + String vserverSelfLink = vserver.getVserverSelflink(); + vserverSelfLinks.add(vserverSelfLink); + } + } + logger.debug("vmIdsArray is: {}", vserverSelfLinks); + logger.debug("vserverIdsArray is: {}", vserverIds); + execution.setVariable("vmIdList", vserverSelfLinks); + execution.setVariable("vserverIdList", vserverIds); + } + } + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 99ba35232c..356fe8d9a2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -1555,7 +1555,7 @@ public class WorkflowAction { if (flows == null) flows = new ArrayList<>(); for (OrchestrationFlow flow : flows) { - if (!flow.getFlowName().contains("BB")) { + if (!flow.getFlowName().contains("BB") && !flow.getFlowName().contains("Activity")) { List<OrchestrationFlow> macroQueryFlows = catalogDbClient.getOrchestrationFlowByAction(flow.getFlowName()); for (OrchestrationFlow macroFlow : macroQueryFlows) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 39aa9d6c41..9d45272a60 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -23,10 +23,17 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.UUID; import javax.persistence.EntityNotFoundException; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.InstanceGroup; +import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.Vnfc; +import org.onap.aai.domain.yang.VolumeGroup; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; @@ -357,6 +364,8 @@ public class WorkflowActionBBTasks { } else if (resourceType == WorkflowType.INSTANCE_GROUP) { request.setInstanceGroupId(resourceId); } + setInstanceName(resourceId, resourceType, request); + request.setLastModifiedBy("CamundaBPMN"); requestDbclient.updateInfraActiveRequests(request); } catch (Exception ex) { logger.error("Exception in updateInstanceId", ex); @@ -461,4 +470,50 @@ public class WorkflowActionBBTasks { configBB.setConfigurationResourceKeys(configurationResourceKeys); return configBB; } + + protected void setInstanceName(String resourceId, WorkflowType resourceType, InfraActiveRequests request) { + logger.debug("Setting instanceName in infraActiveRequest"); + try { + if (resourceType == WorkflowType.SERVICE && request.getServiceInstanceName() == null) { + ServiceInstance service = bbInputSetupUtils.getAAIServiceInstanceById(resourceId); + if (service != null) { + request.setServiceInstanceName(service.getServiceInstanceName()); + } + } else if (resourceType == WorkflowType.VNF && request.getVnfName() == null) { + GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(resourceId); + if (vnf != null) { + request.setVnfName(vnf.getVnfName()); + } + } else if (resourceType == WorkflowType.VFMODULE && request.getVfModuleName() == null) { + VfModule vfModule = bbInputSetupUtils.getAAIVfModule(request.getVnfId(), resourceId); + if (vfModule != null) { + request.setVfModuleName(vfModule.getVfModuleName()); + } + } else if (resourceType == WorkflowType.VOLUMEGROUP && request.getVolumeGroupName() == null) { + Optional<VolumeGroup> volumeGroup = + bbInputSetupUtils.getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId); + if (volumeGroup.isPresent()) { + request.setVolumeGroupName(volumeGroup.get().getVolumeGroupName()); + } + } else if (resourceType == WorkflowType.NETWORK && request.getNetworkName() == null) { + L3Network network = bbInputSetupUtils.getAAIL3Network(resourceId); + if (network != null) { + request.setNetworkName(network.getNetworkName()); + } + } else if (resourceType == WorkflowType.CONFIGURATION && request.getConfigurationName() == null) { + org.onap.aai.domain.yang.Configuration configuration = + bbInputSetupUtils.getAAIConfiguration(resourceId); + if (configuration != null) { + request.setConfigurationName(configuration.getConfigurationName()); + } + } else if (resourceType == WorkflowType.INSTANCE_GROUP && request.getInstanceGroupName() == null) { + InstanceGroup instanceGroup = bbInputSetupUtils.getAAIInstanceGroup(resourceId); + if (instanceGroup != null) { + request.setInstanceGroupName(instanceGroup.getInstanceGroupName()); + } + } + } catch (Exception ex) { + logger.error("Exception in setInstanceName", ex); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java index 9857adbd09..bc618e17de 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java @@ -879,6 +879,10 @@ public class VnfAdapterVfModuleObjectMapper { deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId()); deleteVfModuleRequest.setVnfId(genericVnf.getVnfId()); deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId()); + if (vfModule.getModelInfoVfModule() != null) { + deleteVfModuleRequest + .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID()); + } if (!StringUtils.isEmpty(vfModule.getHeatStackId())) { deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());// DoDVfMod_heatStackId } else { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java new file mode 100644 index 0000000000..c78b652bd0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -0,0 +1,166 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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.bpmn.infrastructure.appc.tasks; + +import static com.shazam.shazamcrest.MatcherAssert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Optional; +import org.junit.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.onap.aai.domain.yang.Vserver; +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.client.policy.JettisonStyleMapperProvider; +import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { + + private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/"; + + @InjectMocks + private AppcOrchestratorPreProcessor appcOrchestratorPreProcessor = new AppcOrchestratorPreProcessor(); + + private ObjectMapper mapper = new JettisonStyleMapperProvider().getMapper(); + + @Test + public void buildAppcTaskRequestTest() throws Exception { + final String expectedRequestJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "appcTaskRequest.json"))); + ApplicationControllerTaskRequest expectedTaskRequest = + mapper.readValue(expectedRequestJson, ApplicationControllerTaskRequest.class); + execution.getLookupMap().put(ResourceKey.GENERIC_VNF_ID, "-TEST"); + fillRequiredAppcExecutionFields(); + GenericVnf genericVnf = getTestGenericVnf(); + when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(genericVnf); + mockReferenceResponse(); + execution.getLookupMap().put(ResourceKey.VF_MODULE_ID, "VF-MODULE-ID-TEST"); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("VF-MODULE-ID"); + when(extractPojosForBB.extractByKey(eq(execution), eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule); + appcOrchestratorPreProcessor.buildAppcTaskRequest(execution, "Lock"); + ApplicationControllerTaskRequest actualTaskRequest = execution.getVariable("appcOrchestratorRequest"); + assertThat(actualTaskRequest, sameBeanAs(expectedTaskRequest)); + } + + @Test + public void getVserversForAppcTest() throws Exception { + + GenericVnf genericVnf = getTestGenericVnf(); + + final String aaiVnfJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiGenericVnfWithVservers.json"))); + final String aaiVserverJson = + new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVserverQueryResponse.json"))); + AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(aaiVnfJson); + ObjectMapper mapper = new ObjectMapper(); + Vserver vserver = mapper.readValue(aaiVserverJson, Vserver.class); + doReturn(aaiResultWrapper).when(aaiVnfResources).queryVnfWrapperById(genericVnf); + doReturn(Optional.of(vserver)).when(aaiVnfResources).getVserver(ArgumentMatchers.any(AAIResourceUri.class)); + appcOrchestratorPreProcessor.getVserversForAppc(execution, genericVnf); + ArrayList<String> vserverIdList = execution.getVariable("vserverIdList"); + ArrayList<String> expectedVserverIdList = new ArrayList<String>(); + expectedVserverIdList.add("1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5"); + expectedVserverIdList.add("14551849-1e70-45cd-bc5d-a256d49548a2"); + expectedVserverIdList.add("48bd7f11-408f-417c-b834-b41c1b98f7d7"); + ArrayList<String> vmIdList = execution.getVariable("vmIdList"); + ArrayList<String> expectedVmIdList = new ArrayList<String>(); + expectedVmIdList.add("http://VSERVER-link.com"); + expectedVmIdList.add("http://VSERVER-link.com"); + expectedVmIdList.add("http://VSERVER-link.com"); + assertEquals(vserverIdList, expectedVserverIdList); + assertEquals(vmIdList, expectedVmIdList); + } + + @Test + public void addVmInfoToAppcTaskRequestTest() throws Exception { + ApplicationControllerTaskRequest appcTaskRequest = new ApplicationControllerTaskRequest(); + ApplicationControllerVnf applicationControllerVnf = new ApplicationControllerVnf(); + appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + ArrayList<String> vmIdList = new ArrayList<String>(); + vmIdList.add("http://VSERVER-link.com"); + vmIdList.add("http://VSERVER-link.com"); + vmIdList.add("http://VSERVER-link.com"); + execution.setVariable("vmIdList", vmIdList); + ArrayList<String> vserverIdList = new ArrayList<String>(); + vserverIdList.add("1b3f44e5-d96d-4aac-bd9a-310e8cfb0af5"); + vserverIdList.add("14551849-1e70-45cd-bc5d-a256d49548a2"); + vserverIdList.add("48bd7f11-408f-417c-b834-b41c1b98f7d7"); + execution.setVariable("vserverIdList", vserverIdList); + execution.setVariable("vmIndex", 1); + appcOrchestratorPreProcessor.addVmInfoToAppcTaskRequest(execution); + Integer nextVmIndex = execution.getVariable("vmIndex"); + assertThat(nextVmIndex == 2); + Integer vmIdListSize = execution.getVariable("vmIdListSize"); + assertThat(vmIdListSize == 3); + appcTaskRequest = execution.getVariable("appcOrchestratorRequest"); + assertEquals(appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVserverId(), + "14551849-1e70-45cd-bc5d-a256d49548a2"); + assertEquals(appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVmId(), + "http://VSERVER-link.com"); + } + + private void mockReferenceResponse() { + ControllerSelectionReference reference = new ControllerSelectionReference(); + reference.setControllerName("TEST-CONTROLLER-NAME"); + when(catalogDbClient.getControllerSelectionReferenceByVnfTypeAndActionCategory(eq("TEST-VNF-TYPE"), + eq(Action.Lock.toString()))).thenReturn(reference); + } + + private void fillRequiredAppcExecutionFields() { + RequestContext context = new RequestContext(); + context.setMsoRequestId("TEST-MSO-ID"); + execution.setVariable("aicIdentity", "AIC-TEST"); + execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); + execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); + execution.setVariable("identityUrl", "IDENTITY-URL-TEST"); + execution.getGeneralBuildingBlock().setRequestContext(context); + } + + private GenericVnf getTestGenericVnf() { + GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId("TEST-VNF-ID"); + genericVnf.setVnfType("TEST-VNF-TYPE"); + genericVnf.setVnfName("TEST-VNF-NAME"); + genericVnf.setIpv4OamAddress("127.0.0.1"); + return genericVnf; + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index ac7d82cd51..4991fa59ee 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -21,14 +21,18 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; @@ -40,17 +44,25 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.Spy; +import org.onap.aai.domain.yang.Configuration; import org.onap.aai.domain.yang.GenericVnf; +import org.onap.aai.domain.yang.InstanceGroup; +import org.onap.aai.domain.yang.L3Network; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.VolumeGroup; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; import org.springframework.core.env.Environment; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -479,5 +491,98 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { assertEquals(workflowActionBBTasks.getConfigurationId(vnfc), "configurationId"); } + @Test + public void setServiceInstanceNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.SERVICE; + InfraActiveRequests request = new InfraActiveRequests(); + ServiceInstance service = new ServiceInstance(); + service.setServiceInstanceName("serviceInstanceName"); + doReturn(service).when(bbSetupUtils).getAAIServiceInstanceById(resourceId); + + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + assertEquals("serviceInstanceName", request.getServiceInstanceName()); + } + + @Test + public void setVnfNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.VNF; + InfraActiveRequests request = new InfraActiveRequests(); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfName("vnfName"); + doReturn(vnf).when(bbSetupUtils).getAAIGenericVnf(resourceId); + + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + assertEquals("vnfName", request.getVnfName()); + } + @Test + public void setVfModuleNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.VFMODULE; + InfraActiveRequests request = new InfraActiveRequests(); + request.setVnfId("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e"); + VfModule vfModule = new VfModule(); + vfModule.setVfModuleName("vfModuleName"); + doReturn(vfModule).when(bbSetupUtils).getAAIVfModule("ae5cc3e8-c13c-4d88-aaf6-694ab4977b0e", resourceId); + + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + assertEquals("vfModuleName", request.getVfModuleName()); + } + + @Test + public void setNetworkNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.NETWORK; + InfraActiveRequests request = new InfraActiveRequests(); + L3Network network = new L3Network(); + network.setNetworkName("networkName"); + doReturn(network).when(bbSetupUtils).getAAIL3Network(resourceId); + + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + assertEquals("networkName", request.getNetworkName()); + } + + @Test + public void setConfigurationNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.CONFIGURATION; + InfraActiveRequests request = new InfraActiveRequests(); + Configuration configuration = new Configuration(); + configuration.setConfigurationName("configurationName"); + doReturn(configuration).when(bbSetupUtils).getAAIConfiguration(resourceId); + + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + assertEquals("configurationName", request.getConfigurationName()); + } + + @Test + public void setInstanceGroupNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.INSTANCE_GROUP; + InfraActiveRequests request = new InfraActiveRequests(); + InstanceGroup instanceGroup = new InstanceGroup(); + instanceGroup.setInstanceGroupName("instanceGroupName"); + doReturn(instanceGroup).when(bbSetupUtils).getAAIInstanceGroup(resourceId); + + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + assertEquals("instanceGroupName", request.getInstanceGroupName()); + } + + @Test + public void setVolumeGroupNameTest() { + String resourceId = "40bc4ebd-11df-4610-8055-059f7441ec1c"; + WorkflowType resourceType = WorkflowType.VOLUMEGROUP; + InfraActiveRequests request = new InfraActiveRequests(); + request.setVnfId("4aa72c90-21eb-4465-8847-997e27af6c3e"); + VolumeGroup volumeGroup = new VolumeGroup(); + volumeGroup.setVolumeGroupName("volumeGroupName"); + Optional<VolumeGroup> returnVolumeGroup = Optional.of(volumeGroup); + + doReturn(returnVolumeGroup).when(bbSetupUtils).getRelatedVolumeGroupByIdFromVnf(request.getVnfId(), resourceId); + workflowActionBBTasks.setInstanceName(resourceId, resourceType, request); + + assertEquals("volumeGroupName", request.getVolumeGroupName()); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json index 1d2e7d090f..9a3922650f 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json @@ -1,12 +1,13 @@ -{ +{ "cloudSiteId" : "cloudRegionId", - "tenantId" : "tenantId", + "tenantId" : "tenantId", "vnfId" : "vnfId", "vfModuleId" : "vfModuleId", "vfModuleStackId" : "vfModuleName", "skipAAI" : true, + "modelCustomizationUuid": "vfModuleModelCustomizationUuid", "msoRequest" : { "requestId" : "requestId", - "serviceInstanceId" : "serviceInstanceId" + "serviceInstanceId" : "serviceInstanceId" } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json new file mode 100644 index 0000000000..957c603dc9 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json @@ -0,0 +1,12 @@ +{ + "ApplicationControllerTaskRequest": { + "controllerType": "TEST-CONTROLLER-NAME", + "action": "Lock", + "identityUrl": "IDENTITY-URL-TEST", + "applicationControllerVnf": { + "vnfId": "TEST-VNF-ID", + "vnfName": "TEST-VNF-NAME", + "vnfHostIpAddress": "127.0.0.1" + } + } +}
\ No newline at end of file diff --git a/common/pom.xml b/common/pom.xml index 94b28e91bd..cdd5df950a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -16,6 +16,7 @@ <protobuf.version>3.6.1</protobuf.version> <grpc.netty.version>4.1.30.Final</grpc.netty.version> <ccsdk.version>0.4.2</ccsdk.version> + <appc.client.version>1.6.0-SNAPSHOT</appc.client.version> </properties> <dependencies> @@ -202,6 +203,66 @@ <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-lib</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.onap.appc.client</groupId> + <artifactId>client-kit</artifactId> + <version>${appc.client.version}</version> + <exclusions> + <exclusion> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> <dependencyManagement> <dependencies> diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java new file mode 100644 index 0000000000..3811b52551 --- /dev/null +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java @@ -0,0 +1,104 @@ +package org.onap.so.appc.orchestrator.service.beans; + +import java.io.Serializable; +import org.onap.appc.client.lcm.model.Action; +import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerVnf; + +public class ApplicationControllerTaskRequest implements Serializable { + + private static final long serialVersionUID = -3150320542857627682L; + + private Action action; + private String controllerType; + private String identityUrl; + private String operationsTimeout; + private String bookName; + private String nodeList; + private String fileParameters; + private String existingSoftwareVersion; + private String newSoftwareVersion; + private ApplicationControllerVnf applicationControllerVnf; + + public Action getAction() { + return action; + } + + public void setAction(Action action) { + this.action = action; + } + + public String getControllerType() { + return controllerType; + } + + public void setControllerType(String controllerType) { + this.controllerType = controllerType; + } + + public ApplicationControllerVnf getApplicationControllerVnf() { + return applicationControllerVnf; + } + + public void setApplicationControllerVnf(ApplicationControllerVnf applicationControllerVnf) { + this.applicationControllerVnf = applicationControllerVnf; + } + + public String getIdentityUrl() { + return identityUrl; + } + + public void setIdentityUrl(String identityUrl) { + this.identityUrl = identityUrl; + } + + public String getOperationsTimeout() { + return operationsTimeout; + } + + public void setOperationsTimeout(String operationsTimeout) { + this.operationsTimeout = operationsTimeout; + } + + public String getBookName() { + return bookName; + } + + public void setBookName(String bookName) { + this.bookName = bookName; + } + + public String getNodeList() { + return nodeList; + } + + public void setNodeList(String nodeList) { + this.nodeList = nodeList; + } + + public String getFileParameters() { + return fileParameters; + } + + public void setFileParameters(String fileParameters) { + this.fileParameters = fileParameters; + } + + public String getExistingSoftwareVersion() { + return existingSoftwareVersion; + } + + public void setExistingSoftwareVersion(String existingSoftwareVersion) { + this.existingSoftwareVersion = existingSoftwareVersion; + } + + public String getNewSoftwareVersion() { + return newSoftwareVersion; + } + + public void setNewSoftwareVersion(String newSoftwareVersion) { + this.newSoftwareVersion = newSoftwareVersion; + } + + + +} diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVm.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVm.java new file mode 100644 index 0000000000..75e2053077 --- /dev/null +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVm.java @@ -0,0 +1,30 @@ +package org.onap.so.appc.orchestrator.service.beans; + +import java.io.Serializable; +import java.util.List; + +public class ApplicationControllerVm implements Serializable { + + private static final long serialVersionUID = 2786675508024214638L; + + private String vserverId; + private String vmId; + + public String getVserverId() { + return vserverId; + } + + public void setVserverId(String vserverId) { + this.vserverId = vserverId; + } + + public String getVmId() { + return vmId; + } + + public void setVmId(String vmId) { + this.vmId = vmId; + } + + +} diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVnf.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVnf.java new file mode 100644 index 0000000000..526941dc39 --- /dev/null +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerVnf.java @@ -0,0 +1,49 @@ +package org.onap.so.appc.orchestrator.service.beans; + +import java.io.Serializable; +import java.util.List; + +public class ApplicationControllerVnf implements Serializable { + + private static final long serialVersionUID = 2786675508024214637L; + + private String vnfId; + private String vnfName; + private String vnfHostIpAddress; + private ApplicationControllerVm applicationControllerVm; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + public String getVnfName() { + return vnfName; + } + + public void setVnfName(String vnfName) { + this.vnfName = vnfName; + } + + public String getVnfHostIpAddress() { + return vnfHostIpAddress; + } + + public void setVnfHostIpAddress(String vnfHostIpAddress) { + this.vnfHostIpAddress = vnfHostIpAddress; + } + + public ApplicationControllerVm getApplicationControllerVm() { + return applicationControllerVm; + } + + public void setApplicationControllerVm(ApplicationControllerVm applicationControllerVm) { + this.applicationControllerVm = applicationControllerVm; + } + + + +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/SecurityFilters.java b/common/src/main/java/org/onap/so/security/SecurityFilters.java index 29c9d8f952..7ad0fd05df 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/SecurityFilters.java +++ b/common/src/main/java/org/onap/so/security/SecurityFilters.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.asdc; +package org.onap.so.security; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; diff --git a/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java b/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java new file mode 100644 index 0000000000..c778dde9af --- /dev/null +++ b/common/src/main/java/org/onap/so/security/SoBasicWebSecurityConfigurerAdapter.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.security; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.firewall.StrictHttpFirewall; +import org.springframework.util.StringUtils; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@EnableWebSecurity +@Configuration +@Order(1) +@Profile({"basic"}) +public class SoBasicWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { + + @Autowired + private SoUserCredentialConfiguration soUserCredentialConfiguration; + + @Override + protected void configure(final HttpSecurity http) throws Exception { + http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() + .antMatchers("/**") + .hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ",")) + .and().httpBasic(); + } + + @Override + public void configure(final WebSecurity web) throws Exception { + super.configure(web); + final StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } + + @Override + protected void configure(final AuthenticationManagerBuilder auth) throws Exception { + auth.userDetailsService(soUserCredentialConfiguration.userDetailsService()) + .passwordEncoder(soUserCredentialConfiguration.passwordEncoder()); + } + +} diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/SoCadiFilter.java b/common/src/main/java/org/onap/so/security/SoCadiFilter.java index 52144e264e..2763d6ee15 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/SoCadiFilter.java +++ b/common/src/main/java/org/onap/so/security/SoCadiFilter.java @@ -20,7 +20,7 @@ * =================================================================== * */ -package org.onap.so.asdc; +package org.onap.so.security; import javax.servlet.FilterConfig; import javax.servlet.ServletException; @@ -38,9 +38,6 @@ public class SoCadiFilter extends CadiFilter { protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") private String cadiLoglevel; @@ -83,6 +80,9 @@ public class SoCadiFilter extends CadiFilter { @Value("${mso.config.cadi.apiEnforcement:#{null}}") private String apiEnforcement; + @Value("${mso.config.cadi.userExpires:#{null}}") + private String userExpires; + private void checkIfNullProperty(String key, String value) { /* * When value is null, it is not defined in application.yaml set nothing in System properties @@ -108,6 +108,7 @@ public class SoCadiFilter extends CadiFilter { checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); checkIfNullProperty(Config.AAF_URL, aafUrl); checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); + checkIfNullProperty(Config.AAF_USER_EXPIRES, userExpires); // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); logger.debug(" *** init Filter Config *** "); super.init(filterConfig); diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/SecurityFilters.java b/common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java index a422e6a60d..b3e4842bbd 100644 --- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/SecurityFilters.java +++ b/common/src/main/java/org/onap/so/security/SoNoAuthWebSecurityConfigurerAdapter.java @@ -1,8 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,27 +13,33 @@ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ +package org.onap.so.security; -package org.onap.so.adapters.requestsdb.application; - -import org.springframework.boot.web.servlet.FilterRegistrationBean; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.firewall.StrictHttpFirewall; +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@EnableWebSecurity @Configuration -@Profile("aaf") -public class SecurityFilters { - - @Bean - public FilterRegistrationBean<SoCadiFilter> loginRegistrationBean() { - FilterRegistrationBean<SoCadiFilter> filterRegistrationBean = new FilterRegistrationBean<>(); - filterRegistrationBean.setFilter(new SoCadiFilter()); - filterRegistrationBean.setName("cadiFilter"); - filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE); - return filterRegistrationBean; +@Order(2) +@Profile({"aaf", "test"}) +public class SoNoAuthWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { + @Override + public void configure(final WebSecurity web) throws Exception { + web.ignoring().antMatchers("/**"); + final StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); } } diff --git a/common/src/main/java/org/onap/so/security/WebSecurityConfig.java b/common/src/main/java/org/onap/so/security/SoUserCredentialConfiguration.java index 44ac62d14f..ee680511b9 100644 --- a/common/src/main/java/org/onap/so/security/WebSecurityConfig.java +++ b/common/src/main/java/org/onap/so/security/SoUserCredentialConfiguration.java @@ -1,8 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +13,10 @@ * 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. + * + * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - package org.onap.so.security; import java.util.ArrayList; @@ -25,17 +24,20 @@ import java.util.List; import javax.annotation.PostConstruct; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Component; - +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +@Component @ConfigurationProperties(prefix = "spring.security") -public class WebSecurityConfig { +public class SoUserCredentialConfiguration { - private List<UserCredentials> credentials; - private List<String> roles = new ArrayList<>(); + private List<UserCredentials> credentials = new ArrayList<>(); + private final List<String> roles = new ArrayList<>(); public List<String> getRoles() { return roles; @@ -52,8 +54,10 @@ public class WebSecurityConfig { return credentials; } - public void setUsercredentials(List<UserCredentials> usercredentials) { - this.credentials = usercredentials; + public void setUsercredentials(final List<UserCredentials> usercredentials) { + if (usercredentials != null) { + this.credentials = usercredentials; + } } @Bean diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java index a2eb35464b..ca67f566b1 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Vnfs.java @@ -51,7 +51,8 @@ public class Vnfs implements Serializable { private List<Map<String, String>> instanceParams = new ArrayList<>(); @JsonProperty("vfModules") private List<VfModules> vfModules = new ArrayList<>(); - + @JsonProperty("applicationId") + protected String applicationId; public ModelInfo getModelInfo() { return modelInfo; @@ -117,12 +118,20 @@ public class Vnfs implements Serializable { this.vfModules = vfModules; } + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + @Override public String toString() { return "Vnfs [modelInfo=" + modelInfo + ", cloudConfiguration=" + cloudConfiguration + ", instanceName=" + instanceName + ", platform=" + platform + ", " + "lineOfBusiness=" + lineOfBusiness + ", productFamilyId=" + productFamilyId + ", instanceParams=" + instanceParams + ", vfModules=" - + vfModules + "]"; + + vfModules + ", applicaionId=" + applicationId + " ]"; } } diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java index ff69e3e4b1..1c38dfb774 100644 --- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java @@ -76,6 +76,8 @@ public final class CryptoUtils { * @throws GeneralSecurityException */ public static String decrypt(String message, String keyString) throws GeneralSecurityException { + if (message.equals(System.getenv("PLAINTEXTPASSWORD"))) + return message; SecretKeySpec sks = getSecretKeySpec(keyString); byte[] cipherText = hexStringToByteArray(message); Cipher cipher = Cipher.getInstance(AES_GCM_NO_PADDING); diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java index 8bde3c4eb7..9e8a0184ab 100644 --- a/common/src/test/java/org/onap/so/BeansTest.java +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -60,6 +60,7 @@ public class BeansTest { @Test public void pojoStructure() { + test("org.onap.so.appc.orchestrator.service.beans"); test("org.onap.so.client.policy.entities"); test("org.onap.so.client.grm.beans"); test("org.onap.so.client.ruby.beans"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoCadiFilter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoCadiFilter.java deleted file mode 100644 index 6510440991..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoCadiFilter.java +++ /dev/null @@ -1,117 +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.apihandlerinfra; - -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import org.onap.aaf.cadi.config.Config; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile("aaf") -public class SoCadiFilter extends CadiFilter { - - protected final Logger logger = LoggerFactory.getLogger(SoCadiFilter.class); - - private static String AFT_ENVIRONMENT_VAR = "AFT_ENVIRONMENT"; - private static String AAF_API_VERSION = "aaf_api_version"; - - @Value("${mso.config.cadi.cadiLoglevel:#{null}}") - private String cadiLoglevel; - - @Value("${mso.config.cadi.cadiKeyFile:#{null}}") - private String cadiKeyFile; - - @Value("${mso.config.cadi.cadiTruststorePassword:#{null}}") - private String cadiTrustStorePassword; - - @Value("${mso.config.cadi.cadiTrustStore:#{null}}") - private String cadiTrustStore; - - @Value("${mso.config.cadi.cadiLatitude:#{null}}") - private String cadiLatitude; - - @Value("${mso.config.cadi.cadiLongitude:#{null}}") - private String cadiLongitude; - - @Value("${mso.config.cadi.aafEnv:#{null}}") - private String aafEnv; - - @Value("${mso.config.cadi.aafApiVersion:#{null}}") - private String aafApiVersion; - - @Value("${mso.config.cadi.aafRootNs:#{null}}") - private String aafRootNs; - - @Value("${mso.config.cadi.aafId:#{null}}") - private String aafMechId; - - @Value("${mso.config.cadi.aafPassword:#{null}}") - private String aafMechIdPassword; - - @Value("${mso.config.cadi.aafLocateUrl:#{null}}") - private String aafLocateUrl; - - @Value("${mso.config.cadi.aafUrl:#{null}}") - private String aafUrl; - - @Value("${mso.config.cadi.apiEnforcement:#{null}}") - private String apiEnforcement; - - private void checkIfNullProperty(String key, String value) { - /* - * When value is null, it is not defined in application.yaml set nothing in System properties - */ - if (value != null) { - System.setProperty(key, value); - } - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - checkIfNullProperty(Config.CADI_LOGLEVEL, cadiLoglevel); - checkIfNullProperty(Config.CADI_KEYFILE, cadiKeyFile); - checkIfNullProperty(Config.CADI_TRUSTSTORE, cadiTrustStore); - checkIfNullProperty(Config.CADI_TRUSTSTORE_PASSWORD, cadiTrustStorePassword); - checkIfNullProperty(Config.CADI_LATITUDE, cadiLatitude); - checkIfNullProperty(Config.CADI_LONGITUDE, cadiLongitude); - checkIfNullProperty(Config.AAF_ENV, aafEnv); - checkIfNullProperty(Config.AAF_API_VERSION, aafApiVersion); - checkIfNullProperty(Config.AAF_ROOT_NS, aafRootNs); - checkIfNullProperty(Config.AAF_APPID, aafMechId); - checkIfNullProperty(Config.AAF_APPPASS, aafMechIdPassword); - checkIfNullProperty(Config.AAF_LOCATE_URL, aafLocateUrl); - checkIfNullProperty(Config.AAF_URL, aafUrl); - checkIfNullProperty(Config.CADI_API_ENFORCEMENT, apiEnforcement); - // checkIfNullProperty(AFT_ENVIRONMENT_VAR, aftEnv); - logger.debug(" *** init Filter Config *** "); - super.init(filterConfig); - } - - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java index 5842531dc3..b76cd42bb3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java @@ -26,7 +26,8 @@ public enum SoSubsystems implements Subsystem { CATALOGDB("CatalogDb Adapter"), OPENSTACK("Openstack Adapter"), REQUESTDB("RequestDB Adapter"), - SDNC("SDNC Adapter"); + SDNC("SDNC Adapter"), + SOAPPCORCHESTRATOR("SO APPC Orchestrator"); private String subsystem; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java deleted file mode 100644 index a0f4615f87..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.apihandlerinfra; - -import org.onap.so.security.MSOSpringFirewall; -import org.onap.so.security.WebSecurityConfig; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.firewall.StrictHttpFirewall; -import org.springframework.util.StringUtils; - -@EnableWebSecurity -@Configuration("att-security-config") -// @Order(2) -public class WebSecurityConfigImpl extends WebSecurityConfig { - - @Profile({"basic", "test"}) - @Bean - public WebSecurityConfigurerAdapter basicAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and() - .httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(WebSecurityConfigImpl.this.userDetailsService()) - .passwordEncoder(WebSecurityConfigImpl.this.passwordEncoder()); - } - }; - } - - @Profile("aaf") - @Bean - public WebSecurityConfigurerAdapter noAuth() { - return new WebSecurityConfigurerAdapter() { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().antMatchers("/**").permitAll(); - } - }; - } - -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml index 27e1ae90d2..1d6722278c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml @@ -23,6 +23,8 @@ mso: uri: http://localhost:${wiremock.server.port} - subsystem: sdnc uri: http://localhost:${wiremock.server.port} + - subsystem: soappcorchestrator + uri: http://localhost:${wiremock.server.port} infra-requests: archived: period: 180 diff --git a/mso-catalog-db/pom.xml b/mso-catalog-db/pom.xml index 08e9719f50..6a4a6774e6 100644 --- a/mso-catalog-db/pom.xml +++ b/mso-catalog-db/pom.xml @@ -102,5 +102,10 @@ <artifactId>asm-xml</artifactId> <version>6.1</version> </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index 8754673f40..7f5907e9bf 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -124,37 +124,38 @@ public class CatalogDbClient { private static final String SEARCH = "/search"; private static final String URI_SEPARATOR = "/"; - private static final String SERVICE_MODEL_UUID = "serviceModelUUID"; - private static final String SERVICE_NAME = "serviceName"; - private static final String MODEL_UUID = "modelUUID"; - private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; - private static final String ACTION = "action"; - private static final String MODEL_NAME = "modelName"; - private static final String MODEL_VERSION = "modelVersion"; - private static final String MODEL_INVARIANT_UUID = "modelInvariantUUID"; - private static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID"; - private static final String NF_ROLE = "nfRole"; - private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID"; - private static final String VNF_COMPONENT_TYPE = "vnfComponentType"; - private static final String BUILDING_BLOCK_NAME = "buildingBlockName"; - private static final String RESOURCE_TYPE = "resourceType"; - private static final String ORCHESTRATION_STATUS = "orchestrationStatus"; - private static final String TARGET_ACTION = "targetAction"; - private static final String REQUEST_SCOPE = "requestScope"; - private static final String IS_ALACARTE = "isALaCarte"; - private static final String CLOUD_OWNER = "cloudOwner"; - private static final String FLOW_NAME = "flowName"; - private static final String ERROR_MESSAGE = "errorMessage"; - private static final String SERVICE_ROLE = "serviceRole"; - private static final String SERVICE_TYPE = "serviceType"; - private static final String VNF_TYPE = "vnfType"; - private static final String ERROR_CODE = "errorCode"; - private static final String WORK_STEP = "workStep"; - private static final String CLLI = "clli"; - private static final String CLOUD_VERSION = "cloudVersion"; - private static final String HOMING_INSTANCE = "/homingInstance"; - private static final String ARTIFACT_UUID = "artifactUUID"; - private static final String SOURCE = "source"; + protected static final String SERVICE_MODEL_UUID = "serviceModelUUID"; + protected static final String SERVICE_NAME = "serviceName"; + protected static final String MODEL_UUID = "modelUUID"; + protected static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID"; + protected static final String ACTION = "action"; + protected static final String MODEL_NAME = "modelName"; + protected static final String MODEL_VERSION = "modelVersion"; + protected static final String MODEL_INVARIANT_UUID = "modelInvariantUUID"; + protected static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID"; + protected static final String PNF_RESOURCE_MODEL_UUID = "pnfResourceModelUUID"; + protected static final String NF_ROLE = "nfRole"; + protected static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID"; + protected static final String VNF_COMPONENT_TYPE = "vnfComponentType"; + protected static final String BUILDING_BLOCK_NAME = "buildingBlockName"; + protected static final String RESOURCE_TYPE = "resourceType"; + protected static final String ORCHESTRATION_STATUS = "orchestrationStatus"; + protected static final String TARGET_ACTION = "targetAction"; + protected static final String REQUEST_SCOPE = "requestScope"; + protected static final String IS_ALACARTE = "isALaCarte"; + protected static final String CLOUD_OWNER = "cloudOwner"; + protected static final String FLOW_NAME = "flowName"; + protected static final String ERROR_MESSAGE = "errorMessage"; + protected static final String SERVICE_ROLE = "serviceRole"; + protected static final String SERVICE_TYPE = "serviceType"; + protected static final String VNF_TYPE = "vnfType"; + protected static final String ERROR_CODE = "errorCode"; + protected static final String WORK_STEP = "workStep"; + protected static final String CLLI = "clli"; + protected static final String CLOUD_VERSION = "cloudVersion"; + protected static final String HOMING_INSTANCE = "/homingInstance"; + protected static final String ARTIFACT_UUID = "artifactUUID"; + protected static final String SOURCE = "source"; private static final String TARGET_ENTITY = "SO:CatalogDB"; private static final String ASTERISK = "*"; @@ -201,6 +202,7 @@ public class CatalogDbClient { private String findPnfResourceCustomizationByModelUuid = "/findPnfResourceCustomizationByModelUuid"; private String findWorkflowByArtifactUUID = "/findByArtifactUUID"; private String findWorkflowByModelUUID = "/findWorkflowByModelUUID"; + private String findWorkflowByPnfModelUUID = "/findWorkflowByPnfModelUUID"; private String findWorkflowBySource = "/findBySource"; private String findVnfResourceCustomizationByModelUuid = "/findVnfResourceCustomizationByModelUuid"; @@ -338,6 +340,7 @@ public class CatalogDbClient { findWorkflowByArtifactUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByArtifactUUID; findWorkflowByModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByModelUUID; + findWorkflowByPnfModelUUID = endpoint + WORKFLOW + SEARCH + findWorkflowByPnfModelUUID; findWorkflowBySource = endpoint + WORKFLOW + SEARCH + findWorkflowBySource; findVnfResourceCustomizationByModelUuid = @@ -817,7 +820,7 @@ public class CatalogDbClient { return client.get(uri); } - private <T> List<T> getMultipleResources(Client<T> client, URI uri) { + protected <T> List<T> getMultipleResources(Client<T> client, URI uri) { Iterable<T> iterator = client.getAll(uri); List<T> list = new ArrayList<>(); Iterator<T> it = iterator.iterator(); @@ -998,6 +1001,11 @@ public class CatalogDbClient { .queryParam(VNF_RESOURCE_MODEL_UUID, vnfResourceModelUUID).build().toString())); } + public List<Workflow> findWorkflowByPnfModelUUID(String pnfResourceModelUUID) { + return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowByPnfModelUUID) + .queryParam(PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build().toString())); + } + public List<Workflow> findWorkflowBySource(String source) { return this.getMultipleResources(workflowClient, getUri(UriBuilder.fromUri(findWorkflowBySource).queryParam(SOURCE, source).build().toString())); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java index eaeb4292fb..42d107c1ff 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java @@ -23,9 +23,10 @@ package org.onap.so.db.catalog.data.repository; import org.onap.so.db.catalog.beans.NetworkResource; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -@Repository +@RepositoryRestResource(collectionResourceRel = "networkResource", path = "networkResource") public interface NetworkResourceRepository extends JpaRepository<NetworkResource, String> { /** diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java index 8bcc60c8be..f1b399325e 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/WorkflowRepository.java @@ -39,10 +39,23 @@ public interface WorkflowRepository extends JpaRepository<Workflow, Integer> { * This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on * model UUID without projection. * - * @param vnfResourceModelUUIDmodel UUID + * @param vnfResourceModelUUID UUID * @return List of Workflow */ @Query(value = "select b.* from vnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.VNF_RESOURCE_MODEL_UUID = ?1", nativeQuery = true) List<Workflow> findWorkflowByModelUUID(String vnfResourceModelUUID); + + /** + * Used to fetch the @{link Workflow} by the Pnf Model UUID. + * + * This operation is required by {@link org.onap.so.db.catalog.client.CatalogDbClient} to provide Workflow based on + * pnf model UUID without projection. + * + * @param pnfResourceModelUUID UUID + * @return List of Workflow + */ + @Query(value = "select b.* from pnf_resource_to_workflow a join workflow b where a.WORKFLOW_ID = b.ID and a.PNF_RESOURCE_MODEL_UUID = ?1", + nativeQuery = true) + List<Workflow> findWorkflowByPnfModelUUID(String pnfResourceModelUUID); } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index b82c17dc84..66fc0f5dc5 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -19,26 +19,33 @@ */ package org.onap.so.db.catalog.client; + import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; import java.util.ArrayList; +import java.util.List; import javax.persistence.EntityNotFoundException; -import org.junit.Before; +import javax.ws.rs.core.UriBuilder; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.beans.Workflow; +import uk.co.blackpepper.bowman.Client; +@RunWith(MockitoJUnitRunner.class) public class CatalogDbClientTest { + @Spy private CatalogDbClient catalogDbClient; - - @Before - public void init() { - catalogDbClient = new CatalogDbClient(); - } - @Rule public ExpectedException thrown = ExpectedException.none(); @@ -171,4 +178,16 @@ public class CatalogDbClientTest { assertTrue(aCvnfc.getModelCustomizationUUID().equals("a123")); } + @Test + public final void testFindWorkflowByPnfModelUUID() throws Exception { + String pnfResourceModelUUID = "f2d1f2b2-88bb-49da-b716-36ae420ccbff"; + + doReturn(new ArrayList()).when(catalogDbClient).getMultipleResources(any(), any()); + List<Workflow> results = catalogDbClient.findWorkflowByPnfModelUUID(pnfResourceModelUUID); + verify(catalogDbClient).getMultipleResources(any(Client.class), + eq(UriBuilder.fromUri("/findWorkflowByPnfModelUUID") + .queryParam(CatalogDbClient.PNF_RESOURCE_MODEL_UUID, pnfResourceModelUUID).build())); + + } + } diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index f1d5b53ace..5d09ffb0d6 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -231,6 +231,31 @@ </assembly> </build> </image> + <image> + <name>${docker.image.prefix}/so-appc-orchestrator</name> + <build> + <cleanup>try</cleanup> + <dockerFileDir>docker-files</dockerFileDir> + <dockerFile>Dockerfile.so-app</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latesttag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.so.adapters:so-appc-orchestrator</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> <image> <name>${docker.image.prefix}/sdc-controller</name> <build> @@ -58,7 +58,7 @@ <docker.buildArg.project_version>${project.version}</docker.buildArg.project_version> <docker.buildArg.artifact_id>${project.artifactId}</docker.buildArg.artifact_id> <docker.buildArg.docker_repository>${dockerPullRepo}</docker.buildArg.docker_repository> - <enforcer.skip>true</enforcer.skip> + <enforcer.skip>false</enforcer.skip> <nexusproxy>https://nexus.onap.org</nexusproxy> <releaseNexusPath>content/repositories/releases/</releaseNexusPath> <snapshotNexusPath>content/repositories/snapshots/</snapshotNexusPath> @@ -497,6 +497,42 @@ </dependency> </dependencies> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>3.0.0-M3</version> + <executions> + <execution> + <id>enforce-property</id> + <configuration> + <skip>true</skip> + </configuration> + </execution> + <execution> + <id>enforce-no-snapshots</id> + <configuration> + <skip>true</skip> + </configuration> + </execution> + <execution> + <id>enforce-banned-dependencies</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <bannedDependencies> + <excludes> + <exclude>org.powermock</exclude> + </excludes> + <searchTransitive>false</searchTransitive> + </bannedDependencies> + </rules> + <fail>true</fail> + </configuration> + </execution> + </executions> + </plugin> </plugins> <pluginManagement> <plugins> diff --git a/so-monitoring/so-monitoring-service/pom.xml b/so-monitoring/so-monitoring-service/pom.xml index ff70a77239..762e3a5ee6 100644 --- a/so-monitoring/so-monitoring-service/pom.xml +++ b/so-monitoring/so-monitoring-service/pom.xml @@ -37,15 +37,10 @@ <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-security</artifactId> - </exclusion> - <exclusion> - <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </exclusion> </exclusions> </dependency> - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> diff --git a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java index 7c5a8965b7..aff4fecfdc 100644 --- a/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java +++ b/so-monitoring/so-monitoring-service/src/main/java/org/onap/so/monitoring/rest/api/SoMonitoringApplication.java @@ -22,11 +22,12 @@ package org.onap.so.monitoring.rest.api; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; /** * @author waqas.ikram@ericsson.com */ -@SpringBootApplication(scanBasePackages = {"org.onap"}) +@SpringBootApplication(scanBasePackages = {"org.onap"}, exclude = SecurityAutoConfiguration.class) public class SoMonitoringApplication { public static void main(String[] args) { diff --git a/so-monitoring/so-monitoring-ui/pom.xml b/so-monitoring/so-monitoring-ui/pom.xml index a5f1a6c18e..c362a83a9b 100644 --- a/so-monitoring/so-monitoring-ui/pom.xml +++ b/so-monitoring/so-monitoring-ui/pom.xml @@ -28,7 +28,9 @@ </parent> <artifactId>so-monitoring-ui</artifactId> - + <properties> + <yarn.proxy>false</yarn.proxy> + </properties> <build> <plugins> <plugin> @@ -66,7 +68,7 @@ <goal>yarn</goal> </goals> <configuration> - <yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven> + <yarnInheritsProxyConfigFromMaven>${yarn.proxy}</yarnInheritsProxyConfigFromMaven> <arguments>build</arguments> </configuration> </execution> diff --git a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/toastr-notification-service.service.spec.ts b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/toastr-notification-service.service.spec.ts index cb685c9e98..ceda3c9ea9 100644 --- a/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/toastr-notification-service.service.spec.ts +++ b/so-monitoring/so-monitoring-ui/src/main/frontend/src/app/toastr-notification-service.service.spec.ts @@ -29,7 +29,7 @@ class StubbedToastrNotificationService extends ToastrNotificationService { }
}
-describe('ToasterNotificationService', () => {
+describe('ToastrNotificationService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [ToastrNotificationService,
diff --git a/so-simulator/src/main/java/org/onap/so/simulator/Simulator.java b/so-simulator/src/main/java/org/onap/so/simulator/Simulator.java index 02032e485f..a5489d19c0 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/Simulator.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/Simulator.java @@ -3,6 +3,7 @@ package org.onap.so.simulator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.http.HttpStatus; import org.springframework.ws.soap.SoapVersion; @@ -15,7 +16,7 @@ import com.consol.citrus.simulator.http.SimulatorRestAdapter; import com.consol.citrus.simulator.http.SimulatorRestConfigurationProperties; -@SpringBootApplication +@SpringBootApplication(exclude = SecurityAutoConfiguration.class) public class Simulator extends SimulatorRestAdapter { public static void main(String[] args) { |