summaryrefslogtreecommitdiffstats
path: root/ueb-listener/src
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@linuxfoundation.org>2020-12-01 11:52:01 -0800
committerJessica Wagantall <jwagantall@linuxfoundation.org>2020-12-01 11:52:01 -0800
commitff3eecb980bfdc8d43d2ed3a4c786d634fa6f4e2 (patch)
tree680db1c4f69f5c181b8f1fb7d7d8f46942783b3e /ueb-listener/src
parent02b6c140f031c19cfcb791fd0142f03167db69b1 (diff)
Migrate sli-northbound repo
Migrate sli-northbound repo files into new directory "northbound". Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
Diffstat (limited to 'ueb-listener/src')
-rw-r--r--ueb-listener/src/assembly/assemble_zip.xml63
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java106
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java125
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java1123
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModel.java84
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java220
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncOdlConnection.java158
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModel.java142
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java125
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java1263
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java107
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java317
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java360
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java485
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java51
-rw-r--r--ueb-listener/src/main/resources/log4j2.xml26
-rwxr-xr-xueb-listener/src/main/resources/normalizeTagNames.xslt13
-rwxr-xr-xueb-listener/src/main/resources/removeNs.xslt16
-rw-r--r--ueb-listener/src/main/scripts/start-ueb-listener.sh68
-rw-r--r--ueb-listener/src/main/scripts/stop-ueb-listener.sh56
-rw-r--r--ueb-listener/src/site/apt/index.apt46
-rw-r--r--ueb-listener/src/site/site.xml31
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java50
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java39
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java71
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java102
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java76
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java101
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java104
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java28
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java45
-rw-r--r--ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java475
-rw-r--r--ueb-listener/src/test/resources/artifact.map2
-rw-r--r--ueb-listener/src/test/resources/dblib.properties38
-rw-r--r--ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csarbin43966 -> 0 bytes
-rw-r--r--ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csarbin38938 -> 0 bytes
-rw-r--r--ueb-listener/src/test/resources/incoming/vf-license-model.xml1
-rw-r--r--ueb-listener/src/test/resources/log4j.properties30
-rwxr-xr-xueb-listener/src/test/resources/ueb-listener.properties22
39 files changed, 0 insertions, 6169 deletions
diff --git a/ueb-listener/src/assembly/assemble_zip.xml b/ueb-listener/src/assembly/assemble_zip.xml
deleted file mode 100644
index 7a21aca48..000000000
--- a/ueb-listener/src/assembly/assemble_zip.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- openECOMP : SDN-C
- ================================================================================
- 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=========================================================
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>assemble_zip</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>src/main/scripts</directory>
- <outputDirectory>bin</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>target</directory>
- <outputDirectory>lib</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/resources</directory>
- <outputDirectory>lib</outputDirectory>
- <includes>
- <include>*.xslt</include>
- <include>*.properties</include>
- </includes>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- <useProjectArtifact>true</useProjectArtifact>
- <scope>runtime</scope>
- </dependencySet>
- </dependencySets>
-</assembly>
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java
deleted file mode 100644
index f1e514da4..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModel.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * Modifications Copyright © 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
-import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.tosca.parser.enums.SdcTypes;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncARModel extends SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncARModel.class);
-
- private String type = null;
- private String subcategory = null;
-
- public SdncARModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails arEntity, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
-
- super(sdcCsarHelper, arEntity, jdbcDataSource, config);
-
- // extract metadata
- Metadata metadata = arEntity.getMetadata();
- type = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_TYPE);
- subcategory = extractValue (metadata, "subcategory");
- addParameter("type", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_TYPE));
-
- // extract properties
- addParameter("role", extractValue (arEntity, "nf_role"));
- addParameter("type", extractValue (arEntity, "nf_type"));
- addParameter("ecomp_generated_naming", extractBooleanValue (arEntity, "nf_naming", "ecomp_generated_naming"));
- addParameter("naming_policy", extractValue (arEntity, "nf_naming", "naming_policy"));
- }
-
- public void insertAllottedResourceModelData () throws IOException {
- try {
- cleanUpExistingToscaData("ALLOTTED_RESOURCE_MODEL", "customization_uuid", getCustomizationUUID());
- LOG.info("Call insertToscaData for ALLOTTED_RESOURCE_MODEL where customization_uuid = " + getCustomizationUUID());
- insertToscaData(buildSql("ALLOTTED_RESOURCE_MODEL", model_yaml), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the ALLOTTED_RESOURCE_MODEL table");
- throw new IOException (e);
- }
- }
-
- public void insertAllottedResourceVfcModelData () throws IOException {
-
- // Insert the child VFCs (not CVFC) into VFC_MODEL
- String vfCustomizationUuid = getCustomizationUUID().replace("\"", "");
- EntityQuery vfcEntityQuery = EntityQuery.newBuilder(SdcTypes.VFC).build();
- TopologyTemplateQuery vfcTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
- .customizationUUID(vfCustomizationUuid)
- .build();
- List<IEntityDetails> nestedVfcs = sdcCsarHelper.getEntity(vfcEntityQuery, vfcTopologyTemplateQuery, true); // true allows for nested search
- if (nestedVfcs == null || nestedVfcs.isEmpty()) {
- LOG.info("Could not find the nested VFCs for: " + vfCustomizationUuid);
- }
-
- for (IEntityDetails nestedVfc: nestedVfcs) {
- try {
- SdncVFCModel arVfcModel = new SdncVFCModel (sdcCsarHelper, nestedVfc, jdbcDataSource, config);
- arVfcModel.insertVFCModelData();
- } catch (IOException e) {
- LOG.info("Could not find the nested VFCs for: " + vfCustomizationUuid);
- }
- }
- }
-
- public String getSubcategory() {
- return subcategory;
- }
-
- public void setSubcategory(String subcategory) {
- this.subcategory = subcategory;
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java
deleted file mode 100644
index 601569a19..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncArtifactMap.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * Modifications Copyright © 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncArtifactMap {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncArtifactMap.class);
-
- public class SdncArtifactType {
- private String tag;
- private String artifactType;
- private String rpc;
- private int pass;
-
- private SdncArtifactType(String tag, String rpc, String pass) {
- this.tag = tag;
- this.rpc = rpc;
- try {
- this.pass = Integer.parseInt(pass);
- } catch (Exception e) {
- LOG.error("Invalid pass value for artifact map entry ({} {} {})", tag, rpc, pass, e);
- }
- }
-
- public String getTag() {
- return tag;
- }
- public String getArtifactType() {
- return artifactType;
- }
- public String getRpc() {
- return rpc;
- }
-
- public int getPass() {
- return pass;
- }
-
- public String getRpcUrl(String base) {
- return base+rpc;
- }
- }
-
-
-
- private Map<String, SdncArtifactType> mapItems = new HashMap<>();
-
- private int numPasses = 1;
-
- public int getNumPasses() {
- return numPasses;
- }
-
- public void load(String fileName) {
-
- File mapFile = new File(fileName);
-
- if (mapFile.exists() && mapFile.canRead()) {
-
- try (BufferedReader rdr = new BufferedReader(new FileReader(mapFile))) {
-
- for (String ln ; (ln = rdr.readLine()) != null ; ) {
- String[] lnFields = ln.split(",");
- if (lnFields.length == 3) {
- SdncArtifactType entry = new SdncArtifactType(lnFields[0], lnFields[1], lnFields[2]);
- mapItems.put(entry.getTag(), entry);
- if (entry.getPass() + 1 > numPasses ) {
- numPasses = entry.getPass() + 1;
- }
- }
- }
-
-
- } catch (Exception e) {
- LOG.error("Caught exception reading artifact map", e);
- return;
- }
- } else {
- LOG.info("Artifact map {} does not exist or is not readable", fileName);
- }
- }
-
- public SdncArtifactType getMapping(String tag) {
- if (mapItems.containsKey(tag)) {
- return mapItems.get(tag);
- } else {
- return null;
- }
- }
-
- public static SdncArtifactMap getInstance() {
- return new SdncArtifactMap();
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java
deleted file mode 100644
index bced6a830..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncBaseModel.java
+++ /dev/null
@@ -1,1123 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.sql.rowset.CachedRowSet;
-
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
-import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.tosca.parser.enums.SdcTypes;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.CapabilityAssignment;
-import org.onap.sdc.toscaparser.api.CapabilityAssignments;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncBaseModel.class);
-
- protected String customizationUUID = null;
- protected String invariantUUID = null;
- protected String UUID = null;
- protected String model_yaml = null;
- protected String version = null;
- protected String name = null;
-
- protected String PARAM_INVARIANT_UUID_KEY = "invariant_uuid";
- protected String PARAM_CUSTOMIZATION_UUID_KEY = "customization_uuid";
- protected String PARAM_UUID_KEY = "uuid";
- protected String PARAM_VERSION_KEY = "version";
- protected String PARAM_NAME_KEY = "name";
- protected String PARAM_DESCRIPTION_KEY = "description";
- protected String PARAM_TYPE_KEY = "type";
- protected String PARAM_CATEGORY_KEY = "category";
-
- protected Map<String, String> params = null;
- protected Map<String, String> attributeValueParams = null;
- protected ISdcCsarHelper sdcCsarHelper = null;
- protected static DBResourceManager jdbcDataSource = null;
- protected static SdncUebConfiguration config = null;
- protected IEntityDetails entityDetails = null;
-
-
- public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
- this (sdcCsarHelper, entityDetails);
- this.sdcCsarHelper = sdcCsarHelper;
- this.entityDetails = entityDetails;
- SdncBaseModel.jdbcDataSource = jdbcDataSource;
- SdncBaseModel.config = config;
- }
-
- public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata, DBResourceManager jdbcDataSource) {
-
- params = new HashMap<String, String>();
- this.sdcCsarHelper = sdcCsarHelper;
- SdncBaseModel.jdbcDataSource = jdbcDataSource;
-
- // extract service metadata
- invariantUUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
- addParameter(PARAM_INVARIANT_UUID_KEY,invariantUUID);
- addParameter(PARAM_VERSION_KEY,extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_VERSION));
- name = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME);
- addParameter(PARAM_NAME_KEY,name);
- addParameter(PARAM_DESCRIPTION_KEY,extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- addParameter(PARAM_TYPE_KEY,extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_TYPE));
- addParameter(PARAM_CATEGORY_KEY,extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- }
-
- public SdncBaseModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails) {
-
- params = new HashMap<String, String>();
- attributeValueParams = new HashMap<String, String>();
- this.sdcCsarHelper = sdcCsarHelper;
- this.entityDetails = entityDetails;
-
- // extract common nodeTemplate metadata
- Metadata metadata = entityDetails.getMetadata();
- customizationUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- invariantUUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
- addParameter(PARAM_INVARIANT_UUID_KEY, invariantUUID);
- UUID = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_UUID);
- addParameter(PARAM_UUID_KEY, UUID);
- addParameter(PARAM_VERSION_KEY, extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_VERSION));
- }
-
-
-/* This is the generic approach Shoujit attempted for 18.06 but can't be implemented without parser API to
- * get properties with substring match on the name
- * protected void extractRelevantAttributeData(List<Property> propList, SdncUebConfiguration config) {
-
- //List<Property> propList = nodeTemplate.getPropertiesObjects();
- for (Property prop : propList) {
- String propName = prop.getName();
- Object propValue = prop.getValue();
-
- if (propValue instanceof Map)
-
- LOG.info("Property: propertyName: " + propName + " propertyValue: " + propValue.toString());
-
- // Compare this property name with each config.relevant-attribute-name
- List<String> attributeNames = config.getRelevantAttributeNames();
- for (String attributeName : attributeNames) {
- if (prop.getName().contains(attributeName))
- addParameter(prop.getName(), prop.getValue().toString(), attributeValueParams);
- }
-
- }
-
- }*/
-
- protected void insertRelevantAttributeData() throws IOException{
-
- insertRelevantAttributeData("");
- }
-
- protected void insertRelevantAttributeData(String type) throws IOException{
-
- // type can be passed as "group" or taken from the nodeTemplate
- String metadataType = "";
- if (!type.isEmpty()) metadataType = type;
- else {
- Metadata metadata = entityDetails.getMetadata();
- metadataType = extractValue (metadata, PARAM_TYPE_KEY);
- }
-
- // Clean up all attributes for this resource
- try {
- cleanUpExistingToscaData("ATTRIBUTE_VALUE_PAIR", "resource_uuid", getUUID(), "resource_type", "\"" + metadataType + "\"");
- } catch (IOException e) {
- LOG.error("Could not cleanup Tosca CSAR data from the ATTRIBUTE_VALUE_PAIR table");
- throw new IOException (e);
- }
-
- for (String paramName : attributeValueParams.keySet()) {
- String paramValue = attributeValueParams.get(paramName);
-
- Map<String, String> attributeParams = new HashMap<String, String>();
- addParameter("attribute_name", paramName, attributeParams);
- addParameter("attribute_value", paramValue, attributeParams);
- addParameter("resource_type", metadataType, attributeParams);
- addParameter("resource_customization_uuid", getCustomizationUUID(), attributeParams);
-
- LOG.info("Call insertToscaData for ATTRIBUTE_VALUE_PAIR where resource_uuid = " + getUUID() + " and attribute_name = \"" + paramName + "\"");
- try {
- insertToscaData(buildSql("ATTRIBUTE_VALUE_PAIR", "resource_uuid", getUUID(), model_yaml, attributeParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the ATTRIBUTE_VALUE_PAIR table");
- throw new IOException (e);
- }
- }
- }
-
- protected void insertEntityGroupData (IEntityDetails entityDetails, IEntityDetails targetNode, String groupType) throws IOException {
-
- // Get the Groups on a node - Convert to use getEntity in 19.08
- EntityQuery entityQuery = EntityQuery.newBuilder(groupType).build();
- String customizationUuid = getCustomizationUUIDNoQuotes();
- SdcTypes entitySdcType = SdcTypes.valueOf(extractValue(entityDetails.getMetadata(), SdcPropertyNames.PROPERTY_NAME_TYPE));
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(entitySdcType)
- .customizationUUID(customizationUuid).build();
- List<IEntityDetails> groupList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- if (groupList == null) {
- return;
- }
-
- for (IEntityDetails group : groupList){
-
- // Insert into RESOURCE_GROUP/ATTRIBUTE_VALUE_PAIR and RESOURCE_GROUP_TO_TARGET_NODE_MAPPING
- // RESOURCE_GROUP (group metadata): resource_uuid (CR node UUID), uuid, customization_uuid, invariant_uuid, name, version
- // ATTRIBUTE_VALUE_PAIR (group properties): group_type, group_role, group_function
- // RESOURCE_GROUP_TO_TARGET_NODE_MAPPING: group_uuid, parent_uuid (CR node UUID), target_node_uuid, target_type, table_name
-
- SdncGroupModel groupModel = new SdncGroupModel (sdcCsarHelper, group, entityDetails, config, jdbcDataSource);
- String resourceUuid = getUUID();
- groupModel.insertGroupData(resourceUuid);
-
- // insert RESOURCE_GROUP_TO_TARGET_NODE_MAPPING
- try {
- Map<String, String> mappingCleanupParams = new HashMap<String, String>();
- addParameter("group_uuid", groupModel.getUUID(), mappingCleanupParams);
- addParameter("parent_uuid", extractValue(entityDetails.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID), mappingCleanupParams);
- addParameter("target_node_uuid", extractValue(targetNode.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID), mappingCleanupParams);
- cleanupExistingToscaData("RESOURCE_GROUP_TO_TARGET_NODE_MAPPING", mappingCleanupParams);
-
- Map<String, String> mappingParams = new HashMap<String, String>();
- addParameter("parent_uuid", extractValue(entityDetails.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID), mappingParams);
- addParameter("target_node_uuid", extractValue(targetNode.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID), mappingParams);
- String targetType = extractValue(targetNode.getMetadata(), PARAM_TYPE_KEY);
- addParameter("target_type", targetType, mappingParams);
- String tableName = "";
- switch (targetType) {
- case "CVFC":
- tableName = "VFC_MODEL";
- break;
- case "VL":
- tableName = "NETWORK_MODEL";
- break;
- }
- addParameter("table_name", tableName, mappingParams);
- LOG.info("Call insertToscaData for RESOURCE_GROUP_TO_TARGET_NODE_MAPPING where group_uuid = " + groupModel.getUUID());
- insertToscaData(buildSql("RESOURCE_GROUP_TO_TARGET_NODE_MAPPING", "group_uuid", groupModel.getUUID(), model_yaml, mappingParams), null);
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the RESOURCE_GROUP_TO_TARGET_NODE_MAPPING");
- throw new IOException (e);
- }
- }
- }
-
- protected void insertEntityPolicyData (String nodeTemplateCustomizationUuid, String nodeTemplateUuid, SdcTypes queryType, String targetCustomizationUuid, String targetUuid, String targetType, String policyType) throws IOException {
-
- EntityQuery policyEntityQuery = EntityQuery.newBuilder(policyType).build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(queryType).customizationUUID(nodeTemplateCustomizationUuid).build();
- List<IEntityDetails> policyEntities = sdcCsarHelper.getEntity(policyEntityQuery, topologyTemplateQuery, false);
- if (policyEntities == null || policyEntities.isEmpty()) {
- LOG.debug("insertPolicyData: Could not find policy data for: " + nodeTemplateCustomizationUuid);
- return;
- }
-
- String resourceUuid = getUUID();
-
- for (IEntityDetails policyEntity : policyEntities) {
-
- // extract policy metadata
- String policyUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID);
- String policyCustomizationUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
-
- insertResourcePolicyData(policyEntity, resourceUuid);
- insertResourcePolicyToTargetNodeMappingData(policyUuid, nodeTemplateUuid, targetUuid, targetCustomizationUuid, policyCustomizationUuid, targetType);
- }
- }
-
- public void insertEntityPolicyData (String resourceCustomizationUuid, String resourceUuid, String parentUuid, String policyType, SdcTypes queryType) throws IOException {
-
- EntityQuery policyEntityQuery = EntityQuery.newBuilder(policyType).build();
- TopologyTemplateQuery topologyTemplateQuery;
- if (queryType == SdcTypes.VF) {
- topologyTemplateQuery = TopologyTemplateQuery.newBuilder(queryType).customizationUUID(resourceCustomizationUuid).build();
- } else {
- topologyTemplateQuery = TopologyTemplateQuery.newBuilder(queryType).build();
- }
-
- List<IEntityDetails> policyEntities = sdcCsarHelper.getEntity(policyEntityQuery, topologyTemplateQuery, false);
- if (policyEntities == null || policyEntities.isEmpty()) {
- LOG.debug("insertPolicyData: Could not find policy data for Service/VF: " + resourceUuid);
- return;
- }
-
- for (IEntityDetails policyEntity : policyEntities) {
-
- // extract policy metadata
- String policyUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID);
- String policyCustomizationUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
-
- insertResourcePolicyData(policyEntity, resourceUuid);
- List<IEntityDetails> targetEntities = policyEntity.getTargetEntities();
- if (targetEntities == null || targetEntities.isEmpty()) {
- LOG.debug("insertPolicyData: Could not find targetEntites for policy: " + policyUuid);
- continue;
- }
-
- for (IEntityDetails targetEntity : targetEntities) {
-
- String targetUuid = extractValue(targetEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID);
- String targetCustomizationUuid = extractValue(targetEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String targetType = extractValue(targetEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_TYPE);
- insertResourcePolicyToTargetNodeMappingData(policyUuid, parentUuid, targetUuid, targetCustomizationUuid, policyCustomizationUuid, targetType);
- }
- }
- }
-
- protected void insertResourcePolicyData (IEntityDetails policyEntity, String resourceUuid) throws IOException {
-
- // extract policy metadata
- String policyUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID);
- String policyInvariantUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
- String policyCustomizationUuid = extractValue(policyEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
-
- // cleanup existing RESOURCE_POLICY data
- Map<String, String> cleanupParams = new HashMap<String, String>();
- addParameter("resource_uuid", resourceUuid, cleanupParams);
- addParameter("policy_uuid", policyUuid, cleanupParams);
- addParameter("policy_invariant_uuid", policyInvariantUuid, cleanupParams);
-
- // insert into RESOURCE_POLICY
- Map<String, String> policyParams = new HashMap<String, String>();
- addParameter("policy_uuid", policyUuid, policyParams);
- addParameter("policy_customization_uuid", policyCustomizationUuid, policyParams);
- addParameter("policy_invariant_uuid", policyInvariantUuid, policyParams);
- addParameter("policy_name", extractValue(policyEntity.getMetadata(), PARAM_NAME_KEY), policyParams);
- addParameter(PARAM_VERSION_KEY, extractValue(policyEntity.getMetadata(), PARAM_VERSION_KEY), policyParams);
- addParameter("policy_type", policyEntity.getToscaType(), policyParams);
-
- // extract properties
- addParameter("property_type", extractValue(policyEntity, PARAM_TYPE_KEY), policyParams);
- addParameter("property_source", extractValue(policyEntity, "source"), policyParams);
- addParameter("property_name", extractValue(policyEntity, PARAM_NAME_KEY), policyParams);
-
- // Insert into RESOURCE_POLICY and RESOURCE_POLICY_TO_TARGET_NODE_MAPPING
- // RESOURCE_POLICY: resource_uuid (CR node UUID), uuid, customization_uuid, invariant_uuid, name, version, policy_type,
- // property_type, property_source, property_name
-
- try {
-
- // insert into RESOURCE_POLICY
- cleanupExistingToscaData("RESOURCE_POLICY", cleanupParams);
- LOG.info("Call insertToscaData for RESOURCE_POLICY where resource_uuid = " + resourceUuid + " and policy_uuid = " + "\"" + policyUuid + "\"" );
- insertToscaData(buildSql("RESOURCE_POLICY", "resource_uuid", resourceUuid, model_yaml, policyParams), null);
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the RESOURCE_POLICY table");
- throw new IOException (e);
- }
-
- }
-
- protected void insertResourcePolicyToTargetNodeMappingData(String policyUuid, String parentUuid, String targetUuid, String targetCustomizationUuid, String policyCustomizationUuid, String targetType) throws IOException {
-
- // insert RESOURCE_POLICY_TO_TARGET_NODE_MAPPING: policy_uuid, parent_uuid (CR node UUID), target_node_uuid, target_type, table_name
- try {
- Map<String, String> mappingCleanupParams = new HashMap<String, String>();
- addParameter("policy_uuid", policyUuid, mappingCleanupParams);
- addParameter("parent_uuid", parentUuid, mappingCleanupParams);
- addParameter("target_node_uuid", targetUuid, mappingCleanupParams);
- cleanupExistingToscaData("RESOURCE_POLICY_TO_TARGET_NODE_MAPPING", mappingCleanupParams);
-
- Map<String, String> mappingParams = new HashMap<String, String>();
- addParameter("parent_uuid", parentUuid, mappingParams);
- addParameter("target_node_uuid", targetUuid, mappingParams);
- addParameter("target_node_customization_uuid", targetCustomizationUuid, mappingParams);
- addParameter("policy_customization_uuid", policyCustomizationUuid, mappingParams);
- addParameter("target_type", targetType, mappingParams);
- LOG.info("Call insertToscaData for RESOURCE_POLICY_TO_TARGET_NODE_MAPPING where policy_uuid = " + "\"" + policyUuid + "\" and parent_uuid = " + "\"" + parentUuid + "\" and target_node_uuid = " + "\"" + targetUuid + "\"");
- insertToscaData(buildSql("RESOURCE_POLICY_TO_TARGET_NODE_MAPPING", "policy_uuid", "\"" + policyUuid + "\"", model_yaml, mappingParams), null);
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the RESOURCE_POLICY_TO_TARGET_NODE_MAPPING");
- throw new IOException (e);
- }
- }
-
-
- protected void insertNodeCapabilitiesData (CapabilityAssignments capabilities) throws IOException {
-
- // Process the capabilities on the node template
-
- List<CapabilityAssignment> capabilityList = capabilities.getAll();
-
- for (CapabilityAssignment capability : capabilities.getAll()) {
-
- // Insert into NODE_CAPABILITY:
- // capability_id (generated)
- // capability_provider_uuid - UUID of this node
- // capability_provider_customization_uuid - customization UUID of this node
- // capability_name - capability.getName()
- // capability_type - ?
-
- // Check capability name against relevant capabilities
- boolean capabilityIsRelevant = false;
- /*List<String> relevantCapabilities = config.getRelevantCapabilityNames();
- for (String relevantCapabilityName : relevantCapabilities ) {
-
- if (capability.getName().toLowerCase().contains(relevantCapabilityName.toLowerCase())) {
- capabilityIsRelevant = true;
- }
- }*/
-
- if (capabilityIsRelevant == false){
- continue;
- }
-
- String capabilityProviderUuid = getUUID();
-
- Map<String, String> cleanupParams = new HashMap<String, String>();
- addParameter("capability_provider_uuid", capabilityProviderUuid, cleanupParams); // node customization UUID
- addParameter("capability_provider_customization_uuid", getCustomizationUUIDNoQuotes(), cleanupParams); // node customization UUID
- addParameter("capability_name", capability.getName(), cleanupParams);
-
- Map<String, String> nodeCapabilityParams = new HashMap<String, String>();
- addParameter("capability_provider_customization_uuid", getCustomizationUUIDNoQuotes(), nodeCapabilityParams); // node customization UUID
- addParameter("capability_name", capability.getName(), nodeCapabilityParams);
- addParameter("capability_type", extractValue(capability, PARAM_TYPE_KEY), nodeCapabilityParams);
-
- // Insert NODE_CAPABILITY data for each capability
- String capabilityId = "";
- try {
-
- cleanupExistingToscaData("NODE_CAPABILITY", cleanupParams); // will also delete NODE_CAPABILITY_PROPERTY with same capability_id
- LOG.info("Call insertToscaData for NODE_CAPABILITY where capability_provider_uuid = " + capabilityProviderUuid + " and capability_name = \"" + capability.getName() + "\"");
- insertToscaData(buildSql("NODE_CAPABILITY", "capability_provider_uuid", capabilityProviderUuid, model_yaml, nodeCapabilityParams), null);
-
- // Get capabilityId for capability just inserted
- CachedRowSet rowData = getToscaData("NODE_CAPABILITY", nodeCapabilityParams);
- rowData.first();
- int capabilityIdint = rowData.getInt("capability_id");
- capabilityId = String.valueOf(capabilityIdint);
-
- } catch (IOException | SQLException e) {
- LOG.error("Could not insert Tosca CSAR data into the NODE_CAPABILITY table");
- throw new IOException (e);
- }
-
- insertNodeCapabilityPropertyData (capability, capabilityId);
- }
- }
-
- protected void insertNodeCapabilitiesEntityData (List<CapabilityAssignment> capabilities) throws IOException {
-
- // Process the capabilities
- for (CapabilityAssignment capability : capabilities) {
-
- // Insert into NODE_CAPABILITY:
- // capability_id (generated)
- // capability_provider_uuid - UUID of this node
- // capability_provider_customization_uuid - customization UUID of this node
- // capability_name - capability.getName()
- // capability_type - ?
-
- // Check capability name against relevant capabilities
- boolean capabilityIsRelevant = false;
- /*List<String> relevantCapabilities = config.getRelevantCapabilityNames();
- for (String relevantCapabilityName : relevantCapabilities ) {
-
- if (capability.getName().toLowerCase().contains(relevantCapabilityName.toLowerCase())) {
- capabilityIsRelevant = true;
- }
- }*/
-
- if (capabilityIsRelevant == false){
- continue;
- }
-
- String capabilityProviderUuid = getUUID();
-
- Map<String, String> cleanupParams = new HashMap<String, String>();
- addParameter("capability_provider_uuid", capabilityProviderUuid, cleanupParams); // node customization UUID
- addParameter("capability_provider_customization_uuid", getCustomizationUUIDNoQuotes(), cleanupParams); // node customization UUID
- addParameter("capability_name", capability.getName(), cleanupParams);
-
- Map<String, String> nodeCapabilityParams = new HashMap<String, String>();
- addParameter("capability_provider_customization_uuid", getCustomizationUUIDNoQuotes(), nodeCapabilityParams); // node customization UUID
- addParameter("capability_name", capability.getName(), nodeCapabilityParams);
- addParameter("capability_type", extractValue(capability, PARAM_TYPE_KEY), nodeCapabilityParams);
-
- // Insert NODE_CAPABILITY data for each capability
- String capabilityId = "";
- try {
-
- cleanupExistingToscaData("NODE_CAPABILITY", cleanupParams); // will also delete NODE_CAPABILITY_PROPERTY with same capability_id
- LOG.info("Call insertToscaData for NODE_CAPABILITY where capability_provider_uuid = " + capabilityProviderUuid + " and capability_name = \"" + capability.getName()+ "\"");
- insertToscaData(buildSql("NODE_CAPABILITY", "capability_provider_uuid", capabilityProviderUuid, model_yaml, nodeCapabilityParams), null);
-
- // Get capabilityId for capability just inserted
- CachedRowSet rowData = getToscaData("NODE_CAPABILITY", nodeCapabilityParams);
- rowData.first();
- int capabilityIdint = rowData.getInt("capability_id");
- capabilityId = String.valueOf(capabilityIdint);
-
- } catch (IOException | SQLException e) {
- LOG.error("Could not insert Tosca CSAR data into the NODE_CAPABILITY table");
- throw new IOException (e);
- }
-
- insertNodeCapabilityPropertyData (capability, capabilityId);
- }
- }
-
- protected void insertNodeCapabilityPropertyData(CapabilityAssignment capability, String capabilityId) throws IOException {
-
- // Insert property name / value into NODE_CAPABILITY_PROPERTY
- LinkedHashMap<String, Property> propertiesMap = capability.getProperties();
- Map<String, String> nodeCapabilityPropertyParams = new HashMap<String, String>();
-
- for (String propertyMapKey : propertiesMap.keySet() ) {
- //LOG.info("property map key = " + propertyMapKey);
- Property property = propertiesMap.get(propertyMapKey);
-
- addParameter ("capability_property_name", property.getName(), nodeCapabilityPropertyParams);
- addParameter ("capability_property_type", property.getValue().toString(), nodeCapabilityPropertyParams);
-
- try {
- // Data from NODE_CAPABILITY_PROPERTY is cleaned up via cascade delete on NODE_CAPABILITY
- LOG.info("Call insertToscaData for NODE_CAPABILITY_PROPERTY where capability_id = \"" + capabilityId + "\" and capability_property_name = \"" + property.getName() + "\" and capability_property_type = \"" + property.getValue().toString() + "\"");
- insertToscaData(buildSql("NODE_CAPABILITY_PROPERTY", "capability_id", capabilityId, model_yaml, nodeCapabilityPropertyParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the NODE_CAPABILITY_PROPERTY table");
- throw new IOException (e);
- }
- }
-
- }
-
- protected void addParameter (String name, String value) {
- if (value != null && !value.isEmpty()) {
- // check if value already contain quotes
- if (value.startsWith("\"", 0) && value.endsWith("\"")) {
- params.put(name, value);
- } else {
- params.put(name, "\"" + value + "\"");
- }
- }
- }
-
- protected void addIntParameter (String name, String value) {
- if (value != null && !value.isEmpty()) {
- params.put(name, value);
- }
- }
-
- public static void addParameter (String name, String value, Map<String, String> params) {
- if (value != null && !value.isEmpty()) {
- // remove any quotes within the string
- String strippedValue = value.replace("\"","");
-
- // check if value already contain quotes
- if (strippedValue.startsWith("\"", 0) && value.endsWith("\"")) {
- params.put(name, strippedValue);
- } else {
- params.put(name, "\"" + strippedValue + "\"");
- }
- }
- }
-
- protected String extractValue (Metadata metadata, String name) {
- String value = metadata.getValue(name);
- if (value != null) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractBooleanValue (Metadata metadata, String name) {
- String value = metadata.getValue(name);
- if (value != null && !value.isEmpty()) {
- return value.contains("true") ? "Y" : "N";
- } else {
- return "";
- }
- }
-
- public static String extractValue (ISdcCsarHelper sdcCsarHelper, Metadata metadata, String name) {
- String value = metadata.getValue(name);
- if (value != null) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractValue (IEntityDetails entityDetails, String name) {
- String value = "";
- if (entityDetails.getProperties().containsKey(name)) {
- Property property = entityDetails.getProperties().get(name);
- if (property != null && property.getValue() != null) {
- value = property.getValue().toString();
- }
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractValue (IEntityDetails entityDetails, String path, String name) {
- String value = "";
-
- if (entityDetails.getProperties().containsKey(path)) {
- Property property = entityDetails.getProperties().get(path);
- if (property != null && !property.getLeafPropertyValue(name).isEmpty()) {
- value = property.getLeafPropertyValue(name).get(0);
- }
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractValue (IEntityDetails entityDetails, String path1, String path2, String name) {
- String value = "";
-
- value = extractNestedValue (entityDetails, path1, path2, name);
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractValue (IEntityDetails entityDetails, String path1, String path2, String path3, String name) {
- String value = "";
-
- value = extractNestedValue (entityDetails, path1, path2, path3, name);
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractBooleanValue (IEntityDetails entityDetails, String path1, String path2, String name) {
- String value = "";
-
- value = extractNestedValue (entityDetails, path1, path2, name);
-
- if (value != null && !value.isEmpty()) {
- return value.contains("true") ? "Y" : "N";
- } else {
- return "";
- }
- }
-
- protected String extractNestedValue (IEntityDetails entityDetails, String path1, String path2, String name) {
- String value = "";
-
- if (entityDetails.getProperties().containsKey(path1)) {
- Property path1Property = entityDetails.getProperties().get(path1);
- if (path1Property != null) {
- Map<String, Object> path1PropertyValue = (Map<String, Object>) path1Property.getValue();
- if (path1PropertyValue.containsKey(path2)) {
- Map<String, Object> path2PropertyValue = (Map<String, Object>) path1PropertyValue.get(path2);
- if (path2PropertyValue != null && path2PropertyValue.containsKey(name)) {
- value = path2PropertyValue.get(name).toString();
- }
- }
- }
- }
-
- return value;
- }
-
- protected String extractNestedValue (IEntityDetails entityDetails, String path1, String path2, String path3, String name) {
- String value = "";
-
- if (entityDetails.getProperties().containsKey(path1)) {
- Property path1Property = entityDetails.getProperties().get(path1);
- if (path1Property != null) {
- Map<String, Object> path1PropertyValue = (Map<String, Object>) path1Property.getValue();
- if (path1PropertyValue.containsKey(path2)) {
- Map<String, Object> path2PropertyValue = (Map<String, Object>) path1PropertyValue.get(path2);
- if (path2PropertyValue != null && path2PropertyValue.containsKey(path3)) {
- Map<String, Object> path3PropertyValue = (Map<String, Object>) path2PropertyValue.get(path3);
- if (path3PropertyValue != null && path3PropertyValue.containsKey(name)) {
- value = path3PropertyValue.get(name).toString();
- }
- }
- }
- }
- }
-
- return value;
- }
-
- protected String extractIntegerValue (Property property, String name) {
- String value = "";
-
- if (!property.getLeafPropertyValue(name).isEmpty()) {
- value = property.getLeafPropertyValue(name).get(0);
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractGetInputValue (IEntityDetails group, IEntityDetails entityDetails, String name) {
-
- // Extract the property on entityDetails after getting the property name from the group
- String getInputName = extractGetInputName (group, name);
- String entityPropertyValue = "";
-
- if (entityDetails.getProperties().containsKey(getInputName)) {
- Property entityProperty = entityDetails.getProperties().get(getInputName);
- entityPropertyValue = entityProperty.getValue().toString();
- }
-
- if (!entityPropertyValue.isEmpty()) {
- return entityPropertyValue;
- } else {
- return "";
- }
- }
-
- protected String extractGetInputName (IEntityDetails group, String name) {
-
- String getInputName = name;
- String groupPropertyValue = "";
- if (group.getProperties().containsKey(name)) {
- Property groupProperty = group.getProperties().get(name);
- groupPropertyValue = groupProperty.getValue().toString();
- }
- if (!groupPropertyValue.isEmpty()) {
- int getInputIndex = groupPropertyValue.indexOf("{get_input=");
- if (getInputIndex > -1) {
- getInputName = groupPropertyValue.substring(getInputIndex+11, groupPropertyValue.length()-1);
- }
- }
-
- return getInputName;
-
- }
-
- protected String extractValue (CapabilityAssignment capability, String name) {
- String value = "";
-
- if (capability.getProperties().containsKey(name)) {
- Property property = capability.getProperties().get(name);
- value = property.getLeafPropertyValue(name).get(0);
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractValue (CapabilityAssignment capability, String path, String name) {
- String value = "";
-
- if (capability.getProperties().containsKey(path)) {
- Property property = capability.getProperties().get(path);
- if (property != null && !property.getLeafPropertyValue(name).isEmpty()) {
- value = property.getLeafPropertyValue(name).get(0);
- }
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String extractBooleanValue (IEntityDetails entityDetails, String name) {
- String value = null;
- if (entityDetails.getProperties().containsKey(name)) {
- Property property = entityDetails.getProperties().get(name);
- if (property != null && property.getValue() != null) {
- value = property.getValue().toString();
- }
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value.contains("true") ? "Y" : "N";
- } else {
- return "";
- }
- }
-
- protected String extractBooleanValue (IEntityDetails entityDetails, String path, String name) {
- String value = null;
- if (entityDetails.getProperties().containsKey(path)) {
- Property property = entityDetails.getProperties().get(path);
- if (property != null) {
- if (property != null && !property.getLeafPropertyValue(name).isEmpty()) {
- value = property.getLeafPropertyValue(name).get(0);
- }
- }
- }
-
- if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
- return value.contains("true") ? "Y" : "N";
- } else {
- return "";
- }
- }
-
- protected Object extractObjectValue (IEntityDetails entityDetails, String name) {
- Object value = "";
- if (entityDetails.getProperties().containsKey(name)) {
- Property property = entityDetails.getProperties().get(name);
- if (property != null && property.getValue() != null) {
- value = property.getValue();
- }
- }
-
- if (value != null) {
- return value;
- } else {
- return "";
- }
- }
-
- public static String extractSubstitutionMappingTypeName (ISdcCsarHelper sdcCsarHelper) {
- String value = sdcCsarHelper.getServiceSubstitutionMappingsTypeName();
- if (value != null) {
- return value;
- } else {
- return "";
- }
- }
-
- protected String getUUID() {
- return ("\"" + UUID + "\"");
- }
- public String getInvariantUUID() {
- return ("\"" + invariantUUID + "\"");
- }
- public String getCustomizationUUID() {
- return ("\"" + customizationUUID + "\"");
- }
- public String getCustomizationUUIDNoQuotes() {
- return (customizationUUID);
- }
- public void setCustomizationUUID(String customizationUUID) {
- this.customizationUUID = customizationUUID;
- }
- public String getName() {
- return name;
- }
-
- public String buildSql(String tableName, String model_yaml) {
-
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT into " + tableName + " (customization_uuid, model_yaml, ");
-
- int paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- sb.append(paramKey);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(") values (" + getCustomizationUUID() + ", \"" + model_yaml + "\", ");
-
- paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- String paramValue = params.get(paramKey);
- sb.append(paramValue);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(");");
- return sb.toString();
- }
-
- public String buildSql(String tableName, String keyName, String keyValue, String model_yaml, Map<String, String> params) {
-
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT into " + tableName + " (" + keyName + ", ");
-
- int paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- sb.append(paramKey);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(") values (" + keyValue + ", ");
-
- paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- String paramValue = params.get(paramKey);
- sb.append(paramValue);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(");");
- return sb.toString();
- }
-
- public static String getSql(String tableName, String keyName, String keyValue, String model_yaml, Map<String, String> params) {
-
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT into " + tableName + " (" + keyName + ", ");
-
- int paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- sb.append(paramKey);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(") values (" + keyValue + ", ");
-
- paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- String paramValue = params.get(paramKey);
- sb.append(paramValue);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(");");
- return sb.toString();
- }
-
- protected void insertToscaData(String toscaDataString, ArrayList<String> arguments) throws IOException
- {
- LOG.debug("insertToscaData: " + toscaDataString);
-
- try {
-
- jdbcDataSource.writeData(toscaDataString, arguments, null);
-
- } catch (SQLException e) {
- LOG.error("Could not insert Tosca data into the database");
- throw new IOException (e);
- }
-
- }
-
- protected void cleanUpExistingToscaData(String tableName, String keyName, String keyValue) throws IOException
- {
-
- try {
- int rowCount = 0;
- CachedRowSet data = jdbcDataSource.getData("SELECT * from " + tableName + " where " + keyName + " = " + keyValue + ";", null, "");
- if (data != null) {
- while(data.next()) {
- rowCount ++;
- }
- if (rowCount != 0) {
- LOG.debug("cleanUpExistingToscaData from: " + tableName + " for " + keyValue);
- jdbcDataSource.writeData("DELETE from " + tableName + " where " + keyName + " = " + keyValue + ";", null, null);
- }
- }
-
- } catch (SQLException e) {
- LOG.error("Could not clean up existing " + tableName + " for " + keyValue, e);
- }
-
- }
-
- protected void cleanUpExistingToscaData(String tableName, String key1Name, String key1Value, String key2Name, String key2Value) throws IOException
- {
-
- try {
- int rowCount = 0;
- CachedRowSet data = jdbcDataSource.getData("SELECT * from " + tableName + " where " + key1Name + " = " + key1Value + " AND " + key2Name + " = " + key2Value + ";", null, "");
- if (data != null) {
- while(data.next()) {
- rowCount ++;
- }
- if (rowCount != 0) {
- LOG.debug("cleanUpExistingToscaData from : " + tableName + " for " + key1Value + " and " + key2Value);
- jdbcDataSource.writeData("DELETE from " + tableName + " where " + key1Name + " = " + key1Value + " AND " + key2Name + " = " + key2Value + ";", null, null);
- }
- }
-
- } catch (SQLException e) {
- LOG.error("Could not clean up existing " + tableName + " for " + key1Value + " and " + key2Value, e);
- }
-
- }
-
- protected boolean cleanupExistingToscaData(String tableName, Map<String, String> keyParams) throws IOException
- {
- return SdncBaseModel.cleanupExistingToscaData(SdncBaseModel.jdbcDataSource, tableName, keyParams);
- }
-
- public static boolean cleanupExistingToscaData(DBResourceManager jdbcDataSource, String tableName, Map<String, String> keyParams) throws IOException
- {
- boolean dataExists = false;
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT * from " + tableName + " where ");
-
- int paramCount = 0;
- for (String paramKey : keyParams.keySet()) {
- paramCount++;
- String paramValue = keyParams.get(paramKey);
- sb.append(paramKey);
- sb.append(" = ");
- sb.append(paramValue);
- if (paramCount < keyParams.size()) sb.append(" AND ");
- }
-
- sb.append(";");
-
- try {
- int rowCount = 0;
- CachedRowSet data = jdbcDataSource.getData(sb.toString(), null, "");
- while(data.next()) {
- rowCount ++;
- data.deleteRow();
- }
- if (rowCount != 0) {
- LOG.debug("cleanupExistingToscaData in " + tableName + ": Data FOUND");
- String deleteStmt = sb.replace(sb.indexOf("SELECT *"), sb.indexOf("SELECT")+8, "DELETE").toString();
- jdbcDataSource.writeData(deleteStmt, null, null);
- dataExists = true;
- }
-
- } catch (SQLException e) {
- LOG.error("Could not get data in " + tableName, e);
- }
-
- return dataExists;
- }
-
- protected boolean checkForExistingToscaData(String tableName, Map<String, String> keyParams) throws IOException
- {
- boolean dataExists = false;
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT * from " + tableName + " where ");
-
- int paramCount = 0;
- for (String paramKey : keyParams.keySet()) {
- paramCount++;
- String paramValue = keyParams.get(paramKey);
- sb.append(paramKey);
- sb.append(" = ");
- sb.append(paramValue);
- if (paramCount < keyParams.size()) sb.append(" AND ");
- }
-
- sb.append(";");
-
- try {
- int rowCount = 0;
- CachedRowSet data = jdbcDataSource.getData(sb.toString(), null, "");
- while(data.next()) {
- rowCount ++;
- }
- if (rowCount != 0) {
- LOG.debug("checkForExistingToscaData in " + tableName + ": Data FOUND");
- dataExists = true;
- }
-
- } catch (SQLException e) {
- LOG.error("Could not get data in " + tableName, e);
- }
-
- return dataExists;
- }
-
- protected CachedRowSet getToscaData(String tableName, Map<String, String> keyParams) throws IOException
- {
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT * from " + tableName + " where ");
-
- int paramCount = 0;
- for (String paramKey : keyParams.keySet()) {
- paramCount++;
- String paramValue = keyParams.get(paramKey);
- sb.append(paramKey);
- sb.append(" = ");
- sb.append(paramValue);
- if (paramCount < keyParams.size()) sb.append(" AND ");
- }
-
- sb.append(";");
-
- CachedRowSet data = null;
- try {
- int rowCount = 0;
- data = jdbcDataSource.getData(sb.toString(), null, "");
- while(data.next()) {
- rowCount ++;
- }
- if (rowCount == 0) {
- LOG.info("getToscaData in " + tableName + ": Data NOT found");
- }
-
- } catch (SQLException e) {
- LOG.error("Could not get data in " + tableName, e);
- }
-
- return data;
- }
-
- protected void addParamsToMap (Map<String, String> fromMap, Map<String, String> toMap) {
- for (String key : fromMap.keySet()) {
- if (!toMap.containsKey(key)) {
- toMap.put(key, fromMap.get(key));
- }
- }
- }
-
- protected String nullCheck (Object extractedObject) {
- String stringValue = "";
- if (extractedObject != null) {
- return extractedObject.toString();
- }
- return stringValue;
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModel.java
deleted file mode 100644
index 622936652..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModel.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights
- * reserved.
- * Modifications Copyright © 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncGroupModel extends SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncGroupModel.class);
-
- private static final String groupType = "group_type";
-
- public SdncGroupModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails group, IEntityDetails entityDetails, SdncUebConfiguration config, DBResourceManager jdbcDataSource) throws IOException {
-
- super(sdcCsarHelper, group);
-
- // Metadata for Resource group is not extracted in base class due to inconsistency in TOSCA model Group object
- Metadata metadata = group.getMetadata();
- params.remove("invariant_uuid"); // remove invariant_uuid which is added by base class, it does not apply for groups
- invariantUUID = extractValue (metadata, "invariantUUID");
- addParameter("group_invariant_uuid", invariantUUID);
- params.remove("uuid"); // remove uuid which is added by base class, it does not apply for groups
- UUID = extractValue (metadata, "UUID");
- addParameter("group_uuid", UUID);
- addParameter("group_name", extractValue (metadata, "name"));
- addParameter(groupType, group.getToscaType());
- addParameter("version", extractValue (metadata, "version"));
-
- // extract properties
- addParameter("vfc_parent_port_role", extractValue(group, "vfc_parent_port_role"), attributeValueParams);
- addParameter("subinterface_role", extractValue(group, "subinterface_role"), attributeValueParams);
-
- // relevant complex group properties are extracted and inserted into ATTRIBUTE_VALUE_PAIR
- addParameter(extractGetInputName (group, groupType), extractGetInputValue(group, entityDetails, groupType), attributeValueParams);
- addParameter(extractGetInputName (group, "group_role"), extractGetInputValue(group, entityDetails, "group_role"), attributeValueParams);
- addParameter(extractGetInputName (group, "group_function"), extractGetInputValue(group, entityDetails, "group_function"), attributeValueParams);
- }
-
- public void insertGroupData(String resourceUuid) throws IOException {
-
- try {
-
- // insert into RESOURCE_GROUP/ATTRIBUTE_VALUE_PAIR
- cleanUpExistingToscaData("RESOURCE_GROUP", "resource_uuid", resourceUuid, "group_uuid", getUUID()) ;
- LOG.info("Call insertToscaData for RESOURCE_GROUP where group_uuid = " + getUUID() + " and resource_uuid = " + resourceUuid);
- insertToscaData(buildSql("RESOURCE_GROUP", "resource_uuid", resourceUuid, model_yaml, params), null);
- insertRelevantAttributeData("group");
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the RESOURCE_GROUP table");
- throw new IOException (e);
- }
-
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java
deleted file mode 100644
index 8e790d9be..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModel.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncNodeModel extends SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncNodeModel.class);
-
- private String serviceUUID = null;
- private String ecompGeneratedNaming = null;
- private String [] bindingUuids = null;
-
- // Using ASDC TOSCA Parser 17.07
- public SdncNodeModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails nodeEntity, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
-
- super(sdcCsarHelper, nodeEntity, jdbcDataSource, config);
-
- // extract properties
- addParameter("ecomp_generated_naming", extractBooleanValue (nodeEntity, "exVL_naming", "ecomp_generated_naming")); // should be extractBooleanValue?
- addParameter("naming_policy", extractValue (nodeEntity, "exVL_naming", "naming_policy"));
-
- addParameter("network_type", extractValue (nodeEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- addParameter("network_role", extractValue (nodeEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- addParameter("network_scope", extractValue (nodeEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
- addParameter("network_technology", extractValue (nodeEntity, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
-
- // extract properties - network_assignments
- addParameter("is_shared_network", extractBooleanValue (nodeEntity, "network_assignments", "is_shared_network"));
- addParameter("is_external_network", extractBooleanValue (nodeEntity, "network_assignments", "is_external_network"));
- String trunkNetworkIndicator = extractBooleanValue(nodeEntity, "network_assignments", "is_trunked");
- addParameter("trunk_network_indicator", trunkNetworkIndicator);
-
- // extract properties - network_assignments - ipv4_subnet_default_assignment
- String useIpv4 = extractBooleanValue(nodeEntity, "network_assignments", "ipv4_subnet_default_assignment", "use_ipv4");
- addParameter("use_ipv4", useIpv4);
- addParameter("ipv4_dhcp_enabled", extractBooleanValue(nodeEntity, "network_assignments", "ipv4_subnet_default_assignment", "dhcp_enabled"));
- addParameter("ipv4_ip_version", extractValue(nodeEntity, "network_assignments", "ipv4_subnet_default_assignment", "ip_version"));
- addParameter("ipv4_cidr_mask", extractValue(nodeEntity, "network_assignments", "ipv4_subnet_default_assignment", "cidr_mask"));
- addParameter("eipam_v4_address_plan", extractValue(nodeEntity, "network_assignments", "ipv4_subnet_default_assignment", "ip_network_address_plan"));
-
- // extract properties - network_assignments - ipv6_subnet_default_assignment
- String useIpv6 = extractBooleanValue(nodeEntity, "network_assignments", "ipv6_subnet_default_assignment", "use_ipv6");
- addParameter("use_ipv6", useIpv6);
- addParameter("ipv6_dhcp_enabled", extractBooleanValue(nodeEntity, "network_assignments", "ipv6_subnet_default_assignment", "dhcp_enabled"));
- addParameter("ipv6_ip_version", extractValue(nodeEntity, "network_assignments", "ipv6_subnet_default_assignment", "ip_version"));
- addParameter("ipv6_cidr_mask", extractValue(nodeEntity, "network_assignments", "ipv6_subnet_default_assignment", "cidr_mask"));
- addParameter("eipam_v6_address_plan", extractValue(nodeEntity, "network_assignments", "ipv6_subnet_default_assignment", "ip_network_address_plan"));
-
- // extract properties - provider_network
- addParameter("is_provider_network", extractBooleanValue (nodeEntity, "provider_network", "is_provider_network"));
- addParameter("physical_network_name", extractValue(nodeEntity, "provider_network", "physical_network_name"));
-
- // extract properties - network_flows
- addParameter("is_bound_to_vpn", extractBooleanValue (nodeEntity, "network_flows", "is_bound_to_vpn"));
-
- // extract properties - network_flows - vpn_bindings
- String vpnBindingString = extractValue (nodeEntity, "network_flows", "vpn_binding");
- bindingUuids = vpnBindingString.split(",");
-
- }
-
- public String getServiceUUID() {
- return serviceUUID;
- }
- public void setServiceUUID(String serviceUUID) {
- this.serviceUUID = serviceUUID;
- }
-
- public String getEcompGeneratedNaming() {
- return ecompGeneratedNaming;
- }
- public void setEcompGeneratedNaming(String ecompGeneratedNaming) {
- this.ecompGeneratedNaming = ecompGeneratedNaming;
- if (ecompGeneratedNaming != null && !ecompGeneratedNaming.isEmpty()) {
- params.put("ecomp_generated_naming", "\"" + ecompGeneratedNaming + "\"");
- }
- }
- public void setComplexResourceUUID(String complexResourceUuid) {
- if (complexResourceUuid != null && !complexResourceUuid.isEmpty()) {
- params.put("complex_resource_uuid", complexResourceUuid);
- }
- }
-
- public void setComplexResourceCustomizationUUID(String complexResourceCustomizationUuid) {
- if (complexResourceCustomizationUuid != null && !complexResourceCustomizationUuid.isEmpty()) {
- params.put("complex_resource_customization_uuid", complexResourceCustomizationUuid);
- }
- }
-
- public void insertNetworkModelData () throws IOException {
- try {
- // Clean up NETWORK_MODEL data for this customization_uuid and service_uuid?
- cleanUpExistingToscaData("NETWORK_MODEL", "customization_uuid", getCustomizationUUID());
- cleanUpExistingToscaData("VPN_BINDINGS", "network_customization_uuid", getCustomizationUUID());
- LOG.info("Call insertToscaData for NETWORK_MODEL where customization_uuid = " + getCustomizationUUID());
- insertToscaData(getSql(model_yaml), null);
- insertToscaData(getVpnBindingsSql(), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the NETWORK_MODEL table");
- throw new IOException (e);
- }
- }
-
- public void insertRelatedNetworkRoleData () throws IOException {
-
- if (entityDetails.getProperties().containsKey("network_assignments")) {
-
- Map<String, Object> networkAssignmentsPropertyValue = (Map<String, Object>) entityDetails.getProperties().get("network_assignments").getValue();
-
- if (networkAssignmentsPropertyValue != null && networkAssignmentsPropertyValue.containsKey("related_networks")) {
-
- ArrayList<Map<String, String>> relatedNetworkList = (ArrayList) networkAssignmentsPropertyValue.get("related_networks");
- String networkModelCustomizationUUID = getCustomizationUUID();
-
- try {
- cleanUpExistingToscaData("RELATED_NETWORK_ROLE", "network_model_customization_uuid", networkModelCustomizationUUID);
- } catch (IOException e) {
- LOG.error("Could not clean up Tosca CSAR data in the RELATED_NETWORK_ROLE table");
- throw new IOException (e);
- }
-
- for (Map<String, String> relatedNetworkValue : relatedNetworkList) {
- String relatedNetworkRoleValue = relatedNetworkValue.get("related_network_role");
- LOG.debug("Node Template [" + entityDetails.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkRoleValue);
-
- try {
- // Table cleanup RELATED_NETWORK_ROLE occurs per network
- // If related_network_role for this service already exist in RELATED_NETWORK_ROLE, don't attempt insertion
- Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>();
- addParameter("related_network_role", relatedNetworkRoleValue, relatedNetworkRoleParamsCheck);
- addParameter("network_model_customization_uuid", networkModelCustomizationUUID, relatedNetworkRoleParamsCheck);
- if (checkForExistingToscaData("RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) {
- relatedNetworkRoleParamsCheck.remove("related_network_role");
- LOG.info("Call insertToscaData for RELATED_NETWORK_ROLE where network_model_customization_uuid = " + networkModelCustomizationUUID);
- insertToscaData(buildSql("RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRoleValue + "\"", model_yaml, relatedNetworkRoleParamsCheck), null);
- }
- } catch (IOException e) {
- LOG.debug("Could not insert Tosca CSAR data into the RELATED_NETWORK_ROLE table");
- throw new IOException (e);
- }
- }
- }
- else {
- LOG.debug("Node Template [" + entityDetails.getName() + "], property [" + "related_networks" + "] property value: " + null);
- }
- }
-
- }
-
- public String getSql(String model_yaml) {
-
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT into NETWORK_MODEL (service_uuid, customization_uuid, model_yaml, ");
-
- int paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- sb.append(paramKey);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(") values (" + serviceUUID + ", " + getCustomizationUUID() + ", \"" + model_yaml + "\", ");
-
- paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- String paramValue = params.get(paramKey);
- sb.append(paramValue);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(");");
- return sb.toString();
- }
-
- public String getVpnBindingsSql() {
-
- StringBuilder sb = new StringBuilder();
- for (int i=0; i < bindingUuids.length; i++) {
- sb.append("INSERT into VPN_BINDINGS (network_customization_uuid, binding_uuid) values (" + getCustomizationUUID() + ", \"" + bindingUuids[i] + "\"); ");
- }
-
- return sb.toString();
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncOdlConnection.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncOdlConnection.java
deleted file mode 100644
index 78d9c5bc9..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncOdlConnection.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.Authenticator;
-import java.net.HttpURLConnection;
-import java.net.PasswordAuthentication;
-import java.net.URL;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLSession;
-
-import org.apache.commons.codec.binary.Base64;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class SdncOdlConnection {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncOdlConnection.class);
-
- private HttpURLConnection httpConn = null;
-
- private String url = null;
- private String user = null;
- private String password = null;
-
- private class SdncAuthenticator extends Authenticator {
-
- private String user;
- private String passwd;
-
- SdncAuthenticator(String user, String passwd) {
- this.user = user;
- this.passwd = passwd;
- }
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(user, passwd.toCharArray());
- }
-
- }
-
- private SdncOdlConnection() {
-
- }
-
- private SdncOdlConnection(String url, String user, String password) {
- this.url = url;
- this.user = user;
- this.password = password;
-
- try {
- URL sdncUrl = new URL(url);
- Authenticator.setDefault(new SdncAuthenticator(user, password));
-
- this.httpConn = (HttpURLConnection) sdncUrl.openConnection();
- } catch (Exception e) {
- LOG.error("Unable to create http connection", e);
- }
- }
-
- public static SdncOdlConnection newInstance(String url, String user, String password) throws IOException
- {
- return new SdncOdlConnection(url, user, password);
- }
-
-
-
- public String send(String method, String contentType, String msg) throws IOException {
-
- LOG.info("Sending REST " + method + " to " + url);
- LOG.info("Message body:\n" + msg);
- String authStr = user + ":" + password;
- String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
-
- httpConn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
-
- httpConn.setRequestMethod(method);
- httpConn.setRequestProperty("Content-Type", contentType);
- httpConn.setRequestProperty("Accept", contentType);
-
- httpConn.setDoInput(true);
- httpConn.setDoOutput(true);
- httpConn.setUseCaches(false);
-
- if (httpConn instanceof HttpsURLConnection) {
- HostnameVerifier hostnameVerifier = new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- };
- ((HttpsURLConnection) httpConn).setHostnameVerifier(hostnameVerifier);
- }
-
- // Write message
- httpConn.setRequestProperty("Content-Length", "" + msg.length());
- DataOutputStream outStr = new DataOutputStream(httpConn.getOutputStream());
- outStr.write(msg.getBytes());
- outStr.close();
-
- // Read response
- BufferedReader respRdr;
-
- LOG.info("Response: " + httpConn.getResponseCode() + " " + httpConn.getResponseMessage());
-
- if (httpConn.getResponseCode() < 300) {
-
- respRdr = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
- } else {
- respRdr = new BufferedReader(new InputStreamReader(httpConn.getErrorStream()));
- }
-
- StringBuilder respBuff = new StringBuilder();
-
- String respLn;
-
- while ((respLn = respRdr.readLine()) != null) {
- respBuff.append(respLn + "\n");
- }
- respRdr.close();
-
- String respString = respBuff.toString();
-
- LOG.info("Response body :\n" + respString);
-
- return respString;
-
- }
-
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModel.java
deleted file mode 100644
index 296b13819..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModel.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncPNFModel extends SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncVFModel.class);
-
- private String vendor = null;
- private String vendorModelDescription = null;
- private String nfNamingCode = null;
- private String serviceUUID = null;
- private String serviceInvariantUUID = null;
-
- public SdncPNFModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
-
- super(sdcCsarHelper, entityDetails, jdbcDataSource, config);
-
- // extract metadata
- Metadata metadata = entityDetails.getMetadata();
- addParameter("name", extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME));
- vendor = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR);
- addParameter("vendor", vendor);
- vendorModelDescription = extractValue (metadata, "description");
- addParameter("vendor_version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE));
-
- // extract properties
- addParameter("ecomp_generated_naming", extractBooleanValue(entityDetails, "nf_naming#ecomp_generated_naming"));
- addParameter("naming_policy", extractValue(entityDetails, "nf_naming#naming_policy"));
- addParameter("nf_type", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- addParameter("nf_role", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- nfNamingCode = extractValue(entityDetails, "nf_naming_code");
- addParameter("nf_code", nfNamingCode);
- addParameter("nf_function", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- addIntParameter("avail_zone_max_count", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONEMAXCOUNT));
- addParameter("sdnc_model_name", extractValue(entityDetails, "sdnc_model_name"));
- addParameter("sdnc_model_version", extractValue(entityDetails, "sdnc_model_version"));
- addParameter("sdnc_artifact_name", extractValue(entityDetails, "sdnc_artifact_name"));
-
- }
-
- public void insertData() throws IOException {
-
- insertPNFModelData();
- }
-
- private void insertPNFModelData () throws IOException {
-
- try {
- cleanUpExistingToscaData("VF_MODEL", "customization_uuid", getCustomizationUUID()) ;
- cleanUpExistingToscaData("SERVICE_MODEL_TO_VF_MODEL_MAPPING", "service_uuid", serviceUUID, "vf_customization_uuid", getCustomizationUUID());
-
- // insert into VF_MODEL/ATTRIBUTE_VALUE_PAIR and SERVICE_MODEL_TO_VF_MODEL_MAPPING
- LOG.info("Call insertToscaData for VF_MODEL where customization_uuid = " + getCustomizationUUID());
- insertToscaData(buildSql("VF_MODEL", model_yaml), null);
- //insertRelevantAttributeData();
-
- Map<String, String> mappingParams = new HashMap<String, String>();
- addParameter("service_invariant_uuid", serviceInvariantUUID, mappingParams);
- addParameter("vf_uuid", getUUID(), mappingParams);
- addParameter("vf_customization_uuid", getCustomizationUUIDNoQuotes(), mappingParams);
- insertToscaData(buildSql("SERVICE_MODEL_TO_VF_MODEL_MAPPING", "service_uuid", serviceUUID, model_yaml, mappingParams), null);
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VF_MODEL table");
- throw new IOException (e);
- }
-
- }
-
- public String getVendor() {
- return vendor;
- }
-
- public void setVendor(String vendor) {
- this.vendor = vendor;
- }
-
- public String getVendorModelDescription() {
- return vendorModelDescription;
- }
-
- public void setVendorModelDescription(String vendorModelDescription) {
- this.vendorModelDescription = vendorModelDescription;
- }
-
- public String getNfNamingCode() {
- return nfNamingCode;
- }
-
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
-
- public String getServiceUUID() {
- return serviceUUID;
- }
- public void setServiceUUID(String serviceUUID) {
- this.serviceUUID = serviceUUID;
- }
-
- public String getServiceInvariantUUID() {
- return serviceInvariantUUID;
- }
-
- public void setServiceInvariantUUID(String serviceInvariantUUID) {
- this.serviceInvariantUUID = serviceInvariantUUID;
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java
deleted file mode 100644
index 52e38624a..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModel.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncServiceModel extends SdncBaseModel {
-
- private String UUID = null;
- private String resourceVendor = null;
- private String resourceVendorRelease = null;
- private String serviceInstanceNamePrefix = null;
- private String filename = null;
-
- public SdncServiceModel(ISdcCsarHelper sdcCsarHelper, Metadata metadata, DBResourceManager jdbcDataSource) {
-
- super(sdcCsarHelper, metadata, jdbcDataSource);
-
- UUID = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_UUID);
-
- // extract ecompGeneratedNaming and namingPolicy from Service Metadata
- addParameter("ecomp_naming",extractBooleanValue(metadata, "ecompGeneratedNaming"));
- addParameter("naming_policy",extractValue(metadata, "namingPolicy"));
-
- // extract service topology template input data - ecompGeneratedNaming and namingPolicy moved to Service Metadata
- //addParameter("ecomp_naming",extractBooleanInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING));
- //addParameter("naming_policy",extractInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_NAMINGPOLICY));
-
- // extract resourceVendor and resourceVendorRelease for use in SdncServiceProxy class
- resourceVendor = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR);
- resourceVendorRelease = extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE);
- }
-
- public String getServiceUUID() {
- return "\"" + UUID + "\"";
- }
- public void setServiceUUID(String serviceUUID) {
- this.UUID = serviceUUID;
- }
- public String getServiceInvariantUUID() {
- return "\"" + invariantUUID + "\"";
- }
- public String getServiceInstanceNamePrefix() {
- return serviceInstanceNamePrefix;
- }
- public void setServiceInstanceNamePrefix(String serviceInstanceNamePrefix) {
- if (serviceInstanceNamePrefix != null && !serviceInstanceNamePrefix.isEmpty()) {
- this.serviceInstanceNamePrefix = serviceInstanceNamePrefix;
- params.put("service_instance_name_prefix", "\"" + serviceInstanceNamePrefix + "\"");
- }
- }
- public String getFilename() {
- return filename;
- }
- public void setFilename(String filename) {
- this.filename = filename;
- }
-
- public String getSql(String model_yaml) {
-
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT into SERVICE_MODEL (service_uuid, model_yaml, filename, ");
-
- int paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- sb.append(paramKey);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(") values (" + getServiceUUID() + ", \"" + model_yaml + "\", \"" + filename + "\", ");
-
- paramCount = 0;
- for (String paramKey : params.keySet()) {
- paramCount++;
- String paramValue = params.get(paramKey);
- sb.append(paramValue);
- if (paramCount < params.size()) sb.append(", ");
- }
-
- sb.append(");");
- return sb.toString();
- }
-
- public String getResourceVendor() {
- return resourceVendor;
- }
-
- public void setResourceVendor(String resourceVendor) {
- this.resourceVendor = resourceVendor;
- }
-
- public String getResourceVendorRelease() {
- return resourceVendorRelease;
- }
-
- public void setResourceVendorRelease(String resourceVendorRelease) {
- this.resourceVendorRelease = resourceVendorRelease;
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
deleted file mode 100644
index 8c3a290e0..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
+++ /dev/null
@@ -1,1263 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.Authenticator;
-import java.net.HttpURLConnection;
-import java.net.PasswordAuthentication;
-import java.net.URL;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.sql.SQLException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.sql.rowset.CachedRowSet;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
-import javax.xml.XMLConstants;
-
-import org.apache.commons.codec.binary.Base64;
-import org.onap.sdc.api.IDistributionClient;
-import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
-import org.onap.sdc.api.consumer.IDistributionStatusMessage;
-import org.onap.sdc.api.consumer.INotificationCallback;
-import org.onap.sdc.api.notification.IArtifactInfo;
-import org.onap.sdc.api.notification.INotificationData;
-import org.onap.sdc.api.notification.IResourceInstance;
-import org.onap.sdc.api.results.IDistributionClientDownloadResult;
-import org.onap.sdc.api.results.IDistributionClientResult;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
-import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.tosca.parser.enums.SdcTypes;
-import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.sdc.utils.ArtifactTypeEnum;
-import org.onap.sdc.utils.DistributionActionResultEnum;
-import org.onap.sdc.utils.DistributionStatusEnum;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.onap.ccsdk.sli.northbound.uebclient.SdncArtifactMap.SdncArtifactType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-public class SdncUebCallback implements INotificationCallback {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncUebCallback.class);
-
- protected static DBResourceManager jdbcDataSource = null;
- private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
- private static final String COMPONENT_NAME = "SDNC";
- private static final int NUM_PASSES = 2;
-
- // If any ASDC artifact in a distribution fails to download or deploy send SDC event COMPONENT_DONE_ERROR
- // once after the entire distribution is processed. Otherwise, send COMPONENT_DONE_OK.
- private static boolean COMPONENT_DOWNLOAD_ERROR = false;
- private static boolean COMPONENT_DEPLOY_ERROR = false;
- private static boolean CSAR_ARTIFACT_DEPLOY_ERROR = false;
-
- private class SdncAuthenticator extends Authenticator {
-
- private final String user;
- private final String passwd;
-
- SdncAuthenticator(String user, String passwd) {
- this.user = user;
- this.passwd = passwd;
- }
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(user, passwd.toCharArray());
- }
-
- }
-
- private class DeployableArtifact {
- SdncArtifactType type;
- IArtifactInfo artifactInfo;
- String svcName;
- String resourceName;
- String artifactName;
- String artifactVersion;
- File file;
-
- public String getArtifactName() {
- return artifactName;
- }
-
-
-
- public String getArtifactVersion() {
- return artifactVersion;
- }
-
-
- public SdncArtifactType getType() {
- return type;
- }
-
-
-
- public IArtifactInfo getArtifactInfo() {
- return artifactInfo;
- }
-
-
- public File getFile() {
- return file;
- }
-
-
-
-
- public DeployableArtifact(SdncArtifactType type, String svcName, String resourceName, IArtifactInfo artifactInfo, File file) {
- this.type = type;
- this.artifactInfo = artifactInfo;
- this.svcName = svcName;
- this.resourceName = resourceName;
- this.artifactName = artifactInfo.getArtifactName();
- this.artifactVersion = artifactInfo.getArtifactVersion();
- this.file = file;
- }
-
-
- public DeployableArtifact(SdncArtifactType type, String svcName, String resourceName, String artifactName, String artifactVersion, File file) {
- this.type = type;
- this.artifactInfo = null;
- this.svcName = svcName;
- this.resourceName = resourceName;
- this.artifactName = artifactName;
- this.artifactVersion = artifactVersion;
- this.file = file;
- }
-
-
-
- public String getSvcName() {
- return svcName;
- }
-
-
-
- public String getResourceName() {
- return resourceName;
- }
-
- }
-
- private final IDistributionClient client;
- protected final SdncUebConfiguration config;
-
- private LinkedList<DeployableArtifact> deployList[];
-
-
- private static void setJdbcDataSource() throws IOException {
-
- String propPath = null;
- String propDir = System.getenv(SDNC_CONFIG_DIR);
- if (propDir == null) {
-
- propDir = "/opt/sdnc/data/properties";
- }
- propPath = propDir + "/dblib.properties";
- File propFile = new File(propPath);
-
- if (!propFile.exists()) {
-
- throw new FileNotFoundException(
- "Missing configuration properties file : "
- + propFile);
- }
-
- Properties props = new Properties();
- props.load(new FileInputStream(propFile));
-
- setJdbcDataSource(new DBResourceManager(props));
- }
-
- static void setJdbcDataSource(DBResourceManager dbMgr) {
-
- jdbcDataSource = dbMgr;
-
- if(jdbcDataSource.isActive()){
- LOG.warn( "DBLIB: JDBC DataSource has been initialized.");
- } else {
- LOG.warn( "DBLIB: JDBC DataSource did not initialize successfully.");
- }
- }
-
- private static void loadArtifactMap() {
-
- }
-
- public SdncUebCallback(IDistributionClient client, SdncUebConfiguration config) {
- this.client = client;
- this.config = config;
-
- this.deployList = new LinkedList[NUM_PASSES];
-
- for (int i = 0 ; i < NUM_PASSES ; i++) {
- this.deployList[i] = new LinkedList<DeployableArtifact>();
- }
- }
-
- @Override
- public void activateCallback(INotificationData data) {
-
- LOG.info("Received notification : ("+data.getDistributionID()+","+data.getServiceName()+","+data.getServiceVersion()+
- ","+data.getServiceDescription() + ")");
-
- COMPONENT_DOWNLOAD_ERROR = false;
- COMPONENT_DEPLOY_ERROR = false;
- CSAR_ARTIFACT_DEPLOY_ERROR = false;
-
- // TOSCA_TEMPLATE artifact should only be downloaded if TOSCA_CSAR artifact fails due to version non-compliance
- IArtifactInfo toscaTemplateArtifact = null;
-
- String incomingDirName = config.getIncomingDir();
- String archiveDirName = config.getArchiveDir();
-
- File incomingDir = new File(incomingDirName);
- File archiveDir = new File(archiveDirName);
-
- LOG.debug("IncomingDirName is {}", incomingDirName);
-
- if (!incomingDir.exists()) {
- incomingDir.mkdirs();
- }
-
-
- if (!archiveDir.exists()) {
- archiveDir.mkdirs();
- }
-
- // Process service level artifacts
- List<IArtifactInfo> artifactList = data.getServiceArtifacts();
-
- if (artifactList != null) {
-
- incomingDir = new File(incomingDirName + "/" + escapeFilename(data.getServiceName()));
- if (!incomingDir.exists()) {
- incomingDir.mkdirs();
- }
-
- archiveDir = new File(archiveDirName + "/" + escapeFilename(data.getServiceName()));
- if (!archiveDir.exists()) {
- archiveDir.mkdirs();
- }
- for (IArtifactInfo curArtifact : artifactList)
- {
-
- LOG.info("Received artifact " + curArtifact.getArtifactName());
-
- // If artifact is TOSCA_TEMPLATE, don't handle it. We will handle if last TOSCA_CSAR ingestion fails.
- if (curArtifact.getArtifactType().contains("TOSCA_TEMPLATE") || curArtifact.getArtifactName().contains(".yml")) {
- toscaTemplateArtifact = curArtifact;
- } else {
-
- handleArtifact(data, data.getServiceName(), null, null, curArtifact, incomingDir, archiveDir);
- }
- }
-
- // After all artifacts have been processed if CSAR_ARTIFACT_DEPLOY_ERROR is true, download and deploy the TOSCA_TEMPLATE artifact
- if (CSAR_ARTIFACT_DEPLOY_ERROR == true) {
- LOG.info("TOSCA_CSAR artifact deploy error encountered, downloading TOSCA_TEMPLATE artifact: " + toscaTemplateArtifact.getArtifactName());
- handleArtifact(data, data.getServiceName(), null, null, toscaTemplateArtifact, incomingDir, archiveDir);
- }
- }
-
-
- // Process resource level artifacts
- for (IResourceInstance curResource : data.getResources()) {
-
- LOG.info("Received resource : "+curResource.getResourceName());
- artifactList = curResource.getArtifacts();
-
- if (artifactList != null) {
-
- incomingDir = new File(incomingDirName + "/" + escapeFilename(data.getServiceName()) + "/" + escapeFilename(curResource.getResourceName()));
- if (!incomingDir.exists()) {
- incomingDir.mkdirs();
- }
-
- archiveDir = new File(archiveDirName + "/" + escapeFilename(data.getServiceName()) + "/" + escapeFilename(curResource.getResourceName()));
- if (!archiveDir.exists()) {
- archiveDir.mkdirs();
- }
- for (IArtifactInfo curArtifact : artifactList)
- {
-
- LOG.info("Received artifact " + curArtifact.getArtifactName());
-
- handleArtifact(data, data.getServiceName(), curResource.getResourceName(), curResource.getResourceType(), curArtifact, incomingDir, archiveDir);
- }
- }
- }
-
- deployDownloadedFiles(incomingDir, archiveDir, data);
-
- // Send Component Status: COMPONENT_DONE_ERROR or COMPONENT_DONE_OK
- LOG.info("Sending Component Status for Distribution: ("+data.getDistributionID()+","+data.getServiceName()+","+data.getServiceVersion()+
- ","+data.getServiceDescription() + ")");
- IDistributionClientResult result = null;
- if (COMPONENT_DOWNLOAD_ERROR == true || COMPONENT_DEPLOY_ERROR == true) {
-
- String errorReason = (COMPONENT_DEPLOY_ERROR == true ? "SDN-C encountered an error deploying an artifact in this distribution" : "");
- errorReason = (COMPONENT_DOWNLOAD_ERROR == true ? "SDN-C encountered an error downloading an artifact in this distribution" : errorReason);
- result = client.sendComponentDoneStatus(buildComponentStatusMessage(
- client, data, DistributionStatusEnum.COMPONENT_DONE_ERROR), errorReason);
- if (result != null) {
- LOG.info("Sending Component Status COMPONENT_DONE_ERROR for Distribution result: " + result.getDistributionMessageResult());
- }
- } else {
-
- result = client.sendComponentDoneStatus(buildComponentStatusMessage(
- client, data, DistributionStatusEnum.COMPONENT_DONE_OK));
- if (result != null) {
- LOG.info("Sending Component Status COMPONENT_DONE_OK for Distribution result: " + result.getDistributionMessageResult());
- }
- }
-
- }
-
-
- public void deployDownloadedFiles(File incomingDir, File archiveDir, INotificationData data) {
-
- if (incomingDir == null) {
- LOG.debug("incomingDir is null - using {}", config.getIncomingDir());
- incomingDir = new File(config.getIncomingDir());
-
- if (!incomingDir.exists()) {
- incomingDir.mkdirs();
- }
-
- } else {
- LOG.debug("incomingDir is not null - it is {}", incomingDir.getPath());
- }
-
- if (archiveDir == null) {
- archiveDir = new File(config.getArchiveDir());
-
- if (!archiveDir.exists()) {
- archiveDir.mkdirs();
- }
- }
-
- String curFileName = "";
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(incomingDir.toPath())) {
- for (Path file: stream) {
- curFileName = file.toString();
- // Skip TOSCA files (csar and yml) if we are deploying files that were downloaded from ASDC (data is not NULL),
- // they have already been deployed. If they are still in the incoming directory there was an error during ingestion.
- if (data != null && (curFileName.contains(".csar") || curFileName.contains(".yml"))) {
- LOG.info("Skipping deploy of file TOSCA file: "+ curFileName + " it has already been handled");
- continue;
- }
-
- try {
- handleSuccessfulDownload(null,null, null, null, file.toFile(), archiveDir);
- } catch (Exception x) {
- COMPONENT_DEPLOY_ERROR = true;
- LOG.error("Exception in handleSuccessfulDownload: Cannot process spool file "+ curFileName, x);
- }
-
- }
- } catch (Exception x) {
- // IOException can never be thrown by the iteration.
- // In this snippet, it can only be thrown by newDirectoryStream.
- LOG.warn("Cannot process spool file "+ curFileName, x);
- }
-
- // Deploy scheduled deployments
- /*int numPasses = config.getMaxPasses();
-
- deployList = new LinkedList[numPasses];
-
- for (int i = 0 ; i < numPasses ; i++) {
- deployList[i] = new LinkedList<DeployableArtifact>();
- }*/
- for (int pass = 0 ; pass < config.getMaxPasses() ; pass++) {
-
- if (deployList[pass] != null) {
- while (! deployList[pass].isEmpty()) {
- DeployableArtifact artifact = deployList[pass].pop();
-
- DistributionStatusEnum deployResult = DistributionStatusEnum.DEPLOY_ERROR;
-
-
- try {
-
- deployResult = deploySpoolFile(artifact);
- } catch (Exception e) {
- LOG.error("Caught exception trying to deploy file", e);
- }
-
-
- IArtifactInfo artifactInfo = artifact.getArtifactInfo();
-
- if ((artifactInfo != null) && (data != null)) {
- IDistributionClientResult deploymentStatus;
- deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(
- client, data, artifactInfo,
- deployResult));
- if (deployResult == DistributionStatusEnum.DEPLOY_ERROR) {
- COMPONENT_DEPLOY_ERROR = true;
- }
- }
-
- }
- }
- }
- }
-
- private void handleArtifact(INotificationData data, String svcName, String resourceName, String resourceType, IArtifactInfo artifact, File incomingDir, File archiveDir) {
-
- // Download Artifact
- IDistributionClientDownloadResult downloadResult = client.download(artifact);
-
- if (downloadResult == null) {
-
- handleFailedDownload(data, artifact);
- return;
- }
-
- byte[] payloadBytes = downloadResult.getArtifactPayload();
-
- if (payloadBytes == null) {
- handleFailedDownload(data, artifact);
- return;
- }
-
- boolean writeSucceeded = false;
- File spoolFile = new File(incomingDir.getAbsolutePath() + "/" + artifact.getArtifactName());
-
- // Save zip if TOSCA_CSAR
- if (artifact.getArtifactType().contains("TOSCA_CSAR") || artifact.getArtifactName().contains(".csar")) {
-
- try(FileOutputStream outFile = new FileOutputStream(incomingDir.getAbsolutePath() + "/" + artifact.getArtifactName())) {
- outFile.write(payloadBytes, 0, payloadBytes.length);
- writeSucceeded = true;
- } catch (Exception e) {
- LOG.error("Unable to save downloaded zip file to spool directory ("+ incomingDir.getAbsolutePath() +")", e);
- }
-
- } else {
-
- String payload = new String(payloadBytes);
-
- try(FileWriter spoolFileWriter = new FileWriter(spoolFile)) {
- spoolFileWriter.write(payload);
- writeSucceeded = true;
- } catch (Exception e) {
- LOG.error("Unable to save downloaded file to spool directory ("+ incomingDir.getAbsolutePath() +")", e);
- }
- }
-
-
- if (writeSucceeded && (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS)) {
- handleSuccessfulDownload(data, svcName, resourceName, artifact, spoolFile, archiveDir);
-
-
- } else {
- handleFailedDownload(data, artifact);
- }
-
- }
-
- private void handleFailedDownload(INotificationData data,
- IArtifactInfo relevantArtifact) {
- // Send Download Status
- client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_ERROR));
- COMPONENT_DOWNLOAD_ERROR = true;
- }
-
- private void handleSuccessfulDownload(INotificationData data, String svcName, String resourceName,
- IArtifactInfo artifact, File spoolFile, File archiveDir) {
-
- if ((data != null) && (artifact != null)) {
- // Send Download Status
- IDistributionClientResult sendDownloadStatus = client
- .sendDownloadStatus(buildStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK));
- }
-
- // If an override file exists, read that instead of the file we just downloaded
- ArtifactTypeEnum artifactEnum = ArtifactTypeEnum.YANG_XML;
-
- String overrideFileName = config.getOverrideFile();
- if ((overrideFileName != null) && (overrideFileName.length() > 0)) {
- File overrideFile = new File(overrideFileName);
-
- if (overrideFile.exists()) {
- artifactEnum = ArtifactTypeEnum.YANG_XML;
- spoolFile = overrideFile;
- }
-
- }
-
- // If the artifact is a TOSCA artifact, don't schedule a deployment to SDN-C REST intfc, process it in ueb-listener
- if (artifactIsTosca(artifact, spoolFile) == true)
- {
- handleToscaArtifact (data, svcName, resourceName, artifact, spoolFile, archiveDir);
- return;
- }
-
- processSpoolFile (data, svcName, resourceName, artifact, spoolFile, archiveDir);
-
- }
-
- protected void processSpoolFile(INotificationData data, String svcName, String resourceName,
- IArtifactInfo artifact, File spoolFile, File archiveDir) {
-
- // Process spool file
- Document spoolDoc = null;
- File transformedFile = null;
-
- // Apply XSLTs and get Doc object
- try {
- if (!spoolFile.isDirectory()) {
- transformedFile = applyXslts(spoolFile);
- }
- } catch (Exception e) {
- LOG.error("Caught exception trying to parse XML file", e);
- }
-
- if (transformedFile != null) {
- try {
-
- try {
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory
- .newInstance();
- dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
- dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- DocumentBuilder db = dbf.newDocumentBuilder();
-
- spoolDoc = db.parse(transformedFile);
- } catch (Exception e) {
- LOG.error(
- "Caught exception trying to parse transformed XML file "
- + transformedFile.getAbsolutePath(), e);
- }
-
- } catch (Exception e) {
- LOG.error("Caught exception trying to deploy file", e);
- }
- }
-
- ArtifactTypeEnum artifactEnum = ArtifactTypeEnum.YANG_XML;
- if (spoolDoc != null) {
- // Analyze file type
- SdncArtifactType artifactType = analyzeFileType(artifactEnum,
- spoolFile, spoolDoc);
-
- if (artifactType != null) {
-
- scheduleDeployment(artifactType, svcName, resourceName, artifact, spoolFile.getName(), transformedFile);
-
- }
-
- // SDNGC-2660 : Move file to archive directory even if it is an unrecognized type so that
- // we do not keep trying and failing to process it.
- try {
- Path source = spoolFile.toPath();
- Path targetDir = archiveDir.toPath();
-
- Files.move(source, targetDir.resolve(source.getFileName()), StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e) {
- LOG.warn("Could not move "+spoolFile.getAbsolutePath()+" to "+archiveDir.getAbsolutePath(), e);
- }
- }
-
- }
-
- private void handleToscaArtifact (INotificationData data, String svcName, String resourceName, IArtifactInfo artifact,
- File spoolFile, File archiveDir) {
-
- DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- if ((artifact != null && artifact.getArtifactType().contains("TOSCA_TEMPLATE")) || spoolFile.toString().contains(".yml")) {
- deployStatus = processToscaYaml (spoolFile);
- } else if ((artifact != null && artifact.getArtifactType().contains("TOSCA_CSAR")) || spoolFile.toString().contains(".csar")) {
- deployStatus = processToscaCsar (data, svcName, resourceName, artifact, spoolFile, archiveDir);
- // if parser error on CSAR, process the TOSCA_TEMPLATE artifact last
- if (deployStatus.equals(DistributionStatusEnum.DEPLOY_ERROR)) {
- CSAR_ARTIFACT_DEPLOY_ERROR = true;
- }
-
- } else {
- LOG.error("handleToscaArtifact: Encountered unknown TOSCA artifact");
- }
-
- if (deployStatus.equals(DistributionStatusEnum.DEPLOY_OK)) {
- LOG.info("Update to SDN-C succeeded");
-
- try {
- Path source = spoolFile.toPath();
- Path targetDir = archiveDir.toPath();
-
- Files.move(source, targetDir.resolve(source.getFileName()), StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e) {
- LOG.warn("Could not move "+spoolFile.getAbsolutePath()+" to "+archiveDir.getAbsolutePath(), e);
- }
-
- } else {
- LOG.info("Update to SDN-C failed");
- COMPONENT_DEPLOY_ERROR = true;
- }
-
- // Send deployment status for ingestion
- if ((artifact != null) && (data != null)) {
- client.sendDeploymentStatus(buildStatusMessage(client, data, artifact,deployStatus));
- }
- }
-
- protected DistributionStatusEnum processToscaYaml(File spoolFile) {
-
- return DistributionStatusEnum.DEPLOY_OK;
- }
-
-
- private DistributionStatusEnum processToscaCsar(INotificationData data, String svcName, String resourceName, IArtifactInfo artifact,
- File spoolFile, File archiveDir) {
-
- // Use ASDC Dist Client 1.1.5 with TOSCA parsing APIs to extract relevant TOSCA model data
-
- // TOSCA data extraction flow 1707:
- // Use ASDC dist-client to get yaml string - not yet available
- String model_yaml = null;
- LOG.info("Process TOSCA CSAR file: "+spoolFile.toString());
- ISdcCsarHelper sdcCsarHelper = null;
- DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
-
- try {
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath());
- } catch (SdcToscaParserException e) {
- LOG.error("Could not create SDC TOSCA Parser ", e);
- return DistributionStatusEnum.DEPLOY_ERROR;
- }
-
- // Ingest Service Data - 1707
- Metadata serviceMetadata = sdcCsarHelper.getServiceMetadata();
- SdncServiceModel serviceModel = new SdncServiceModel(sdcCsarHelper, serviceMetadata, jdbcDataSource);
- serviceModel.setFilename(spoolFile.toString().substring(spoolFile.toString().lastIndexOf("/")+1)); // will be csar file name
- serviceModel.setServiceInstanceNamePrefix(SdncBaseModel.extractSubstitutionMappingTypeName(sdcCsarHelper).substring(SdncBaseModel.extractSubstitutionMappingTypeName(sdcCsarHelper).lastIndexOf(".")+1));
-
- try {
- cleanUpExistingToscaServiceData(serviceModel.getServiceUUID());
- LOG.info("Call insertToscaData for SERVICE_MODEL where service_uuid = " + serviceModel.getServiceUUID());
- insertToscaData(serviceModel.getSql(model_yaml), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the SERVICE_MODEL table ", e);
- return DistributionStatusEnum.DEPLOY_ERROR;
-
- }
-
- // Ingest Network (VL) Data - 1707 / migrate to getEntity - 1908
- EntityQuery vlEntityQuery = EntityQuery.newBuilder(SdcTypes.VL).build();
- TopologyTemplateQuery vlTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
- List<IEntityDetails> vlEntities = sdcCsarHelper.getEntity(vlEntityQuery, vlTopologyTemplateQuery, false); // false to not recurse
- if (vlEntities != null && !vlEntities.isEmpty()) {
- for (IEntityDetails vlEntity : vlEntities){
-
- try {
- SdncNodeModel nodeModel = new SdncNodeModel (sdcCsarHelper, vlEntity, jdbcDataSource, config);
- nodeModel.setServiceUUID(serviceModel.getServiceUUID());
-
- nodeModel.insertNetworkModelData();
- nodeModel.insertRelatedNetworkRoleData();
- } catch (IOException e) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
- }
- }
-
- // Ingest Allotted Resource Data - 1707 / migrate to getEntity - 1908
- // Use getEntity to get all VFs in the service filter by metadata Category = Allotted Resource
- EntityQuery vfEntityQuery = EntityQuery.newBuilder(SdcTypes.VF).build();
- TopologyTemplateQuery vfTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
- List<IEntityDetails> vfEntities = sdcCsarHelper.getEntity(vfEntityQuery, vfTopologyTemplateQuery, true);
- if (vfEntities != null) {
- for (IEntityDetails vfEntity : vfEntities){
-
- // If this VF has metadata Category: Allotted Resource, insert it into ALLOTTED_RESOURCE_MODEL table
- String vfCategory = SdncBaseModel.extractValue(sdcCsarHelper, vfEntity.getMetadata(), "category");
- if (vfCategory.contains("Allotted Resource")) {
-
- try {
- SdncARModel arModel = new SdncARModel (sdcCsarHelper, vfEntity, jdbcDataSource, config);
- arModel.insertAllottedResourceModelData ();
- arModel.insertAllottedResourceVfcModelData();
- } catch (IOException e) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
- }
- }
- }
-
- // Ingest Network (VF) Data - 1707 / migrate to getEntity - 1911
- // Use getEntity to get all VFs in the service
- if (vfEntities != null) {
- for (IEntityDetails vfEntity : vfEntities){
-
- SdncVFModel vfNodeModel = null;
- try {
- vfNodeModel = new SdncVFModel (sdcCsarHelper, vfEntity, jdbcDataSource, config);
- vfNodeModel.setServiceUUID(serviceModel.getServiceUUID());
- vfNodeModel.setServiceInvariantUUID(serviceModel.getServiceInvariantUUID());
- vfNodeModel.insertData();
-
- } catch (IOException e) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
-
- // For each VF, insert VNF Configuration data
- DistributionStatusEnum vnfConfigDeployStatus = customProcessVnfConfig(sdcCsarHelper, vfNodeModel, jdbcDataSource);
- if (vnfConfigDeployStatus == DistributionStatusEnum.DEPLOY_ERROR) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
-
- } // VF loop
- }
-
-
- // Ingest Network (PNF) Data - Dublin/1906
- EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
-
- List<IEntityDetails> pnfs = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- if (!pnfs.isEmpty()) {
-
- for (IEntityDetails pnf : pnfs) {
-
- try {
- SdncPNFModel pnfModel = new SdncPNFModel(sdcCsarHelper, pnf, jdbcDataSource, config);
- pnfModel.setServiceUUID(serviceModel.getServiceUUID());
- pnfModel.setServiceInvariantUUID(serviceModel.getServiceInvariantUUID());
- pnfModel.insertData();
-
- } catch (IOException e) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
- } // PNF loop
- }
-
- DistributionStatusEnum complexToscaDeployStatus = customProcessComplexTosca(sdcCsarHelper, config, jdbcDataSource, serviceModel,
- data, svcName, resourceName, artifact, archiveDir);
- if (complexToscaDeployStatus == DistributionStatusEnum.DEPLOY_ERROR) {
- deployStatus = DistributionStatusEnum.DEPLOY_ERROR;
- }
-
- return deployStatus;
- }
-
- protected DistributionStatusEnum customProcessVnfConfig(ISdcCsarHelper sdcCsarHelper,
- SdncVFModel vfNodeModel, DBResourceManager jdbcDataSource2) {
- return DistributionStatusEnum.DEPLOY_OK;
- }
-
- protected DistributionStatusEnum customProcessComplexTosca(ISdcCsarHelper sdcCsarHelper,
- SdncUebConfiguration config, DBResourceManager jdbcDataSource2, SdncServiceModel serviceModelINotification,
- INotificationData data, String svcName, String resourceName, IArtifactInfo artifact, File archiveDir) {
- return DistributionStatusEnum.DEPLOY_OK;
- }
-
- protected void cleanUpExistingToscaData(String tableName, String keyName, String keyValue) throws IOException
- {
-
- if (jdbcDataSource == null) {
- setJdbcDataSource();
- }
- try {
- int rowCount = 0;
- CachedRowSet data = jdbcDataSource.getData("SELECT * from " + tableName + " where " + keyName + " = " + keyValue + ";", null, "");
- while(data.next()) {
- rowCount ++;
- }
- if (rowCount != 0) {
- LOG.info("cleanUpExistingToscaData: " + keyValue);
- jdbcDataSource.writeData("DELETE from " + tableName + " where " + keyName + " = " + keyValue + ";", null, null);
- }
-
- } catch (SQLException e) {
- LOG.error("Could not clean up existing " + tableName + " for " + keyValue, e);
- }
-
- }
-
-
- protected void cleanUpExistingToscaServiceData(String serviceUUID) throws IOException
- {
-
- if (jdbcDataSource == null) {
- setJdbcDataSource();
- }
- try {
- int rowCount = 0;
- CachedRowSet data = jdbcDataSource.getData("SELECT * from SERVICE_MODEL where service_uuid = " + serviceUUID + ";", null, "");
- while(data.next()) {
- rowCount ++;
- }
- if (rowCount != 0) {
- LOG.info("cleanUpExistingToscaData: " + serviceUUID);
- jdbcDataSource.writeData("DELETE from NETWORK_MODEL where service_uuid = " + serviceUUID + ";", null, null);
- jdbcDataSource.writeData("DELETE from SERVICE_MODEL where service_uuid = " + serviceUUID + ";", null, null);
- }
-
- } catch (SQLException e) {
- LOG.error("Could not clean up existing NETWORK_MODEL and SERVICE_MODEL for service_UUID " + serviceUUID, e);
- }
-
- }
-
-
- protected void insertToscaData(String toscaDataString, ArrayList<String> arguments) throws IOException
- {
- LOG.debug("insertToscaData: " + toscaDataString);
-
- if (jdbcDataSource == null) {
- setJdbcDataSource();
- }
- try {
-
- jdbcDataSource.writeData(toscaDataString, arguments, null);
-
- } catch (SQLException e) {
- LOG.error("Could not insert Tosca YAML data into the database ");
- throw new IOException (e);
- }
-
- }
-
-
- private SdncArtifactType analyzeFileType(ArtifactTypeEnum artifactType, File spoolFile, Document spoolDoc) {
-
- if (artifactType != ArtifactTypeEnum.YANG_XML) {
- LOG.error("Unexpected artifact type - expecting YANG_XML, got "+artifactType);
- return null;
- }
-
- // Examine outer tag
-
- try {
-
-
- Element root = spoolDoc.getDocumentElement();
-
- String rootName = root.getTagName();
-
- if (rootName.contains(":")) {
- String[] rootNameElems = rootName.split(":");
- rootName = rootNameElems[rootNameElems.length - 1];
- }
-
- if (rootName != null) {
- SdncArtifactType mapEntry = config.getMapping(rootName);
-
-
- if (mapEntry == null) {
-
- LOG.error("Unexpected file contents - root tag is "+rootName);
- }
- return mapEntry;
- } else {
- LOG.error("Cannot get root tag from file");
- return null;
- }
-
- } catch (Exception e) {
- LOG.error("Could not parse YANG_XML file "+spoolFile.getName(), e);
- return null;
- }
- }
-
- private void scheduleDeployment(SdncArtifactType type, String svcName, String resourceName, IArtifactInfo artifactInfo, String spoolFileName, File spoolFile) {
-
- if (type.getPass() < deployList.length) {
-
- if (artifactInfo != null) {
- LOG.debug("Scheduling "+artifactInfo.getArtifactName()+" version "+artifactInfo.getArtifactVersion()+" for deployment");
-
- deployList[type.getPass()].add(new DeployableArtifact(type, svcName, resourceName, artifactInfo, spoolFile));
- } else {
- SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS");//dd/MM/yyyy
- Date now = new Date();
- String artifactVersion = sdfDate.format(now);
- LOG.debug("Scheduling "+spoolFileName+" version "+artifactVersion+" for deployment");
- String artifactName = spoolFileName;
- if (artifactInfo != null) {
- artifactName = artifactInfo.getArtifactName();
- }
- deployList[type.getPass()].add(new DeployableArtifact(type, svcName, resourceName, artifactName, artifactVersion, spoolFile));
- }
- } else {
- LOG.info("Pass for type "+type.getTag()+" is "+type.getPass()+" which is not <= "+deployList.length);
- }
- }
-
-
- private DistributionStatusEnum deploySpoolFile(DeployableArtifact artifact) {
-
- DistributionStatusEnum deployResult = DistributionStatusEnum.DEPLOY_OK;
-
- StringBuffer msgBuffer = new StringBuffer();
-
-
- String namespace = config.getAsdcApiNamespace();
- //String namespace = artifact.getType().getNamespace();
-
- msgBuffer.append("<input xmlns='");
- msgBuffer.append(namespace);
- msgBuffer.append("'>\n");
-
- String svcName = artifact.getSvcName();
- String resourceName = artifact.getResourceName();
- String artifactName = artifact.getArtifactName();
-
- if (svcName != null) {
- if (resourceName != null) {
- artifactName = svcName + "/" + resourceName + "/" + artifactName;
- } else {
- artifactName = svcName + "/" + artifactName;
- }
- }
-
- // don't add artifact name/version for get-path-segments
- if (!artifactName.contains("get-path-segments")) {
- msgBuffer.append("<artifact-name>"+artifactName+"</artifact-name>\n");
- msgBuffer.append("<artifact-version>"+artifact.getArtifactVersion()+"</artifact-version>\n");
- }
-
- try(BufferedReader rdr = new BufferedReader(new FileReader(artifact.getFile()))) {
-
- String curLine = rdr.readLine();
-
- while (curLine != null) {
-
- if (!curLine.startsWith("<?")) {
-
- // skip get-path-segments tags
- boolean skipThisLine = false;
- if (artifactName.contains("get-path-segments")) {
- if (curLine.contains("<get-path-segments>") || curLine.contains("</get-path-segments>")) {
- skipThisLine = true;
- }
- }
-
- if (!skipThisLine) {
- msgBuffer.append(curLine+"\n");
- }
- }
- curLine = rdr.readLine();
- }
- } catch (Exception e) {
- LOG.error("Could not process spool file "+artifact.getFile().getName(), e);
- return(DistributionStatusEnum.DEPLOY_ERROR);
- }
-
- msgBuffer.append("</input>\n");
-
-
- byte[] msgBytes = msgBuffer.toString().getBytes();
-
- Document results = postRestXml(artifact.getType().getRpcUrl(config.getAsdcApiBaseUrl()), msgBytes);
-
- if (results == null) {
-
- deployResult = DistributionStatusEnum.DEPLOY_ERROR;
- } else {
-
- XPathFactory xpf = XPathFactory.newInstance();
- XPath xp = xpf.newXPath();
-
- String asdcApiResponseCode = "500";
-
- try {
-
- asdcApiResponseCode = xp.evaluate("//asdc-api-response-code[position()=1]/text()", results.getDocumentElement());
- } catch (Exception e) {
- LOG.error("Caught exception retrying to evaluate xpath", e);
- }
-
- if (asdcApiResponseCode.contains("200")) {
- LOG.info("Update to SDN-C succeeded");
- deployResult = DistributionStatusEnum.DEPLOY_OK;
- } else {
- LOG.info("Update to SDN-C failed (response code "+asdcApiResponseCode+")");
-
- if (asdcApiResponseCode.contains("409")) {
- deployResult = DistributionStatusEnum.ALREADY_DEPLOYED;
- } else {
-
- deployResult = DistributionStatusEnum.DEPLOY_ERROR;
- }
- }
- }
-
-
-
- return deployResult;
- }
-
-
-
-
-
- public static IDistributionStatusMessage buildStatusMessage(
- final IDistributionClient client, final INotificationData data,
- final IArtifactInfo relevantArtifact,
- final DistributionStatusEnum status) {
- IDistributionStatusMessage statusMessage = new IDistributionStatusMessage() {
-
- @Override
- public long getTimestamp() {
- long currentTimeMillis = System.currentTimeMillis();
- return currentTimeMillis;
- }
-
- @Override
- public DistributionStatusEnum getStatus() {
- return status;
- }
-
- @Override
- public String getDistributionID() {
- return data.getDistributionID();
- }
-
- @Override
- public String getConsumerID() {
- return client.getConfiguration().getConsumerID();
- }
-
- @Override
- public String getArtifactURL() {
- return relevantArtifact.getArtifactURL();
- }
- };
- return statusMessage;
-
- }
-
- public static IComponentDoneStatusMessage buildComponentStatusMessage(
- final IDistributionClient client, final INotificationData data,
- final DistributionStatusEnum status) {
- IComponentDoneStatusMessage statusMessage = new IComponentDoneStatusMessage() {
-
- @Override
- public long getTimestamp() {
- long currentTimeMillis = System.currentTimeMillis();
- return currentTimeMillis;
- }
-
- @Override
- public DistributionStatusEnum getStatus() {
- return status;
- }
-
- @Override
- public String getDistributionID() {
- return data.getDistributionID();
- }
-
- @Override
- public String getConsumerID() {
- return client.getConfiguration().getConsumerID();
- }
-
- @Override
- public String getComponentName() {
- // TODO Auto-generated method stub
- return COMPONENT_NAME;
- }
- };
- return statusMessage;
-
- }
-
- private HttpURLConnection getRestXmlConnection(String urlString, String method) throws IOException
- {
- URL sdncUrl = new URL(urlString);
- Authenticator.setDefault(new SdncAuthenticator(config.getSdncUser(), config.getSdncPasswd()));
-
- HttpURLConnection conn = (HttpURLConnection) sdncUrl.openConnection();
-
- String authStr = config.getSdncUser()+":"+config.getSdncPasswd();
- String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
-
- conn.addRequestProperty("Authentication", "Basic "+encodedAuthStr);
-
- conn.setRequestMethod(method);
- conn.setRequestProperty("Content-Type", "application/xml");
- conn.setRequestProperty("Accept", "application/xml");
-
- conn.setDoInput(true);
- conn.setDoOutput(true);
- conn.setUseCaches(false);
-
- return conn;
-
- }
-
- private Document postRestXml(String urlString, byte[] msgBytes) {
- Document response = null;
-
- try {
- SdncOdlConnection odlConn = SdncOdlConnection.newInstance(urlString, config.getSdncUser(), config.getSdncPasswd());
-
- String sdncResp = odlConn.send("POST", "application/xml", new String(msgBytes));
-
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
- dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
- dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
-
- DocumentBuilder db = dbf.newDocumentBuilder();
-
- response = db.parse(new ByteArrayInputStream(sdncResp.getBytes()));
- } catch (Exception e) {
- LOG.error("Caught exception posting to ODL tier", e);
- }
-
- return(response);
-
- }
-
- private File applyXslts(File srcFile) {
-
- Document doc = null;
-
-
- File inFile = srcFile;
- File outFile = null;
-
- String xsltPathList = config.getXsltPathList();
-
- if ((xsltPathList == null) || (xsltPathList.length() == 0)) {
- outFile = inFile;
- } else {
-
- String[] xsltPaths = xsltPathList.split(",");
-
- for (String xsltPath : xsltPaths) {
- try{
-
- outFile = File.createTempFile("tmp", "xml");
- TransformerFactory factory = TransformerFactory.newInstance();
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- //factory.setFeature("http://xml.org/sax/features/external-general-entities", false); -- breaks transform
- //factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- Source xslt = new StreamSource(new File(xsltPath));
- Transformer transformer = factory.newTransformer(xslt);
- Source text = new StreamSource(inFile);
-
-
- transformer.transform(text, new StreamResult(outFile));
-
- inFile = outFile;
-
- } catch (Exception e) {
- LOG.error("Caught exception trying to apply XSLT template "+xsltPath, e);
-
- }
-
- }
- }
-
- // After transformations, parse transformed XML
-
-
- return outFile;
- }
-
- private String escapeFilename(String str) {
- if (str == null) {
- str = "";
- }
-
- StringBuffer retval = new StringBuffer();
-
- for (int i = 0 ; i < str.length() ; i++) {
- char curchar = str.charAt(i);
- if (Character.isJavaIdentifierPart(curchar)) {
- retval.append(curchar);
- }
- }
-
- return retval.toString();
-
- }
-
- private boolean artifactIsTosca(IArtifactInfo artifact, File spoolFile) {
-
- boolean toscaYamlType = false;
- boolean toscaCsarType = false;
- if (artifact != null) {
- String artifactTypeString = artifact.getArtifactType();
- if (artifactTypeString.contains("TOSCA_TEMPLATE")) {
- toscaYamlType = true;
- } else if (artifactTypeString.contains("TOSCA_CSAR")) {
- toscaCsarType = true;
- }
- } else {
- if (spoolFile.toString().contains(".yml")) {
- toscaYamlType = true;
- } else if (spoolFile.toString().contains(".csar")) {
- toscaCsarType = true;
- }
- }
-
- return (toscaYamlType||toscaCsarType ? true : false);
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java
deleted file mode 100644
index e5dec14c7..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebClient.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import org.onap.sdc.api.IDistributionClient;
-import org.onap.sdc.api.results.IDistributionClientResult;
-import org.onap.sdc.impl.DistributionClientFactory;
-import org.onap.sdc.utils.DistributionActionResultEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.onap.sdc.utils.DistributionActionResultEnum;
-
-public class SdncUebClient {
-
- private static final Logger LOG = LoggerFactory.getLogger(SdncUebConfiguration.class);
-
- public static void main(String[] args) {
-
- SdncUebConfiguration config = new SdncUebConfiguration();
-
- long startTm = System.currentTimeMillis();
- int sleepTm = config.getPollingInterval() * 1000;
- long maxWaitTm = config.getClientStartupTimeout() * 1000L;
-
- boolean keepWaiting = true;
- boolean listenerStarted = false;
- boolean processDownloads = true;
-
- while (keepWaiting) {
- LOG.info("Initializing ASDC distribution client");
-
- IDistributionClient client = DistributionClientFactory.createDistributionClient();
- SdncUebCallback cb = new SdncUebCallback(client, config);
- IDistributionClientResult result = client.init(config, cb);
- LOG.info("Initialized ASDC distribution client - results = {}", result.getDistributionMessageResult());
-
- if (result.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) {
- if (processDownloads) {
- LOG.info("Scanning for local distribution artifacts before starting client");
- cb.deployDownloadedFiles(null, null, null);
- processDownloads = false;
- }
- LOG.info("Starting client...");
- try {
- IDistributionClientResult start = client.start();
- LOG.info("Client startup result = {}", start.getDistributionMessageResult());
-
- // Only stop waiting if the result is success
- if (start.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) {
-
- keepWaiting = false;
- listenerStarted = true;
- } else {
- LOG.info("SDC returned {} - exitting", start.getDistributionActionResult().toString());
- try {
- client.stop();
- } catch (Exception e1) {
- // Ignore exception on stop
- }
- }
- } catch (Exception e) {
- LOG.info("Client startup failure", e);
- }
- }
-
- if (System.currentTimeMillis() - startTm < maxWaitTm) {
- keepWaiting = false;
- } else {
-
- try {
- Thread.sleep(sleepTm);
- } catch (InterruptedException e) {
- // Ignore
- }
- }
-
- }
-
- if (!listenerStarted) {
- LOG.info("Timed out waiting to connect to SDC");
- System.exit(0);
- }
-
-
-
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java
deleted file mode 100644
index 0088a14a8..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebConfiguration.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * Modifications Copyright © 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.onap.sdc.api.consumer.IConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncUebConfiguration implements IConfiguration{
-
- private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncUebConfiguration.class);
-
- private String asdcAddress = null;
- private String consumerGroup = null;
- private String consumerID = null;
- private String environmentName = null;
- private String password = null;
- private int pollingInterval = 30;
- private int pollingTimeout = 15;
- private int clientStartupTimeout = 900;
- private List<String> relevantArtifactTypes = null;
- private String user = null;
-
- private String sdncUser = null;
- private String sdncPasswd = null;
- private String asdcApiBaseUrl = null;
- private String asdcApiNamespace = null;
- private List<String> msgBusAddress = null;
-
- private SdncArtifactMap artifactMap = SdncArtifactMap.getInstance();
-
- private String incomingDir = null;
-
- private String archiveDir = null;
-
- private String overrideFile = null;
-
- private boolean activateServerTLSAuth;
- private String keyStorePassword;
- private String keyStorePath;
-
- private String xsltPathList;
-
- public SdncUebConfiguration() {
- String propDir = System.getenv(SDNC_CONFIG_DIR);
- if (propDir == null) {
-
- propDir = "/opt/sdnc/data/properties";
- }
- try {
- init(propDir);
- } catch (Exception e) {
- LOG.error("Cannot initialize SdncUebConfiguration", e);
- }
- }
-
- public SdncUebConfiguration(String propDir) {
- try {
- init(propDir);
- } catch (Exception e) {
- LOG.error("Cannot initialize SdncUebConfiguration", e);
- }
- }
-
- public String getAsdcApiNamespace() {
- return asdcApiNamespace;
- }
-
- public String getXsltPathList() {
- return xsltPathList;
- }
-
- public String getOverrideFile() {
- return overrideFile;
- }
-
- public void init(String propDir) throws IOException {
- String propPath;
-
-
- propPath = propDir + "/ueb-listener.properties";
- File propFile = new File(propPath);
-
-
- if (!propFile.exists()) {
-
- throw new FileNotFoundException(
- "Missing configuration properties file : "
- + propFile);
- }
-
- Properties props = new Properties();
- props.load(new FileInputStream(propFile));
-
- asdcAddress = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-address");
- consumerGroup = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-group");
- consumerID = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.consumer-id");
- environmentName = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.environment-name");
- password = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.password");
- user = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.user");
-
- sdncUser = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-user");
- sdncPasswd = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd");
- asdcApiBaseUrl = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url");
- asdcApiNamespace = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace");
-
- incomingDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.incoming");
- archiveDir = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.spool.archive");
- overrideFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.override-file");
-
- String curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-interval");
- if ((curval != null) && (curval.length() > 0)) {
- try {
- pollingInterval = Integer.parseInt(curval);
- } catch (Exception e) {
- LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-interval ({}) ", curval, e);
- }
- }
-
- curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.polling-timeout");
- if ((curval != null) && (curval.length() > 0)) {
- try {
- pollingTimeout = Integer.parseInt(curval);
- } catch (Exception e) {
- LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
- }
- }
-
- curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.client-startup-timeout");
- if ((curval != null) && (curval.length() > 0)) {
- try {
- clientStartupTimeout = Integer.parseInt(curval);
- } catch (Exception e) {
- LOG.warn("Illegal value for org.onap.ccsdk.sli.northbound.uebclient.polling-timeout ({}) ", curval, e);
- }
- }
- curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types");
- if ((curval != null) && (curval.length() > 0)) {
- String[] artifactTypes = curval.split(",");
-
- relevantArtifactTypes = new LinkedList<>();
-
- for (String artifactType : artifactTypes) {
-
- relevantArtifactTypes.add(artifactType);
-
- }
-
- }
-
- curval = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth", "false");
- activateServerTLSAuth = "true".equalsIgnoreCase(curval);
- keyStorePath = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-path");
- keyStorePassword = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.keystore-password");
- xsltPathList = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list");
-
-
- String artifactMapFile = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.artifact-map");
- if (artifactMapFile != null) {
- LOG.info("Loading artifactMapFile {}", artifactMapFile);
- artifactMap.load(artifactMapFile);
- } else {
- LOG.warn("artifact-map is unset");
- }
-
- msgBusAddress = new LinkedList<>();
- String msgBusAddressStr = props.getProperty("org.onap.ccsdk.sli.northbound.uebclient.msg-bus-address");
- if (msgBusAddressStr != null) {
- String[] msgBusAddressArray = msgBusAddressStr.split(",");
- for (int i = 0 ; i < msgBusAddressArray.length ; i++) {
- msgBusAddress.add(msgBusAddressArray[i]);
- }
- }
-
-
- }
-
- @Override
- public String getAsdcAddress() {
- return asdcAddress;
- }
-
- @Override
- public String getConsumerGroup() {
- return consumerGroup;
- }
-
- @Override
- public String getConsumerID() {
- return consumerID;
- }
-
- @Override
- public String getEnvironmentName() {
- return environmentName;
- }
-
- @Override
- public String getPassword() {
- return password;
- }
-
- @Override
- public int getPollingInterval() {
- return pollingInterval;
- }
-
- @Override
- public int getPollingTimeout() {
- return pollingTimeout;
- }
-
- @Override
- public List<String> getRelevantArtifactTypes() {
- return relevantArtifactTypes;
- }
-
- public int getClientStartupTimeout() {
- return clientStartupTimeout;
- }
-
- @Override
- public String getUser() {
- return user;
- }
-
-
- public String getSdncUser() {
- return sdncUser;
- }
-
- public String getSdncPasswd() {
- return sdncPasswd;
- }
-
- public String getAsdcApiBaseUrl() {
- return asdcApiBaseUrl;
- }
-
- @Override
- public boolean activateServerTLSAuth() {
- return activateServerTLSAuth;
- }
-
- @Override
- public String getKeyStorePassword() {
- return keyStorePassword;
- }
-
- @Override
- public String getKeyStorePath() {
- return keyStorePath;
- }
-
- public String getIncomingDir() {
- return incomingDir;
- }
-
- public String getArchiveDir() {
- return archiveDir;
- }
-
- public int getMaxPasses() {
- return artifactMap.getNumPasses();
- }
-
- public SdncArtifactMap.SdncArtifactType getMapping(String tag) {
- return artifactMap.getMapping(tag);
- }
-
- @Override
- public boolean isFilterInEmptyResources() {
- return false;
- }
-
- @Override
- public Boolean isUseHttpsWithDmaap() {
- return false;
- }
-
- @Override
- public List<String> getMsgBusAddress() {
- return msgBusAddress;
- }
-
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java
deleted file mode 100644
index fc288aaa9..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModel.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
-import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.tosca.parser.enums.SdcTypes;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncVFCModel extends SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncVFCModel.class);
-
- private String vmType = null;
- private String vmCount = null;
-
- public SdncVFCModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
-
- super(sdcCsarHelper, entityDetails, jdbcDataSource, config);
-
- // extract properties
- addParameter("ecomp_generated_naming", extractBooleanValue (entityDetails, "nfc_naming", "ecomp_generated_naming"));
- addParameter("naming_policy", extractValue (entityDetails, "nfc_naming", "naming_policy"));
- vmCount = extractValue (entityDetails, "service_template_filter", "count"); // need path to vm_count, extracted as service_template_filter#count
- if (vmCount.isEmpty()) {
- vmCount = "0"; // vm_count can not be null
- }
- vmType = extractValue (entityDetails, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG);
- addParameter("vm_type", vmType); // populate vm_type with vm_type_tag value
- addParameter("vm_type_tag", vmType);
- addParameter("nfc_naming_code", extractValue (entityDetails, "nfc_naming_code"));
- addParameter("nfc_function", extractValue (entityDetails, "nfc_function"));
- addParameter("high_availability", extractValue (entityDetails, "high_availablity"));
- addParameter("vm_image_name", extractValue (entityDetails, "vm_image_name"));
- addParameter("vm_flavor_name", extractValue (entityDetails, "vm_flavor_name"));
- addParameter("nfc_naming", extractValue (entityDetails, "nfc_naming"));
- addParameter("min_instances", extractValue (entityDetails, "min_instances"));
- addParameter("max_instances", extractValue (entityDetails, "max_instances"));
- }
-
- public void insertVFCModelData () throws IOException {
- try {
- cleanUpExistingToscaData("VFC_MODEL", "customization_uuid", getCustomizationUUID());
- LOG.info("Call insertToscaData for VFC_MODEL where customization_uuid = " + getCustomizationUUID());
- insertToscaData(buildSql("VFC_MODEL", model_yaml), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_MODEL table");
- throw new IOException (e);
- }
-
- }
-
- public void insertVFCtoNetworkRoleMappingData (IEntityDetails cvfcEntity) throws IOException {
-
- // Get the CPs on this VFC - using getEntity
- // For each VFC node, get CP properties to insert into VFC_TO_NETWORK_ROLE_MAPPING
- // VFC_TO_NETWORK_ROLE_MAPPING: vfc_customization_uuid, network_role, network_role_tag, vm_type, ipv4_count, ipv6_count,
- // ipv4_use_dhcp, ipv6_use_dhcp, ipv4_ip_version, ipv6_ip_version, extcp_subnetpool_id
-
- String vfcCustomizationUuid = getCustomizationUUID().replace("\"", "");
- EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
- TopologyTemplateQuery topologyTemplateQueryVFC = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(vfcCustomizationUuid).build();
- List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVFC, true);
- if (cpEntities == null || cpEntities.isEmpty()) {
- LOG.debug("insertVFCtoNetworkRoleMappingData: Could not find the nested CVFCs for: " + vfcCustomizationUuid);
- return;
- }
-
- // Clean up all VFC_TO_NETWORK_ROLE_MAPPING data for this VFC node
- try {
- cleanUpExistingToscaData("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID());
- } catch (IOException e) {
- LOG.error("Could not clean up data in VFC_TO_NETWORK_ROLE_MAPPING table ", e);
- }
-
- // There can be multiple insertions per CP:
- // Insert once for each unique IP Version / Subnet Role combination per CP (network_role)
- for (IEntityDetails cpEntity : cpEntities) {
-
- // Extract common parameters
- Map<String, String> commonParams = new HashMap<String, String>(); // non-IP Version specific parameters
- // Get vm_type from VFC node
- addParameter("vm_type", getVmType(), commonParams);
-
- // Extract non-IP Version specific parameters - outside the ip_requirements block
- String networkRole = extractValue(cpEntity, "network_role").isEmpty() ? "default-network-role" : extractValue(cpEntity, "network_role"); // set default-network-role?
- addParameter("network_role", networkRole, commonParams); // can not be null
- addParameter("network_role_tag", nullCheck(extractValue(cpEntity, "network_role_tag")), commonParams);
- addParameter("extcp_subnetpool_id", nullCheck(extractValue(cpEntity, "subnetpoolid")), commonParams);
- String subinterfaceIndicator = extractBooleanValue (cpEntity, "subinterface_indicator");
- addParameter("subinterface_indicator", subinterfaceIndicator, commonParams);
-
- // Build lists of all IPV4 and IPV6 ip_requirements elements
- ArrayList<Map<String, String>> ipv4PropParamsList = new ArrayList<Map<String, String>>();
- ArrayList<Map<String, String>> ipv6PropParamsList = new ArrayList<Map<String, String>>();
-
- // Extract IP Version specific parameters
- if (cpEntity.getProperties().containsKey("ip_requirements")) {
-
- ArrayList<Map<String, Object>> ipPropsList = new ArrayList<Map<String, Object>>();
- ipPropsList = (ArrayList<Map<String, Object>>) cpEntity.getProperties().get("ip_requirements").getValue();
-
- if (ipPropsList != null) {
- for (Map<String, Object> ipPropMap : ipPropsList) {
- //LOG.info("ip_requirements prop map = " + nullCheck(ipPropMap));
-
- String ipVersion = nullCheck(ipPropMap.get("ip_version"));
- if (ipVersion == null) {
- LOG.error("SdncVFCModel: ipVersion not included in ip_requirements element");
- continue;
- }
-
- String subnetRole = nullCheck(ipPropMap.get("subnet_role"));
-
- if (ipVersion.contains("4")) {
-
- // If we have already encountered this subnetRole for IPV4, skip this ip_requirements element
- if (!ipPropParamsMapContainsSubnetRole (ipv4PropParamsList, subnetRole)) {
-
- Map<String, String> ipv4PropParams = new HashMap<String, String>();
- SdncBaseModel.addParameter("ipv4_ip_version", ipVersion, ipv4PropParams);
- SdncBaseModel.addParameter("ipv4_use_dhcp", nullCheck(ipPropMap.get("dhcp_enabled")).contains("true") ? "Y" : "N", ipv4PropParams);
- Map<String, Object> ipCountRequired = (Map<String, Object>)ipPropMap.get("ip_count_required");
- if (ipCountRequired != null && ipCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv4_count", nullCheck(ipCountRequired.get("count")), ipv4PropParams);
- }
- Map<String, Object> floatingIpCountRequired = (Map<String, Object>)ipPropMap.get("floating_ip_count_required");
- if (floatingIpCountRequired != null && floatingIpCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv4_floating_count", nullCheck(floatingIpCountRequired.get("count")), ipv4PropParams);
- }
- SdncBaseModel.addParameter("ipv4_address_plan_name", nullCheck(ipPropMap.get("ip_address_plan_name")), ipv4PropParams);
- SdncBaseModel.addParameter("ipv4_vrf_name", nullCheck(ipPropMap.get("vrf_name")), ipv4PropParams);
- SdncBaseModel.addParameter("subnet_role", nullCheck(ipPropMap.get("subnet_role")), ipv4PropParams);
-
- ipv4PropParamsList.add(ipv4PropParams);
-
- } else {
- LOG.error("SdncVFCModel: Additional V4 ip-requirements element encountered for this subnet_role: ", subnetRole);
- }
-
- } else if (ipVersion.contains("6")) {
-
- // If we have already encountered this subnetRole for IPV6, skip this ip_requirements element
- if (!ipPropParamsMapContainsSubnetRole (ipv6PropParamsList, subnetRole)) {
-
- Map<String, String> ipv6PropParams = new HashMap<String, String>();
- SdncBaseModel.addParameter("ipv6_ip_version", ipVersion, ipv6PropParams);
- SdncBaseModel.addParameter("ipv6_use_dhcp", nullCheck(ipPropMap.get("dhcp_enabled")).contains("true") ? "Y" : "N", ipv6PropParams);
- Map<String, Object> ipCountRequired = (Map<String, Object>)ipPropMap.get("ip_count_required");
- if (ipCountRequired != null && ipCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv6_count", nullCheck(ipCountRequired.get("count")), ipv6PropParams);
- }
- Map<String, Object> floatingIpCountRequired = (Map<String, Object>)ipPropMap.get("floating_ip_count_required");
- if (floatingIpCountRequired != null && floatingIpCountRequired.get("count") != null) {
- SdncBaseModel.addParameter("ipv6_floating_count", nullCheck(floatingIpCountRequired.get("count")), ipv6PropParams);
- }
- SdncBaseModel.addParameter("ipv6_address_plan_name", nullCheck(ipPropMap.get("ip_address_plan_name")), ipv6PropParams);
- SdncBaseModel.addParameter("ipv6_vrf_name", nullCheck(ipPropMap.get("vrf_name")), ipv6PropParams);
- SdncBaseModel.addParameter("subnet_role", nullCheck(ipPropMap.get("subnet_role")), ipv6PropParams);
-
- ipv6PropParamsList.add(ipv6PropParams);
-
- } else {
- LOG.error("SdncVFCModel: Additional V6 ip-requirements element encountered for this subnetRole: ", subnetRole);
- }
-
- } else {
- LOG.error("SdncVFCModel: invalid IP version encountered: ", ipVersion);
- }
-
- } // for each ip-requirements element
-
- } // ipPropsList null check
-
- // After all Common and IP Version specific parameters are extracted, insert IPV4 and IPV6 data separately
- // Insert IPV4 data
- for (Map<String, String> ipv4PropParams: ipv4PropParamsList) {
-
- Map<String, String> mappingParams = new HashMap<String, String>(); // final list for single insertion
- addParamsToMap(commonParams, mappingParams);
- addParamsToMap(ipv4PropParams, mappingParams);
-
- // Insert ipv4PropParams into VFC_TO_NETWORK_ROLE_MAPPING
- try {
- LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING where vfc_customization_uuid = " + getCustomizationUUID());
- addRequiredParameters(mappingParams);
- insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID(), "", mappingParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_TO_NETWORK_ROLE_MAPPING table");
- throw new IOException (e);
- }
-
- }
-
- // Insert IPV6 data
- for (Map<String, String> ipv6PropParams: ipv6PropParamsList) {
-
- Map<String, String> mappingParams = new HashMap<String, String>(); // final list for single insertion
- addParamsToMap(commonParams, mappingParams);
- addParamsToMap(ipv6PropParams, mappingParams);
-
- // Insert ipv6PropParams into VFC_TO_NETWORK_ROLE_MAPPING
- try {
- LOG.info("Call insertToscaData for VFC_TO_NETWORK_ROLE_MAPPING where vfc_customization_uuid = " + getCustomizationUUID());
- addRequiredParameters(mappingParams);
- insertToscaData(SdncBaseModel.getSql("VFC_TO_NETWORK_ROLE_MAPPING", "vfc_customization_uuid", getCustomizationUUID(), "", mappingParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_TO_NETWORK_ROLE_MAPPING table");
- throw new IOException (e);
- }
- }
- }
- }
- }
-
- protected boolean ipPropParamsMapContainsSubnetRole (ArrayList<Map<String, String>> ipPropParamsList, String subnetRole) {
-
- boolean subnetRoleFound = false;
-
- if (subnetRole != null && !subnetRole.isEmpty()) {
- for (Map<String, String> ipPropMap : ipPropParamsList) {
- if (ipPropMap.get("subnet_role").contentEquals(subnetRole)) {
- return true;
- }
- }
- }
- return subnetRoleFound;
- }
-
- private void addRequiredParameters (Map<String, String> mappingParams) {
-
- // Add parameters which can not be null if they have not already been added - network_role, ipv4_count, ipv6_count
- String ipvCountDefault = "0";
- if (!mappingParams.containsKey("ipv4_count")) {
- SdncBaseModel.addParameter("ipv4_count", ipvCountDefault, mappingParams);
- }
- if (!mappingParams.containsKey("ipv6_count")) {
- SdncBaseModel.addParameter("ipv6_count", ipvCountDefault, mappingParams);
- }
- }
-
- public void insertVFCRelatedNetworkRoleData (String vfCustomizationUUID, IEntityDetails cvfcEntity) throws IOException {
-
- // Get the CPs on this VFC - using getEntity
-
- String vfcCustomizationUuid = getCustomizationUUID().replace("\"", "");
- // Get the CPs on this VFC - ASDC suggests getNodeTemplateChildren
- //List<NodeTemplate> cpNodesList = sdcCsarHelper.getNodeTemplateChildren(vfcNode);
- EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
- TopologyTemplateQuery topologyTemplateQueryVFC = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).customizationUUID(vfcCustomizationUuid).build();
- List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVFC, true);
- if (cpEntities == null || cpEntities.isEmpty()) {
- LOG.debug("insertVFCRelatedNetworkRoleData: Could not find the nested CVFCs for: " + vfcCustomizationUuid);
- return;
- }
-
- try {
- cleanUpExistingToscaData("VFC_RELATED_NETWORK_ROLE", "vfc_customization_uuid", getCustomizationUUID());
- } catch (IOException e) {
- LOG.error("Could not clean up Tosca CSAR data in the VFC_RELATED_NETWORK_ROLE table");
- throw new IOException (e);
- }
-
- for (IEntityDetails cpEntity : cpEntities){
- String networkRole = extractValue(cpEntity, "network_role");
- Map<String, String> relatedNetworkRoleParams = new HashMap<String, String>();
- addParameter("vfc_customization_uuid", getCustomizationUUID(), relatedNetworkRoleParams);
- addParameter("vm_type", vmType, relatedNetworkRoleParams);
- addParameter("network_role", networkRole, relatedNetworkRoleParams);
-
- if (cpEntity.getProperties().containsKey("related_networks")) {
-
- Property relatedNetworksProperty = cpEntity.getProperties().get("related_networks");
- List<String> relatedNetworkRoles = relatedNetworksProperty.getLeafPropertyValue("related_network_role");
-
- for (String relatedNetworkRole : relatedNetworkRoles) {
- LOG.debug("CP [" + cpEntity.getName() + "], property [" + "related_network_role" + "] property value: " + relatedNetworkRole);
-
- try {
- // Table cleanup for VFC_RELATED_NETWORK_ROLE occurs per vfc
- // If cp related_network_role, cp network_role and vm_type for this vfc already exist in VFC_RELATED_NETWORK_ROLE,
- // don't attempt insertion
- Map<String, String> relatedNetworkRoleParamsCheck = new HashMap<String, String>();
- addParamsToMap(relatedNetworkRoleParams, relatedNetworkRoleParamsCheck);
- addParameter("related_network_role", relatedNetworkRole, relatedNetworkRoleParamsCheck);
- if (checkForExistingToscaData("VFC_RELATED_NETWORK_ROLE", relatedNetworkRoleParamsCheck) == false) {
- LOG.info("Call insertToscaData for VFC_RELATED_NETWORK_ROLE where vfc_customization_uuid = " + getCustomizationUUID());
- insertToscaData(buildSql("VFC_RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRole + "\"", model_yaml, relatedNetworkRoleParams), null);
- }
-
- // Table cleanup for VNF_RELATED_NETWORK_ROLE occurs per vf (up one level)
- // Insert same related_network_role data into VNF_RELATED_NETWORK_ROLE
- Map<String, String> vfRelatedNetworkRoleParamsCheck = new HashMap<String, String>();
- addParameter("vnf_customization_uuid", vfCustomizationUUID, vfRelatedNetworkRoleParamsCheck);
- addParameter("network_role", networkRole, vfRelatedNetworkRoleParamsCheck);
- addParameter("related_network_role", relatedNetworkRole, vfRelatedNetworkRoleParamsCheck);
- if (checkForExistingToscaData("VNF_RELATED_NETWORK_ROLE", vfRelatedNetworkRoleParamsCheck) == false) {
- vfRelatedNetworkRoleParamsCheck.remove("related_network_role");
- LOG.info("Call insertToscaData for VNF_RELATED_NETWORK_ROLE where vnf_customization_uuid = " + vfCustomizationUUID);
- insertToscaData(buildSql("VNF_RELATED_NETWORK_ROLE", "related_network_role", "\"" + relatedNetworkRole + "\"", model_yaml, vfRelatedNetworkRoleParamsCheck), null);
- }
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VFC_RELATED_NETWORK_ROLE table");
- throw new IOException (e);
- }
- }
- }
- }
- }
-
- public String getVmType() {
- return vmType;
- }
-
- public void setVmType(String vmType) {
- this.vmType = vmType;
- }
-
- public String getVmCount() {
- return vmCount;
- }
-
- public void setVmCount(String vmCount) {
- this.vmCount = vmCount;
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
deleted file mode 100644
index fa54c7c41..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModel.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * 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.ccsdk.sli.northbound.uebclient;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.enums.SdcTypes;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.elements.queries.EntityQuery;
-import org.onap.sdc.tosca.parser.elements.queries.TopologyTemplateQuery;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SdncVFModel extends SdncBaseModel {
-
- private static final Logger LOG = LoggerFactory
- .getLogger(SdncVFModel.class);
-
- private String vendor = null;
- private String vendorModelDescription = null;
- private String nfNamingCode = null;
- private String serviceUUID = null;
- private String serviceInvariantUUID = null;
-
- public SdncVFModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails entityDetails, DBResourceManager jdbcDataSource, SdncUebConfiguration config) throws IOException {
-
- super(sdcCsarHelper, entityDetails, jdbcDataSource, config);
-
- // extract metadata
- Metadata metadata = entityDetails.getMetadata();
- addParameter("name", extractValue(metadata, SdcPropertyNames.PROPERTY_NAME_NAME));
- vendor = extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDOR);
- addParameter("vendor", vendor);
- vendorModelDescription = extractValue (metadata, "description");
- addParameter("vendor_version", extractValue (metadata, SdcPropertyNames.PROPERTY_NAME_RESOURCEVENDORRELEASE));
-
- // extract properties
- addParameter("ecomp_generated_naming", extractBooleanValue(entityDetails, "nf_naming", "ecomp_generated_naming"));
- addParameter("naming_policy", extractValue(entityDetails, "nf_naming", "naming_policy"));
- addParameter("nf_type", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- addParameter("nf_role", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- nfNamingCode = extractValue(entityDetails, "nf_naming_code");
- addParameter("nf_code", nfNamingCode);
- addParameter("nf_function", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- addIntParameter("avail_zone_max_count", extractValue(entityDetails, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONEMAXCOUNT));
- addParameter("sdnc_model_name", extractValue(entityDetails, "sdnc_model_name"));
- addParameter("sdnc_model_version", extractValue(entityDetails, "sdnc_model_version"));
- addParameter("sdnc_artifact_name", extractValue(entityDetails, "sdnc_artifact_name"));
-
- // store additional properties in ATTRIBUTE_VALUE_PAIR
- // additional complex properties are extracted via VfcInstanceGroup
- EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup").build();
- String vfCustomizationUuid = getCustomizationUUIDNoQuotes();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
- .customizationUUID(vfCustomizationUuid).build();
- List<IEntityDetails> vfcInstanceGroupListForVf = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- if (vfcInstanceGroupListForVf != null) {
-
- for (IEntityDetails group : vfcInstanceGroupListForVf){
-
- String vfcInstanceGroupFunction = extractGetInputValue(group, entityDetails, "vfc_instance_group_function");
- addParameter("vfc_instance_group_function", vfcInstanceGroupFunction, attributeValueParams);
- String networkCollectionFunction = extractGetInputValue(group, entityDetails, "network_collection_function");
- addParameter("network_collection_function", networkCollectionFunction, attributeValueParams);
- String initSubinterfaceQuantity = extractGetInputValue(group, entityDetails, "init_subinterface_quantity");
- addParameter("init_subinterface_quantity", initSubinterfaceQuantity, attributeValueParams);
- }
- }
- }
-
- public void insertData() throws IOException {
-
- insertVFModelData();
- insertVFModuleData();
- insertVFtoNetworkRoleMappingData();
- insertVFCData();
- insertVFCInstanceGroupData();
- insertVFPolicyData();
- }
-
- private void insertVFModelData () throws IOException {
-
- try {
- cleanUpExistingToscaData("VF_MODEL", "customization_uuid", getCustomizationUUID()) ;
- //cleanUpExistingToscaData("SERVICE_MODEL_TO_VF_MODEL_MAPPING", "service_uuid", serviceUUID, "vf_uuid", getUUID());
-
- // insert into VF_MODEL/ATTRIBUTE_VALUE_PAIR and SERVICE_MODEL_TO_VF_MODEL_MAPPING
- LOG.info("Call insertToscaData for VF_MODEL where customization_uuid = " + getCustomizationUUID());
- insertToscaData(buildSql("VF_MODEL", model_yaml), null);
- //insertRelevantAttributeData();
-
- Map<String, String> mappingParams = new HashMap<String, String>();
- addParameter("service_invariant_uuid", serviceInvariantUUID, mappingParams);
- addParameter("vf_uuid", getUUID(), mappingParams);
- addParameter("vf_customization_uuid", getCustomizationUUIDNoQuotes(), mappingParams);
- //insertToscaData(buildSql("SERVICE_MODEL_TO_VF_MODEL_MAPPING", "service_uuid", serviceUUID, model_yaml, mappingParams), null);
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VF_MODEL table");
- throw new IOException (e);
- }
-
- }
-
- private void insertVFModuleData () throws IOException {
-
- // Pre-Step: Get all CVFC with VFC inside use this list to filter before insert into VF_MODULE_TO_VFC_MAPPING
- // Get all VFC in all CFVC in entire model (getEntity VFC, CVFC, true) and then check resulting entity has parent that matches member
- // if parent of VFC has customizationUUID that matches customizationUUID of group member, then insert into VF_MODULE_TO_VFC_MAPPING
- // then get count property
- EntityQuery vfcEntityQuery = EntityQuery.newBuilder(SdcTypes.VFC).build();
- TopologyTemplateQuery cvfcTopologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC).build();
- List<IEntityDetails> allVfcsInsideAllCvfcs = sdcCsarHelper.getEntity(vfcEntityQuery, cvfcTopologyTemplateQuery, true);
-
- // Step 1: Get all the VF Module groups (entities) in this Service
- EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.groups.VfModule").build();
- String vfCustomizationUuid = getCustomizationUUIDNoQuotes();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
- List<IEntityDetails> vfModules = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- if (vfModules == null) {
- return;
- }
-
- // Insert each VF Module group (entity) into VF_MODULE_MODEL if its name is prefixed with the VF name
- for (IEntityDetails vfModule : vfModules){
-
- // If this vfModule name is prefixed with the VF name of the VF being processed, insert this VF Module in VF_MODULE_MODEL
- String normailizedVfName = entityDetails.getName().toLowerCase().replace(" ", "").replace("-", "").replace(".", ""); // need full set of normalization rules from ASDC
- if (!vfModule.getName().startsWith(normailizedVfName)) {
- continue;
- }
-
- SdncVFModuleModel vfModuleModel = new SdncVFModuleModel(sdcCsarHelper, vfModule, this);
-
- try {
- cleanUpExistingToscaData("VF_MODULE_MODEL", "customization_uuid", vfModuleModel.getCustomizationUUID());
- cleanUpExistingToscaData("VF_MODULE_TO_VFC_MAPPING", "vf_module_customization_uuid", vfModuleModel.getCustomizationUUID());
- LOG.info("Call insertToscaData for VF_MODULE_MODEL where customization_uuid = " + vfModuleModel.getCustomizationUUID());
- insertToscaData(vfModuleModel.buildSql("VF_MODULE_MODEL", model_yaml), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VF_MODULE_MODEL table ");
- throw new IOException (e);
- }
-
- // Step 2: Get the non-catalog VF Module in order to get the group members
- String vfModuleUuid = vfModuleModel.getUUID().replace("\"", "");
- EntityQuery entityQuery2 = EntityQuery.newBuilder("org.openecomp.groups.VfModule")
- .uUID(vfModuleUuid)
- .build();
- TopologyTemplateQuery topologyTemplateQuery2 = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
- .customizationUUID(vfCustomizationUuid) // customization UUID of the VF if exists
- .build();
- List<IEntityDetails> vfModulesNonCatalog = sdcCsarHelper.getEntity(entityQuery2, topologyTemplateQuery2, false);
- if (vfModulesNonCatalog == null || vfModulesNonCatalog.isEmpty()) {
- LOG.debug("insertVFModuleData: Could not find the non-catelog VF Module for: " + vfModuleModel.getCustomizationUUID() + ". Unable to insert members into VF_MODULE_TO_VFC_MAPPING");
- continue;
- }
-
- List<IEntityDetails> vfModuleMembers = vfModulesNonCatalog.get(0).getMemberNodes(); // does getMemberNodes give nested CFVCs?
-
- // Find all members for each VF Module that are of type CVFC and insert it and any nested CFVCs into VF_MODULE_TO_VFC_MAPPING
- for (IEntityDetails vfModuleMember: vfModuleMembers) {
- if (vfModuleMember.getMetadata().getValue("type").equals(SdcTypes.CVFC.getValue())) {
-
- String cvfcCustomizationUuid = extractValue(vfModuleMember.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
-
- // Additional check to see if this CVFC has a VFC in it? We only are to map CVFCs with VFC in it.
- if (cvfcContainsVfc(allVfcsInsideAllCvfcs, vfModuleMember) == true) {
-
- // Insert this CVFC data into VF_MODULE_TO_VFC_MAPPING
- String vfcVmType = extractValue (vfModuleMember, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG); // extracted as vm_type_tag
- String vfcVmCount = "";
- if (vfModuleMember.getProperties().containsKey("service_template_filter")) {
- vfcVmCount = extractIntegerValue (vfModuleMember.getProperties().get("service_template_filter"), "count");
- }
- if (vfcVmCount.isEmpty()) {
- vfcVmCount = "0"; // vm_count can not be null
- }
-
- try {
- LOG.info("Call insertToscaData for VF_MODULE_TO_VFC_MAPPING where vf_module_customization_uuid = " + vfModuleModel.getCustomizationUUID());
- insertToscaData("insert into VF_MODULE_TO_VFC_MAPPING (vf_module_customization_uuid, vfc_customization_uuid, vm_type, vm_count) values (" +
- vfModuleModel.getCustomizationUUID() + ", \"" + cvfcCustomizationUuid + "\", \"" + vfcVmType + "\", \"" + vfcVmCount + "\")", null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VF_MODULE_TO_VFC_MAPPING table");
- throw new IOException (e);
- }
- }
-
- // Step 3: Get any nested CVFCs under this CVFC
- EntityQuery entityQuery3 = EntityQuery.newBuilder(SdcTypes.CVFC).build();
- TopologyTemplateQuery topologyTemplateQuery3 = TopologyTemplateQuery.newBuilder(SdcTypes.CVFC)
- .customizationUUID(cvfcCustomizationUuid) // customization UUID of the CVFC if exists
- .build();
- List<IEntityDetails> nestedCvfcs = sdcCsarHelper.getEntity(entityQuery3, topologyTemplateQuery3, true); // true allows for nested search
- if (nestedCvfcs == null || nestedCvfcs.isEmpty()) {
- LOG.debug("insertVFModuleData: Could not find the nested CVFCs for: " + cvfcCustomizationUuid);
- continue;
- }
-
- for (IEntityDetails nestedCvfc: nestedCvfcs) {
-
- // Additional check to see if this CVFC has a VFC in it? We only are to map CVFCs with VFC in it.
- if (cvfcContainsVfc(allVfcsInsideAllCvfcs, nestedCvfc) == false) {
- continue; // continue to next CVFC
- }
-
- // Insert this CVFC data into VF_MODULE_TO_VFC_MAPPING
- String nestedCvfcCustomizationUuid = extractValue(nestedCvfc.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String nestedVfcVmType = extractValue (nestedCvfc, SdcPropertyNames.PROPERTY_NAME_VMTYPETAG); // extracted as vm_type_tag
- String nestedVfcVmCount = "";
- if (nestedCvfc.getProperties().containsKey("service_template_filter")) {
- nestedVfcVmCount = extractIntegerValue (nestedCvfc.getProperties().get("service_template_filter"), "count");
- }
- if (nestedVfcVmCount.isEmpty()) {
- nestedVfcVmCount = "0"; // vm_count can not be null
- }
-
- try {
- LOG.info("Call insertToscaData for VF_MODULE_TO_VFC_MAPPING where vf_module_customization_uuid = " + vfModuleModel.getCustomizationUUID());
- insertToscaData("insert into VF_MODULE_TO_VFC_MAPPING (vf_module_customization_uuid, vfc_customization_uuid, vm_type, vm_count) values (" +
- vfModuleModel.getCustomizationUUID() + ", \"" + nestedCvfcCustomizationUuid + "\", \"" + nestedVfcVmType + "\", \"" + nestedVfcVmCount + "\")", null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VF_MODULE_TO_VFC_MAPPING table");
- throw new IOException (e);
- }
- }
- }
- } // For each VF Module member
- } // For each VF Module
- }
-
- private boolean cvfcContainsVfc (List<IEntityDetails> allVfcsInsideAllCvfcs, IEntityDetails cvfcEntity) {
- boolean containsVfc = false;
-
- for (IEntityDetails vfcEntity: allVfcsInsideAllCvfcs) {
- IEntityDetails vfcParentEntity = vfcEntity.getParent();
- String parentCustomizationUuid = extractValue (vfcParentEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String cvfcEntityCustomizationUuid = extractValue (cvfcEntity.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- if (parentCustomizationUuid == cvfcEntityCustomizationUuid) {
- return true;
- }
- }
-
- return containsVfc;
- }
-
- private void insertVFtoNetworkRoleMappingData () throws IOException {
-
- // Cleanup existing VF_TO_NETWORK_ROLE_MAPPING for this VF
- try {
- cleanUpExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", "vf_customization_uuid", getCustomizationUUID());
- } catch (IOException e) {
- LOG.error("Could not cleanup Tosca CSAR data into the VF_TO_NETWORK_ROLE_MAPPING table");
- throw new IOException (e);
- }
-
- // For this VF, insert VF_TO_NETWORK_ROLE_MAPPING data. network_role is a property on the CPs for this VF.
- // Use getEntity to extract all the CPs on this VF
- EntityQuery entityQueryCP = EntityQuery.newBuilder(SdcTypes.CP).build();
- TopologyTemplateQuery topologyTemplateQueryVF = TopologyTemplateQuery.newBuilder(SdcTypes.VF).customizationUUID(getCustomizationUUIDNoQuotes()).build();
- List<IEntityDetails> cpEntities = sdcCsarHelper.getEntity(entityQueryCP, topologyTemplateQueryVF, true);
- if (cpEntities == null || cpEntities.isEmpty()) {
- LOG.debug("insertVFtoNetworkRoleMappingData: Could not find CPs for VF: " + getCustomizationUUIDNoQuotes());
- return;
- }
-
- for (IEntityDetails entity: cpEntities ) {
-
- Map<String, Property> properties = entity.getProperties();
- if (properties.containsKey("network_role")) {
-
- Property networkRoleProperty = properties.get("network_role");
- if (networkRoleProperty != null && networkRoleProperty.getValue() != null) {
- String cpNetworkRole = networkRoleProperty.getValue().toString();
- LOG.debug("insertVFtoNetworkRoleMappingData: " + "VF: " + getCustomizationUUID() + ", networkRole = " + cpNetworkRole);
-
- // Only insert unique network_role values for this VF
- boolean networkRoleExists = false;
- Map<String, String> networkRoleyKeys = new HashMap<String, String>();
- networkRoleyKeys.put("vf_customization_uuid", getCustomizationUUID());
- networkRoleyKeys.put("network_role", "\"" + cpNetworkRole + "\"");
- networkRoleExists = checkForExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", networkRoleyKeys);
-
- if (networkRoleExists == false) {
- try {
- //cleanUpExistingToscaData("VF_TO_NETWORK_ROLE_MAPPING", "vf_customization_uuid", getCustomizationUUID());
- LOG.info("Call insertToscaData for VF_TO_NETWORK_ROLE_MAPPING where vf_customization_uuid = " + getCustomizationUUID());
- insertToscaData("insert into VF_TO_NETWORK_ROLE_MAPPING (vf_customization_uuid, network_role) values (" +
- getCustomizationUUID() + ", \"" + cpNetworkRole + "\")", null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the VF_TO_NETWORK_ROLE_MAPPING table");
- throw new IOException (e);
- }
- }
- }
- }
-
- } // CP loop
-
- }
-
- private void insertVFCData() throws IOException {
-
- /* For each VF, insert VFC_MODEL, VFC_TO_NETWORK_ROLE_MAPPING, VNF_RELATED_NETWORK_ROLE and VFC_RELATED_NETWORK_ROLE data
-
- try {
- cleanUpExistingToscaData("VNF_RELATED_NETWORK_ROLE", "vnf_customization_uuid", getCustomizationUUID());
- } catch (IOException e) {
- LOG.error("Could not clean up Tosca CSAR data in the VNF_RELATED_NETWORK_ROLE table");
- throw new IOException (e);
- }*/
-
- // Get any CVFCs under this VF (top-level and nested)
- String vfCustomizationUid = customizationUUID;
- EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.CVFC)
- .build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
- .customizationUUID(vfCustomizationUid) // customization UUID of the VF if exists
- .build();
- List<IEntityDetails> cvfcEntities = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, true); // true allows for nested search
- if (cvfcEntities == null || cvfcEntities.isEmpty()) {
- LOG.debug("insertVFCDataEntity: Could not find the CVFCs for: " + vfCustomizationUid);
- }
-
- for (IEntityDetails cvfcEntity: cvfcEntities) {
-
- // Insert this CVFC data into VFC_MODEL
- try {
-
- SdncVFCModel vfcModel = new SdncVFCModel(sdcCsarHelper, cvfcEntity, jdbcDataSource, config);
-
- vfcModel.insertVFCModelData();
- vfcModel.insertVFCtoNetworkRoleMappingData(cvfcEntity);
- //vfcModel.insertVFCRelatedNetworkRoleData(getCustomizationUUID(), cvfcEntity);
-
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR VFC data");
- throw new IOException (e);
- }
- }
-
- }
-
- public void insertVFCInstanceGroupData () throws IOException {
-
- // Insert Group data in RESOURCE_GROUP
- // Store group capabilities and capability properties in NODE_CAPABILITY and NODE_CAPABILITY_PROPERTY table
-
- // For each VF, insert VFC Instance Group data (convert to use getEntity in 19.08)
- EntityQuery entityQuery = EntityQuery.newBuilder("org.openecomp.groups.VfcInstanceGroup").build();
- String vfCustomizationUuid = getCustomizationUUIDNoQuotes();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.VF)
- .customizationUUID(vfCustomizationUuid).build();
- List<IEntityDetails> vfcInstanceGroupListForVf = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- if (vfcInstanceGroupListForVf == null) {
- return;
- }
-
- for (IEntityDetails group : vfcInstanceGroupListForVf){
-
- SdncGroupModel groupModel = new SdncGroupModel (sdcCsarHelper, group, entityDetails, config, jdbcDataSource);
- groupModel.insertGroupData(getUUID());
-
- // For each group, populate NODE_CAPABILITY/NODE_CAPABILITY_PROPERTY
- insertNodeCapabilitiesEntityData(group.getCapabilities());
-
- // Store relationship between VfcInstanceGroup and node-type=VFC in RESOURCE_GROUP_TO_TARGET_NODE_MAPPING table
- // target is each VFC in targets section of group
- List<IEntityDetails> targetNodeList = group.getMemberNodes();
- for (IEntityDetails targetNode : targetNodeList) {
-
- String targetNodeUuid = extractValue(targetNode.getMetadata(), SdcPropertyNames.PROPERTY_NAME_UUID);
- String targetNodeCustomizationUuid = extractValue(targetNode.getMetadata(), SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String targetNodeType = extractValue(targetNode.getMetadata(), SdcPropertyNames.PROPERTY_NAME_TYPE);
-
- // insert RESOURCE_GROUP_TO_TARGET_NODE_MAPPING
- try {
- Map<String, String> mappingCleanupParams = new HashMap<String, String>();
- addParameter("group_uuid", groupModel.getUUID(), mappingCleanupParams);
- addParameter("parent_uuid", getUUID(), mappingCleanupParams);
- addParameter("target_node_uuid", targetNodeUuid, mappingCleanupParams);
- cleanupExistingToscaData("RESOURCE_GROUP_TO_TARGET_NODE_MAPPING", mappingCleanupParams);
-
- Map<String, String> mappingParams = new HashMap<String, String>();
- addParameter("parent_uuid", getUUID(), mappingParams);
- addParameter("target_node_uuid", targetNodeUuid, mappingParams);
- addParameter("target_type", targetNodeType, mappingParams);
- String tableName = "";
- switch (targetNodeType) {
- case "CVFC":
- tableName = "VFC_MODEL";
- break;
- case "VL":
- tableName = "NETWORK_MODEL";
- break;
- }
- addParameter("table_name", tableName, mappingParams);
- LOG.info("Call insertToscaData for RESOURCE_GROUP_TO_TARGET_NODE_MAPPING where group_uuid = " + groupModel.getUUID() + " and target_node_uuid = \"" + targetNodeUuid + "\"");
- insertToscaData(buildSql("RESOURCE_GROUP_TO_TARGET_NODE_MAPPING", "group_uuid", groupModel.getUUID(), model_yaml, mappingParams), null);
- } catch (IOException e) {
- LOG.error("Could not insert Tosca CSAR data into the RESOURCE_GROUP_TO_TARGET_NODE_MAPPING");
- throw new IOException (e);
- }
-
- // For each target node, get External policies
- SdcTypes queryType = SdcTypes.valueOf(extractValue(entityDetails.getMetadata(), SdcPropertyNames.PROPERTY_NAME_TYPE));
- insertEntityPolicyData(getCustomizationUUIDNoQuotes(), getUUID().replace("\"", ""), queryType, targetNodeCustomizationUuid, targetNodeUuid, targetNodeType, "org.openecomp.policies.External"); // AFTER getEntity
- }
- }
- }
-
- private void insertVFPolicyData() throws IOException {
-
- // For each VF node, ingest External Policy data
- insertEntityPolicyData (getCustomizationUUIDNoQuotes(), getUUID(), serviceUUID.replace("\"", ""), "org.openecomp.policies.External", SdcTypes.VF);
- }
-
- public String getVendor() {
- return vendor;
- }
-
- public void setVendor(String vendor) {
- this.vendor = vendor;
- }
-
- public String getVendorModelDescription() {
- return vendorModelDescription;
- }
-
- public void setVendorModelDescription(String vendorModelDescription) {
- this.vendorModelDescription = vendorModelDescription;
- }
-
- public String getNfNamingCode() {
- return nfNamingCode;
- }
-
- public void setNfNamingCode(String nfNamingCode) {
- this.nfNamingCode = nfNamingCode;
- }
-
- public String getServiceUUID() {
- return serviceUUID;
- }
- public void setServiceUUID(String serviceUUID) {
- this.serviceUUID = serviceUUID;
- }
-
- public String getServiceInvariantUUID() {
- return serviceInvariantUUID;
- }
-
- public void setServiceInvariantUUID(String serviceInvariantUUID) {
- this.serviceInvariantUUID = serviceInvariantUUID;
- }
-
-}
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java
deleted file mode 100644
index ef815d027..000000000
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModel.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights
- * reserved.
- * Modifications Copyright © 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.ccsdk.sli.northbound.uebclient;
-
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-
-public class SdncVFModuleModel extends SdncBaseModel {
-
- public SdncVFModuleModel(ISdcCsarHelper sdcCsarHelper, IEntityDetails vfModule, SdncVFModel vfNodeModel) {
-
- super(sdcCsarHelper, vfModule);
- // override base implementation for setting metadata because properties are called differently for Groups
- customizationUUID = extractValue (vfModule.getMetadata(), "vfModuleModelCustomizationUUID");
- invariantUUID = extractValue (vfModule.getMetadata(), "vfModuleModelInvariantUUID");
- UUID = extractValue (vfModule.getMetadata(), "vfModuleModelUUID");
- version = extractValue (vfModule.getMetadata(), "vfModuleModelVersion");
- addParameter("vf_customization_uuid", vfNodeModel.getCustomizationUUIDNoQuotes());
- addParameter("invariant_uuid", invariantUUID);
- addParameter("uuid", UUID);
- addParameter("version", version);
-
- // extract properties
- addParameter("vf_module_type", extractValue(vfModule, SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE));
- addParameter("vf_module_label", extractValue(vfModule, "vf_module_label"));
- addIntParameter("availability_zone_count", extractValue(vfModule, SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT));
- addParameter("ecomp_generated_vm_assignments", extractBooleanValue(vfModule, SdcPropertyNames.PROPERTY_NAME_ECOMPGENERATEDVMASSIGNMENTS));
- }
-
-}
diff --git a/ueb-listener/src/main/resources/log4j2.xml b/ueb-listener/src/main/resources/log4j2.xml
deleted file mode 100644
index 23ab908a5..000000000
--- a/ueb-listener/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<Configuration status="debug">
- <Properties>
- <Property name="logDir">$${env:LOGDIR:-logs}</Property>
- </Properties>
- <Appenders>
- <RollingFile name="LOGFILE" fileName="${logDir}/ueb-listener.log"
- filePattern="${logDir}/ueb-listener-%i.log">
- <PatternLayout pattern="%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n" />
- <Policies>
- <SizeBasedTriggeringPolicy size="10 MB" />
- </Policies>
- <DefaultRolloverStrategy max="10"/>
- </RollingFile>
- <Console name="CONSOLE" target="SYSTEM_OUT">
- <PatternLayout pattern="%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n" />
- </Console>
- </Appenders>
- <Loggers>
- <Root level="debug">
- <AppenderRef ref="LOGFILE"/>
- <AppenderRef ref="CONSOLE"/>
- </Root>
- </Loggers>
-</Configuration> \ No newline at end of file
diff --git a/ueb-listener/src/main/resources/normalizeTagNames.xslt b/ueb-listener/src/main/resources/normalizeTagNames.xslt
deleted file mode 100755
index c37a5e049..000000000
--- a/ueb-listener/src/main/resources/normalizeTagNames.xslt
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
- <xsl:template match="@*|node()">
- <xsl:copy>
- <xsl:apply-templates select="@*|node()" />
- </xsl:copy>
- </xsl:template>
-
- <xsl:template match="vf-license-model/feature-group-list/feature-group/entitlement-pool-list/entitlement-pool/entitlement-metric/value/text()[.='# of software instances']">num of software instances</xsl:template>
- <xsl:template match="vf-license-model/feature-group-list/feature-group/entitlement-pool-list/entitlement-pool/firstClassCitizenId"/>
-</xsl:stylesheet>
diff --git a/ueb-listener/src/main/resources/removeNs.xslt b/ueb-listener/src/main/resources/removeNs.xslt
deleted file mode 100755
index 7aa927b14..000000000
--- a/ueb-listener/src/main/resources/removeNs.xslt
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
-
- <xsl:template match="*">
- <xsl:element name="{local-name(.)}">
- <xsl:apply-templates select="@* | node()" />
- </xsl:element>
- </xsl:template>
- <xsl:template match="@*">
- <xsl:attribute name="{local-name(.)}">
- <xsl:value-of select="." />
- </xsl:attribute>
- </xsl:template>
-</xsl:stylesheet> \ No newline at end of file
diff --git a/ueb-listener/src/main/scripts/start-ueb-listener.sh b/ueb-listener/src/main/scripts/start-ueb-listener.sh
deleted file mode 100644
index 80ede3c8b..000000000
--- a/ueb-listener/src/main/scripts/start-ueb-listener.sh
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# 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=========================================================
-###
-
-PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
-
-
-LISTENER=ueb-listener
-
-PIDFILE=/tmp/.${LISTENER}-pid
-UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/ueb-listener}
-JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle}
-JAVA_OPTS=${JAVA_OPTS:--Dhttps.protocols=TLSv1.1,TLSv1.2}
-JAVA=${JAVA:-${JAVA_HOME}/bin/java}
-
-# Redirect output from script to $LISTENER.out
-exec >> ${UEBLISTENERROOT}/logs/$LISTENER.out
-exec 2>&1
-
-if [ -f $PIDFILE ]
-then
- pid=$(cat $PIDFILE)
- if [ "$pid" != "" ]
- then
- if kill -0 $pid
- then
- echo "$LISTENER already running"
- exit 0
- fi
- fi
-fi
-
-if [ ! -d ${UEBLISTENERROOT}/logs ]
-then
- mkdir ${UEBLISTENERROOT}/logs
-fi
-
-for file in ${UEBLISTENERROOT}/lib/*.jar
-do
- LISTENERCLASSPATH=$LISTENERCLASSPATH:$file
-done
-
-${JAVA} ${JAVA_OPTS} -jar ${UEBLISTENERROOT}/lib/ueb-listener*.jar -Dlog4j.configuration=file:${UEBLISTENERROOT}/lib/log4j.properties -cp ${LISTENERCLASSPATH} &
-
-
-echo $! > $PIDFILE
-
-echo "$LISTENER started!"
-exit 0
diff --git a/ueb-listener/src/main/scripts/stop-ueb-listener.sh b/ueb-listener/src/main/scripts/stop-ueb-listener.sh
deleted file mode 100644
index cf110c5cc..000000000
--- a/ueb-listener/src/main/scripts/stop-ueb-listener.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# 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=========================================================
-###
-
-PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
-
-if [ -f ${PROPERTY_DIR}/dmaap-listener.properties ]
-then
- LISTENER=dmaap-listener
-else
- LISTENER=ueb-listener
-fi
-
-PIDFILE=/tmp/.${LISTENER}-pid
-UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/ueb-listener}
-
-if [ -f $PIDFILE ]
-then
- pid=$(cat $PIDFILE)
- if [ "$pid" != "" ]
- then
- if kill -0 $pid
- then
- echo "Stopping $LISTENER"
- kill $pid && rm $PIDFILE
- exit 0
- else
- echo "$LISTENER not running"
- exit 1
- fi
- else
- echo "$LISTENER not running"
- exit 1
- fi
-fi
-
-
diff --git a/ueb-listener/src/site/apt/index.apt b/ueb-listener/src/site/apt/index.apt
deleted file mode 100644
index 370ddd4db..000000000
--- a/ueb-listener/src/site/apt/index.apt
+++ /dev/null
@@ -1,46 +0,0 @@
-~~~
-~~ ============LICENSE_START=======================================================
-~~ openECOMP : SDN-C
-~~ ================================================================================
-~~ 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=========================================================
-~~~
-
- ---
- UEB Listener
- ---
-
-
-UEB Listener
-
- The UEB Listener is a daemon that listens for notifications from SDC, posted to UEB (Universal Event Bus).
- On receipt of an event, the UEB listener downloads any artifacts posted and examines them to determine if
- the format (the outer XML tag) matches a supported format. If so, it posts the file to the ASDC-API REST
- API in order to update the SDN-C database.
-
-File Locations
-
- * Root directory : /opt/app/ueb-listener
-
- * Log files : /opt/app/ueb-listener/logs
-
- * Incoming files to be processed : /opt/app/ueb-listener/spool/asdc/incoming
-
- * Files already processed : /opt/app/ueb-listener/spool/asdc/archive
-
-
-
-
diff --git a/ueb-listener/src/site/site.xml b/ueb-listener/src/site/site.xml
deleted file mode 100644
index 6b97d925e..000000000
--- a/ueb-listener/src/site/site.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- ============LICENSE_START=======================================================
- openECOMP : SDN-C
- ================================================================================
- 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=========================================================
- -->
-
-<project>
-
- <body>
- <menu ref="modules"/>
-
- <menu ref="reports"/>
-
- </body>
-</project>
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
deleted file mode 100644
index 11556df1b..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncARModelTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
- import static org.junit.Assert.*;
- import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-
- public class SdncARModelTest {
-
- SdncARModel testSdncARModel = null;
-
- @Before
- public void setUp() throws Exception {
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- Metadata mockMetadata = mock(Metadata.class);
- IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
-
- when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
-
- testSdncARModel = new SdncARModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
- assertNotNull(testSdncARModel);
- }
-
- @Test
- public void testSetGetSubcategory() {
- String subcategory = "test-subcategory";
- testSdncARModel.setSubcategory(subcategory);
- String result = testSdncARModel.getSubcategory();
- assertEquals(subcategory, result);
- }
-
- @Test
- public void testInsertAllottedResourceModelData() {
- try {
- testSdncARModel.insertAllottedResourceModelData();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java
deleted file mode 100644
index 0dfbf087f..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncGroupModelTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-
- public class SdncGroupModelTest {
-
- @Test
- public void testSdncGroupModelConstructor() {
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- IEntityDetails group = mock(IEntityDetails.class);
- IEntityDetails entityDetails = mock(IEntityDetails.class);
- Metadata mockMetadata = mock(Metadata.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
-
- when(entityDetails.getMetadata()).thenReturn(mockMetadata);
- when(group.getMetadata()).thenReturn(mockMetadata);
-
- SdncGroupModel testSdncGroupModel = null;
- try {
- testSdncGroupModel = new SdncGroupModel(mockCsarHelper,group,entityDetails,mockSdncUebConfiguration,mockDBResourceManager);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- assertNotNull(testSdncGroupModel);
- }
-
- }
-
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java
deleted file mode 100644
index 3f4728f07..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncNodeModelTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-
-public class SdncNodeModelTest {
-
- SdncNodeModel sdncNodeModel;
-
- @Before
- public void setUp() throws Exception {
- SdncUebConfiguration config = mock(SdncUebConfiguration.class);
- ISdcCsarHelper isdcCsarHelper = mock(ISdcCsarHelper.class);
- IEntityDetails entityDetails = mock(IEntityDetails.class);
- Metadata mockMetadata = mock(Metadata.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
-
- when(entityDetails.getMetadata()).thenReturn(mockMetadata);
- when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
-
- sdncNodeModel = new SdncNodeModel(isdcCsarHelper, entityDetails, mockDBResourceManager, config);
- sdncNodeModel.setServiceUUID("0e8d757f-1c80-40af-85de-31d64f1f5af8");
- sdncNodeModel.setEcompGeneratedNaming("hello-world");
- }
-
- @Test
- public void testGetServiceUUID() {
- String result = sdncNodeModel.getServiceUUID();
- assertNotNull(result != null);
- }
-
- @Test
- public void testGetEcompGeneratedNaming() {
- String result = sdncNodeModel.getEcompGeneratedNaming();
- assertEquals("hello-world", result);
- }
-
- @Test
- public void testGetSqlString() {
- String result = sdncNodeModel.getSql("TEST-HELLO");
- String test = "INSERT into NETWORK_MODEL (service_uuid, customization_uuid, model_yaml, ecomp_generated_naming) values (0e8d757f-1c80-40af-85de-31d64f1f5af8, \"aaaa-bbbb-cccc-dddd\", \"TEST-HELLO\", \"hello-world\");";
- assertEquals(test, result);
- }
-
- @Test
- public void testGetVpnBindingsSql() {
- String result = sdncNodeModel.getVpnBindingsSql();
- assertNotNull(result);
- }
-
- @Test
- public void testInsertNetworkModelData() {
- try {
- sdncNodeModel.insertNetworkModelData();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
-}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java
deleted file mode 100644
index 97c3942dc..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncPNFModelTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.sdc.toscaparser.api.Property;
-
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-
- public class SdncPNFModelTest {
-
- SdncPNFModel testSdncPNFModel = null;
-
- @Before
- public void setUp() throws Exception {
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
- Metadata mockMetadata = mock(Metadata.class);
- Property mockProperty = mock(Property.class);
- Map<String, Property> mockProperties = new HashMap<String, Property>();
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
-
- when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
- when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
- mockProperty.setValue("test-nf-naming-code");
- when(mockProperties.get("nf_naming_code")).thenReturn(mockProperty);
-
- try {
- testSdncPNFModel = new SdncPNFModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
- testSdncPNFModel.setServiceUUID("bbbb-cccc-dddd-eeee");
- testSdncPNFModel.setServiceInvariantUUID("cccc-dddd-eeee-ffff");
- testSdncPNFModel.setVendor("Cisco");
- testSdncPNFModel.setVendorModelDescription("Cisco Equipment Model");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- assertNotNull(testSdncPNFModel);
- }
-
- @Test
- public void testSetGetVendor() {
- String newVendorModel = "new-vendor-model";
- testSdncPNFModel.setVendor(newVendorModel);
- String result = testSdncPNFModel.getVendor();
- assertEquals(result, newVendorModel);
- }
-
- @Test
- public void testSetGetVendorModelDescription() {
- String newVendorModelDescription = "new-vendor-model-description";
- testSdncPNFModel.setVendorModelDescription(newVendorModelDescription);
- String result = testSdncPNFModel.getVendorModelDescription();
- assertEquals(result, newVendorModelDescription);
- }
-
- @Test
- public void testSetGetNfNamingCode() {
- String newNfNamingCode = "new-nf-naming-code";
- testSdncPNFModel.setNfNamingCode(newNfNamingCode);
- String result = testSdncPNFModel.getNfNamingCode();
- assertEquals(result, newNfNamingCode);
- }
-
- @Test
- public void testSetGetServiceUUID() {
- String newServiceUuid = "cccc-dddd-eeee-ffff";
- testSdncPNFModel.setServiceUUID(newServiceUuid);
- String result = testSdncPNFModel.getServiceUUID();
- assertEquals(newServiceUuid, result);
- }
-
- @Test
- public void testSetGetServiceInvariantUUID() {
- String newServiceInvariantUuid = "dddd-eeee-ffff-eeee";
- testSdncPNFModel.setServiceInvariantUUID(newServiceInvariantUuid);
- String result = testSdncPNFModel.getServiceInvariantUUID();
- assertEquals(result, newServiceInvariantUuid);
- }
-
- @Test
- public void testInsertData() {
- try {
- testSdncPNFModel.insertData();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java
deleted file mode 100644
index b86a8e131..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncServiceModelTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-
- public class SdncServiceModelTest {
-
- SdncServiceModel testSdncServiceModel = null;
-
- @Before
- public void setUp() throws Exception {
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- Metadata mockMetadata = mock(Metadata.class);
-
- when(mockMetadata.getValue("UUID")).thenReturn("aaaa-bbbb-cccc-dddd");
- when(mockMetadata.getValue("invariantUUID")).thenReturn("bbbb-cccc-dddd-eeee");
- when(mockMetadata.getValue("namingPolicy")).thenReturn("test-naming-policy");
- testSdncServiceModel = new SdncServiceModel(mockCsarHelper,mockMetadata,mockDBResourceManager);
-
- assertNotNull(testSdncServiceModel);
- }
-
- @Test
- public void testSetGetServiceUUID() {
- String newServiceUuid = "cccc-dddd-eeee-ffff";
- testSdncServiceModel.setServiceUUID(newServiceUuid);
- String result = testSdncServiceModel.getServiceUUID();
- assertEquals("\"" + newServiceUuid + "\"", result);
- }
-
- @Test
- public void testSetGetServiceInvariantUUID() {
- String result = testSdncServiceModel.getServiceInvariantUUID();
- assertEquals(result, "\"bbbb-cccc-dddd-eeee\"");
- }
-
- @Test
- public void testSetGeServiceInstanceNamePrefix() {
- String serviceInstanceNamePrefix = "test-service-instance-name-prefix";
- testSdncServiceModel.setServiceInstanceNamePrefix(serviceInstanceNamePrefix);
- String result = testSdncServiceModel.getServiceInstanceNamePrefix();
- assertEquals(serviceInstanceNamePrefix, result);
- }
-
- @Test
- public void testSetGetResourceVendor() {
- String resourceVendor = "Fortinet";
- testSdncServiceModel.setResourceVendor(resourceVendor);
- String result = testSdncServiceModel.getResourceVendor();
- assertEquals(resourceVendor, result);
- }
-
- @Test
- public void testSetGetResourceVendorRelease() {
- String resourceVendorRelease = "1.0.0";
- testSdncServiceModel.setResourceVendorRelease(resourceVendorRelease);
- String result = testSdncServiceModel.getResourceVendorRelease();
- assertEquals(resourceVendorRelease, result);
- }
-
- @Test
- public void testGetSqlString() {
- String result = testSdncServiceModel.getSql("TEST-HELLO");
- String test = "INSERT into SERVICE_MODEL (service_uuid, model_yaml, filename, naming_policy, invariant_uuid) values (\"aaaa-bbbb-cccc-dddd\", \"TEST-HELLO\", \"null\", \"test-naming-policy\", \"bbbb-cccc-dddd-eeee\");";
- assertEquals(test, result);
- }
-
-
- }
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
deleted file mode 100644
index f8680522f..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFCModelTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-
-public class SdncVFCModelTest {
-
- SdncVFCModel testSdncVFCModel;
- IEntityDetails mockEntityDetails = null;
-
- @Before
- public void setup() {
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- mockEntityDetails = mock(IEntityDetails.class);
- Metadata mockMetadata = mock(Metadata.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
-
- when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
- when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
-
- Map<String,Map<String,Object>> cpPropertiesMap = new HashMap<String,Map<String,Object>>();
- Map<String,Object> propertiesMap = new HashMap<String,Object>();
- propertiesMap.put("network-role", "test-network-role");
- propertiesMap.put("network-role-tag", "test-network-role-tag");
-
- ArrayList<Map<String, Object>> ipRequirementsList = new ArrayList<Map<String, Object>>();
- Map<String,Object> ip4Prop = new HashMap<String,Object>();
- ip4Prop.put("ip_version", "4");
- ipRequirementsList.add(ip4Prop);
- Map<String,Object> ip6Prop = new HashMap<String,Object>();
- ip4Prop.put("ip_version", "6");
- ipRequirementsList.add(ip4Prop);
-
- propertiesMap.put("ip_requirements", ipRequirementsList);
- cpPropertiesMap.put("cp-node-1", propertiesMap);
-
- try {
- testSdncVFCModel = new SdncVFCModel(mockCsarHelper, mockEntityDetails, mockDBResourceManager, mockSdncUebConfiguration);
- testSdncVFCModel.setVmType("Test-type");
- testSdncVFCModel.setVmCount("5");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testSdncVFCModelSetGetVmType() {
- String newVMtype = "new-vm-type";
- testSdncVFCModel.setVmType(newVMtype);
- assertEquals(testSdncVFCModel.getVmType(), "new-vm-type");
- }
-
- @Test
- public void testSdncVFCModelSetGetVmCount() {
- String newVMcount = "4";
- testSdncVFCModel.setVmCount(newVMcount);
- assertEquals(testSdncVFCModel.getVmCount(), "4");
- }
-
- @Test
- public void testInsertVFCModelData() {
- try {
- testSdncVFCModel.insertVFCModelData();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testInsertVFCtoNetworkRoleMappingData() {
- try {
- testSdncVFCModel.insertVFCtoNetworkRoleMappingData(mockEntityDetails);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Test
- public void testIpPropParamsMapContainsSubnetRole() {
- ArrayList<Map<String, String>> testList = new ArrayList<Map<String, String>>();
- testSdncVFCModel.ipPropParamsMapContainsSubnetRole(testList, "test-subnet-role");
- }
-
-}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
deleted file mode 100644
index 93f7d3467..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModelTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
-import org.onap.sdc.toscaparser.api.Property;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-
- public class SdncVFModelTest {
-
- SdncVFModel testSdncVFModel = null;
-
- @Before
- public void setUp() throws Exception {
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- IEntityDetails mockEntityDetails = mock(IEntityDetails.class);
- Metadata mockMetadata = mock(Metadata.class);
- DBResourceManager mockDBResourceManager = mock(DBResourceManager.class);
- SdncUebConfiguration mockSdncUebConfiguration = mock(SdncUebConfiguration.class);
-
- Property mockProperty = mock(Property.class);
- Map<String, Property> mockProperties = new HashMap<String, Property>();
-
- when(mockEntityDetails.getMetadata()).thenReturn(mockMetadata);
- when(mockEntityDetails.getProperties()).thenReturn(mockProperties);
- when(mockMetadata.getValue("customizationUUID")).thenReturn("aaaa-bbbb-cccc-dddd");
- when(mockMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)).thenReturn("VF");
- mockProperty.setValue("test-nf-naming-code");
- when(mockProperties.get("nf_naming_code")).thenReturn(mockProperty);
- try {
- testSdncVFModel = new SdncVFModel(mockCsarHelper,mockEntityDetails,mockDBResourceManager,mockSdncUebConfiguration);
- testSdncVFModel.setServiceUUID("bbbb-cccc-dddd-eeee");
- testSdncVFModel.setServiceInvariantUUID("cccc-dddd-eeee-ffff");
- testSdncVFModel.setVendor("Cisco");
- testSdncVFModel.setVendorModelDescription("Cisco Equipment Model");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- assertNotNull(testSdncVFModel);
- }
-
- @Test
- public void testSetGetVendor() {
- String newVendorModel = "new-vendor-model";
- testSdncVFModel.setVendor(newVendorModel);
- String result = testSdncVFModel.getVendor();
- assertEquals(result, newVendorModel);
- }
-
- @Test
- public void testSetGetVendorModelDescription() {
- String newVendorModelDescription = "new-vendor-model-description";
- testSdncVFModel.setVendorModelDescription(newVendorModelDescription);
- String result = testSdncVFModel.getVendorModelDescription();
- assertEquals(result, newVendorModelDescription);
- }
-
- @Test
- public void testSetGetNfNamingCode() {
- String newNfNamingCode = "new-nf-naming-code";
- testSdncVFModel.setNfNamingCode(newNfNamingCode);
- String result = testSdncVFModel.getNfNamingCode();
- assertEquals(result, newNfNamingCode);
- }
-
- @Test
- public void testSetGetServiceUUID() {
- String newServiceUuid = "cccc-dddd-eeee-ffff";
- testSdncVFModel.setServiceUUID(newServiceUuid);
- String result = testSdncVFModel.getServiceUUID();
- assertEquals(newServiceUuid, result);
- }
-
- @Test
- public void testSetGetServiceInvariantUUID() {
- String newServiceInvariantUuid = "dddd-eeee-ffff-eeee";
- testSdncVFModel.setServiceInvariantUUID(newServiceInvariantUuid);
- String result = testSdncVFModel.getServiceInvariantUUID();
- assertEquals(result, newServiceInvariantUuid);
- }
-
- @Test
- public void testInsertData() {
- try {
- testSdncVFModel.insertData();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java
deleted file mode 100644
index e19e8dfa9..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/SdncVFModuleModelTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.junit.Test;
-import org.onap.sdc.tosca.parser.api.IEntityDetails;
-import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.toscaparser.api.elements.Metadata;
-import org.onap.ccsdk.sli.northbound.uebclient.SdncVFModel;
-
-public class SdncVFModuleModelTest {
-
- @Test
- public void testSdncVFModuleModelConstructor() {
- IEntityDetails mockEntity = mock(IEntityDetails.class);
- Metadata mockMetadata = mock(Metadata.class);
- ISdcCsarHelper mockCsarHelper = mock(ISdcCsarHelper.class);
- SdncVFModel mockSdncVFModel = mock(SdncVFModel.class);
-
- when(mockEntity.getMetadata()).thenReturn(mockMetadata);
-
- SdncVFModuleModel testSdncVFModel = new SdncVFModuleModel(mockCsarHelper, mockEntity, mockSdncVFModel);
- assertNotNull(testSdncVFModel);
- }
-
-}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java
deleted file mode 100644
index 1b4b22f42..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncOdlConnection.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import ch.vorburger.mariadb4j.DB;
-import ch.vorburger.mariadb4j.DBConfigurationBuilder;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.onap.sdc.api.IDistributionClient;
-import org.onap.sdc.api.notification.INotificationData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.ConnectException;
-import java.net.URL;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.Properties;
-
-import static org.mockito.Mockito.mock;
-
-public class TestSdncOdlConnection {
-
- @Test
- public void test() {
-
- try {
- SdncOdlConnection sdncOdlConnection = SdncOdlConnection.newInstance("https://127.0.0.1:8447/aai/v11/network/pnfs/pnf/a8098c1a-f86e-11da-bd1a-00112444be1e", "", "");
- sdncOdlConnection.send("PUT", "application/json", "{\n" +
- " \"input\" : { \n" +
- " }\n" +
- "}");
- } catch (ConnectException e) {
- //Connection exception
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java b/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java
deleted file mode 100644
index 24dfd36b1..000000000
--- a/ueb-listener/src/test/java/org/onap/ccsdk/sli/northbound/uebclient/TestSdncUebCallback.java
+++ /dev/null
@@ -1,475 +0,0 @@
-package org.onap.ccsdk.sli.northbound.uebclient;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.*;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
-import org.onap.sdc.api.IDistributionClient;
-import org.onap.sdc.api.notification.IArtifactInfo;
-import org.onap.sdc.api.notification.INotificationData;
-import org.onap.sdc.api.notification.IResourceInstance;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import ch.vorburger.mariadb4j.DB;
-import ch.vorburger.mariadb4j.DBConfigurationBuilder;
-
-public class TestSdncUebCallback {
-
-
- private static final String CRTBL_SERVICE_MODEL = "CREATE TABLE `SERVICE_MODEL` (\n" +
- " `service_uuid` varchar(255) NOT NULL,\n" +
- " `model_yaml` longblob,\n" +
- " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `name` varchar(255) DEFAULT NULL,\n" +
- " `description` varchar(1024) DEFAULT NULL,\n" +
- " `type` varchar(255) DEFAULT NULL,\n" +
- " `category` varchar(255) DEFAULT NULL,\n" +
- " `ecomp_naming` char(1) DEFAULT NULL,\n" +
- " `service_instance_name_prefix` varchar(255) DEFAULT NULL,\n" +
- " `filename` varchar(100) DEFAULT NULL,\n" +
- " `naming_policy` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`service_uuid`)\n" +
- ") ";
-
- private static final String CRTBL_SERVICE_MODEL_TO_VF_MODEL_MAPPING = "CREATE TABLE `SERVICE_MODEL_TO_VF_MODEL_MAPPING` (\n" +
- " `service_uuid` varchar(255) NOT NULL,\n" +
- " `vf_uuid` varchar(255) DEFAULT NULL,\n" +
- " `vf_customization_uuid` varchar(255) DEFAULT NULL,\n" +
- " `service_invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`service_uuid`)\n" +
- ") ";
-
- private static final String CRTBL_ATTRIBUTE_VALUE_PAIR = "CREATE TABLE `ATTRIBUTE_VALUE_PAIR` (\n" +
- " `resource_uuid` varchar(255) NOT NULL,\n" +
- " `attribute_name` varchar(255) NOT NULL,\n" +
- " `resource_type` varchar(255) NOT NULL,\n" +
- " `attribute_value` varchar(255) DEFAULT NULL,\n" +
- " `resource_customization_uuid` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`resource_uuid`,`attribute_name`,`resource_type`)\n" +
- ") ";
-
- private static final String CRTBL_NETWORK_MODEL = "CREATE TABLE `NETWORK_MODEL` (\n" +
- " `customization_uuid` varchar(255) NOT NULL,\n" +
- " `service_uuid` varchar(255) NOT NULL,\n" +
- " `model_yaml` longblob,\n" +
- " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `uuid` varchar(255) DEFAULT NULL,\n" +
- " `network_type` varchar(255) DEFAULT NULL,\n" +
- " `network_role` varchar(255) DEFAULT NULL,\n" +
- " `network_technology` varchar(255) DEFAULT NULL,\n" +
- " `network_scope` varchar(255) DEFAULT NULL,\n" +
- " `naming_policy` varchar(255) DEFAULT NULL,\n" +
- " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
- " `is_shared_network` char(1) DEFAULT NULL,\n" +
- " `is_external_network` char(1) DEFAULT NULL,\n" +
- " `is_provider_network` char(1) DEFAULT NULL,\n" +
- " `physical_network_name` varchar(255) DEFAULT NULL,\n" +
- " `is_bound_to_vpn` char(1) DEFAULT NULL,\n" +
- " `vpn_binding` varchar(255) DEFAULT NULL,\n" +
- " `use_ipv4` char(1) DEFAULT NULL,\n" +
- " `ipv4_dhcp_enabled` char(1) DEFAULT NULL,\n" +
- " `ipv4_ip_version` char(1) DEFAULT NULL,\n" +
- " `ipv4_cidr_mask` varchar(255) DEFAULT NULL,\n" +
- " `eipam_v4_address_plan` varchar(255) DEFAULT NULL,\n" +
- " `use_ipv6` char(1) DEFAULT NULL,\n" +
- " `ipv6_dhcp_enabled` char(1) DEFAULT NULL,\n" +
- " `ipv6_ip_version` char(1) DEFAULT NULL,\n" +
- " `ipv6_cidr_mask` varchar(255) DEFAULT NULL,\n" +
- " `eipam_v6_address_plan` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`customization_uuid`),\n" +
- " KEY `FK_NETWORK_MODEL` (`service_uuid`),\n" +
- " CONSTRAINT `FK_NETWORK_MODEL` FOREIGN KEY (`service_uuid`) REFERENCES `SERVICE_MODEL` (`service_uuid`) ON DELETE NO ACTION ON UPDATE NO ACTION\n" +
- ")";
-
- private static final String CRTBL_ALLOTTED_RESOURCE_MODEL = "CREATE TABLE `ALLOTTED_RESOURCE_MODEL` (\n" +
- " `customization_uuid` varchar(255) NOT NULL,\n" +
- " `model_yaml` longblob,\n" +
- " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `uuid` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `naming_policy` varchar(255) DEFAULT NULL,\n" +
- " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
- " `depending_service` varchar(255) DEFAULT NULL,\n" +
- " `role` varchar(255) DEFAULT NULL,\n" +
- " `type` varchar(255) DEFAULT NULL,\n" +
- " `service_dependency` varchar(255) DEFAULT NULL,\n" +
- " `allotted_resource_type` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`customization_uuid`)\n" +
- ") ";
-
- private static final String CRTBL_VFC_MODEL = "CREATE TABLE `VFC_MODEL` (\n" +
- " `customization_uuid` varchar(255) NOT NULL,\n" +
- " `model_yaml` longblob,\n" +
- " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `uuid` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `naming_policy` varchar(255) DEFAULT NULL,\n" +
- " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
- " `nfc_function` varchar(255) DEFAULT NULL,\n" +
- " `nfc_naming_code` varchar(255) DEFAULT NULL,\n" +
- " `vm_type` varchar(255) DEFAULT NULL,\n" +
- " `vm_type_tag` varchar(255) DEFAULT NULL,\n" +
- " `vm_image_name` varchar(255) DEFAULT NULL,\n" +
- " `vm_flavor_name` varchar(255) DEFAULT NULL,\n" +
- " `high_availability` varchar(255) DEFAULT NULL,\n" +
- " `nfc_naming` varchar(255) DEFAULT NULL,\n" +
- " `min_instances` int(11) DEFAULT NULL,\n" +
- " `max_instances` int(11) DEFAULT NULL,\n" +
- " PRIMARY KEY (`customization_uuid`)\n" +
- ") ";
-
- private static final String CRTBL_VFC_RELATED_NETWORK_ROLE = "CREATE TABLE `VFC_RELATED_NETWORK_ROLE` (\n" +
- " `vfc_customization_uuid` varchar(255) NOT NULL,\n" +
- " `vm_type` varchar(255) NOT NULL,\n" +
- " `network_role` varchar(255) NOT NULL,\n" +
- " `related_network_role` varchar(255) NOT NULL,\n" +
- " PRIMARY KEY (`vfc_customization_uuid`,`vm_type`,`network_role`,`related_network_role`)\n" +
- ") ";
-
- private static final String CRTBL_VFC_TO_NETWORK_ROLE_MAPPING = "CREATE TABLE `VFC_TO_NETWORK_ROLE_MAPPING` (\n" +
- " `seq` int(11) NOT NULL AUTO_INCREMENT,\n" +
- " `vfc_customization_uuid` varchar(255) NOT NULL,\n" +
- " `network_role` varchar(255) NOT NULL,\n" +
- " `vm_type` varchar(255) DEFAULT NULL,\n" +
- " `network_role_tag` varchar(255) DEFAULT NULL,\n" +
- " `ipv4_count` int(11) NOT NULL,\n" +
- " `ipv6_count` int(11) NOT NULL,\n" +
- " `ipv4_use_dhcp` char(1) DEFAULT NULL,\n" +
- " `ipv6_use_dhcp` char(1) DEFAULT NULL,\n" +
- " `ipv4_ip_version` char(1) DEFAULT NULL,\n" +
- " `ipv6_ip_version` char(1) DEFAULT NULL,\n" +
- " `extcp_subnetpool_id` varchar(512) DEFAULT NULL,\n" +
- " `ipv4_floating_count` int(11) DEFAULT NULL,\n" +
- " `ipv6_floating_count` int(11) DEFAULT NULL,\n" +
- " `ipv4_address_plan_name` varchar(512) DEFAULT NULL,\n" +
- " `ipv6_address_plan_name` varchar(512) DEFAULT NULL,\n" +
- " `ipv4_vrf_name` varchar(512) DEFAULT NULL,\n" +
- " `ipv6_vrf_name` varchar(512) DEFAULT NULL,\n" +
- " `subnet_role` varchar(255) DEFAULT NULL,\n" +
- " `subinterface_indicator` char(1) DEFAULT NULL,\n" +
- " PRIMARY KEY (`seq`),\n" +
- " KEY `IX1_VFC_TO_NETWORK_ROLE_MAPPING` (`vfc_customization_uuid`)\n" +
- ") ";
-
- private static final String CRTBL_VF_MODEL = "CREATE TABLE `VF_MODEL` (\n" +
- " `customization_uuid` varchar(255) NOT NULL,\n" +
- " `model_yaml` longblob,\n" +
- " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `uuid` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `name` varchar(255) DEFAULT NULL,\n" +
- " `naming_policy` varchar(255) DEFAULT NULL,\n" +
- " `ecomp_generated_naming` char(1) DEFAULT NULL,\n" +
- " `avail_zone_max_count` int(11) DEFAULT NULL,\n" +
- " `nf_function` varchar(255) DEFAULT NULL,\n" +
- " `nf_code` varchar(255) DEFAULT NULL,\n" +
- " `nf_type` varchar(255) DEFAULT NULL,\n" +
- " `nf_role` varchar(255) DEFAULT NULL,\n" +
- " `vendor` varchar(255) DEFAULT NULL,\n" +
- " `vendor_version` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`customization_uuid`)\n" +
- ")";
-
- private static final String CRTBL_VNF_RELATED_NETWORK_ROLE = "CREATE TABLE `VNF_RELATED_NETWORK_ROLE` (\n" +
- " `vnf_customization_uuid` varchar(255) NOT NULL,\n" +
- " `network_role` varchar(255) NOT NULL,\n" +
- " `related_network_role` varchar(255) NOT NULL,\n" +
- " PRIMARY KEY (`vnf_customization_uuid`,`network_role`,`related_network_role`)\n" +
- ")";
-
- private static final String CRTBL_VF_TO_NETWORK_ROLE_MAPPING = "CREATE TABLE `VF_TO_NETWORK_ROLE_MAPPING` (\n" +
- " `seq` int(11) NOT NULL AUTO_INCREMENT,\n" +
- " `vf_customization_uuid` varchar(255) NOT NULL,\n" +
- " `network_role` varchar(255) NOT NULL,\n" +
- " PRIMARY KEY (`seq`),\n" +
- " KEY `IX1_VF_TO_NETWORK_ROLE_MAPPING` (`vf_customization_uuid`)\n" +
- ")";
-
- private static final String CRTBL_VF_MODULE_MODEL = "CREATE TABLE `VF_MODULE_MODEL` (\n" +
- " `customization_uuid` varchar(255) NOT NULL,\n" +
- " `model_yaml` longblob,\n" +
- " `invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `uuid` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `vf_module_type` varchar(255) DEFAULT NULL,\n" +
- " `availability_zone_count` int(11) DEFAULT NULL,\n" +
- " `ecomp_generated_vm_assignments` char(1) DEFAULT NULL,\n" +
- " `vf_customization_uuid` char(255) DEFAULT NULL,\n" +
- " `vf_module_label` char(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`customization_uuid`)\n" +
- ")";
-
- private static final String CRTBL_VF_MODULE_TO_VFC_MAPPING = "CREATE TABLE `VF_MODULE_TO_VFC_MAPPING` (\n" +
- " `seq` int(11) NOT NULL AUTO_INCREMENT,\n" +
- " `vf_module_customization_uuid` varchar(255) NOT NULL,\n" +
- " `vfc_customization_uuid` varchar(255) NOT NULL,\n" +
- " `vm_type` varchar(255) NOT NULL,\n" +
- " `vm_count` int(11) NOT NULL,\n" +
- " PRIMARY KEY (`seq`),\n" +
- " KEY `IX1_VF_MODULE_TO_VFC_MAPPING` (`vf_module_customization_uuid`)\n" +
- ")";
-
- private static final String CRTBL_RESOURCE_GROUP = "CREATE TABLE `RESOURCE_GROUP` (\n" +
- " `resource_uuid` varchar(255) NOT NULL,\n" +
- " `group_uuid` varchar(255) NOT NULL,\n" +
- " `group_customization_uuid` varchar(255) DEFAULT NULL,\n" +
- " `group_invariant_uuid` varchar(255) DEFAULT NULL,\n" +
- " `group_name` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `group_type` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`resource_uuid`,`group_uuid`)\n" +
- ")";
-
- private static final String CRTBL_RESOURCE_GROUP_TO_TARGET_NODE_MAPPING = "CREATE TABLE `RESOURCE_GROUP_TO_TARGET_NODE_MAPPING` (\n" +
- " `group_uuid` varchar(255) NOT NULL,\n" +
- " `parent_uuid` varchar(255) NOT NULL,\n" +
- " `target_node_uuid` varchar(255) NOT NULL,\n" +
- " `target_type` varchar(255) DEFAULT NULL,\n" +
- " `table_name` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`group_uuid`,`parent_uuid`,`target_node_uuid`)\n" +
- ")";
-
- private static final String CRTBL_RESOURCE_POLICY = "CREATE TABLE `RESOURCE_POLICY` (\n" +
- " `resource_uuid` varchar(255) NOT NULL,\n" +
- " `policy_uuid` varchar(255) NOT NULL,\n" +
- " `policy_invariant_uuid` varchar(255) NOT NULL,\n" +
- " `policy_name` varchar(255) DEFAULT NULL,\n" +
- " `version` varchar(255) DEFAULT NULL,\n" +
- " `policy_type` varchar(255) DEFAULT NULL,\n" +
- " `property_type` varchar(255) DEFAULT NULL,\n" +
- " `property_source` varchar(255) DEFAULT NULL,\n" +
- " `property_name` varchar(255) DEFAULT NULL,\n" +
- " `policy_customization_uuid` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`resource_uuid`,`policy_uuid`)\n" +
- ")";
-
- private static final String CRTBL_RESOURCE_POLICY_TO_TARGET_NODE_MAPPING = "CREATE TABLE `RESOURCE_POLICY_TO_TARGET_NODE_MAPPING` (\n" +
- " `policy_uuid` varchar(255) NOT NULL,\n" +
- " `parent_uuid` varchar(255) NOT NULL,\n" +
- " `target_node_uuid` varchar(255) NOT NULL,\n" +
- " `target_type` varchar(255) DEFAULT NULL,\n" +
- " `target_node_customization_uuid` varchar(255) DEFAULT NULL,\n" +
- " `policy_customization_uuid` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`policy_uuid`,`parent_uuid`,`target_node_uuid`)\n" +
- ")";
-
- private static final String CRTBL_NODE_CAPABILITY = "CREATE TABLE `NODE_CAPABILITY` (\n" +
- " `capability_id` int(11) NOT NULL AUTO_INCREMENT,\n" +
- " `capability_provider_uuid` varchar(255) NOT NULL,\n" +
- " `capability_provider_customization_uuid` varchar(255) NOT NULL,\n" +
- " `capability_name` varchar(255) DEFAULT NULL,\n" +
- " `capability_type` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`capability_id`)\n" +
- ")";
-
- private static final String CRTBL_NODE_CAPABILITY_PROPERTY = "CREATE TABLE `NODE_CAPABILITY_PROPERTY` (\n" +
- " `capability_id` int(11) NOT NULL AUTO_INCREMENT,\n" +
- " `capability_property_name` varchar(255) NOT NULL,\n" +
- " `capability_property_type` varchar(255) DEFAULT NULL,\n" +
- " PRIMARY KEY (`capability_id`,`capability_property_name`),\n" +
- " CONSTRAINT `NODE_CAPABILITY_PROPERTY_TO_NODE_CAPABILITY` FOREIGN KEY (`capability_id`) REFERENCES `NODE_CAPABILITY` (`capability_id`) ON DELETE CASCADE\n" +
- ")";
-
-
- private static final Logger LOG = LoggerFactory
- .getLogger(TestSdncUebCallback.class);
- SdncUebConfiguration config;
- DBResourceManager dblibSvc;
- DB db;
- List<IArtifactInfo > processLevelArtifactList;
- List<IArtifactInfo > serviceLevelArtifactList;
- ArrayList<IResourceInstance> resourceList;
- IArtifactInfo mockProcessArtifact1;
- IArtifactInfo mockProcessArtifact2;
- IArtifactInfo mockProcessArtifact3;
- IArtifactInfo mockServiceArtifact1;
- IResourceInstance resource;
-
-
- @Before
- public void setUp() throws Exception {
- config = new SdncUebConfiguration("src/test/resources");
-
-
- URL propUrl = getClass().getResource("/dblib.properties");
-
- InputStream propStr = getClass().getResourceAsStream("/dblib.properties");
-
- Properties props = new Properties();
-
- props.load(propStr);
-
-
- // Start MariaDB4j database
- DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
- config.setPort(0); // 0 => autom. detect free port
- db = DB.newEmbeddedDB(config.build());
- db.start();
-
-
- // Override jdbc URL and database name
- props.setProperty("org.onap.ccsdk.sli.jdbc.database", "test");
- props.setProperty("org.onap.ccsdk.sli.jdbc.url", config.getURL("test"));
-
-
- // Create dblib connection
- dblibSvc = new DBResourceManager(props);
-
- // Create TOSCA tables
- dblibSvc.writeData(CRTBL_SERVICE_MODEL, null, null);
- dblibSvc.writeData(CRTBL_SERVICE_MODEL_TO_VF_MODEL_MAPPING, null, null);
- dblibSvc.writeData(CRTBL_ATTRIBUTE_VALUE_PAIR, null, null);
- dblibSvc.writeData(CRTBL_NETWORK_MODEL, null, null);
- dblibSvc.writeData(CRTBL_VFC_MODEL, null, null);
- dblibSvc.writeData(CRTBL_VFC_RELATED_NETWORK_ROLE, null, null);
- dblibSvc.writeData(CRTBL_VFC_TO_NETWORK_ROLE_MAPPING, null, null);
- dblibSvc.writeData(CRTBL_VF_MODEL, null, null);
- dblibSvc.writeData(CRTBL_VNF_RELATED_NETWORK_ROLE, null, null);
- dblibSvc.writeData(CRTBL_VF_TO_NETWORK_ROLE_MAPPING, null, null);
- dblibSvc.writeData(CRTBL_VF_MODULE_MODEL, null, null);
- dblibSvc.writeData(CRTBL_VF_MODULE_TO_VFC_MAPPING, null, null);
- dblibSvc.writeData(CRTBL_ALLOTTED_RESOURCE_MODEL, null, null);
- dblibSvc.writeData(CRTBL_RESOURCE_GROUP, null, null);
- dblibSvc.writeData(CRTBL_RESOURCE_GROUP_TO_TARGET_NODE_MAPPING, null, null);
- dblibSvc.writeData(CRTBL_RESOURCE_POLICY, null, null);
- dblibSvc.writeData(CRTBL_RESOURCE_POLICY_TO_TARGET_NODE_MAPPING, null, null);
- dblibSvc.writeData(CRTBL_NODE_CAPABILITY, null, null);
- dblibSvc.writeData(CRTBL_NODE_CAPABILITY_PROPERTY, null, null);
-
- processLevelArtifactList = new ArrayList<>();
- serviceLevelArtifactList = new ArrayList<>();
- resourceList = new ArrayList<>();
-
-
- mockProcessArtifact1 = mock(IArtifactInfo.class);
- when(mockProcessArtifact1.getArtifactName()).thenReturn("mockProcessArtifact1");
- when(mockProcessArtifact1.getArtifactType()).thenReturn("HEAT");
- when(mockProcessArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
- when(mockProcessArtifact1.getArtifactChecksum()).thenReturn("123tfg123 1234ftg");
- when(mockProcessArtifact1.getArtifactTimeout()).thenReturn(110);
-
- mockProcessArtifact2 = mock(IArtifactInfo.class);
- when(mockProcessArtifact2.getArtifactName()).thenReturn("mockProcessArtifact2");
- when(mockProcessArtifact2.getArtifactType()).thenReturn("DG_XML");
- when(mockProcessArtifact2.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
- when(mockProcessArtifact2.getArtifactChecksum()).thenReturn("456jhgt 1234ftg");
- when(mockProcessArtifact2.getArtifactTimeout()).thenReturn(110);
-
- mockProcessArtifact3 = mock(IArtifactInfo.class);
- when(mockProcessArtifact3.getArtifactName()).thenReturn("mockProcessArtifact3");
- when(mockProcessArtifact3.getArtifactType()).thenReturn("HEAT");
- when(mockProcessArtifact3.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
- when(mockProcessArtifact3.getArtifactChecksum()).thenReturn("123tfg123 543gtd");
- when(mockProcessArtifact3.getArtifactTimeout()).thenReturn(110);
-
-
- mockServiceArtifact1 = mock(IArtifactInfo.class);
- when(mockServiceArtifact1.getArtifactName()).thenReturn("mockProcessArtifact4");
- when(mockServiceArtifact1.getArtifactType()).thenReturn("HEAT");
- when(mockServiceArtifact1.getArtifactURL()).thenReturn("https://asdc.sdc.com/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml");
- when(mockServiceArtifact1.getArtifactChecksum()).thenReturn("123t3455 543gtd");
- when(mockServiceArtifact1.getArtifactTimeout()).thenReturn(110);
-
- resource = mock(IResourceInstance.class);
- }
-
- @After
- public void tearDown() throws Exception {
- // Move anything in archive back to incoming
- String curFileName = "";
-
- Path incomingPath = new File(config.getIncomingDir()).toPath();
- File archiveDir = new File(config.getArchiveDir());
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(archiveDir.toPath())) {
- for (Path file: stream) {
- Files.move(file, incomingPath.resolve(file.getFileName()), StandardCopyOption.REPLACE_EXISTING);
- }
- } catch (Exception x) {
- // IOException can never be thrown by the iteration.
- // In this snippet, it can only be thrown by newDirectoryStream.
- LOG.warn("Cannot replace spool file {}", curFileName, x);
- }
-
- db.stop();
-
- }
-
- @Test
- public void test() {
-
- IDistributionClient iDistClient = mock(IDistributionClient.class);
- SdncUebCallback cb = new SdncUebCallback(iDistClient, config);
- SdncUebCallback.setJdbcDataSource(dblibSvc);
-
- INotificationData iData = mock(INotificationData.class);
- /*IArtifactInfo iArtifactInfo = mock(IArtifactInfo.class);
- when(iArtifactInfo.getArtifactName()).thenReturn("testArtifact1");
- when(iArtifactInfo.getArtifactType()).thenReturn("TOSCA_CSAR");
- List artifactInfoList = new ArrayList();
- artifactInfoList.add(iArtifactInfo);*/
-
- when(iData.getServiceName()).thenReturn("testServiceName");
- //when(iData.getServiceArtifacts()).thenReturn(artifactInfoList);
- cb.deployDownloadedFiles(null, null, null);
- cb.activateCallback(iData);
-
- }
-
-
-
- @Test
- public void testServiceAndProcessArtifactsactivateCallback() {
-
- try {
- processLevelArtifactList.add(mockProcessArtifact1);
- processLevelArtifactList.add(mockProcessArtifact2);
- processLevelArtifactList.add(mockProcessArtifact3);
-
- resourceList.add(resource);
- serviceLevelArtifactList.add(mockServiceArtifact1);
- when(resource.getArtifacts()).thenReturn(serviceLevelArtifactList);
- when(resource.getResourceName()).thenReturn("Resource_service_name");
-
-
- IDistributionClient iDistClient1 = mock(IDistributionClient.class);
- INotificationData mockData = mock(INotificationData.class);
- when(mockData.getResources()).thenReturn(resourceList);
- when(mockData.getServiceName()).thenReturn("Test_service_name");
- when(mockData.getServiceArtifacts()).thenReturn(processLevelArtifactList);
-
- /*IArtifactInfo iArtifactInfo = mock(IArtifactInfo.class);
- when(iArtifactInfo.getArtifactName()).thenReturn("testArtifact1");
- when(iArtifactInfo.getArtifactType()).thenReturn("TOSCA_CSAR");
- List artifactInfoList = new ArrayList();
- artifactInfoList.add(iArtifactInfo);
-
- //when(mockData.getServiceName()).thenReturn("testServiceName");
- when(mockData.getServiceArtifacts()).thenReturn(artifactInfoList);*/
-
-
- SdncUebCallback cb1 = new SdncUebCallback(iDistClient1, config);
- cb1.activateCallback(mockData);
- assertTrue(true);
- } catch (Exception e) {
- assertTrue(false);
- }
- }
-
-}
diff --git a/ueb-listener/src/test/resources/artifact.map b/ueb-listener/src/test/resources/artifact.map
deleted file mode 100644
index 0256515f0..000000000
--- a/ueb-listener/src/test/resources/artifact.map
+++ /dev/null
@@ -1,2 +0,0 @@
-vf-license-model,ASDC-API:vf-license-model-update,0
-bad-entry,0
diff --git a/ueb-listener/src/test/resources/dblib.properties b/ueb-listener/src/test/resources/dblib.properties
deleted file mode 100644
index 9506ac8d1..000000000
--- a/ueb-listener/src/test/resources/dblib.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# 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=========================================================
-###
-
-# dblib.properrties
-org.onap.ccsdk.sli.dbtype=jdbc
-
-org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01
-org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl
-org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver
-org.onap.ccsdk.sli.jdbc.database=sdnctl
-org.onap.ccsdk.sli.jdbc.user=sdnctl
-org.onap.ccsdk.sli.jdbc.password=gamma
-org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01
-org.onap.ccsdk.sli.jdbc.connection.timeout=50
-org.onap.ccsdk.sli.jdbc.request.timeout=100
-org.onap.ccsdk.sli.jdbc.limit.init=10
-org.onap.ccsdk.sli.jdbc.limit.min=10
-org.onap.ccsdk.sli.jdbc.limit.max=20
-org.onap.dblib.connection.recovery=false
-
diff --git a/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar b/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar
deleted file mode 100644
index bb09f1c2f..000000000
--- a/ueb-listener/src/test/resources/incoming/src_test_resources_csars_nsepc.csar
+++ /dev/null
Binary files differ
diff --git a/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar b/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar
deleted file mode 100644
index 329076a15..000000000
--- a/ueb-listener/src/test/resources/incoming/src_test_resources_csars_service-NfodService-csar.csar
+++ /dev/null
Binary files differ
diff --git a/ueb-listener/src/test/resources/incoming/vf-license-model.xml b/ueb-listener/src/test/resources/incoming/vf-license-model.xml
deleted file mode 100644
index c5e33eeb5..000000000
--- a/ueb-listener/src/test/resources/incoming/vf-license-model.xml
+++ /dev/null
@@ -1 +0,0 @@
-<vf-license-model xmlns="http://xmlns.openecomp.org/asdc/license-model/1.0"><vendor-name>Broadsoft</vendor-name><vf-id>E5A18BC3D2454091B02EA3F69EB1DB46</vf-id><feature-group-list><feature-group><entitlement-pool-list><entitlement-pool><name>Broadsoft EP</name><description>tbp</description><increments>200</increments><entitlement-pool-uuid>728ad6b0-912e-432b-853e-373845d410ad</entitlement-pool-uuid><manufacturer-reference-number>tbp</manufacturer-reference-number><sp-limits/><vendor-limits/><operational-scope><value>VM</value></operational-scope><start-date/><expiry-date/><threshold-value><unit>Absolute</unit><value>100</value></threshold-value></entitlement-pool></entitlement-pool-list><license-key-group-list><license-key-group><name>Placeholder BS LPK</name><description>tbp</description><type>Universal</type><increments/><license-key-group-uuid>3be519b2-abf3-449f-9851-0ac70ccb5632</license-key-group-uuid><manufacturer-reference-number>tbp</manufacturer-reference-number><sp-limits/><vendor-limits/><operational-scope><value>VM</value></operational-scope><start-date/><expiry-date/><threshold-value><unit/><value/></threshold-value></license-key-group></license-key-group-list><description>tbp</description><part-number>asdfasfdsdf</part-number><name>Placeholder LPK</name><feature-group-uuid>4ACF252A84FA4FEC9C98AA0DFCFFFBCE</feature-group-uuid></feature-group></feature-group-list></vf-license-model> \ No newline at end of file
diff --git a/ueb-listener/src/test/resources/log4j.properties b/ueb-listener/src/test/resources/log4j.properties
deleted file mode 100644
index 71849c3db..000000000
--- a/ueb-listener/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# 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=========================================================
-###
-
-log4j.rootLogger=DEBUG,CONSOLE
-
-# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
-
-
diff --git a/ueb-listener/src/test/resources/ueb-listener.properties b/ueb-listener/src/test/resources/ueb-listener.properties
deleted file mode 100755
index c017cbd7b..000000000
--- a/ueb-listener/src/test/resources/ueb-listener.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-org.onap.ccsdk.sli.northbound.uebclient.asdc-address=localhost:1234
-org.onap.ccsdk.sli.northbound.uebclient.consumer-group=ccsdk1
-org.onap.ccsdk.sli.northbound.uebclient.consumer-id=localhost_ccsdk1
-org.onap.ccsdk.sli.northbound.uebclient.environment-name=UNITTEST
-org.onap.ccsdk.sli.northbound.uebclient.password=123456
-org.onap.ccsdk.sli.northbound.uebclient.user=test
-org.onap.ccsdk.sli.northbound.uebclient.sdnc-user=test
-org.onap.ccsdk.sli.northbound.uebclient.sdnc-passwd=test
-org.onap.ccsdk.sli.northbound.uebclient.asdc-api-base-url=http://localhost:8282/restconf/operations/
-org.onap.ccsdk.sli.northbound.uebclient.asdc-api-namespace=org:onap:ccsdk
-org.onap.ccsdk.sli.northbound.uebclient.spool.incoming=src/test/resources/incoming
-org.onap.ccsdk.sli.northbound.uebclient.spool.archive=src/test/resources/archive
-org.onap.ccsdk.sli.northbound.uebclient.polling-interval=30
-org.onap.ccsdk.sli.northbound.uebclient.polling-timeout=15
-org.onap.ccsdk.sli.northbound.uebclient.client-startup-timeout=60
-org.onap.ccsdk.sli.northbound.uebclient.relevant-artifact-types=YANG_XML,VF_LICENSE,TOSCA_TEMPLATE,TOSCA_CSAR,UCPE_LAYER_2_CONFIGURATION
-org.onap.ccsdk.sli.northbound.uebclient.relevant-capability-names=RoutingConfiguration,routing_configuration,VLANAssignment,vlan_assignment
-org.onap.ccsdk.sli.northbound.uebclient.activate-server-tls-auth=false
-org.onap.ccsdk.sli.northbound.uebclient.keystore-path=
-org.onap.ccsdk.sli.northbound.uebclient.keystore-password=
-org.onap.ccsdk.sli.northbound.uebclient.xslt-path-list=
-org.onap.ccsdk.sli.northbound.uebclient.artifact-map=src/test/resources/artifact.map