From 9296b7674ea71cb86fe2ea99e80d9d055267ae5b Mon Sep 17 00:00:00 2001 From: Skip Wonnell Date: Tue, 15 Aug 2017 17:26:38 -0500 Subject: [PATCH] Initial commit for appc-flow-controller bundle This bundle contains the APPC orchestration control for the directed graph for model driven transactions Issue-ID: APPC-73 Change-Id: Ia812fe14b2d6aa46c3acd5b2bfab0c004507c628 Signed-off-by: Skip Wonnell --- appc-config/appc-flow-controller/.gitignore | 1 + .../appc-flow-controller/features/.gitignore | 1 + appc-config/appc-flow-controller/features/pom.xml | 103 ++++ .../features/src/main/resources/features.xml | 43 ++ appc-config/appc-flow-controller/installer/pom.xml | 148 ++++++ .../src/assembly/assemble_installer_zip.xml | 59 +++ .../src/assembly/assemble_mvnrepo_zip.xml | 47 ++ .../src/main/resources/scripts/install-feature.sh | 40 ++ appc-config/appc-flow-controller/pom.xml | 49 ++ .../appc-flow-controller/provider/.gitignore | 1 + appc-config/appc-flow-controller/provider/pom.xml | 138 +++++ .../flow/controller/FlowControllerActivator.java | 80 +++ .../DefaultResponseHandler.java | 55 ++ .../flow/controller/data/ActionIdentifier.java | 70 +++ .../appc/flow/controller/data/Parameters.java | 82 +++ .../appc/flow/controller/data/PreCheck.java | 93 ++++ .../appc/flow/controller/data/PrecheckOption.java | 109 ++++ .../appc/flow/controller/data/Response.java | 79 +++ .../appc/flow/controller/data/ResponseAction.java | 103 ++++ .../appc/flow/controller/data/Transaction.java | 365 +++++++++++++ .../appc/flow/controller/data/Transactions.java | 50 ++ .../controller/dbervices/FlowControlDBService.java | 220 ++++++++ .../controller/executorImpl/GraphExecutor.java | 163 ++++++ .../flow/controller/executorImpl/NodeExecutor.java | 47 ++ .../flow/controller/executorImpl/RestExecutor.java | 156 ++++++ .../executorImpl/SecureRestClientTrustManager.java | 54 ++ .../controller/interfaceData/ActionIdentifier.java | 158 ++++++ .../controller/interfaceData/Capabilities.java | 190 +++++++ .../controller/interfaceData/DependencyInfo.java | 86 ++++ .../appc/flow/controller/interfaceData/Input.java | 199 ++++++++ .../controller/interfaceData/InventoryInfo.java | 80 +++ .../controller/interfaceData/ObjectFactory.java | 147 ++++++ .../flow/controller/interfaceData/RequestInfo.java | 164 ++++++ .../interfaceData/TunableParameters.java | 153 ++++++ .../appc/flow/controller/interfaceData/Vm.java | 108 ++++ .../flow/controller/interfaceData/VnfInfo.java | 172 +++++++ .../appc/flow/controller/interfaceData/Vnfcs.java | 176 +++++++ .../flow/controller/interfaceData/Vnfcslist.java | 127 +++++ .../flow/controller/interfaceData/Vnflist.java | 150 ++++++ .../controller/interfaceData/package-info.java | 29 ++ .../interfaces/FlowExecutorInterface.java | 37 ++ .../appc/flow/controller/node/FlowControlNode.java | 562 +++++++++++++++++++++ .../appc/flow/controller/node/FlowGenerator.java | 80 +++ .../appc/flow/controller/node/JsonParsingNode.java | 98 ++++ .../appc/flow/controller/node/RestServiceNode.java | 207 ++++++++ .../appc/flow/controller/utils/EscapeUtils.java | 39 ++ .../controller/utils/FlowControllerConstants.java | 117 +++++ .../main/resources/appc-flow-controller.properties | 23 + .../provider/src/main/resources/jaxby.properties | 21 + .../flow/executor/node/TestFlowExecutorNode.java | 89 ++++ .../appc/flow/executor/node/TestParsingNode.java | 90 ++++ .../flow/executor/node/TestRestServiceNode.java | 125 +++++ .../provider/src/test/resources/Info.out.xml | 19 + .../src/test/resources/svclogic.properties | 33 ++ .../src/test/resources/transactionModel.json | 63 +++ appc-config/jacoco.exec | Bin 9623 -> 0 bytes appc-config/pom.xml | 161 +++--- 57 files changed, 5979 insertions(+), 80 deletions(-) create mode 100644 appc-config/appc-flow-controller/.gitignore create mode 100644 appc-config/appc-flow-controller/features/.gitignore create mode 100644 appc-config/appc-flow-controller/features/pom.xml create mode 100644 appc-config/appc-flow-controller/features/src/main/resources/features.xml create mode 100644 appc-config/appc-flow-controller/installer/pom.xml create mode 100644 appc-config/appc-flow-controller/installer/src/assembly/assemble_installer_zip.xml create mode 100644 appc-config/appc-flow-controller/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 appc-config/appc-flow-controller/installer/src/main/resources/scripts/install-feature.sh create mode 100644 appc-config/appc-flow-controller/pom.xml create mode 100644 appc-config/appc-flow-controller/provider/.gitignore create mode 100644 appc-config/appc-flow-controller/provider/pom.xml create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/FlowControllerActivator.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandler.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ActionIdentifier.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Parameters.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PreCheck.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PrecheckOption.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Response.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ResponseAction.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transaction.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transactions.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/GraphExecutor.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/NodeExecutor.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/RestExecutor.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/SecureRestClientTrustManager.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ActionIdentifier.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Capabilities.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/DependencyInfo.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Input.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/InventoryInfo.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ObjectFactory.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/RequestInfo.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/TunableParameters.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vm.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/VnfInfo.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcs.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcslist.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnflist.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/package-info.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaces/FlowExecutorInterface.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowControlNode.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowGenerator.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/JsonParsingNode.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/RestServiceNode.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/EscapeUtils.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/FlowControllerConstants.java create mode 100644 appc-config/appc-flow-controller/provider/src/main/resources/appc-flow-controller.properties create mode 100644 appc-config/appc-flow-controller/provider/src/main/resources/jaxby.properties create mode 100644 appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java create mode 100644 appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java create mode 100644 appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java create mode 100644 appc-config/appc-flow-controller/provider/src/test/resources/Info.out.xml create mode 100644 appc-config/appc-flow-controller/provider/src/test/resources/svclogic.properties create mode 100644 appc-config/appc-flow-controller/provider/src/test/resources/transactionModel.json delete mode 100644 appc-config/jacoco.exec diff --git a/appc-config/appc-flow-controller/.gitignore b/appc-config/appc-flow-controller/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-config/appc-flow-controller/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-config/appc-flow-controller/features/.gitignore b/appc-config/appc-flow-controller/features/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-config/appc-flow-controller/features/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-config/appc-flow-controller/features/pom.xml b/appc-config/appc-flow-controller/features/pom.xml new file mode 100644 index 000000000..9db5fee14 --- /dev/null +++ b/appc-config/appc-flow-controller/features/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + org.openecomp.appc + appc-config-flow-controller + 1.1.0-SNAPSHOT + + appc-config-flow-controller-features + Flow Executor - Features + jar + + + + org.openecomp.appc + appc-config-flow-controller-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.version} + features + xml + + runtime + + + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/appc-config/appc-flow-controller/features/src/main/resources/features.xml b/appc-config/appc-flow-controller/features/src/main/resources/features.xml new file mode 100644 index 000000000..76161bd18 --- /dev/null +++ b/appc-config/appc-flow-controller/features/src/main/resources/features.xml @@ -0,0 +1,43 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features + + + + odl-mdsal-broker + sdnc-sli + + mvn:commons-lang/commons-lang/2.6 + mvn:commons-collections/commons-collections/${common.collections.version} + + wrap:mvn:com.att.eelf/eelf-core/${eelf.version} + mvn:ch.qos.logback/logback-core/${logback.version} + mvn:ch.qos.logback/logback-classic/${logback.version} + mvn:org.openecomp.appc/appc-flow-controller-provider/${project.version} + + diff --git a/appc-config/appc-flow-controller/installer/pom.xml b/appc-config/appc-flow-controller/installer/pom.xml new file mode 100644 index 000000000..11c8f8752 --- /dev/null +++ b/appc-config/appc-flow-controller/installer/pom.xml @@ -0,0 +1,148 @@ + + + + 4.0.0 + + org.openecomp.appc + appc-config-flow-controller + 1.1.0-SNAPSHOT + + + appc-config-flow-controller-installer + Config Component Params - Installer + pom + + appc-config-flow-controller + appc-config-flow-controller + mvn:org.openecomp.appc/appc-config-flow-controller-features/${project.version}/xml/features + false + + + + org.openecomp.appc + appc-config-flow-controller-features + features + xml + + + * + * + + + + + org.openecomp.appc + appc-config-flow-controller-provider + 1.1.0-SNAPSHOT + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + + + + installer-zip + + single + + package + + false + true + ${application.name}-${project.version} + + src/assembly/assemble_installer_zip.xml + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.opendaylight + provided + + + + + + maven-resources-plugin + + + copy-version + + copy-resources + + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + diff --git a/appc-config/appc-flow-controller/installer/src/assembly/assemble_installer_zip.xml b/appc-config/appc-flow-controller/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..3ea5ea062 --- /dev/null +++ b/appc-config/appc-flow-controller/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + flow-controller + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/appc-config/appc-flow-controller/installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-config/appc-flow-controller/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..c29a43ebf --- /dev/null +++ b/appc-config/appc-flow-controller/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,47 @@ + + + + + + flow-controller + + zip + + + + false + + + + target/assembly/ + . + + + + + + diff --git a/appc-config/appc-flow-controller/installer/src/main/resources/scripts/install-feature.sh b/appc-config/appc-flow-controller/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..d3d2ea6e7 --- /dev/null +++ b/appc-config/appc-flow-controller/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-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========================================================= +# ECOMP is a trademark and service mark of AT&T Intellectual Property. +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-config/appc-flow-controller/pom.xml b/appc-config/appc-flow-controller/pom.xml new file mode 100644 index 000000000..60cb3a20e --- /dev/null +++ b/appc-config/appc-flow-controller/pom.xml @@ -0,0 +1,49 @@ + + + + org.openecomp.appc + appc-config + 1.1.0-SNAPSHOT + + + 4.0.0 + pom + appc-config-flow-controller + + APPC Flow Executor + + + UTF-8 + + + + + + + + org.openecomp.appc + appc-config-flow-controller-features + features + xml + ${project.version} + + + + org.openecomp.appc + appc-config-flow-controller-provider + ${project.version} + + + + + + + + + provider + features + installer + + Flow sequence executor for APPC + diff --git a/appc-config/appc-flow-controller/provider/.gitignore b/appc-config/appc-flow-controller/provider/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-config/appc-flow-controller/provider/pom.xml b/appc-config/appc-flow-controller/provider/pom.xml new file mode 100644 index 000000000..e76d42dae --- /dev/null +++ b/appc-config/appc-flow-controller/provider/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + + org.openecomp.appc + appc-config-flow-controller + 1.1.0-SNAPSHOT + + appc-config-flow-controller-provider + bundle + Flow Executor - Provider + http://maven.apache.org + + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.openecomp.sdnc.core + sli-provider + + + commons-io + commons-io + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.att.eelf + eelf-core + + + org.openecomp.sdnc.adaptors + sql-resource-provider + compile + + + org.openecomp.sdnc.core + sli-provider + + + org.openecomp.sdnc.core + sli-common + + + com.sun.jersey + jersey-client + 1.17 + provided + + + + junit + junit + test + + + + org.json + json + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.appc.flow.controller + org.openecomp.appc.flow.controller.FlowControllerActivator + org.openecomp.appc.flow.controller + * + * + + ${project.basedir}/src/main/resources/META-INF + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + + diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/FlowControllerActivator.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/FlowControllerActivator.java new file mode 100644 index 000000000..e7e80b731 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/FlowControllerActivator.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller; + +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.openecomp.appc.flow.controller.node.FlowControlNode; +import org.openecomp.appc.flow.controller.node.JsonParsingNode; +import org.openecomp.appc.flow.controller.node.RestServiceNode; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class FlowControllerActivator implements BundleActivator{ + + private List registrations = new LinkedList(); + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowControllerActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception + { + + try { + + FlowControlNode flowExecutorNode = new FlowControlNode(); + log.debug("Registering service "+ flowExecutorNode.getClass().getName()); + registrations.add(ctx.registerService(flowExecutorNode.getClass().getName(), flowExecutorNode, null)); + log.debug("Registering service sccessful for "+ flowExecutorNode.getClass().getName()); + + RestServiceNode restServiceNode = new RestServiceNode(); + log.debug("Registering service "+ restServiceNode.getClass().getName()); + registrations.add(ctx.registerService(restServiceNode.getClass().getName(), restServiceNode, null)); + log.debug("Registering service sccessful for "+ restServiceNode.getClass().getName()); + + JsonParsingNode jsonParsingNode = new JsonParsingNode(); + log.debug("Registering service "+ jsonParsingNode.getClass().getName()); + registrations.add(ctx.registerService(jsonParsingNode.getClass().getName(), jsonParsingNode, null)); + log.debug("Registering service sccessful for "+ jsonParsingNode.getClass().getName()); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + @Override + public void stop(BundleContext arg0) throws Exception + { + for (ServiceRegistration registration: registrations) + { + registration.unregister(); + registration = null; + } + + } +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandler.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandler.java new file mode 100644 index 000000000..58877348f --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandler.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.ResponseHandlerImpl; + +import java.util.ArrayList; +import java.util.List; + +import org.openecomp.appc.flow.controller.data.Response; +import org.openecomp.appc.flow.controller.data.ResponseAction; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class DefaultResponseHandler { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(DefaultResponseHandler.class); + + public ResponseAction handlerResponse(Transaction transaction){ + + log.info("Transaction Input params " + transaction.toString()); + ResponseAction responseAction = new ResponseAction(); + if(transaction.getResponses() != null && !transaction.getResponses().isEmpty()){ + for(Response response : transaction.getResponses()){ + if(response.getResponseCode() != null && response.getResponseCode().equals(transaction.getStatusCode())){ + responseAction = response.getResponseAction(); + break; + } + + } + + } + return responseAction ; + } +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ActionIdentifier.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ActionIdentifier.java new file mode 100644 index 000000000..422bb1152 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ActionIdentifier.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ActionIdentifier { + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((vnfId == null) ? 0 : vnfId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ActionIdentifier other = (ActionIdentifier) obj; + if (vnfId == null) { + if (other.vnfId != null) + return false; + } else if (!vnfId.equals(other.vnfId)) + return false; + return true; + } + + @JsonProperty("vnf-id") + private String vnfId ; + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } + + @Override + public String toString() { + return "ActionIdentifier [vnfId=" + vnfId + "]"; + } + + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Parameters.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Parameters.java new file mode 100644 index 000000000..fe3ae8ff0 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Parameters.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Parameters { + + + @JsonProperty("name") + private String paramName ; + + @JsonProperty("value") + private String paramValue ; + + + public String getParamValue() { + return paramValue; + } + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + public String getParamName() { + return paramName; + } + public void setParamName(String paramName) { + this.paramName = paramName; + } + @Override + public String toString() { + return "Parameters [paramName=" + paramName + ", paramValue=" + paramValue + "]"; + } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((paramName == null) ? 0 : paramName.hashCode()); + result = prime * result + ((paramValue == null) ? 0 : paramValue.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Parameters other = (Parameters) obj; + if (paramName == null) { + if (other.paramName != null) + return false; + } else if (!paramName.equals(other.paramName)) + return false; + if (paramValue == null) { + if (other.paramValue != null) + return false; + } else if (!paramValue.equals(other.paramValue)) + return false; + return true; + } + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PreCheck.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PreCheck.java new file mode 100644 index 000000000..9ee3d615a --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PreCheck.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class PreCheck { + + + @JsonProperty("precheck-operator") + private String precheckOperator; + + public String getPrecheckOperator() { + return precheckOperator; + } + + public void setPrecheckOperator(String precheckOperator) { + this.precheckOperator = precheckOperator; + } + + @JsonProperty("precheck-options") + private List precheckOptions; + + public List getPrecheckOptions() { + return precheckOptions; + } + + public void setPrecheckOptions(List precheckOptions) { + this.precheckOptions = precheckOptions; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((precheckOperator == null) ? 0 : precheckOperator.hashCode()); + result = prime * result + ((precheckOptions == null) ? 0 : precheckOptions.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PreCheck other = (PreCheck) obj; + if (precheckOperator == null) { + if (other.precheckOperator != null) + return false; + } else if (!precheckOperator.equals(other.precheckOperator)) + return false; + if (precheckOptions == null) { + if (other.precheckOptions != null) + return false; + } else if (!precheckOptions.equals(other.precheckOptions)) + return false; + return true; + } + + @Override + public String toString() { + return "PreCheck [precheckOperator=" + precheckOperator + ", precheckOptions=" + precheckOptions + "]"; + } + + + + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PrecheckOption.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PrecheckOption.java new file mode 100644 index 000000000..efa19025a --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/PrecheckOption.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class PrecheckOption { + + + @JsonProperty("pre-transaction-id") + private int pTransactionID ; + + @JsonProperty("param-name") + private String paramName ; + + + @JsonProperty("param-value") + private String paramValue ; + + @JsonProperty("rule") + private String rule ; + + public int getpTransactionID() { + return pTransactionID; + } + + public void setpTransactionID(int pTransactionID) { + this.pTransactionID = pTransactionID; + } + + public String getParamName() { + return paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamValue() { + return paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + + + @Override + public String toString() { + return "PrecheckOption [pTransactionID=" + pTransactionID + ", paramName=" + paramName + ", paramValue=" + + paramValue + ", rule=" + rule + "]"; + } + + + public String getRule() { + return rule; + } + + public void setRule(String rule) { + this.rule = rule; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PrecheckOption other = (PrecheckOption) obj; + if (pTransactionID != other.pTransactionID) + return false; + if (paramName == null) { + if (other.paramName != null) + return false; + } else if (!paramName.equals(other.paramName)) + return false; + if (paramValue == null) { + if (other.paramValue != null) + return false; + } else if (!paramValue.equals(other.paramValue)) + return false; + if (rule != other.rule) + return false; + return true; + } + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Response.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Response.java new file mode 100644 index 000000000..fb20edb6b --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Response.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Response { + + @JsonProperty("response-code") + private String responseCode; + + @JsonProperty("response-message") + private String responseMessage; + + @JsonProperty("response-action") + private ResponseAction responseAction; + + private String responseActionHanlder; + + public String getResponseCode() { + return responseCode; + } + + public void setResponseCode(String responseCode) { + this.responseCode = responseCode; + } + + public String getResponseMessage() { + return responseMessage; + } + + public void setResponseMessage(String responseMessage) { + this.responseMessage = responseMessage; + } + + + public String getResponseActionHanlder() { + return responseActionHanlder; + } + + public void setResponseActionHanlder(String responseActionHanlder) { + this.responseActionHanlder = responseActionHanlder; + } + + public ResponseAction getResponseAction() { + return responseAction; + } + + public void setResponseAction(ResponseAction responseAction) { + this.responseAction = responseAction; + } + + @Override + public String toString() { + return "Response [responseCode=" + responseCode + ", responseMessage=" + responseMessage + ", responseAction=" + + responseAction + ", responseActionHanlder=" + responseActionHanlder + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ResponseAction.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ResponseAction.java new file mode 100644 index 000000000..84497de35 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/ResponseAction.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ResponseAction { + + @JsonProperty("wait") + private String wait; + + @JsonProperty("retry") + private String retry; + + @JsonProperty("jump") + private String jump; + + @JsonProperty("ignore") + private boolean ignore; + + @JsonProperty("stop") + private boolean stop; + + @JsonProperty("intermediate-message") + private boolean intermediateMessage; + + public String getWait() { + return wait; + } + + public void setWait(String wait) { + this.wait = wait; + } + + public String getRetry() { + return retry; + } + + public void setRetry(String retry) { + this.retry = retry; + } + + public String getJump() { + return jump; + } + + public void setJump(String jump) { + this.jump = jump; + } + + public boolean isIgnore() { + return ignore; + } + + public void setIgnore(boolean ignore) { + this.ignore = ignore; + } + + public boolean isStop() { + return stop; + } + + public void setStop(boolean stop) { + this.stop = stop; + } + + + + @Override + public String toString() { + return "ResponseAction [wait=" + wait + ", retry=" + retry + ", jump=" + jump + ", ignore=" + ignore + ", stop=" + + stop + ", intermediateMessage=" + intermediateMessage + "]"; + } + + public boolean isIntermediateMessage() { + return intermediateMessage; + } + + public void setIntermediateMessage(boolean intermediateMessage) { + this.intermediateMessage = intermediateMessage; + } + + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transaction.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transaction.java new file mode 100644 index 000000000..8f26e80ff --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transaction.java @@ -0,0 +1,365 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class Transaction { + + @JsonProperty("transaction-id") + private int transactionId ; + + @JsonProperty("action") + private String action ; + + @JsonProperty("action-level") + private String actionLevel ; + + @JsonProperty("action-identifier") + private ActionIdentifier actionIdentifier ; + + @JsonProperty("parameters") + private List parameters ; + + private String executionType; + + private String uId; + + private String statusCode; + + private String pswd; + + private String executionEndPoint; + + private String executionModule; + + private String executionRPC; + + @JsonProperty("state") + private String state; + + @JsonProperty("precheck") + private PreCheck precheck; + + @JsonProperty("payload") + private String payload ; + + @JsonProperty("responses") + private List responses ; + + + private String status = "PENDING"; + + public String getuId() { + return uId; + } + + public void setuId(String uId) { + this.uId = uId; + } + + public String getPswd() { + return pswd; + } + + public void setPswd(String pswd) { + this.pswd = pswd; + } + + public String getExecutionEndPoint() { + return executionEndPoint; + } + + public void setExecutionEndPoint(String executionEndPoint) { + this.executionEndPoint = executionEndPoint; + } + + + public String getExecutionType() { + return executionType; + } + + public void setExecutionType(String executionType) { + this.executionType = executionType; + } + + public String getExecutionModule() { + return executionModule; + } + + + public void setExecutionModule(String executionModule) { + this.executionModule = executionModule; + } + + + public String getExecutionRPC() { + return executionRPC; + } + + + public void setExecutionRPC(String executionRPC) { + this.executionRPC = executionRPC; + } + + + public List getParameters() { + return parameters; + } + + + public void setParameters(List parameters) { + this.parameters = parameters; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public PreCheck getPrecheck() { + return precheck; + } + + public void setPrecheck(PreCheck precheck) { + this.precheck = precheck; + } + + public String getStatus() { + return status; + } + + + public void setStatus(String status) { + this.status = status; + } + + public List getResponses() { + return responses; + } + + + public void setResponses(List responses) { + this.responses = responses; + } + + public int getTransactionId() { + return transactionId; + } + + + public void setTransactionId(int transactionId) { + this.transactionId = transactionId; + } + + + public String getAction() { + return action; + } + + + public void setAction(String action) { + this.action = action; + } + + + public String getActionLevel() { + return actionLevel; + } + + + public void setActionLevel(String actionLevel) { + this.actionLevel = actionLevel; + } + + + + public String getPayload() { + return payload; + } + + + public void setPayload(String payload) { + this.payload = payload; + } + + + public ActionIdentifier getActionIdentifier() { + return actionIdentifier; + } + + + public void setActionIdentifier(ActionIdentifier actionIdentifier) { + this.actionIdentifier = actionIdentifier; + } + + public String getStatusCode() { + return statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + @Override + public String toString() { + return "Transaction [transactionId=" + transactionId + ", action=" + action + ", actionLevel=" + actionLevel + + ", actionIdentifier=" + actionIdentifier + ", parameters=" + parameters + ", executionType=" + + executionType + ", uId=" + uId + ", statusCode=" + statusCode + ", pswd=" + pswd + + ", executionEndPoint=" + executionEndPoint + ", executionModule=" + executionModule + + ", executionRPC=" + executionRPC + ", state=" + state + ", precheck=" + precheck + ", payload=" + + payload + ", responses=" + responses + ", status=" + status + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((action == null) ? 0 : action.hashCode()); + result = prime * result + ((actionIdentifier == null) ? 0 : actionIdentifier.hashCode()); + result = prime * result + ((actionLevel == null) ? 0 : actionLevel.hashCode()); + result = prime * result + ((executionEndPoint == null) ? 0 : executionEndPoint.hashCode()); + result = prime * result + ((executionModule == null) ? 0 : executionModule.hashCode()); + result = prime * result + ((executionRPC == null) ? 0 : executionRPC.hashCode()); + result = prime * result + ((executionType == null) ? 0 : executionType.hashCode()); + result = prime * result + ((parameters == null) ? 0 : parameters.hashCode()); + result = prime * result + ((payload == null) ? 0 : payload.hashCode()); + result = prime * result + ((precheck == null) ? 0 : precheck.hashCode()); + result = prime * result + ((pswd == null) ? 0 : pswd.hashCode()); + result = prime * result + ((responses == null) ? 0 : responses.hashCode()); + result = prime * result + ((state == null) ? 0 : state.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((statusCode == null) ? 0 : statusCode.hashCode()); + result = prime * result + transactionId; + result = prime * result + ((uId == null) ? 0 : uId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Transaction other = (Transaction) obj; + if (action == null) { + if (other.action != null) + return false; + } else if (!action.equals(other.action)) + return false; + if (actionIdentifier == null) { + if (other.actionIdentifier != null) + return false; + } else if (!actionIdentifier.equals(other.actionIdentifier)) + return false; + if (actionLevel == null) { + if (other.actionLevel != null) + return false; + } else if (!actionLevel.equals(other.actionLevel)) + return false; + if (executionEndPoint == null) { + if (other.executionEndPoint != null) + return false; + } else if (!executionEndPoint.equals(other.executionEndPoint)) + return false; + if (executionModule == null) { + if (other.executionModule != null) + return false; + } else if (!executionModule.equals(other.executionModule)) + return false; + if (executionRPC == null) { + if (other.executionRPC != null) + return false; + } else if (!executionRPC.equals(other.executionRPC)) + return false; + if (executionType == null) { + if (other.executionType != null) + return false; + } else if (!executionType.equals(other.executionType)) + return false; + if (parameters == null) { + if (other.parameters != null) + return false; + } else if (!parameters.equals(other.parameters)) + return false; + if (payload == null) { + if (other.payload != null) + return false; + } else if (!payload.equals(other.payload)) + return false; + if (precheck == null) { + if (other.precheck != null) + return false; + } else if (!precheck.equals(other.precheck)) + return false; + if (pswd == null) { + if (other.pswd != null) + return false; + } else if (!pswd.equals(other.pswd)) + return false; + if (responses == null) { + if (other.responses != null) + return false; + } else if (!responses.equals(other.responses)) + return false; + if (state == null) { + if (other.state != null) + return false; + } else if (!state.equals(other.state)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + if (statusCode == null) { + if (other.statusCode != null) + return false; + } else if (!statusCode.equals(other.statusCode)) + return false; + if (transactionId != other.transactionId) + return false; + if (uId == null) { + if (other.uId != null) + return false; + } else if (!uId.equals(other.uId)) + return false; + return true; + } + + +} + + + diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transactions.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transactions.java new file mode 100644 index 000000000..736b7f3b7 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/data/Transactions.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.data; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Transactions { + + + @JsonProperty("transactions") + private List transactions ; + + public List getTransactions() { + return transactions; + } + + public void setTransactions(List transactions) { + this.transactions = transactions; + } + + @Override + public String toString() { + return "Transactions [transactions=" + transactions + "]"; + } + + +} + + + diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java new file mode 100644 index 000000000..c3ea6ede8 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java @@ -0,0 +1,220 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.dbervices; + +import java.util.HashMap; +import java.util.Map; + +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.utils.EscapeUtils; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.openecomp.sdnc.sli.SvcLogicResource.QueryStatus; +import org.openecomp.sdnc.sli.resource.sql.SqlResource; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class FlowControlDBService { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowControlDBService.class); + private SvcLogicResource serviceLogic; + private static FlowControlDBService dgGeneralDBService = null; + public static FlowControlDBService initialise() { + if (dgGeneralDBService == null) { + dgGeneralDBService = new FlowControlDBService(); + } + return dgGeneralDBService; + } + private FlowControlDBService() { + if (serviceLogic == null) { + serviceLogic = new SqlResource(); + } + } + + public void getFlowReferenceData(SvcLogicContext ctx, Map inParams, SvcLogicContext localContext) throws SvcLogicException { + + String fn = "DBService.getflowModelInfo"; + // log.debug("Testing " + ctx.getAttribute(FlowExecutorConstants.VNF_TYPE) + " and " + ctx.getAttribute(FlowExecutorConstants.ACTION_LEVEL)); + String whereClause = " where ACTION = $" +FlowControllerConstants.REQUEST_ACTION ; + + if(ctx.getAttribute(FlowControllerConstants.VNF_TYPE) !=null) + whereClause = whereClause.concat(" and VNF_TYPE = $" + FlowControllerConstants.VNF_TYPE); + + if(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL) !=null) + whereClause = whereClause.concat(" and ACTION_LEVEL = $" + FlowControllerConstants.ACTION_LEVEL); + + QueryStatus status = null; + if (serviceLogic != null && localContext != null) { + String key = "select SEQUENCE_TYPE, CATEGORY, GENERATION_NODE, EXECUTION_NODE from " + FlowControllerConstants.DB_MULTISTEP_FLOW_REFERENCE + + whereClause ; + log.debug(fn + "Query String : " + key); + status = serviceLogic.query("SQL", false, null, key, null, null, localContext); + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting FlowReferenceData "); + } + } + public String getEndPointByAction(String action) { + // TODO Auto-generated method stub + return null; + } + public String getDesignTimeFlowModel(SvcLogicContext localContext) throws SvcLogicException { + String fn = "DBService.getDesignTimeFlowModel "; + QueryStatus status = null; + if (serviceLogic != null && localContext != null) { + String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from " + FlowControllerConstants.DB_ASDC_ARTIFACTS + + " where artifact_name in (select artifact_name from " + FlowControllerConstants.DB_ASDC_REFERENCE + + " where vnf_type= $" + FlowControllerConstants.VNF_TYPE + + " and vnfc_type = $" + FlowControllerConstants.VNFC_TYPE + + " and action = $" + FlowControllerConstants.REQUEST_ACTION + + " and file_category = $" + FlowControllerConstants.CATEGORY + " )" ; + + + log.debug(fn + "Query String : " + queryString); + status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext); + + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting FlowReferenceData "); + + String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_ASDC_ARTIFACTS + + " where artifact_name = $artifactName and internal_version = $maxInternalVersion "; + + log.debug(fn + "Query String : " + queryString1); + status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext); + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting FlowReferenceData "); + } + + return localContext.getAttribute("artifact-content"); + } + public QueryStatus loadSequenceIntoDB(SvcLogicContext localContext) throws SvcLogicException { + String fn = "DBService.saveArtifacts"; + localContext.setAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED, EscapeUtils.escapeSql(localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT))); + log.debug("ESCAPED sequence for DB : " + localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED)); + + for (Object key : localContext.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = localContext.getAttribute(parmName); + log.debug(" loadSequenceIntoDB " + parmName + "=" + parmValue); + + } + + + QueryStatus status = null; + if (serviceLogic != null && localContext != null) { + String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS + + " set request_id = $" + FlowControllerConstants.REQUEST_ID + + " , action = $" + FlowControllerConstants.REQUEST_ACTION + + " , action_level = $" + FlowControllerConstants.ACTION_LEVEL + + " , vnf_type = $" + FlowControllerConstants.VNF_TYPE + + " , category = $" + FlowControllerConstants.CATEGORY + + " , artifact_content = $" + FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED + + " , updated_date = sysdate() "; + + status = serviceLogic.save("SQL", false, false, queryString, null, null, localContext); + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error While processing storing Artifact: " +localContext.getAttribute(FlowControllerConstants.ARTIFACT_NAME)); + } + return status; + + } + public void populateModuleAndRPC(Transaction transaction, String vnf_type) throws SvcLogicException { + String fn = "FlowControlDBService.populateModuleAndRPC "; + QueryStatus status = null; + SvcLogicContext context = new SvcLogicContext(); + if (serviceLogic != null && context != null) { + String key = "select execution_type, execution_module, execution_rpc from " + FlowControllerConstants.DB_PROCESS_FLOW_REFERENCE + + " where action = '" + transaction.getAction() + "'" + + " and action_level = '" + transaction.getActionLevel() + "'" + + " and protocol in ( select protocol from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE + + " where action = '" + transaction.getAction() + "'" ; + if(vnf_type !=null && !vnf_type.isEmpty()) + key = key + " and vnf_type ='" + vnf_type + "' )" ; + else + key = key + " ) " ; + log.debug(fn + "Query String : " + key); + status = serviceLogic.query("SQL", false, null, key, null, null, context); + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting FlowReferenceData "); + + transaction.setExecutionModule(context.getAttribute(FlowControllerConstants.EXECUTTION_MODULE)); + transaction.setExecutionRPC(context.getAttribute(FlowControllerConstants.EXECUTION_RPC)); + transaction.setExecutionType(context.getAttribute(FlowControllerConstants.EXECUTION_TYPE)); + } + + } + + public String getDependencyInfo(SvcLogicContext localContext) throws SvcLogicException { + String fn = "DBService.getDependencyInfo "; + QueryStatus status = null; + if (serviceLogic != null && localContext != null) { + String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from " + FlowControllerConstants.DB_ASDC_ARTIFACTS + + " where artifact_name in (select artifact_name from " + FlowControllerConstants.DB_ASDC_REFERENCE + + " where vnf_type= $" + FlowControllerConstants.VNF_TYPE + + " and file_category = '" + FlowControllerConstants.DEPENDENCYMODEL +"' )" ; + + log.debug(fn + "Query String : " + queryString); + status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext); + + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting dependencydata "); + + String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_ASDC_ARTIFACTS + + " where artifact_name = $artifactName and internal_version = $maxInternalVersion "; + + log.debug(fn + "Query String : " + queryString1); + status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext); + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting dependencyData "); + } + + return localContext.getAttribute("artifact-content"); + } + + public String getCapabilitiesData(SvcLogicContext localContext) throws SvcLogicException { + String fn = "DBService.getCapabilitiesData "; + QueryStatus status = null; + if (serviceLogic != null && localContext != null) { + String queryString = "select max(internal_version) as maxInternalVersion, artifact_name as artifactName from " + FlowControllerConstants.DB_ASDC_ARTIFACTS + + " where artifact_name in (select artifact_name from " + FlowControllerConstants.DB_ASDC_REFERENCE + + " where vnf_type= $" + FlowControllerConstants.VNF_TYPE + + " and file_category = '" + FlowControllerConstants.CAPABILITY +"' )" ; + + log.info(fn + "Query String : " + queryString); + status = serviceLogic.query("SQL", false, null, queryString, null, null, localContext); + + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting capabilitiesData "); + + String queryString1 = "select artifact_content from " + FlowControllerConstants.DB_ASDC_ARTIFACTS + + " where artifact_name = $artifactName and internal_version = $maxInternalVersion "; + + log.debug(fn + "Query String : " + queryString1); + status = serviceLogic.query("SQL", false, null, queryString1, null, null, localContext); + if(status.toString().equals("FAILURE")) + throw new SvcLogicException("Error - while getting capabilitiesData "); + } + + return localContext.getAttribute("artifact-content"); + } +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/GraphExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/GraphExecutor.java new file mode 100644 index 000000000..9c8a37c0a --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/GraphExecutor.java @@ -0,0 +1,163 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.executorImpl; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.openecomp.appc.flow.controller.data.Parameters; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.interfaces.FlowExecutorInterface; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicGraph; +import org.openecomp.sdnc.sli.provider.SvcLogicService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class GraphExecutor implements FlowExecutorInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(GraphExecutor.class); + + private SvcLogicService svcLogic = null; + + public GraphExecutor() { + BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class) + .getBundleContext(); + + ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); + if (sref != null) { + svcLogic = (SvcLogicService) bctx.getService(sref); + + + } else { + log.warn("Cannot find service reference for " + + SvcLogicService.NAME); + } + log.debug("Graph Executor Initialized successfully"); + } + + public boolean hasGraph(String module, String rpc, String version, + String mode) throws SvcLogicException { + return (svcLogic.hasGraph(module, rpc, version, mode)); + } + + public Properties executeGraph(String module, String rpc, String version, + String mode, Properties parms) throws SvcLogicException { + log.debug("Parameters passed to SLI"); + +// for (Object key : parms.keySet()) { +// String parmName = (String) key; +// String parmValue = parms.getProperty(parmName); +// +// log.debug(parmName + " = " + parmValue); +// } + + Properties respProps = svcLogic.execute(module, rpc, version, mode,parms); + if (log.isDebugEnabled()) { + log.debug("Parameters returned by SLI"); + for (Object key : respProps.keySet()) { + String parmName = (String) key; + String parmValue = respProps.getProperty(parmName); + + log.debug(parmName + " = " + parmValue); + } + } + if ("failure" + .equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { + return (respProps); + } + return (respProps); +} + +@Override +public HashMap execute(Transaction transaction, SvcLogicContext ctx) throws Exception { + + String fn = "GraphExecutor.execute "; + log.debug(fn + "About to execute graph : " + transaction.getExecutionRPC()) ; + + Properties parms = new Properties(); + for (Object key : ctx.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + parms.put(parmName, parmValue); + log.info(fn + "Setting Key= " + parmName + "and Value = " + parmValue); + + } + Properties returnParams = executeGraph(transaction.getExecutionModule(),transaction.getExecutionRPC(), null, "sync", parms); + + //log.debug("Return Params executing DG :" + returnParams.toString()); + + log.debug("Returned Params from DG Module: " + transaction.getExecutionModule() + "and DG NAME: " + transaction.getExecutionRPC() + + returnParams.toString()); + + Enumeration e = returnParams.propertyNames(); + + while (e.hasMoreElements()) { + String key = (String) e.nextElement(); + log.info("NEW KEY = " + key + " -- " + returnParams.getProperty(key)); + + ctx.setAttribute(key, returnParams.getProperty(key)); + } + + + //Get the correct code from the SVC Logic and set it in transaction +// transaction.setStatusCode(returnParams.getProperty("SvcLogic.code")); + + if (FlowControllerConstants.FAILURE + .equalsIgnoreCase(returnParams.getProperty("SvcLogic.status"))) { + transaction.setStatus(FlowControllerConstants.FAILURE); + ctx.setAttribute(ctx.getAttribute(FlowControllerConstants.RESPONSE_PREFIX) + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(ctx.getAttribute(FlowControllerConstants.RESPONSE_PREFIX) + FlowControllerConstants.OUTPUT_STATUS_MESSAGE, returnParams.getProperty("error-message")); + transaction.setStatusCode("401"); + transaction.setState((ctx.getAttribute(transaction.getExecutionModule() + "." + transaction.getExecutionRPC() + "." + FlowControllerConstants.OUTPUT_STATUS_MESSAGE)) !=null ? + ctx.getAttribute(transaction.getExecutionModule() + "." + transaction.getExecutionRPC() + "." + FlowControllerConstants.OUTPUT_STATUS_MESSAGE): null); + //Get error code from above instead setting here ...its for testing purpose + + + } + else if(FlowControllerConstants.SUCCESS + .equalsIgnoreCase(returnParams.getProperty("SvcLogic.status"))) { + transaction.setStatus(FlowControllerConstants.SUCCESS); + transaction.setStatusCode("400"); + ctx.setAttribute(ctx.getAttribute(FlowControllerConstants.RESPONSE_PREFIX) + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_SUCCESS); + transaction.setState((ctx.getAttribute(transaction.getExecutionModule() + "." + transaction.getExecutionRPC() + "." + FlowControllerConstants.OUTPUT_STATUS_MESSAGE)) !=null ? + ctx.getAttribute(transaction.getExecutionModule() + "." + transaction.getExecutionRPC() + "." + FlowControllerConstants.OUTPUT_STATUS_MESSAGE): null); + //Get error code from above instead setting here ...its for testing purpose + } + else { + transaction.setStatus(FlowControllerConstants.OTHERS); + ctx.setAttribute(ctx.getAttribute(FlowControllerConstants.RESPONSE_PREFIX) + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_FAILURE); + transaction.setStatusCode("401"); + ctx.setAttribute(ctx.getAttribute(FlowControllerConstants.RESPONSE_PREFIX) + FlowControllerConstants.OUTPUT_STATUS_MESSAGE, returnParams.getProperty("error-message")); + } + + return null; + //Change null to required value if required in upper level +} +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/NodeExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/NodeExecutor.java new file mode 100644 index 000000000..54c627ef7 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/NodeExecutor.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.executorImpl; + +import java.util.HashMap; +import java.util.Properties; + +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.interfaces.FlowExecutorInterface; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.provider.SvcLogicService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class NodeExecutor implements FlowExecutorInterface { + + private static final EELFLogger LOG = EELFManager.getInstance().getLogger(NodeExecutor.class); + + @Override + public HashMap execute(Transaction transaction, SvcLogicContext ctx) { + return null; + } +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/RestExecutor.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/RestExecutor.java new file mode 100644 index 000000000..ff1ba6195 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/RestExecutor.java @@ -0,0 +1,156 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.executorImpl; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URI; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Properties; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.io.IOUtils; +import org.openecomp.appc.flow.controller.data.Response; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.interfaces.FlowExecutorInterface; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.api.client.config.DefaultClientConfig; +import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + + +public class RestExecutor implements FlowExecutorInterface { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(RestExecutor.class); + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + Properties props = new Properties(); + public RestExecutor() throws Exception { + String propDir = System.getenv(SDNC_CONFIG_DIR_VAR); + if (propDir == null) + throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR); + String propFile = propDir + FlowControllerConstants.APPC_FLOW_CONTROLLER; + InputStream propStream = new FileInputStream(propFile); + try{ + props.load(propStream); + } + catch (Exception e){ + throw new Exception("Could not load properties file " + propFile, e); + } + finally{ + try{ + propStream.close(); + } + catch (Exception e){ + log.warn("Could not close FileInputStream", e); + } + } + } + @Override + public HashMap execute(Transaction transaction, SvcLogicContext ctx) throws Exception{ + log.info("Configuring Rest Operation....." + transaction.toString()); + Response response = new Response(); + HashMap outputMessage = new HashMap(); + Client client = null; + WebResource webResource = null; + ClientResponse clientResponse = null; + String responseDataType=MediaType.APPLICATION_JSON; + String requestDataType=MediaType.APPLICATION_JSON; + + + try{ + DefaultClientConfig defaultClientConfig = new DefaultClientConfig(); + System.setProperty("jsse.enableSNIExtension", "false"); + SSLContext sslContext = null; + SecureRestClientTrustManager secureRestClientTrustManager = new SecureRestClientTrustManager(); + sslContext = SSLContext.getInstance("SSL"); + sslContext.init(null, new javax.net.ssl.TrustManager[] { secureRestClientTrustManager }, null); + defaultClientConfig.getProperties().put( + com.sun.jersey.client.urlconnection.HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, + new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), sslContext)); + client = Client.create(defaultClientConfig); + client.addFilter(new HTTPBasicAuthFilter(transaction.getuId(), transaction.getPswd())); + webResource = client.resource(new URI(transaction.getExecutionEndPoint())); + webResource.setProperty("Content-Type", "application/json;charset=UTF-8"); + + log.info("Starting Rest Operation....."); + if(HttpMethod.GET.equalsIgnoreCase(transaction.getExecutionRPC())){ + clientResponse = webResource.accept(responseDataType).get(ClientResponse.class); + }else if(HttpMethod.POST.equalsIgnoreCase(transaction.getExecutionRPC())){ + clientResponse = webResource.type(requestDataType).post(ClientResponse.class, transaction.getPayload()); + }else if(HttpMethod.PUT.equalsIgnoreCase(transaction.getExecutionRPC())){ + clientResponse = webResource.type(requestDataType).put(ClientResponse.class,transaction.getPayload()); + }else if(HttpMethod.DELETE.equalsIgnoreCase(transaction.getExecutionRPC())){ + clientResponse = webResource.delete(ClientResponse.class); + } + + if(clientResponse.getStatus() == 200){ + response.setResponseCode(String.valueOf(clientResponse.getStatus())); + ArrayList responses = new ArrayList(); + responses.add(response); + transaction.setResponses(responses); + outputMessage.put("restResponse", clientResponse.getEntity(String.class)); + } + else{ + throw new Exception("Can not determine the state of : " + transaction.getActionLevel() + " HTTP error code : " + + clientResponse.getStatus()); + + } + + log.info("Completed Rest Operation....."); + + }catch (Exception e) { + e.printStackTrace(); + log.debug("failed in RESTCONT Action ("+transaction.getExecutionRPC()+") for the resource " + transaction.getExecutionEndPoint() + ", falut message :"+e.getMessage()); + throw new Exception("Error While Sending Rest Request" + e.getMessage()); + } + finally { + // clean up. + webResource = null; + if(client != null){ + client.destroy(); + client = null; + } + } + + return outputMessage; + } + +private HostnameVerifier getHostnameVerifier() { + return new HostnameVerifier() { + @Override + public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) { + return true; + } + }; +} + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/SecureRestClientTrustManager.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/SecureRestClientTrustManager.java new file mode 100644 index 000000000..3cf2d6e63 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/executorImpl/SecureRestClientTrustManager.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.executorImpl; + +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +import javax.net.ssl.X509TrustManager; + + +public class SecureRestClientTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + + public boolean isClientTrusted(X509Certificate[] arg0) { + return true; + } + + public boolean isServerTrusted(X509Certificate[] arg0) { + return true; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ActionIdentifier.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ActionIdentifier.java new file mode 100644 index 000000000..f16477c05 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ActionIdentifier.java @@ -0,0 +1,158 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="vnf-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="vserver-id" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="vnfc-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfId", + "vserverId", + "vnfcName" +}) +@XmlRootElement(name = "action-identifier") +public class ActionIdentifier { + + @XmlElement(name = "vnf-id", required = true) + @JsonProperty("vnf-id") + protected String vnfId; + @XmlElement(name = "vserver-id", required = true) + @JsonProperty("vserver-id") + protected String vserverId; + @XmlElement(name = "vnfc-name", required = true) + @JsonProperty("vnfc-name") + protected String vnfcName; + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the vserverId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVserverId() { + return vserverId; + } + + /** + * Sets the value of the vserverId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVserverId(String value) { + this.vserverId = value; + } + + /** + * Gets the value of the vnfcName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfcName() { + return vnfcName; + } + + /** + * Sets the value of the vnfcName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfcName(String value) { + this.vnfcName = value; + } + + @Override + public String toString() { + return "ActionIdentifier [vnfId=" + vnfId + ", vserverId=" + vserverId + + ", vnfcName=" + vnfcName + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Capabilities.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Capabilities.java new file mode 100644 index 000000000..058d291f8 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Capabilities.java @@ -0,0 +1,190 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlList; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnf", + "vfModule", + "vm", + "vnfc" +}) +@XmlRootElement(name = "capabilities") +public class Capabilities { + + @XmlList + @XmlElement(required = true) + protected List vnf; + @XmlList + @XmlElement(name = "vf-module", required = true) + @JsonProperty("vf-module") + protected List vfModule; + @XmlList + @XmlElement(required = true) + protected List vm; + @XmlList + @XmlElement(required = true) + protected List vnfc; + + /** + * Gets the value of the vnf property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the vnf property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVnf().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getVnf() { + if (vnf == null) { + vnf = new ArrayList(); + } + return this.vnf; + } + + /** + * Gets the value of the vfModule property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the vfModule property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVfModule().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getVfModule() { + if (vfModule == null) { + vfModule = new ArrayList(); + } + return this.vfModule; + } + + /** + * Gets the value of the vm property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the vm property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVm().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getVm() { + if (vm == null) { + vm = new ArrayList(); + } + return this.vm; + } + + /** + * Gets the value of the vnfc property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the vnfc property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVnfc().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getVnfc() { + if (vnfc == null) { + vnfc = new ArrayList(); + } + return this.vnfc; + } + + @Override + public String toString() { + return "Capabilities [vnf=" + vnf + ", vfModule=" + vfModule + ", vm=" + + vm + ", vnfc=" + vnfc + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/DependencyInfo.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/DependencyInfo.java new file mode 100644 index 000000000..0bc01867b --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/DependencyInfo.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfcs" +}) +@XmlRootElement(name = "dependency-info") +@JsonIgnoreProperties(ignoreUnknown = true) +public class DependencyInfo { + + protected List vnfcs; + + /** + * Gets the value of the vnfcs property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the vnfcs property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVnfcs().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Vnfcs } + * + * + */ + public List getVnfcs() { + if (vnfcs == null) { + vnfcs = new ArrayList(); + } + return this.vnfcs; + } + + @Override + public String toString() { + return "DependencyInfo [vnfcs=" + vnfcs + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Input.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Input.java new file mode 100644 index 000000000..43564a4be --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Input.java @@ -0,0 +1,199 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; + + +@XmlAccessorType(XmlAccessType.FIELD) +@JsonRootName(value="input") +@XmlType(name = "input", propOrder = { + "requestInfo", + "inventoryInfo", + "dependencyInfo", + "tunableParameters", + "capabilities" +}) +@JsonPropertyOrder({"requestInfo", + "inventoryInfo", + "dependencyInfo", + "tunableParameters", + "capabilities" }) +public class Input { + + @XmlElement(name = "request-info") + @JsonProperty("request-info") + protected RequestInfo requestInfo; + @XmlElement(name = "inventory-info") + @JsonProperty("inventory-info") + protected InventoryInfo inventoryInfo; + @XmlElement(name = "dependency-info") + @JsonProperty("dependency-info") + protected DependencyInfo dependencyInfo; + @XmlElement(name = "tunable-parameters") + @JsonProperty("tunable-parameters") + protected TunableParameters tunableParameters; + protected Capabilities capabilities; + + /** + * Gets the value of the requestInfo property. + * + * @return + * possible object is + * {@link RequestInfo } + * + */ + public RequestInfo getRequestInfo() { + return requestInfo; + } + + /** + * Sets the value of the requestInfo property. + * + * @param value + * allowed object is + * {@link RequestInfo } + * + */ + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + /** + * Gets the value of the inventoryInfo property. + * + * @return + * possible object is + * {@link InventoryInfo } + * + */ + public InventoryInfo getInventoryInfo() { + return inventoryInfo; + } + + /** + * Sets the value of the inventoryInfo property. + * + * @param value + * allowed object is + * {@link InventoryInfo } + * + */ + public void setInventoryInfo(InventoryInfo value) { + this.inventoryInfo = value; + } + + /** + * Gets the value of the dependencyInfo property. + * + * @return + * possible object is + * {@link DependencyInfo } + * + */ + public DependencyInfo getDependencyInfo() { + return dependencyInfo; + } + + /** + * Sets the value of the dependencyInfo property. + * + * @param value + * allowed object is + * {@link DependencyInfo } + * + */ + public void setDependencyInfo(DependencyInfo value) { + this.dependencyInfo = value; + } + + /** + * Gets the value of the tunableParameters property. + * + * @return + * possible object is + * {@link TunableParameters } + * + */ + public TunableParameters getTunableParameters() { + return tunableParameters; + } + + /** + * Sets the value of the tunableParameters property. + * + * @param value + * allowed object is + * {@link TunableParameters } + * + */ + public void setTunableParameters(TunableParameters value) { + this.tunableParameters = value; + } + + /** + * Gets the value of the capabilities property. + * + * @return + * possible object is + * {@link Capabilities } + * + */ + public Capabilities getCapabilities() { + return capabilities; + } + + /** + * Sets the value of the capabilities property. + * + * @param value + * allowed object is + * {@link Capabilities } + * + */ + public void setCapabilities(Capabilities value) { + this.capabilities = value; + } + + @Override + public String toString() { + return "Input [requestInfo=" + requestInfo + ", inventoryInfo=" + + inventoryInfo + ", dependencyInfo=" + dependencyInfo + + ", tunableParameters=" + tunableParameters + + ", capabilities=" + capabilities + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/InventoryInfo.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/InventoryInfo.java new file mode 100644 index 000000000..12f086ff7 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/InventoryInfo.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfInfo" +}) +@XmlRootElement(name = "inventory-info") +public class InventoryInfo { + + @XmlElement(name = "vnf-info", required = true) + @JsonProperty("vnf-info") + protected VnfInfo vnfInfo; + + /** + * Gets the value of the vnfInfo property. + * + * @return + * possible object is + * {@link VnfInfo } + * + */ + public VnfInfo getVnfInfo() { + return vnfInfo; + } + + /** + * Sets the value of the vnfInfo property. + * + * @param value + * allowed object is + * {@link VnfInfo } + * + */ + public void setVnfInfo(VnfInfo value) { + this.vnfInfo = value; + } + + @Override + public String toString() { + return "InventoryInfo [vnfInfo=" + vnfInfo + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ObjectFactory.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ObjectFactory.java new file mode 100644 index 000000000..80cb3bff0 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/ObjectFactory.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the org.openecomp.appc.flow.controller.interfaceData package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.openecomp.appc.flow.controller.interfaceData + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Capabilities } + * + */ + public Capabilities createCapabilities() { + return new Capabilities(); + } + + /** + * Create an instance of {@link RequestInfo } + * + */ + public RequestInfo createRequestInfo() { + return new RequestInfo(); + } + + /** + * Create an instance of {@link ActionIdentifier } + * + */ + public ActionIdentifier createActionIdentifier() { + return new ActionIdentifier(); + } + + /** + * Create an instance of {@link DependencyInfo } + * + */ + public DependencyInfo createDependencyInfo() { + return new DependencyInfo(); + } + + /** + * Create an instance of {@link Vnfcs } + * + */ + public Vnfcs createVnfcs() { + return new Vnfcs(); + } + + /** + * Create an instance of {@link Vm } + * + */ + public Vm createVm() { + return new Vm(); + } + + /** + * Create an instance of {@link Vnfcslist } + * + */ + public Vnfcslist createVnfcslist() { + return new Vnfcslist(); + } + + /** + * Create an instance of {@link TunableParameters } + * + */ + public TunableParameters createTunableParameters() { + return new TunableParameters(); + } + + /** + * Create an instance of {@link VnfInfo } + * + */ + public VnfInfo createVnfInfo() { + return new VnfInfo(); + } + + /** + * Create an instance of {@link InventoryInfo } + * + */ + public InventoryInfo createInventoryInfo() { + return new InventoryInfo(); + } + + /** + * Create an instance of {@link Input } + * + */ + public Input createInput() { + return new Input(); + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/RequestInfo.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/RequestInfo.java new file mode 100644 index 000000000..0a0607794 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/RequestInfo.java @@ -0,0 +1,164 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "action", + "actionLevel", + "actionIdentifier", + "payload" +}) +@XmlRootElement(name = "request-info") +public class RequestInfo { + + @XmlElement(required = true) + protected String action; + @XmlElement(name = "action-level", required = true) + @JsonProperty("action-level") + protected String actionLevel; + @XmlElement(name = "action-identifier", required = true) + @JsonProperty("action-identifier") + protected ActionIdentifier actionIdentifier; + @XmlElement(required = true) + protected String payload; + + /** + * Gets the value of the action property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getAction() { + return action; + } + + /** + * Sets the value of the action property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setAction(String value) { + this.action = value; + } + + /** + * Gets the value of the actionLevel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getActionLevel() { + return actionLevel; + } + + /** + * Sets the value of the actionLevel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setActionLevel(String value) { + this.actionLevel = value; + } + + /** + * Gets the value of the actionIdentifier property. + * + * @return + * possible object is + * {@link ActionIdentifier } + * + */ + public ActionIdentifier getActionIdentifier() { + return actionIdentifier; + } + + /** + * Sets the value of the actionIdentifier property. + * + * @param value + * allowed object is + * {@link ActionIdentifier } + * + */ + public void setActionIdentifier(ActionIdentifier value) { + this.actionIdentifier = value; + } + + /** + * Gets the value of the payload property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPayload() { + return payload; + } + + /** + * Sets the value of the payload property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPayload(String value) { + this.payload = value; + } + + @Override + public String toString() { + return "RequestInfo [action=" + action + ", actionLevel=" + actionLevel + + ", actionIdentifier=" + actionIdentifier + ", payload=" + + payload + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/TunableParameters.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/TunableParameters.java new file mode 100644 index 000000000..b0bb0e06a --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/TunableParameters.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="strategy" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="wait-time" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="retry-count" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "strategy", + "waitTime", + "retryCount" +}) +@XmlRootElement(name = "tunable-parameters") +public class TunableParameters { + + @XmlElement(required = true) + protected String strategy; + @XmlElement(name = "wait-time", required = true) + protected String waitTime; + @XmlElement(name = "retry-count", required = true) + protected String retryCount; + + /** + * Gets the value of the strategy property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getStrategy() { + return strategy; + } + + /** + * Sets the value of the strategy property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setStrategy(String value) { + this.strategy = value; + } + + /** + * Gets the value of the waitTime property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getWaitTime() { + return waitTime; + } + + /** + * Sets the value of the waitTime property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setWaitTime(String value) { + this.waitTime = value; + } + + /** + * Gets the value of the retryCount property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getRetryCount() { + return retryCount; + } + + /** + * Sets the value of the retryCount property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRetryCount(String value) { + this.retryCount = value; + } + + @Override + public String toString() { + return "TunableParameters [strategy=" + strategy + ", waitTime=" + + waitTime + ", retryCount=" + retryCount + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vm.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vm.java new file mode 100644 index 000000000..750719e30 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vm.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vserverId", + "vnfc" +}) +@XmlRootElement(name = "vm") +public class Vm { + + @XmlElement(name = "vserver-id", required = true) + @JsonProperty("vserver-id") + protected String vserverId; + @XmlElement(required = true) + @JsonProperty("vnfc") + protected Vnfcslist vnfc; + + /** + * Gets the value of the vserverId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVserverId() { + return vserverId; + } + + /** + * Sets the value of the vserverId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVserverId(String value) { + this.vserverId = value; + } + + /** + * Gets the value of the vnfc property. + * + * @return + * possible object is + * {@link Vnfcslist } + * + */ + public Vnfcslist getVnfc() { + return vnfc; + } + + /** + * Sets the value of the vnfc property. + * + * @param value + * allowed object is + * {@link Vnfcslist } + * + */ + public void setVnfc(Vnfcslist value) { + this.vnfc = value; + } + + @Override + public String toString() { + return "Vm [vserverId=" + vserverId + ", vnfc=" + vnfc + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/VnfInfo.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/VnfInfo.java new file mode 100644 index 000000000..08ce862b7 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/VnfInfo.java @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfId", + "vnfName", + "vnfType", + "vm" +}) +@XmlRootElement(name = "vnf-info") +public class VnfInfo { + + @XmlElement(name = "vnf-id", required = true) + @JsonProperty("vnf-id") + protected String vnfId; + @XmlElement(name = "vnf-name", required = true) + @JsonProperty("vnf-name") + protected String vnfName; + @XmlElement(name = "vnf-type", required = true) + @JsonProperty("vnf-type") + protected String vnfType; + @JsonProperty("vm") + protected List vm; + + /** + * Gets the value of the vnfId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfId() { + return vnfId; + } + + /** + * Sets the value of the vnfId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfId(String value) { + this.vnfId = value; + } + + /** + * Gets the value of the vnfName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfName() { + return vnfName; + } + + /** + * Sets the value of the vnfName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfName(String value) { + this.vnfName = value; + } + + /** + * Gets the value of the vnfType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfType() { + return vnfType; + } + + /** + * Sets the value of the vnfType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfType(String value) { + this.vnfType = value; + } + + /** + * Gets the value of the vm property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the vm property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getVm().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Vm } + * + * + */ + public List getVm() { + if (vm == null) { + vm = new ArrayList(); + } + return this.vm; + } + + @Override + public String toString() { + return "VnfInfo [vnfId=" + vnfId + ", vnfName=" + vnfName + + ", vnfType=" + vnfType + ", vm=" + vm + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcs.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcs.java new file mode 100644 index 000000000..a3cab0231 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcs.java @@ -0,0 +1,176 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlList; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "vnfcType", + "mandatory", + "resilience", + "parents" +}) +@XmlRootElement(name = "vnfcs") +@JsonRootName(value="vnfcs") +public class Vnfcs { + + @XmlElement(name = "vnfc-type", required = true) + @JsonProperty("vnfc-type") + protected String vnfcType; + @XmlElement(required = true) + @JsonProperty("mandatory") + protected String mandatory; + @XmlElement(required = true) + @JsonProperty("resilience") + protected String resilience; + @XmlList + @XmlElement(required = true) + @JsonProperty("parents") + protected List parents; + + /** + * Gets the value of the vnfcType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfcType() { + return vnfcType; + } + + /** + * Sets the value of the vnfcType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfcType(String value) { + this.vnfcType = value; + } + + /** + * Gets the value of the mandatory property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMandatory() { + return mandatory; + } + + /** + * Sets the value of the mandatory property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMandatory(String value) { + this.mandatory = value; + } + + /** + * Gets the value of the resilience property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getResilience() { + return resilience; + } + + /** + * Sets the value of the resilience property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setResilience(String value) { + this.resilience = value; + } + + /** + * Gets the value of the parents property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the parents property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getParents().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getParents() { + if (parents == null) { + parents = new ArrayList(); + } + return this.parents; + } + + @Override + public String toString() { + return "Vnfcs [vnfcType=" + vnfcType + ", mandatory=" + mandatory + + ", resilience=" + resilience + ", parents=" + parents + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcslist.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcslist.java new file mode 100644 index 000000000..70692f3f6 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnfcslist.java @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +import com.fasterxml.jackson.annotation.JsonProperty; + + +/** + *

