diff options
author | Ittay Stern <ittay.stern@att.com> | 2018-12-31 17:21:27 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-01-09 20:19:55 +0200 |
commit | 6ad41e3ccd398a2721f41ad61c80b7bb03f7d127 (patch) | |
tree | 3bd672dff83e3218232cd8665680416b7fc26a5d /vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java | |
parent | 5ec29ff5e3864f1ba6ecac71f8bffbefa400cf27 (diff) |
Merge from ECOMP's repository
Main Features
--------------
- Async-Instantiation jobs mechanism major update; still WIP (package
`org.onap.vid.job`)
- New features in View/Edit: Activate fabric configuration; show
related networks; soft delete
- Support AAI service-tree traversal (`AAIServiceTree`)
- In-memory cache for SDC models and certain A&AI queries
(`CacheProviderWithLoadingCache`)
- Upgrade TOSCA Parser and add parsing options; fix malformed TOSCA
models
- Resolve Cloud-Owner values for MSO
- Pass X-ONAP headers to MSO
Infrastructure
--------------
- Remove codehaus' jackson mapper; use soley fasterxml 2.9.7
- Surefire invokes both TestNG and JUnit tests
- Support Kotlin source files
- AaiController2 which handles errors in a "Spring manner"
- Inline generated-sources and remove jsonschema2pojo
Quality
--------
- Cumulative bug fixes (A&AI API, UI timeouts, and many more)
- Many Sonar issues cleaned-up
- Some unused classes removed
- Minor changes in vid-automation project, allowing some API
verification to run
Hard Merges
------------
- HTTP Clients (MSO, A&AI, WebConfig, OutgoingRequestHeadersTest)
- Moved `package org.onap.vid.controllers` to `controller`, without
plural -- just to keep semantic sync with ECOMP.
Reference commit in ECOMP: 3d1141625
Issue-ID: VID-378
Change-Id: I9c8d1e74caa41815891d441fc0760bb5f29c5788
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java new file mode 100644 index 000000000..ca0607b8a --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/VidNotionsBuilder.java @@ -0,0 +1,130 @@ +package org.onap.vid.asdc.parser; + +import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.vid.model.ServiceModel; +import org.onap.vid.model.VidNotions; +import org.onap.vid.properties.Features; +import org.togglz.core.manager.FeatureManager; + +import static org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase; +import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase; + +public class VidNotionsBuilder { + + private final FeatureManager featureManager; + + public VidNotionsBuilder(FeatureManager featureManager) { + this.featureManager = featureManager; + } + + public VidNotions buildVidNotions(ISdcCsarHelper csarHelper, ServiceModel serviceModel) { + final VidNotions.InstantiationUI instantiationUI = suggestInstantiationUI(csarHelper); + + return new VidNotions(instantiationUI, suggestModelCategory(csarHelper), suggestViewEditUI(csarHelper, serviceModel)); + } + + //UI route a-la-carte services to old UI only if InstantiationUI is LEGACY + //So any other value for InstantiationUI other than LEGACY make UI to route + //a-la-carte services to new UI + VidNotions.InstantiationUI suggestInstantiationUI(ISdcCsarHelper csarHelper) { + if(featureManager.isActive(Features.FLAG_EXP_ANY_ALACARTE_NEW_INSTANTIATION_UI) && isALaCarte(csarHelper)) { + return VidNotions.InstantiationUI.ANY_ALACARTE_NEW_UI; + } + if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) { + return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING; + } + if (featureManager.isActive(Features.FLAG_5G_IN_NEW_INSTANTIATION_UI)) { + if (isUuidExactlyHardCoded1ffce89fef3f(csarHelper)) { + return VidNotions.InstantiationUI.SERVICE_UUID_IS_1ffce89f_ef3f_4cbb_8b37_82134590c5de; + } else if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)) { + return VidNotions.InstantiationUI.NETWORK_WITH_PROPERTY_NETWORK_TECHNOLOGY_EQUALS_STANDARD_SRIOV_OR_OVS; + } else if (isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) { + return VidNotions.InstantiationUI.SERVICE_WITH_FABRIC_CONFIGURATION; + } + } + + return VidNotions.InstantiationUI.LEGACY; + + } + + VidNotions.ModelCategory suggestModelCategory(ISdcCsarHelper csarHelper) { + if (isALaCarte(csarHelper) && hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(csarHelper)){ + return VidNotions.ModelCategory.IS_5G_PROVIDER_NETWORK_MODEL; + } else if(isALaCarte(csarHelper) && hasFabricConfiguration(csarHelper)) { + return VidNotions.ModelCategory.IS_5G_FABRIC_CONFIGURATION_MODEL; + } else { + return VidNotions.ModelCategory.OTHER; + } + } + + VidNotions.InstantiationUI suggestViewEditUI(ISdcCsarHelper csarHelper, ServiceModel serviceModel) { + if (!featureManager.isActive(Features.FLAG_ASYNC_INSTANTIATION)){ + return VidNotions.InstantiationUI.LEGACY; + } + if (featureManager.isActive(Features.FLAG_1902_VNF_GROUPING) && isGrouping(csarHelper)) { + return VidNotions.InstantiationUI.SERVICE_WITH_VNF_GROUPING; + } + + if (featureManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT)) { + if (isMacro(serviceModel) && !isMacroExcludedFromAsyncFlow(serviceModel)) { + return VidNotions.InstantiationUI.MACRO_SERVICE; + } + VidNotions.InstantiationUI instantiationUISuggestion = suggestInstantiationUI(csarHelper); + if (instantiationUISuggestion!=VidNotions.InstantiationUI.LEGACY) { + return instantiationUISuggestion; + } + } + + return VidNotions.InstantiationUI.LEGACY; + } + + private boolean isMacro(ServiceModel serviceModel) { + return ToscaParserImpl2.Constants.MACRO.equals(serviceModel.getService().getInstantiationType()); + } + + private boolean isUuidExactlyHardCoded1ffce89fef3f(ISdcCsarHelper csarHelper) { + return equalsIgnoreCase( + csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.UUID), "95eb2c44-bff2-4e8b-ad5d-8266870b7717"); + } + + private boolean hasAnyNetworkWithPropertyNetworkTechnologyEqualsStandardSriovOrOvs(ISdcCsarHelper csarHelper) { + return hasAnyNetworkWithPropertyEqualsToAnyOf(csarHelper, "network_technology","Standard-SR-IOV","OVS") ; + } + + boolean hasFabricConfiguration(ISdcCsarHelper csarHelper) { + return csarHelper.getServiceNodeTemplates().stream() + .flatMap(nodeTemplate -> csarHelper.getNodeTemplateChildren(nodeTemplate).stream()) + .anyMatch(child -> child.getType().equals(ToscaParserImpl2.Constants.FABRIC_CONFIGURATION_TYPE)); + } + + boolean hasAnyNetworkWithPropertyEqualsToAnyOf(ISdcCsarHelper csarHelper, String propertyName, String... propertyValues) { + return csarHelper + .getServiceVlList().stream() + .map(NodeTemplate::getProperties) + .flatMap(props -> props.entrySet().stream()) + .filter(prop -> equalsIgnoreCase(prop.getKey(), propertyName)) + // getValue().getValue() because value is Entry, where it's inner value is what we're looking for + .anyMatch(prop -> equalsAnyIgnoreCase(prop.getValue().getValue().toString(), propertyValues)); + } + + boolean isALaCarte(ISdcCsarHelper csarHelper) { + final String instantiationType = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.INSTANTIATION_TYPE); + return StringUtils.equalsIgnoreCase(instantiationType, ToscaParserImpl2.Constants.A_LA_CARTE); + } + + boolean isMacroExcludedFromAsyncFlow(ServiceModel serviceModel) { + return (MapUtils.isNotEmpty(serviceModel.getPnfs()) || + MapUtils.isNotEmpty(serviceModel.getCollectionResource()) || + (MapUtils.isNotEmpty(serviceModel.getNetworks()) && !featureManager.isActive(Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION))); + + + } + + private boolean isGrouping(ISdcCsarHelper csarHelper) { + final String serviceRole = csarHelper.getServiceMetadata().getValue(ToscaParserImpl2.Constants.SERVICE_ROLE); + return StringUtils.equalsIgnoreCase(serviceRole, ToscaParserImpl2.Constants.GROUPING); + } +} |