From f5f13c4f6b6fe3b4d98e349dfd7db59339803436 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 12:35:04 +0200 Subject: push addional code Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando --- .../openecomp/sdc/enrichment/EnrichmentInfo.java | 63 ++++++++++++ .../enrichment/factory/EnricherHandlerFactory.java | 32 ++++++ .../impl/EnricherHandlerFactoryImpl.java | 33 ++++++ .../sdc/enrichment/impl/EnricherHandlerImpl.java | 89 ++++++++++++++++ .../artifact/ExternalArtifactEnricher.java | 106 +++++++++++++++++++ .../enrichment/impl/tosca/CeilometerEnricher.java | 112 +++++++++++++++++++++ .../sdc/enrichment/impl/tosca/ComponentInfo.java | 47 +++++++++ .../sdc/enrichment/impl/tosca/SnmpEnricher.java | 38 +++++++ .../sdc/enrichment/impl/tosca/ToscaEnricher.java | 73 ++++++++++++++ .../openecomp/sdc/enrichment/inter/Enricher.java | 45 +++++++++ .../sdc/enrichment/inter/EnricherHandler.java | 41 ++++++++ .../src/main/resources/factoryConfiguration.json | 3 + 12 files changed, 682 insertions(+) create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java create mode 100644 openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/resources/factoryConfiguration.json (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main') diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java new file mode 100644 index 0000000000..17c4091a28 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment; + +import org.openecomp.core.enrichment.types.EntityInfo; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class EnrichmentInfo { + Map> additionalInfo = new HashMap<>(); + Map entityInfo = new HashMap<>(); //componentName,EntityInfo + String key; + Version version; + + public Map> getAdditionalInfo() { + return additionalInfo; + } + + public Map getEntityInfo() { + return entityInfo; + } + + public void addEntityInfo(String type, EntityInfo entityInfo) { + this.entityInfo.put(type, entityInfo); + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Version getVersion() { + return version; + } + + public void setVersion(Version version) { + this.version = version; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java new file mode 100644 index 0000000000..47821f6670 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.factory; + +import org.openecomp.core.factory.api.AbstractComponentFactory; +import org.openecomp.core.factory.api.AbstractFactory; +import org.openecomp.sdc.enrichment.inter.EnricherHandler; + +public abstract class EnricherHandlerFactory extends AbstractComponentFactory { + + public static EnricherHandlerFactory getInstance() { + return AbstractFactory.getInstance(EnricherHandlerFactory.class); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java new file mode 100644 index 0000000000..00f5c91661 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl; + + +import org.openecomp.sdc.enrichment.factory.EnricherHandlerFactory; +import org.openecomp.sdc.enrichment.inter.EnricherHandler; + +public class EnricherHandlerFactoryImpl extends EnricherHandlerFactory { + + @Override + public EnricherHandler createInterface() { + return new EnricherHandlerImpl(); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java new file mode 100644 index 0000000000..e2e5b47d2a --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl; + +import org.openecomp.core.enrichment.types.EntityInfo; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.datatypes.model.AsdcModel; +import org.openecomp.sdc.enrichment.EnrichmentInfo; +import org.openecomp.sdc.enrichment.impl.external.artifact.ExternalArtifactEnricher; +import org.openecomp.sdc.enrichment.impl.tosca.ToscaEnricher; +import org.openecomp.sdc.enrichment.inter.Enricher; +import org.openecomp.sdc.enrichment.inter.EnricherHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * The type Enricher handler. + */ +public class EnricherHandlerImpl implements EnricherHandler { + + private static Logger logger = LoggerFactory.getLogger(EnricherHandlerImpl.class); + private EnrichmentInfo input; + private AsdcModel model; + + @Override + public List getEnrichers() { + List enricherList = new ArrayList<>(); + enricherList.add(new ToscaEnricher()); + enricherList.add(new ExternalArtifactEnricher()); + return enricherList; + } + + @Override + public Map> enrich() { + Map> errors = new HashMap<>(); + Map> enricherResponse; + for (Enricher enricher : getEnrichers()) { + enricher.setInput(this.input); + enricher.setModel(this.model); + enricherResponse = enricher.enrich(); + errors.putAll(enricherResponse); + } + return errors; + } + + /** + * Adds additional input. + * + * @param key key + * @param input input + */ + public void addAdditionalInput(String key, Object input) { + if (!this.input.getAdditionalInfo().containsKey(key)) { + this.input.getAdditionalInfo().put(key, new ArrayList<>()); + } + this.input.getAdditionalInfo().get(key).add(input); + } + + public void addEntityInfo(String entityId, EntityInfo entityInfo) { + this.input.getEntityInfo().put(entityId, entityInfo); + } + + public void setModel(AsdcModel model) { + this.model = model; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java new file mode 100644 index 0000000000..a276cfba7d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl.external.artifact; + +import org.openecomp.core.enrichment.types.ComponentArtifactType; +import org.openecomp.core.enrichment.types.MibInfo; +import org.openecomp.core.model.dao.EnrichedServiceModelDao; +import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory; +import org.openecomp.core.model.types.ServiceArtifact; +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.validation.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.enrichment.impl.tosca.ComponentInfo; +import org.openecomp.sdc.enrichment.inter.Enricher; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ExternalArtifactEnricher extends Enricher { + + private static EnrichedServiceModelDao enrichedServiceModelDao = + EnrichedServiceModelDaoFactory.getInstance().createInterface(); + + + @Override + public Map> enrich() { + + Map> errors = new HashMap<>(); + input.getEntityInfo().entrySet().stream().forEach( + entry -> enrichComponentMib(entry.getKey(), (ComponentInfo) entry.getValue(), errors)); + + + return errors; + } + + + private void enrichComponentMib(String componentName, ComponentInfo componentInfo, + Map> errors) { + + String vspId = input.getKey(); + Version version = input.getVersion(); + ServiceArtifact mibServiceArtifact = new ServiceArtifact(); + mibServiceArtifact.setVspId(vspId); + mibServiceArtifact.setVersion(version); + enrichMibFiles(mibServiceArtifact, componentInfo, errors); + } + + private void enrichMibFiles(ServiceArtifact mibServiceArtifact, ComponentInfo componentInfo, + Map> errors) { + if (componentInfo.getMibInfo() == null) { + return; + } + enrichMibByType(componentInfo.getMibInfo().getSnmpTrap(), ComponentArtifactType.SNMP_TRAP, + mibServiceArtifact, errors); + enrichMibByType(componentInfo.getMibInfo().getSnmpPoll(), ComponentArtifactType.SNMP_POLL, + mibServiceArtifact, errors); + } + + private void enrichMibByType(MibInfo mibInfo, ComponentArtifactType type, + ServiceArtifact mibServiceArtifact, + Map> errors) { + if (mibInfo == null) { + return; + } + FileContentHandler mibs; + try { + mibs = FileUtils.getFileContentMapFromZip(FileUtils.toByteArray(mibInfo.getContent())); + } catch (IOException ioException) { + ErrorMessage.ErrorMessageUtil + .addMessage(mibServiceArtifact.getName() + "." + type.name(), errors) + .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage())); + return; + } + Set fileList = mibs.getFileList(); + for (String fileName : fileList) { + mibServiceArtifact.setContentData(FileUtils.toByteArray(mibs.getFileContent(fileName))); + mibServiceArtifact.setName(mibInfo.getName() + File.separator + fileName); + enrichedServiceModelDao.storeExternalArtifact(mibServiceArtifact); + } + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java new file mode 100644 index 0000000000..eb79787b59 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl.tosca; + +import org.apache.commons.collections4.MapUtils; +import org.openecomp.core.enrichment.types.CeilometerInfo; +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.enrichment.EnrichmentInfo; +import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; +import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; +import org.openecomp.sdc.tosca.services.ToscaUtil; +import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl; +import org.openecomp.sdc.translator.services.heattotosca.globaltypes.CommonGlobalTypes; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CeilometerEnricher { + /** + * Enrich map. + * + * @param toscaModel the tosca model + * @param modelNodeType the model node type + * @param input the input + * @return the map + */ + public static Map> enrich(ToscaServiceModel toscaModel, + Map> modelNodeType, + EnrichmentInfo input) { + Map> errors = new HashMap<>(); + input.getEntityInfo().entrySet().stream().forEach( + entry -> enrichNodeType(toscaModel, (ComponentInfo) entry.getValue(), + modelNodeType.get(entry.getKey()))); + + return errors; + } + + private static void enrichNodeType(ToscaServiceModel toscaModel, ComponentInfo componentInfo, + List nodeTypes) { + + for (CeilometerInfo ceilometerInfo : componentInfo.getCeilometerInfo() + .getCeilometerInfoList()) { + String capabilityId = ceilometerInfo.getName(); + + Map properties = getCeilometerProperties(ceilometerInfo); + + //CapabilityType capabilityType = CommonGlobalTypes.createServiceTemplate() + // .getCapability_types(). + // get(ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName()); + //CapabilityType metricCapabilityType = CommonGlobalTypes.createServiceTemplate(). + // getCapability_types().get(ToscaCapabilityType.METRIC.getDisplayName()); + ToscaAnalyzerService toscaAnalyzerService = new ToscaAnalyzerServiceImpl(); + CapabilityType capabilityType = (CapabilityType) toscaAnalyzerService + .getFlatEntity(ToscaElementTypes.CAPABILITY_TYPE, + ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName(), + CommonGlobalTypes.createServiceTemplate(), toscaModel); + + + nodeTypes.stream().forEach(nodeType -> + addCapability(nodeType, capabilityId, ToscaUtil + .convertTypeToDefinition(ToscaCapabilityType.METRIC_CEILOMETER.getDisplayName(), + capabilityType, properties, ceilometerInfo.getDescription()))); + } + } + + private static Map getCeilometerProperties(CeilometerInfo ceilometerInfo) { + Map properties = new HashMap<>(); + properties.put("name", ceilometerInfo.getName()); + properties.put("type", ceilometerInfo.getType()); + properties.put("unit", ceilometerInfo.getUnit()); + if (ceilometerInfo.getCategory() != null) { + properties.put("category", ceilometerInfo.getCategory()); + } + return properties; + } + + private static void addCapability(NodeType nodeType, String capabilityId, + CapabilityDefinition capabilityDefinition) { + if (MapUtils.isEmpty(nodeType.getCapabilities())) { + nodeType.setCapabilities(new HashMap<>()); + } + //clean unnecessary info + capabilityDefinition.setAttributes(null); + capabilityDefinition.setOccurrences(null); + + nodeType.getCapabilities().put(capabilityId, capabilityDefinition); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java new file mode 100644 index 0000000000..0a1f3d36ff --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl.tosca; + +import org.openecomp.core.enrichment.types.ComponentCeilometerInfo; +import org.openecomp.core.enrichment.types.ComponentMibInfo; +import org.openecomp.core.enrichment.types.EntityInfo; + +public class ComponentInfo implements EntityInfo { + + private ComponentCeilometerInfo ceilometerInfo; + private ComponentMibInfo mibInfo; + + public ComponentCeilometerInfo getCeilometerInfo() { + return ceilometerInfo; + } + + public void setCeilometerInfo(ComponentCeilometerInfo ceilometerInfo) { + this.ceilometerInfo = ceilometerInfo; + } + + public ComponentMibInfo getMibInfo() { + return mibInfo; + } + + public void setMibInfo(ComponentMibInfo mibInfo) { + this.mibInfo = mibInfo; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java new file mode 100644 index 0000000000..42cbcdd50b --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl.tosca; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; + +import org.openecomp.sdc.enrichment.EnrichmentInfo; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SnmpEnricher { + public static Map> enrich(Map> modelNodeType, + EnrichmentInfo input) { + return new HashMap<>(); + + } +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java new file mode 100644 index 0000000000..2c0f03480f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.impl.tosca; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.enrichment.inter.Enricher; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.services.ToscaUtil; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ToscaEnricher extends Enricher { + + Map> componentTypNodeTypeMap; + + @Override + public Map> enrich() { + Map> errors = new HashMap<>(); + Map> enrichResponse; + enrichResponse = enrichCilometer(); + errors.putAll(enrichResponse); + enrichResponse = enrichSnmp(); + errors.putAll(enrichResponse); + + + return errors; + } + + private Map> enrichCilometer() { + Map> enrichResponse; + + ToscaServiceModel toscaModel = (ToscaServiceModel) model; + + componentTypNodeTypeMap = + ToscaUtil.normalizeComponentNameNodeType(toscaModel, input.getEntityInfo().keySet()); + + enrichResponse = CeilometerEnricher.enrich(toscaModel, componentTypNodeTypeMap, this.input); + + return enrichResponse; + } + + + private Map> enrichSnmp() { + Map> enrichResponse; + + enrichResponse = SnmpEnricher.enrich(componentTypNodeTypeMap, this.input); + + return enrichResponse; + } + + +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java new file mode 100644 index 0000000000..1d6867d1f3 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.inter; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.datatypes.model.AsdcModel; +import org.openecomp.sdc.enrichment.EnrichmentInfo; + +import java.util.List; +import java.util.Map; + +public abstract class Enricher { + + + protected EnrichmentInfo input; + protected AsdcModel model; + + public void setInput(EnrichmentInfo input) { + this.input = input; + } + + public void setModel(AsdcModel model) { + this.model = model; + } + + public abstract Map> enrich(); +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java new file mode 100644 index 0000000000..717bbc8313 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdc.enrichment.inter; + +import org.openecomp.sdc.datatypes.error.ErrorMessage; +import org.openecomp.sdc.datatypes.model.AsdcModel; + +import java.util.List; +import java.util.Map; + +public interface EnricherHandler { + + + List getEnrichers(); + + Map> enrich(); + + void addAdditionalInput(String key, Object input); + + void setModel(AsdcModel model); + + +} diff --git a/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/resources/factoryConfiguration.json new file mode 100644 index 0000000000..56510be13c --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/resources/factoryConfiguration.json @@ -0,0 +1,3 @@ +{ + "org.openecomp.sdc.enrichment.factory.EnricherHandlerFactory": "org.openecomp.sdc.enrichment.impl.EnricherHandlerFactoryImpl" +} \ No newline at end of file -- cgit 1.2.3-korg