Java class for vnfcslist complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="vnfcslist">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="vnfc-type" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *         <element name="vnfc-name" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "vnfcslist", propOrder = { + "vnfcType", + "vnfcName" +}) +public class Vnfcslist { + + @XmlElement(name = "vnfc-type", required = true) + @JsonProperty("vnfc-type") + protected String vnfcType; + @XmlElement(name = "vnfc-name", required = true) + @JsonProperty("vnfc-name") + protected String vnfcName; + + /** + * Gets the value of the vnfcType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfcType() { + return vnfcType; + } + + /** + * Sets the value of the vnfcType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfcType(String value) { + this.vnfcType = value; + } + + /** + * Gets the value of the vnfcName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVnfcName() { + return vnfcName; + } + + /** + * Sets the value of the vnfcName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVnfcName(String value) { + this.vnfcName = value; + } + + @Override + public String toString() { + return "Vnfcslist [vnfcType=" + vnfcType + ", vnfcName=" + vnfcName + + "]"; + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnflist.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnflist.java new file mode 100644 index 000000000..208970cfc --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/Vnflist.java @@ -0,0 +1,150 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.03 at 03:13:44 PM EDT +// + + +package org.openecomp.appc.flow.controller.interfaceData; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for vnflist. + * + *

The following schema fragment specifies the expected content contained within this class. + *

+ *

+ * <simpleType name="vnflist">
+ *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ *     <enumeration value="Restart"/>
+ *     <enumeration value="Rebuild"/>
+ *     <enumeration value="Migrate"/>
+ *     <enumeration value="Evacuate"/>
+ *     <enumeration value="Snapshot"/>
+ *     <enumeration value="Rollback"/>
+ *     <enumeration value="Sync"/>
+ *     <enumeration value="Audit"/>
+ *     <enumeration value="Start"/>
+ *     <enumeration value="Stop"/>
+ *     <enumeration value="Terminate"/>
+ *     <enumeration value="SoftwareUpload"/>
+ *     <enumeration value="HealthCheck"/>
+ *     <enumeration value="LiveUpgrade"/>
+ *     <enumeration value="ModifyConfig"/>
+ *     <enumeration value="Lock"/>
+ *     <enumeration value="Unlock"/>
+ *     <enumeration value="Test"/>
+ *     <enumeration value="CheckLock"/>
+ *     <enumeration value="Configure"/>
+ *     <enumeration value="ConfigModify"/>
+ *     <enumeration value="ConfigScaleOut"/>
+ *     <enumeration value="ConfigRestore"/>
+ *     <enumeration value="ConfigBackup"/>
+ *     <enumeration value="ConfigBackupDelete"/>
+ *     <enumeration value="ConfigExport"/>
+ *   </restriction>
+ * </simpleType>
+ * 
+ * + */ +@XmlType(name = "vnflist") +@XmlEnum +public enum Vnflist { + + @XmlEnumValue("Restart") + RESTART("Restart"), + @XmlEnumValue("Rebuild") + REBUILD("Rebuild"), + @XmlEnumValue("Migrate") + MIGRATE("Migrate"), + @XmlEnumValue("Evacuate") + EVACUATE("Evacuate"), + @XmlEnumValue("Snapshot") + SNAPSHOT("Snapshot"), + @XmlEnumValue("Rollback") + ROLLBACK("Rollback"), + @XmlEnumValue("Sync") + SYNC("Sync"), + @XmlEnumValue("Audit") + AUDIT("Audit"), + @XmlEnumValue("Start") + START("Start"), + @XmlEnumValue("Stop") + STOP("Stop"), + @XmlEnumValue("Terminate") + TERMINATE("Terminate"), + @XmlEnumValue("SoftwareUpload") + SOFTWARE_UPLOAD("SoftwareUpload"), + @XmlEnumValue("HealthCheck") + HEALTH_CHECK("HealthCheck"), + @XmlEnumValue("LiveUpgrade") + LIVE_UPGRADE("LiveUpgrade"), + @XmlEnumValue("ModifyConfig") + MODIFY_CONFIG("ModifyConfig"), + @XmlEnumValue("Lock") + LOCK("Lock"), + @XmlEnumValue("Unlock") + UNLOCK("Unlock"), + @XmlEnumValue("Test") + TEST("Test"), + @XmlEnumValue("CheckLock") + CHECK_LOCK("CheckLock"), + @XmlEnumValue("Configure") + CONFIGURE("Configure"), + @XmlEnumValue("ConfigModify") + CONFIG_MODIFY("ConfigModify"), + @XmlEnumValue("ConfigScaleOut") + CONFIG_SCALE_OUT("ConfigScaleOut"), + @XmlEnumValue("ConfigRestore") + CONFIG_RESTORE("ConfigRestore"), + @XmlEnumValue("ConfigBackup") + CONFIG_BACKUP("ConfigBackup"), + @XmlEnumValue("ConfigBackupDelete") + CONFIG_BACKUP_DELETE("ConfigBackupDelete"), + @XmlEnumValue("ConfigExport") + CONFIG_EXPORT("ConfigExport"); + private final String value; + + Vnflist(String v) { + value = v; + } + + public String value() { + return value; + } + + public static Vnflist fromValue(String v) { + for (Vnflist c: Vnflist.values()) { + if (c.value.equals(v)) { + return c; + } + } + throw new IllegalArgumentException(v); + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/package-info.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/package-info.java new file mode 100644 index 000000000..825c7f8ce --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaceData/package-info.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.07.31 at 10:30:39 AM EDT +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http:org.openecomp.appc/sequence/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package org.openecomp.appc.flow.controller.interfaceData; diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaces/FlowExecutorInterface.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaces/FlowExecutorInterface.java new file mode 100644 index 000000000..690191015 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/interfaces/FlowExecutorInterface.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.interfaces; + +import java.util.HashMap; + +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public interface FlowExecutorInterface { + + public HashMap execute(Transaction transaction, SvcLogicContext ctx) throws Exception; + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowControlNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowControlNode.java new file mode 100644 index 000000000..6a125af22 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowControlNode.java @@ -0,0 +1,562 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.node; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.flow.controller.ResponseHandlerImpl.DefaultResponseHandler; +import org.openecomp.appc.flow.controller.data.PrecheckOption; +import org.openecomp.appc.flow.controller.data.ResponseAction; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.data.Transactions; +import org.openecomp.appc.flow.controller.dbervices.FlowControlDBService; +import org.openecomp.appc.flow.controller.executorImpl.GraphExecutor; +import org.openecomp.appc.flow.controller.executorImpl.NodeExecutor; +import org.openecomp.appc.flow.controller.executorImpl.RestExecutor; +import org.openecomp.appc.flow.controller.interfaceData.ActionIdentifier; +import org.openecomp.appc.flow.controller.interfaceData.Capabilities; +import org.openecomp.appc.flow.controller.interfaceData.DependencyInfo; +import org.openecomp.appc.flow.controller.interfaceData.Input; +import org.openecomp.appc.flow.controller.interfaceData.InventoryInfo; +import org.openecomp.appc.flow.controller.interfaceData.RequestInfo; +import org.openecomp.appc.flow.controller.interfaceData.Vm; +import org.openecomp.appc.flow.controller.interfaceData.VnfInfo; +import org.openecomp.appc.flow.controller.interfaceData.Vnfcs; +import org.openecomp.appc.flow.controller.interfaceData.Vnfcslist; +import org.openecomp.appc.flow.controller.interfaces.FlowExecutorInterface; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +public class FlowControlNode implements SvcLogicJavaPlugin{ + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowControlNode.class); + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + + public void processFlow(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + log.debug("Received processParamKeys call with params : " + inParams); + String responsePrefix = inParams.get(FlowControllerConstants.INPUT_PARAM_RESPONSE_PRIFIX); + try + { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + FlowControlDBService dbservice = FlowControlDBService.initialise(); + SvcLogicContext localContext = new SvcLogicContext(); + localContext.setAttribute(FlowControllerConstants.REQUEST_ID, ctx.getAttribute(FlowControllerConstants.REQUEST_ID)); + localContext.setAttribute(FlowControllerConstants.VNF_TYPE, ctx.getAttribute(FlowControllerConstants.VNF_TYPE)); + localContext.setAttribute(FlowControllerConstants.REQUEST_ACTION, ctx.getAttribute(FlowControllerConstants.REQUEST_ACTION)); + localContext.setAttribute(FlowControllerConstants.ACTION_LEVEL, ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL)); + localContext.setAttribute(FlowControllerConstants.RESPONSE_PREFIX, responsePrefix); + ctx.setAttribute(FlowControllerConstants.RESPONSE_PREFIX, responsePrefix); + dbservice.getFlowReferenceData(ctx, inParams, localContext); + + for (Object key : localContext.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + log.debug("processFlow " + parmName + "=" + parmValue); + + } + processFlowSequence(inParams, ctx, localContext); + if(!ctx.getAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS).equals(FlowControllerConstants.OUTPUT_STATUS_SUCCESS)) + throw new SvcLogicException(ctx.getAttribute(responsePrefix + FlowControllerConstants.OUTPUT_STATUS_MESSAGE)); + + } catch (Exception e) { + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + e.printStackTrace(); + throw new SvcLogicException(e.getMessage()); + } + } + + private void processFlowSequence( Map inParams, SvcLogicContext ctx, SvcLogicContext localContext) throws Exception + { + String fn = "FlowExecutorNode.processflowSequence"; + log.debug(fn + "Received model for flow : " + localContext.toString()); + FlowControlDBService dbservice = FlowControlDBService.initialise(); + String flowSequnce =null; + for (Object key : localContext.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + log.debug(parmName + "=" + parmValue); + + } + if(localContext != null && localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE) !=null){ + + if(localContext.getAttribute(FlowControllerConstants.GENERATION_NODE) != null){ + GraphExecutor transactionExecutor = new GraphExecutor(); + Boolean generatorExists = transactionExecutor.hasGraph("APPC_COMMOM", localContext.getAttribute(FlowControllerConstants.GENERATION_NODE), null, "sync"); + if(generatorExists){ + flowSequnce = transactionExecutor.executeGraph("APPC_COMMOM", localContext.getAttribute(FlowControllerConstants.GENERATION_NODE), + null, "sync", null).getProperty(FlowControllerConstants.FLOW_SEQUENCE); + } + else + throw new Exception("Can not find Custom defined Flow Generator for " + localContext.getAttribute(FlowControllerConstants.GENERATION_NODE)); + } + else if(((String) localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE)).equalsIgnoreCase(FlowControllerConstants.DESINGTIME)){ + localContext.setAttribute(FlowControllerConstants.VNFC_TYPE, ctx.getAttribute(FlowControllerConstants.VNFC_TYPE)); + flowSequnce = dbservice.getDesignTimeFlowModel(localContext); + if(flowSequnce == null) + throw new Exception("Flow Sequence is not found User Desinged VNF " + ctx.getAttribute(FlowControllerConstants.VNF_TYPE)); + } + else if(((String) localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE)).equalsIgnoreCase(FlowControllerConstants.RUNTIME)){ + + Transaction transaction = new Transaction(); + String input = collectInputParams(ctx,transaction); + log.info("collectInputParamsData" + input ); + + RestExecutor restExe = new RestExecutor(); + HashMapflowSeq= restExe.execute(transaction, localContext); + flowSequnce=flowSeq.get("restResponse"); + + if(flowSequnce == null) + throw new Exception("Failed to get the Flow Sequece runtime for VNF type" + ctx.getAttribute(FlowControllerConstants.VNF_TYPE)); + + } + else if(((String) localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE)).equalsIgnoreCase(FlowControllerConstants.EXTERNAL)){ + //String input = collectInputParams(localContext); + // flowSequnce = ""; //get it from the External interface calling the Rest End point - TBD + if(flowSequnce == null) + throw new Exception("Flow Sequence not found for " + ctx.getAttribute(FlowControllerConstants.VNF_TYPE)); + } + else + { + //No other type of model supported...in Future can get flowModel from other generators which will be included here + throw new Exception("No information found for sequence Owner Design-Time Vs Run-Time" ); + } + } + else{ + FlowGenerator flowGenerator = new FlowGenerator(); + Transactions trans = flowGenerator.createSingleStepModel(inParams,ctx); + ObjectMapper mapper = new ObjectMapper(); + flowSequnce = mapper.writeValueAsString(trans); + log.debug("Single step Flow Sequence : " + flowSequnce); + + } + log.debug("Received Flow Sequence : " + flowSequnce); + + HashMap transactionMap = createTransactionMap(flowSequnce, localContext); + exeuteAllTransaction(transactionMap, ctx); + log.info("Executed all the transacstion successfully"); + + } + + private void exeuteAllTransaction(HashMap transactionMap, SvcLogicContext ctx) throws Exception { + + String fn = "FlowExecutorNode.exeuteAllTransaction "; + int retry = 0; + FlowExecutorInterface flowExecutor = null; + for (int key = 1; key <= transactionMap.size() ; key++ ) + { + log.debug(fn + "Starting transactions ID " + key + " :)=" + retry); + Transaction transaction = transactionMap.get(key); + if(!preProcessor(transactionMap, transaction)){ + log.info("Skipping Transaction ID " + transaction.getTransactionId()); + continue; + } + if(transaction.getExecutionType() != null){ + switch (transaction.getExecutionType()){ + case FlowControllerConstants.GRAPH : + flowExecutor = new GraphExecutor(); + break; + case FlowControllerConstants.NODE : + flowExecutor = new NodeExecutor(); + break; + case FlowControllerConstants.REST : + flowExecutor = new RestExecutor(); + break; + default : + throw new Exception("No Executor found for transaction ID" + transaction.getTransactionId()); + } + flowExecutor.execute(transaction, ctx); + ResponseAction responseAction= handleResponse(transaction); + + if(responseAction.getWait() != null && Integer.parseInt(responseAction.getWait()) > 0){ + log.debug(fn + "Going to Sleep .... " + responseAction.getWait()); + Thread.sleep(Integer.parseInt(responseAction.getWait())*1000); + } + + if(responseAction.isIntermediateMessage()){ + log.debug(fn + "Sending Intermediate Message back .... "); + sendIntermediateMessage(); + } + if(responseAction.getRetry() != null && Integer.parseInt(responseAction.getRetry()) > retry ){ + log.debug(fn + "Ooppss!!! We will retry again ....... "); + key--; + retry++; + log.debug(fn + "key =" + key + "retry =" + retry); + + } + if(responseAction.isIgnore()){ + log.debug(fn + "Ignoring this Error and moving ahead ....... "); + continue; + } + if(responseAction.isStop()){ + log.debug(fn + "Need to Stop ....... "); + break; + } + if(responseAction.getJump() != null && Integer.parseInt(responseAction.getJump()) > 0 ){ + key = Integer.parseInt(responseAction.getJump()); + key --; + } + log.debug(fn + "key =" + key + "retry =" + retry); + + } + else{ + throw new Exception("Don't know how to execute transaction ID " + transaction.getTransactionId()); + } + } + + } + private void sendIntermediateMessage() { + // TODO Auto-generated method stub + + } + + private ResponseAction handleResponse(Transaction transaction) { + log.info("Handling Response for transaction Id " + transaction.getTransactionId()); + DefaultResponseHandler defaultHandler = new DefaultResponseHandler(); + return defaultHandler.handlerResponse(transaction); + } + + private boolean preProcessor(HashMap transactionMap, Transaction transaction) throws IOException { + + log.debug("Starting Preprocessing Logic "); + boolean runthisStep = false; + try{ + if(transaction.getPrecheck() != null && transaction.getPrecheck().getPrecheckOptions() != null + && !transaction.getPrecheck().getPrecheckOptions().isEmpty()){ + List precheckOptions = transaction.getPrecheck().getPrecheckOptions(); + for(PrecheckOption precheck : precheckOptions){ + Transaction trans = transactionMap.get(precheck.getpTransactionID()); + ObjectMapper mapper = new ObjectMapper(); + log.info("Mapper= " + mapper.writeValueAsString(trans)); + HashMap trmap = mapper.readValue(mapper.writeValueAsString(trans), HashMap.class); + if(trmap.get(precheck.getParamName()) != null && + ((String) trmap.get(precheck.getParamName())).equalsIgnoreCase(precheck.getParamValue())) + runthisStep = true; + else + runthisStep = false; + + if(transaction.getPrecheck().getPrecheckOperator() != null && + transaction.getPrecheck().getPrecheckOperator().equalsIgnoreCase("any") && runthisStep) + break; + } + } + + else{ + log.debug("No Pre check defined for transaction ID " + transaction.getTransactionId()); + runthisStep = true; + + } + } + catch(Exception e) + { + e.printStackTrace(); + throw e; + } + log.debug("Returing process current Transaction = " + runthisStep); + + return runthisStep ; + } + + private HashMap createTransactionMap(String flowSequnce, SvcLogicContext localContext) throws SvcLogicException, JsonParseException, JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); + Transactions transactions = mapper.readValue(flowSequnce,Transactions.class); + HashMap transMap = new HashMap(); + for(Transaction transaction : transactions.getTransactions()){ + compileFlowDependencies(transaction, localContext); + //loadTransactionIntoStatus(transactions, ctx); //parse the Transactions Object and create records in process_flow_status table + transMap.put(transaction.getTransactionId(), transaction); + } + return transMap; + } + + private void compileFlowDependencies(Transaction transaction, SvcLogicContext localContext) throws SvcLogicException, JsonParseException, JsonMappingException, IOException { + + String fn = "FlowExecutorNode.compileFlowDependencies"; + FlowControlDBService dbservice = FlowControlDBService.initialise(); + dbservice.populateModuleAndRPC(transaction, localContext.getAttribute(FlowControllerConstants.VNF_TYPE)); + ObjectMapper mapper = new ObjectMapper(); + log.debug("Indivisual Transaction Details :" + transaction.toString()); + if((localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE) == null) || + ( localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE) != null && + ! localContext.getAttribute(FlowControllerConstants.SEQUENCE_TYPE).equalsIgnoreCase(FlowControllerConstants.DESINGTIME))){ + localContext.setAttribute("artifact-content", mapper.writeValueAsString(transaction)); + dbservice.loadSequenceIntoDB(localContext); + } + //get a field in transction class as transactionhandle interface and register the Handler here for each trnactions + } + + private String collectInputParams(SvcLogicContext ctx, Transaction transaction) throws Exception { + + String fn = "FlowExecuteNode.collectInputParams"; + Properties prop = loadProperties(); + log.info("Loaded Properties " + prop.toString()); + + String vnfId = ctx.getAttribute(FlowControllerConstants.VNF_ID); + log.debug(fn + "vnfId :" + vnfId); + + if (StringUtils.isBlank(vnfId)) { + throw new Exception("VnfId is missing"); + } + + ActionIdentifier actionIdentifier = new ActionIdentifier(); + actionIdentifier.setVnfId(vnfId); + actionIdentifier.setVserverId(ctx.getAttribute(FlowControllerConstants.VSERVER_ID)); + actionIdentifier.setVnfcName(ctx.getAttribute(FlowControllerConstants.VNFC_NAME)); + + RequestInfo requestInfo = new RequestInfo(); + requestInfo.setAction(ctx.getAttribute(FlowControllerConstants.ACTION)); + requestInfo.setActionLevel(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL)); + requestInfo.setPayload(ctx.getAttribute(FlowControllerConstants.PAYLOAD)); + requestInfo.setActionIdentifier(actionIdentifier); + + InventoryInfo inventoryInfo = getInventoryInfo(ctx,vnfId); + DependencyInfo dependencyInfo = getDependencyInfo(ctx); + Capabilities capabilites = getCapabilitesData(ctx); + + Input input = new Input(); + input.setRequestInfo(requestInfo); + input.setInventoryInfo(inventoryInfo); + input.setDependencyInfo(dependencyInfo); + input.setCapabilities(capabilites); + //input.setTunableParameters(null); + + + log.info(fn + "Input parameters:" + input.toString()); + + String inputData = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE,true); + inputData = mapper.writeValueAsString(input); + log.info("InputDataJson:"+inputData); + + } catch (Exception e) { + e.printStackTrace(); + } + + String resourceUri = prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_URL); + log.info(fn + "resourceUri= " + resourceUri); + + transaction.setPayload(inputData); + transaction.setExecutionRPC("POST"); + transaction.setuId(prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_UID)); + transaction.setPswd(prop.getProperty(FlowControllerConstants.SEQ_GENERATOR_PWD)); + transaction.setExecutionEndPoint(resourceUri); + + return inputData; + + } + + private DependencyInfo getDependencyInfo(SvcLogicContext ctx) throws Exception { + + String fn = "FlowExecutorNode.getDependencyInfo"; + DependencyInfo dependencyInfo = new DependencyInfo(); + FlowControlDBService dbservice = FlowControlDBService.initialise(); + String dependencyData = dbservice.getDependencyInfo(ctx); + log.info(fn + "dependencyDataInput:" + dependencyData); + + if (dependencyData != null) { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); + mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + JsonNode dependencyInfoData = mapper.readTree(dependencyData).get("dependencyInfo"); + JsonNode vnfcData = mapper.readTree(dependencyInfoData.toString()).get("vnfcs"); + List vnfclist = Arrays.asList(mapper.readValue(vnfcData.toString(), Vnfcs[].class)); + dependencyInfo.getVnfcs().addAll(vnfclist); + + log.info("Dependency Output:"+ dependencyInfo.toString()); + } + + return dependencyInfo; + + } + + private Capabilities getCapabilitesData(SvcLogicContext ctx)throws Exception { + + String fn = "FlowExecutorNode.getCapabilitesData"; + Capabilities capabilities = new Capabilities(); + FlowControlDBService dbservice = FlowControlDBService.initialise(); + String capabilitiesData = dbservice.getCapabilitiesData(ctx); + log.info(fn + "capabilitiesDataInput:" + capabilitiesData); + + if (capabilitiesData != null) { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); + mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + JsonNode capabilitiesNode = mapper.readValue(capabilitiesData,JsonNode.class); + log.info("capabilitiesNode:" + capabilitiesNode.toString()); + + JsonNode vnfs = capabilitiesNode.findValue(FlowControllerConstants.VNF); + List vnfsList = new ArrayList(); + if (vnfs != null) { + for (int i = 0; i < vnfs.size(); i++) { + + String vnf = vnfs.get(i).asText(); + vnfsList.add(vnf); + } + } + + JsonNode vfModules = capabilitiesNode.findValue(FlowControllerConstants.VF_MODULE); + List vfModulesList = new ArrayList(); + if (vfModules != null) { + for (int i = 0; i < vfModules.size(); i++) { + + String vfModule = vfModules.get(i).asText(); + vfModulesList.add(vfModule); + } + } + + JsonNode vnfcs = capabilitiesNode.findValue(FlowControllerConstants.VNFC); + List vnfcsList = new ArrayList(); + if (vnfcs != null) { + for (int i = 0; i < vnfcs.size(); i++) { + + String vnfc1 = vnfcs.get(i).asText(); + vnfcsList.add(vnfc1); + } + } + + JsonNode vms = capabilitiesNode.findValue(FlowControllerConstants.VM); + + List vmList = new ArrayList(); + if (vms != null) { + for (int i = 0; i < vms.size(); i++) { + + String vm1 = vms.get(i).asText(); + vmList.add(vm1); + } + } + + capabilities.getVnfc().addAll(vnfcsList); + capabilities.getVnf().addAll(vnfsList); + capabilities.getVfModule().addAll(vfModulesList); + capabilities.getVm().addAll(vmList); + + log.info("Capabilities Output:"+ capabilities.toString()); + + } + + return capabilities; + + } + + private InventoryInfo getInventoryInfo(SvcLogicContext ctx, String vnfId) throws Exception{ + + String fn = "FlowExecutorNode.getInventoryInfo"; + String vmcount = ctx.getAttribute("tmp.vnfInfo.vm-count"); + int vmCount = Integer.parseInt(vmcount); + log.info(fn +"vmcount:"+ vmCount); + + VnfInfo vnfInfo = new VnfInfo(); + vnfInfo.setVnfId(vnfId); + vnfInfo.setVnfName(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name")); + vnfInfo.setVnfType(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type")); + + Vm vm = new Vm(); + Vnfcslist vnfc = new Vnfcslist(); + + if (vmCount > 0) { + + for (int i = 0; i < vmCount; i++) { + + vm.setVserverId(ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vserverId")); + String vnfccount = ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-count"); + int vnfcCount = Integer.parseInt(vnfccount); + + if (vnfcCount > 0) { + vnfc.setVnfcName(ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-name")); + vnfc.setVnfcType(ctx.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-type")); + vm.setVnfc(vnfc); + } + vnfInfo.getVm().add(vm); + } + } + + InventoryInfo inventoryInfo = new InventoryInfo(); + inventoryInfo.setVnfInfo(vnfInfo); + + return inventoryInfo; + + } + + private String getFlowSequence() throws IOException { + + String sequenceModel = IOUtils.toString(FlowControlNode.class.getClassLoader().getResourceAsStream("sequence.json"), Charset.defaultCharset()); + + return null; + } + + +private static Properties loadProperties() throws Exception { + Properties props = new Properties(); + String propDir = System.getenv(SDNC_CONFIG_DIR_VAR); + if (propDir == null) + throw new Exception("Cannot find Property file -" + SDNC_CONFIG_DIR_VAR); + String propFile = propDir + FlowControllerConstants.APPC_FLOW_CONTROLLER; + InputStream propStream = new FileInputStream(propFile); + try + { + props.load(propStream); + } + catch (Exception e) + { + throw new Exception("Could not load properties file " + propFile, e); + } + finally + { + try + { + propStream.close(); + } + catch (Exception e) + { + log.warn("Could not close FileInputStream", e); + } + } + return props; +} + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowGenerator.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowGenerator.java new file mode 100644 index 000000000..8d81858fc --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/FlowGenerator.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.node; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.openecomp.appc.flow.controller.data.Response; +import org.openecomp.appc.flow.controller.data.ResponseAction; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.data.Transactions; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class FlowGenerator { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(FlowGenerator.class); + + public Transactions createSingleStepModel(Map inParams, SvcLogicContext ctx) { + + String fn = "FlowGenerator.createSingleStepModel"; + log.debug("Starting generating single Step flow" ); + + log.debug("Data in context" + ctx.getAttributeKeySet() ); + Transactions transactions = new Transactions(); + List transactionList = new ArrayList(); + Transaction singleTransaction = new Transaction(); + + singleTransaction.setTransactionId(1); + singleTransaction.setAction(ctx.getAttribute(FlowControllerConstants.REQUEST_ACTION)); + singleTransaction.setActionLevel(FlowControllerConstants.VNF); //Need to discuss how to get action level if not in request + singleTransaction.setPayload(ctx.getAttribute(FlowControllerConstants.PAYLOAD)); + singleTransaction.setActionLevel(ctx.getAttribute(FlowControllerConstants.ACTION_LEVEL)); + + + + + List responseList = new ArrayList(); + Response response = new Response(); + + ResponseAction ra = new ResponseAction(); + ra.setStop(true); + response.setResponseAction(ra); + + responseList.add(response); + singleTransaction.setResponses(responseList); + transactionList.add(singleTransaction); + + transactions.setTransactions(transactionList); + + log.debug("Sequence String" + transactions.toString()); + + return transactions; + } + + + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/JsonParsingNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/JsonParsingNode.java new file mode 100644 index 000000000..b1f31285b --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/JsonParsingNode.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.node; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.executorImpl.RestExecutor; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class JsonParsingNode implements SvcLogicJavaPlugin{ + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(JsonParsingNode.class); + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + + public void parse(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + String fn = "RestServiceNode.sendRequest"; + log.info("Received processParamKeys call with params : " + inParams); + String responsePrefix = inParams.get(FlowControllerConstants.INPUT_PARAM_RESPONSE_PRIFIX); + try + { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + //Remove below for Block + if(isValidJSON(inParams.get("data")) !=null){ + JsonNode jnode = isValidJSON(inParams.get("data")); + ObjectMapper mapper = new ObjectMapper(); + Map map = new HashMap(); + map = mapper.readValue(jnode.toString(), new TypeReference>(){}); + for (Entry entry : map.entrySet()) + { + ctx.setAttribute(responsePrefix + entry.getKey(),(String) entry.getValue()); + } + + } + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_SUCCESS); + + } catch (Exception e) { + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + e.printStackTrace(); + log.error("Error Message : " + e.getMessage()); + throw new SvcLogicException(e.getMessage()); + } + } + + public JsonNode isValidJSON(String json) throws IOException { + JsonNode output = null; + log.info("Received response from Interface " + json); + if(json ==null || json.isEmpty()) + return null; + try{ + ObjectMapper objectMapper = new ObjectMapper(); + output = objectMapper.readTree(json); + } catch(JsonProcessingException e){ + log.warn("Response received from interface is not a valid JSON block" + json); + return null; + } + + return output; + } +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/RestServiceNode.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/RestServiceNode.java new file mode 100644 index 000000000..246f7a4e9 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/node/RestServiceNode.java @@ -0,0 +1,207 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.node; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.executorImpl.RestExecutor; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class RestServiceNode implements SvcLogicJavaPlugin{ + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(RestServiceNode.class); + private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR"; + + public void sendRequest(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + String fn = "RestServiceNode.sendRequest"; + log.info("Received processParamKeys call with params : " + inParams); + String responsePrefix = inParams.get(FlowControllerConstants.INPUT_PARAM_RESPONSE_PRIFIX); + try + { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + //Remove below for Block + for (Object key : ctx.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + log.info(fn + "Getting Key = " + parmName + "and Value = " + parmValue); + } + + send(ctx, inParams); + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_SUCCESS); + + } catch (Exception e) { + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_STATUS, FlowControllerConstants.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + FlowControllerConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + e.printStackTrace(); + log.error("Error Message : " + e.getMessage()); + throw new SvcLogicException(e.getMessage()); + } + } + + public void send(SvcLogicContext ctx, Map inParams) throws Exception{ + try{ + Properties prop = loadProperties(); + log.info("Loaded Properties " + prop.toString()); + String responsePrefix = inParams.get(FlowControllerConstants.INPUT_PARAM_RESPONSE_PRIFIX); + RestExecutor restRequestExecutor = new RestExecutor(); + String resourceUri = ""; + if(ctx.getAttribute(FlowControllerConstants.INPUT_URL) != null && !(ctx.getAttribute(FlowControllerConstants.INPUT_URL).isEmpty())) + resourceUri = ctx.getAttribute(FlowControllerConstants.INPUT_URL); + else{ + resourceUri = resourceUri.concat(FlowControllerConstants.HTTP); + log.info("resourceUri= " + resourceUri ); + resourceUri = resourceUri.concat(ctx.getAttribute(FlowControllerConstants.INPUT_HOST_IP_ADDRESS)); + resourceUri = resourceUri.concat(":"); + resourceUri = resourceUri.concat(ctx.getAttribute(FlowControllerConstants.INPUT_PORT_NUMBER)); + + if(ctx.getAttribute(FlowControllerConstants.INPUT_CONTEXT) != null && !ctx.getAttribute(FlowControllerConstants.INPUT_CONTEXT).isEmpty()){ + resourceUri = resourceUri.concat("/").concat(ctx.getAttribute(FlowControllerConstants.INPUT_CONTEXT)); + log.info("resourceUri= " + resourceUri ); + } + else if(prop.getProperty(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).concat(".context")) != null ){ + log.info("resourceUri = " + resourceUri ); + resourceUri = resourceUri.concat("/").concat(prop.getProperty(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).concat(".context"))); + } + else + throw new Exception("Could Not found the context for operation " + ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION)); + + + if(ctx.getAttribute(FlowControllerConstants.INPUT_SUB_CONTEXT) != null && !ctx.getAttribute(FlowControllerConstants.INPUT_SUB_CONTEXT).isEmpty()){ + resourceUri = resourceUri.concat("/").concat(ctx.getAttribute(FlowControllerConstants.INPUT_SUB_CONTEXT)); + log.info("resourceUri" + resourceUri ); + } + else if(prop.getProperty(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).concat(".sub-context")) != null ){ + resourceUri = resourceUri.concat("/").concat(prop.getProperty(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).concat(".sub-context"))); + log.info("resourceUri" + resourceUri ); + } + } + + log.info("Rest Constructed URL : " + resourceUri); + Transaction transaction = new Transaction(); + + transaction.setExecutionEndPoint(resourceUri); + transaction.setExecutionRPC(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE)); + transaction.setAction(FlowControllerConstants.INPUT_REQUEST_ACTION); + if(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE) == null || ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION_TYPE).isEmpty()) + throw new Exception("Dont know REST operation for Action " + transaction.getExecutionRPC()); + if(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION) == null || ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).isEmpty()) + throw new Exception("Dont know request-action " + transaction.getAction()); + + //This code need to get changed to get the UserID and pass from a common place. + if(transaction.getuId() == null ) + transaction.setuId(prop.getProperty(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).concat(".default-rest-user"))); + if(transaction.getPswd() == null) + transaction.setPswd(prop.getProperty(ctx.getAttribute(FlowControllerConstants.INPUT_REQUEST_ACTION).concat(".default-rest-pass"))); + + HashMap output = restRequestExecutor.execute(transaction, ctx); + + if(output.get("restResponse") !=null && isValidJSON(output.get("restResponse")) != null) + { + ctx.setAttribute(responsePrefix + "." + FlowControllerConstants.OUTPUT_STATUS_MESSAGE , output.get("restResponse")); +// JsonNode restResponse = isValidJSON(output.get("restResponse")); +// for (String key : inParams.keySet()) { +// if(key !=null && key.startsWith("output-")){ +// log.info("Found Key = " + key); +// log.info("Found Key in Params " + inParams.get(key) + "."); +// JsonNode setValue = restResponse.findValue(inParams.get(key)); +// log.info("Found value = " + setValue); +// if(setValue !=null && setValue.textValue() !=null && !setValue.textValue().isEmpty()) +// ctx.setAttribute(responsePrefix + "." + key, setValue.textValue()); +// else +// ctx.setAttribute(responsePrefix + "." + key, null); +// } +// } + } + log.info("Response from Rest :" ); + } + catch(Exception e) + { + e.printStackTrace(); + log.error("Error Message " + e.getMessage()); + throw e; + } + } + + private Properties loadProperties() throws Exception { + Properties props = new Properties(); + String propDir = System.getenv(SDNC_CONFIG_DIR_VAR); + if (propDir == null) + throw new Exception("Cannot find Property file -" + SDNC_CONFIG_DIR_VAR); + String propFile = propDir + FlowControllerConstants.APPC_FLOW_CONTROLLER; + InputStream propStream = new FileInputStream(propFile); + try + { + props.load(propStream); + } + catch (Exception e) + { + throw new Exception("Could not load properties file " + propFile, e); + } + finally + { + try + { + propStream.close(); + } + catch (Exception e) + { + log.warn("Could not close FileInputStream", e); + } + } + // TODO Auto-generated method stub + return props; + } + + public JsonNode isValidJSON(String json) throws IOException { + JsonNode output = null; + log.info("Received response from Interface " + json); + if(json ==null || json.isEmpty()) + return null; + try{ + ObjectMapper objectMapper = new ObjectMapper(); + output = objectMapper.readTree(json); + } catch(JsonProcessingException e){ + log.warn("Response received from interface is not a valid JSON block" + json); + return null; + } + log.info("state is " + output.findValue("state")); + + return output; + } +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/EscapeUtils.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/EscapeUtils.java new file mode 100644 index 000000000..6223fea54 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/EscapeUtils.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.utils; + +import org.apache.commons.lang3.StringUtils; + +public class EscapeUtils { + + public EscapeUtils() { + } + + public static String escapeSql(String str) { + if (str == null) { + return null; + } + String searchList[] = new String[]{"'","\\", "\"" }; + String replacementList[] = new String[]{ "''","\\\\" ,"\\\""}; + return StringUtils.replaceEach(str,searchList, replacementList); + } + +} diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/FlowControllerConstants.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/FlowControllerConstants.java new file mode 100644 index 000000000..70500c4b1 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/utils/FlowControllerConstants.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.controller.utils; + +public class FlowControllerConstants { + + public static String STRING_ENCODING = "utf-8"; + public static String Y = "Y"; + public static String N = "N"; + public static String DATA_TYPE_TEXT = "TEXT"; + public static String DATA_TYPE_JSON = "JSON"; + public static String DATA_TYPE_XML = "XML"; + public static String DATA_TYPE_SQL = "SQL"; + + public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix"; + + public static String OUTPUT_PARAM_STATUS = "status"; + public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + public static String OUTPUT_STATUS_SUCCESS = "success"; + public static String OUTPUT_STATUS_FAILURE = "failure"; + + public static final String DESINGTIME = "DesignTime"; + public static final String RUNTIME = "RunTime"; + public static final String APPC_FLOW_CONTROLLER = "/appc-flow-controller.properties"; + public static final String VNF_TYPE = "vnf-type"; + public static final String ACTION = "action"; + public static final String VNFC_TYPE = "vnfc-type"; + public static final String VM_INSTANCE = "vm-instance"; + public static final String VM = "vm"; + public static final String VNFC = "vnfc"; + public static final String REFERENCE = "reference"; + public static final String VNFC_INSTANCE = "vnfc-instance"; + public static final String DEVICE_PROTOCOL = "device-protocol"; + public static final String DG_RPC = "dg-rpc"; + public static final String MODULE = "module"; + public static final String USER_NAME = "user-name"; + public static final String PORT_NUMBER = "port-number"; + public static final String DOWNLOAD_DG_REFERENCE = "download-dg-reference"; + public static final String REQUEST_ACTION = "request-action"; + public static final String VNF = "vnf"; + public static final String EXTERNAL = "External"; + public static final String ACTION_LEVEL = "action-level"; + public static final String ARTIFACT_NAME = "artifact-name"; + + public static enum endPointType {DG,REST,NODE}; + public static enum flowStatus {PENDING,IN_PROCESS,COMPLETED}; + + public static final String GENERATION_NODE = "GENERATION-NODE"; + public static final String SEQUENCE_TYPE = "SEQUENCE-TYPE"; + public static final String CATEGORY = "CATEGORY"; + public static final String EXECUTION_NODE = "EXECUTION-NODE"; + + + public static final String REQUEST_ID = "reqeust-id"; + public static final String ARTIFACT_CONTENT = "artifact-content"; + public static final String ARTIFACT_CONTENT_ESCAPED = "artifact-content-escaped"; + public static final String FLOW_SEQUENCE = "flow-sequence"; + public static final String EXECUTTION_MODULE = "execution-module"; + public static final String EXECUTION_RPC = "execution-rpc"; + public static final String EXECUTION_TYPE = "execution-type"; + public static final String GRAPH = "graph"; + public static final String NODE = "node"; + public static final String REST = "rest"; + + + public static final String DB_ASDC_ARTIFACTS = "ASDC_ARTIFACTS"; + public static final String DB_ASDC_REFERENCE = "ASDC_REFERENCE"; + public static final String DB_REQUEST_ARTIFACTS = "REQUEST_ARTIFACTS"; + public static final String DB_MULTISTEP_FLOW_REFERENCE = "MULTISTEP_FLOW_REFERENCE"; + public static final String DB_PROTOCOL_REFERENCE = "PROTOCOL_REFERENCE"; + public static final String DB_PROCESS_FLOW_REFERENCE = "PROCESS_FLOW_REFERENCE"; + public static final String MOCK_HEALTHCHECK = "mock-healthcheck"; + public static final String ACTION_IDENTIFIER = "action-identifier"; + public static final String PAYLOAD = "payload"; + public static final String FAILURE = "failure"; + public static final String SUCCESS = "success"; + public static final String OTHERS = "Others"; + public static final String RESPONSE_PREFIX = "response-prefix"; + public static final String OUTPUT_STATUS_MESSAGE = "status-message"; + public static final String HEALTHY = "healthy"; + public static final String INPUT_URL = "input.url"; + public static final String INPUT_HOST_IP_ADDRESS = "host-ip-address"; + public static final String INPUT_PORT_NUMBER = "port-number"; + public static final String INPUT_CONTEXT = "context"; + public static final String INPUT_SUB_CONTEXT = "sub-context"; + public static final String INPUT_REQUEST_ACTION_TYPE = "request-action-type"; + public static final String INPUT_REQUEST_ACTION = "request-action"; + public static final String HTTP = "http://"; + + public static final String VNF_ID = "vnf-id"; + public static final String VSERVER_ID = "vserver-id"; + public static final String SEQ_GENERATOR_URL = "seq_generator_url"; + public static final String SEQ_GENERATOR_UID = "seq_generator.uid"; + public static final String SEQ_GENERATOR_PWD = "seq_generator.pwd"; + public static final String CAPABILITY ="capability"; + public static final String DEPENDENCYMODEL ="tosca_dependency_model"; + public static final String VF_MODULE ="vf-module"; + public static final String VNFC_NAME = "vnfc-name"; + } diff --git a/appc-config/appc-flow-controller/provider/src/main/resources/appc-flow-controller.properties b/appc-config/appc-flow-controller/provider/src/main/resources/appc-flow-controller.properties new file mode 100644 index 000000000..505ab8f43 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/resources/appc-flow-controller.properties @@ -0,0 +1,23 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-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========================================================= +### + +healthcheck.mock=false +healthcheck.default-rest-user=User +healthcheck.default-rest-pass=@#asd723%^ diff --git a/appc-config/appc-flow-controller/provider/src/main/resources/jaxby.properties b/appc-config/appc-flow-controller/provider/src/main/resources/jaxby.properties new file mode 100644 index 000000000..6671e3072 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/main/resources/jaxby.properties @@ -0,0 +1,21 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-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========================================================= +### + +javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java new file mode 100644 index 000000000..cdb9e2da5 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestFlowExecutorNode.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.executor.node; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.appc.flow.controller.node.FlowControlNode; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestFlowExecutorNode { + + private final Logger logger = LoggerFactory.getLogger(TestFlowExecutorNode.class); + + + //@Before + public void setUp() { + Properties props = new Properties(); + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + if (propStr == null) { + System.err.println("src/test/resources/svclogic.properties missing"); + } + try { + System.out.println("Got Properties"); + props.load(propStr); + propStr.close(); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Could not initialize properties"); + } + // Add properties to global properties + + Enumeration propNames = props.keys(); + + while (propNames.hasMoreElements()) { + + String propName = (String) propNames.nextElement(); + System.setProperty(propName, props.getProperty(propName)); + System.out.println("propName" + propName + " Value: " + props.getProperty(propName)); + } + + + } + + + //@Test + public void testFlowExecutorNode() throws Exception { + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB"); + ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "Configure"); + ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "");; + ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK"); + ; + // ctx.setAttribute(FlowControllerConstants.ACTION_LEVEL,"VNF"); + HashMap inParams = new HashMap(); + + FlowControlNode fen = new FlowControlNode(); + fen.processFlow(inParams, ctx); + + System.out.println("Flow sequence" + ctx.getAttribute("transMap")); + + } +} diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java new file mode 100644 index 000000000..9f08424f9 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestParsingNode.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.executor.node; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.appc.flow.controller.node.FlowControlNode; +import org.openecomp.appc.flow.controller.node.JsonParsingNode; +import org.openecomp.appc.flow.controller.node.RestServiceNode; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; + +public class TestParsingNode { + +// @Before + public void setUp() { + Properties props = new Properties(); + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + if (propStr == null) { + System.err.println("src/test/resources/svclogic.properties missing"); + } + try { + System.out.println("Got Properties"); + props.load(propStr); + propStr.close(); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Could not initialize properties"); + } + // Add properties to global properties + + Enumeration propNames = props.keys(); + + while (propNames.hasMoreElements()) { + + String propName = (String) propNames.nextElement(); + System.setProperty(propName, props.getProperty(propName)); + System.out.println("propName" + propName + " Value: " + props.getProperty(propName)); + } + + + + } + + +// @Test + public void testRestServiceNode() throws Exception { + + SvcLogicContext ctx = new SvcLogicContext(); + + + + HashMap inParams = new HashMap(); + JsonParsingNode rsn = new JsonParsingNode(); + inParams.put("data", "{\"identifier\": \"scope represented\",\"state\": \"healthy\",\"test\": \"passed\", \"time\": \"01-01-1000:0000\"}"); + inParams.put("responsePrefix", "APPC.healthcheck"); + rsn.parse(inParams, ctx); + + for (Object key : ctx.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + System.out.println(parmName + "=" + parmValue); + } + + + } +} diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java new file mode 100644 index 000000000..6c3b432c7 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/java/org/openecomp/appc/flow/executor/node/TestRestServiceNode.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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.openecomp.appc.flow.executor.node; + +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Properties; + +import org.junit.Before; +import org.junit.Test; +import org.openecomp.appc.flow.controller.data.Transaction; +import org.openecomp.appc.flow.controller.executorImpl.RestExecutor; +import org.openecomp.appc.flow.controller.interfaceData.ActionIdentifier; +import org.openecomp.appc.flow.controller.interfaceData.InventoryInfo; +import org.openecomp.appc.flow.controller.interfaceData.RequestInfo; +import org.openecomp.appc.flow.controller.interfaceData.Vm; +import org.openecomp.appc.flow.controller.interfaceData.VnfInfo; +import org.openecomp.appc.flow.controller.interfaceData.Vnfcslist; +import org.openecomp.appc.flow.controller.node.FlowControlNode; +import org.openecomp.appc.flow.controller.node.RestServiceNode; +import org.openecomp.appc.flow.controller.utils.FlowControllerConstants; +import org.openecomp.sdnc.sli.SvcLogicContext; + +public class TestRestServiceNode { + +// @Before + public void setUp() { + Properties props = new Properties(); + InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); + if (propStr == null) { + System.err.println("src/test/resources/svclogic.properties missing"); + } + try { + System.out.println("Got Properties"); + props.load(propStr); + propStr.close(); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Could not initialize properties"); + } + // Add properties to global properties + + Enumeration propNames = props.keys(); + + while (propNames.hasMoreElements()) { + + String propName = (String) propNames.nextElement(); + System.setProperty(propName, props.getProperty(propName)); + System.out.println("propName" + propName + " Value: " + props.getProperty(propName)); + } + + + } + + +// @Test + public void testRestServiceNode() throws Exception { + + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute(FlowControllerConstants.VNF_TYPE, "vUSP - vDBE-IPX HUB"); + ctx.setAttribute(FlowControllerConstants.REQUEST_ACTION, "healthcheck"); + ctx.setAttribute(FlowControllerConstants.VNFC_TYPE, "TESTVNFC-CF"); + ctx.setAttribute(FlowControllerConstants.REQUEST_ID,"TESTCOMMONFRMWK"); + ctx.setAttribute("host-ip-address","127.0.0.1"); + ctx.setAttribute("port-number","8888"); + ctx.setAttribute("request-action-type","GET"); + ctx.setAttribute("context", "loader/restconf/operations/appc-provider-lcm:health-check"); + + HashMap inParams = new HashMap(); + RestServiceNode rsn = new RestServiceNode(); + inParams.put("output-state", "state"); + inParams.put("responsePrefix", "healthcheck"); + rsn.sendRequest(inParams, ctx); + + for (Object key : ctx.getAttributeKeySet()) { + String parmName = (String) key; + String parmValue = ctx.getAttribute(parmName); + System.out.println(parmName + "=" + parmValue); + } + + + } + + + //@Test + public void testInputParamsRestServiceNode() throws Exception { + SvcLogicContext ctx = new SvcLogicContext(); + ctx.setAttribute("vnf-id", "test"); + ctx.setAttribute("tmp.vnfInfo.vm-count", "1"); + ctx.setAttribute("tmp.vnfInfo.vm[0].vnfc-count", "1"); + RestExecutor restExe = new RestExecutor(); + Transaction transaction = new Transaction(); + + FlowControlNode node = new FlowControlNode(); + //String output =node.collectInputParams(ctx, transaction); + +// Properties props = new Properties(); +// props.setProperty("SEQ_GENERATOR_URL", "test"); + //System.out.println(output); + //transaction.setExecutionEndPoint(resourceUri); + HashMapflowSeq= restExe.execute(transaction, ctx); + String flowSequnce=flowSeq.get("restResponse"); + System.out.println(flowSequnce); + + } +} diff --git a/appc-config/appc-flow-controller/provider/src/test/resources/Info.out.xml b/appc-config/appc-flow-controller/provider/src/test/resources/Info.out.xml new file mode 100644 index 000000000..787796704 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/resources/Info.out.xml @@ -0,0 +1,19 @@ + diff --git a/appc-config/appc-flow-controller/provider/src/test/resources/svclogic.properties b/appc-config/appc-flow-controller/provider/src/test/resources/svclogic.properties new file mode 100644 index 000000000..f6b424136 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/resources/svclogic.properties @@ -0,0 +1,33 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APP-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========================================================= +### + +org.openecomp.sdnc.sli.dbtype= +org.openecomp.sdnc.sli.jdbc.hosts= +org.openecomp.sdnc.sli.jdbc.url= +org.openecomp.sdnc.sli.jdbc.database= +org.openecomp.sdnc.sli.jdbc.user= +org.openecomp.sdnc.sli.jdbc.password= +org.openecomp.sdnc.sli.jdbc.connection.name= + +org.openecomp.sdnc.sli.jdbc.connection.timeout= +org.openecomp.sdnc.sli.jdbc.request.timeout= +org.openecomp.sdnc.sli.jdbc.limit.init= +org.openecomp.sdnc.sli.jdbc.limit.min= +org.openecomp.sdnc.sli.jdbc.limit.max= diff --git a/appc-config/appc-flow-controller/provider/src/test/resources/transactionModel.json b/appc-config/appc-flow-controller/provider/src/test/resources/transactionModel.json new file mode 100644 index 000000000..b21f48805 --- /dev/null +++ b/appc-config/appc-flow-controller/provider/src/test/resources/transactionModel.json @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-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========================================================= + */ + +{ + "transactions": [{ + "transactionId": 1, + "action": "configure", + "action-level": "vnf", + "action-identifier": { + "vnf-id": "dbgx0001v" + }, + "payload": "This is my Payload", + "parameters": [{ + "name": "value" + }], + "precheck": { + "precheck-operator": "all", + "precheck-options": [{ + "pre-transactionID": "1", + "param-name": "state", + "param-value": "healthy", + "rule": "continue" + }, + { + "pre-transactionID": "2", + "param-name": "state", + "param-value": "healthy", + "rule": "continue" + }] + }, + "state": "healthy", + "responses": [{ + "responseActionHanlder": null, + "responseCode": "401", + "responseMessage": null, + "responseAction": { + "wait": null, + "retry": null, + "jump": null, + "ignore": true, + "stop": false, + "intermediateMessage": null + } + }] + }] +} diff --git a/appc-config/jacoco.exec b/appc-config/jacoco.exec deleted file mode 100644 index c1ac989b4069f92f4bbd53869e42a80ea1e9528d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9623 zcmb_idt4J&_P zwRUZ5wYs)lTeXW-Yk&2zQgWXW9RQpr$-QBttm9b*^H3xH+w6ujV6yj%*DxK zaFqZtFfpQ-4(_Ba=04s?w+6Gur}y@My=4%}@nC~{mu0aG zXC@v?oxq5a>>_WBy>zumXSn5u5*}+>7B5t=mQsg!j_iGUo$m1Y*+KZ?uCH3B-+uou zD5%Z2R8eFE=>??yOje%YKYaS{K4m|Y*-&EJTiYM{5Xz?yE{Pg@U~=5D?@)jDMvFF9 zVgNjrLPmthW|nDY;O%u~vtH`{-~bxXW`GvMG>$h_kUUU-83DOwo13sLmyarzu(It@K@;@2Dcpl$NE7{f87QY%LKi+nk z2&}YJmd;yB*ixIIEbey|;gG{E)zpnksU(sjSCUvxl`))E=7Kyh*F26dEoFo>T4W45 z{6+Ju4_`_D9YT5Tx3obl+xRPkW`G4JlnD%NRw*x1S=Z@L248$Wc4Uw9k&A;+uZJBX zQs6nD5^x3JujuYgcK7|Co<{Wpeej`$@#DWgek_!Pfwuy&Le#B5?N$>7^hi^Xc2z9! z2W2j%|D4`jq1pF;mg# zHh|Z?+p? zuSZ2PbrA=uHOM;-SboZ9z6|3cr;S0<;G?B%EBpwr@S}$Srj9i`5qbP)d^1(b6?wZb|!YL^jbIx#ARG6umlw%*LOgg z6<7{riI*Ra%{vknH)3Z2afxGwxTm;e0LHe!6Rqaj8Drba?V4CCY!g?#yvH@hA``9ZitvW-p+-DA<@7IS*50=fZRQ%JVi|2_T!`>8AbK+;uP&-#QC#t!0ihqS zX$qk1@7lA+JmUF3pNiQghBvp1qh(d?E8?}^jyo{5ZetUA+68Dh+EVIh*lpj~$Jo%W ze~+r?+V#Fi--LU9|3=mb>Gz9JzHF`=kh-Vw493LKGWfUeKS*OC%?pNkDnbtL>Mt&O2lEuec8 zSz>Q(RK4JvieE3;F<{legF_uv3gIlJ+fg+NYk|$Zd*jWFv}^6w=aM{$Gu3Wc*JxC! zZWr~*oXbaM;4O0!kM#fdZ7-5|&cdk3RxC=aWRq03)Oxv8?4A1Q>!YKy|LBRK1;z^6 z7;1?8zz9wZ?d6OAfj=_cifJ;Sl(vYva+7HHQ>5xU+1K_zcG~BQH;(${l@UJ=Fg;2h zk1(*kl=a5jt8eTK|7K!_C;n9kKxTh&0uQ`Pv0d7L|I$-O_0akI^hd@Ec+NiElf_;0&Z0;;a?X&+rGaLJoKg#~6dQnDgicOp z+*-apqw>Ipg^#7%bdDDpImDWiyUd1SIdkv2>|>iUV$l%yIjR_|vNZ%tX-1$skrZ4)Z1ZuhZ1YAW`}{ojgRt|<6nXuUpPEB z;`z0gHvaxO+R%i?@m%Xx zpV3RAUm;}cx(d7MGB)XIO*6uyhzigaEp@M_zp-&}m@&I!k+##yDy z{h2b1)9LUO{by&q3@y{z0m(!al8^+O))e%sJLq-K6ECZt$^Z?UDG0n!1ge5#B;L~1 z7d?R+nzyd#w|{I53YVkhsAH)NMl=bm(wN5OH1!78=Z?Bh5ba3)48iUyV27q`A=I7g z2B(Autc*v`xbTj>6sbZI`av@94;-$;MR7yF(sf^v=82@8L82kQ*GH2_AWW~C``hc& zny(NiI;$f2q(nQalbRyNWP=X8CYQF*Fm^O}*u`&6|EFhh>N{}Lv0HGIX!3+#m0CG)&urPFGz&t$;9CX3( z;7YHTJSh=pXOIE9O5MEB1qJExgcegw>;IfSfu54hb9PByegSD`ROtfYAC@$>|JvmR zLs9p(*bzXhgQ%_%7yNL3_0*sH?=4=8LS4LTmJQ$;;EizHFz;2UVRs`L_`6P3t>kJ$ zVRW9!y8SclnsfeWkJIXTiO74<20l%xiu^E&lM;s8ur(MlVM$8h-88P2JLI z7?B8p+}1RwXy0kmDNiY+WgraY+J>ca$@dDt)stIa-1&OnKor*I=|_fLvnn=+ZWtZ} z6{Efue(7+}ce?I8eP%|ICuyP70B!W7B^nH0;L{DWvZwn^PDKOdJw3YE@w_9q1pGkl zisHuMUDnlARfd}Vjx}11H}uFZ?*>9!HvbLRHT8SLYgYDQPnilggc>_2Spxzc=odUa zUN|J?J~xL6yY49}YDCkN!4i~sxI~3s|3#Rw z*l<|Zh`f@t>$M%|(wtKqy0jgQU3zRYcc(q6WDhB>*JJ&>6Jh!DqrX9YA5Iu;v{tCx zIH+9M*?{n^?96+7BU48Ng&P^*zQ(9486V(_dF!T}el?{GgrB&-B!+4$~s()bG!^^mddknoJyMnA-+1?TrsKnaC-i`l zqud~=c}K`t8TY2cbP?|3M88lSUb&W8nH2lGs~zPex#x{(?fLaPqq9ErB*C1^x}6q@ z$dK>9lp1ebj5{x?Kd{mI>JnQlgIbJbo1n$wd9)0F}51P*slncgbwsaxMlN} zh9?FY-*;8(6*htbGduA4g(uKV9)-xBca{$_t^!a1?p&YBWG}wf@Ys7LdB&0OvH$SJ zNl{~*x>(n(bWxd2GV?E3!r(&Q3m-_Ti_ZL_%V0+#^GJDBg^W)(Txt31{BDh-4}0o2 zRIe(0KaQ8j$xhP^<9oRIn&E%@uK4>jN0w;gPDYVBBBd-)NM89>=1M5SgJc3W+Dty1}6ZW7-#%1I=`5n diff --git a/appc-config/pom.xml b/appc-config/pom.xml index 3aa0513ff..d90a3c8b4 100644 --- a/appc-config/pom.xml +++ b/appc-config/pom.xml @@ -1,96 +1,97 @@ - 4.0.0 - - org.openecomp.appc - appc - 1.1.0-SNAPSHOT - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.openecomp.appc + appc + 1.1.0-SNAPSHOT + - org.openecomp.appc - appc-config - pom - Application Controller Config - Application Controller Config + org.openecomp.appc + appc-config + pom + Application Controller Config + Application Controller Config - - 2.1.1-Boron-SR1 - 2.3.2 - 1.12 - 1.7 - 1.3.7 - 3.2.1 - 2.5 + + 2.1.1-Boron-SR1 + 2.3.2 + 1.12 + 1.7 + 1.3.7 + 3.2.1 + 2.5 - 1.1.0 - 1.1.2 - 1.1.0 - 1.1.0 - + 1.1.0 + 1.1.2 + 1.1.0 + 1.1.0 + - - + + - - org.openecomp.sdnc.adaptors - sql-resource-provider - ${openecomp.sdnc.sql-resource.version} - + + org.openecomp.sdnc.adaptors + sql-resource-provider + ${openecomp.sdnc.sql-resource.version} + - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-properties - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - org.yaml - snakeyaml - ${snakeyaml.version} - - - org.apache.velocity - velocity - ${velocity.version} - - - commons-io - commons-io - ${common.io.version} - - - org.codehaus.jettison - jettison - ${jettison.version} - provided - - + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-properties + ${jackson.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson.version} + + + org.yaml + snakeyaml + ${snakeyaml.version} + + + org.apache.velocity + velocity + ${velocity.version} + + + commons-io + commons-io + ${common.io.version} + + + org.codehaus.jettison + jettison + ${jettison.version} + provided + + - + appc-config-params appc-encryption-tool appc-data-services + appc-flow-controller -- 2.16.6