aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/EnrichmentInfo.java63
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/factory/EnricherHandlerFactory.java32
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/EnricherHandlerImpl.java89
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/external/artifact/ExternalArtifactEnricher.java106
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/CeilometerEnricher.java112
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ComponentInfo.java47
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/SnmpEnricher.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/impl/tosca/ToscaEnricher.java73
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/Enricher.java45
-rw-r--r--openecomp-be/lib/openecomp-sdc-enrichment-lib/openecomp-sdc-enrichment-impl/src/main/java/org/openecomp/sdc/enrichment/inter/EnricherHandler.java41
11 files changed, 679 insertions, 0 deletions
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<String, List<Object>> additionalInfo = new HashMap<>();
+ Map<String, EntityInfo> entityInfo = new HashMap<>(); //componentName,EntityInfo
+ String key;
+ Version version;
+
+ public Map<String, List<Object>> getAdditionalInfo() {
+ return additionalInfo;
+ }
+
+ public Map<String, EntityInfo> 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<EnricherHandler> {
+
+ 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<Enricher> getEnrichers() {
+ List<Enricher> enricherList = new ArrayList<>();
+ enricherList.add(new ToscaEnricher());
+ enricherList.add(new ExternalArtifactEnricher());
+ return enricherList;
+ }
+
+ @Override
+ public Map<String, List<ErrorMessage>> enrich() {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ Map<String, List<ErrorMessage>> 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<String, List<ErrorMessage>> enrich() {
+
+ Map<String, List<ErrorMessage>> 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<String, List<ErrorMessage>> 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<String, List<ErrorMessage>> 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<String, List<ErrorMessage>> 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<String> 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<String, List<ErrorMessage>> enrich(ToscaServiceModel toscaModel,
+ Map<String, List<NodeType>> modelNodeType,
+ EnrichmentInfo input) {
+ Map<String, List<ErrorMessage>> 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<NodeType> nodeTypes) {
+
+ for (CeilometerInfo ceilometerInfo : componentInfo.getCeilometerInfo()
+ .getCeilometerInfoList()) {
+ String capabilityId = ceilometerInfo.getName();
+
+ Map<String, Object> 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<String, Object> getCeilometerProperties(CeilometerInfo ceilometerInfo) {
+ Map<String, Object> 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<String, List<ErrorMessage>> enrich(Map<String, List<NodeType>> 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<String, List<NodeType>> componentTypNodeTypeMap;
+
+ @Override
+ public Map<String, List<ErrorMessage>> enrich() {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ Map<String, List<ErrorMessage>> enrichResponse;
+ enrichResponse = enrichCilometer();
+ errors.putAll(enrichResponse);
+ enrichResponse = enrichSnmp();
+ errors.putAll(enrichResponse);
+
+
+ return errors;
+ }
+
+ private Map<String, List<ErrorMessage>> enrichCilometer() {
+ Map<String, List<ErrorMessage>> enrichResponse;
+
+ ToscaServiceModel toscaModel = (ToscaServiceModel) model;
+
+ componentTypNodeTypeMap =
+ ToscaUtil.normalizeComponentNameNodeType(toscaModel, input.getEntityInfo().keySet());
+
+ enrichResponse = CeilometerEnricher.enrich(toscaModel, componentTypNodeTypeMap, this.input);
+
+ return enrichResponse;
+ }
+
+
+ private Map<String, List<ErrorMessage>> enrichSnmp() {
+ Map<String, List<ErrorMessage>> 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<String, List<ErrorMessage>> 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<Enricher> getEnrichers();
+
+ Map<String, List<ErrorMessage>> enrich();
+
+ void addAdditionalInput(String key, Object input);
+
+ void setModel(AsdcModel model);
+
+
+}