summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-02-15 23:11:26 -0800
committerPatrick Brady <pb071s@att.com>2017-02-15 23:13:06 -0800
commit1c192d2dd68724e292b6a30f463085a262e1e813 (patch)
treed0e2b3a396e169863cd0efaa835c8675e9d5aaac /appc-provider/appc-provider-bundle/src
parentc69ba05c7508aa7d7f675189a45c8c87569369ef (diff)
Moving all files to root directory
Change-Id: Ica5535fd6ec85f350fe1640b42137b49f83f10f0 Signed-off-by: Patrick Brady <pb071s@att.com>
Diffstat (limited to 'appc-provider/appc-provider-bundle/src')
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModule.java85
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModuleFactory.java36
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java53
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java34
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java266
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java81
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java828
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/ResponseHeaderBuilder.java88
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/LCMConstants.java35
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java141
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java91
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java718
-rw-r--r--appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml36
-rw-r--r--appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml118
-rw-r--r--appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/default.properties55
-rw-r--r--appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/logback.xml284
-rw-r--r--appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg144
-rw-r--r--appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang61
-rw-r--r--appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang61
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java84
20 files changed, 3299 insertions, 0 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModule.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModule.java
new file mode 100644
index 000000000..2b55d192c
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModule.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523;
+
+import org.openecomp.appc.provider.AppcProvider;
+
+/**
+ * This was generated code. It was generated into the source tree because it has to be manually modified.
+ *
+ */
+public class AppcProviderModule extends
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523.AbstractAppcProviderModule {
+
+ /**
+ * @param identifier
+ * @param dependencyResolver
+ */
+ @SuppressWarnings("javadoc")
+ public AppcProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ /**
+ * @param identifier
+ * @param dependencyResolver
+ * @param oldModule
+ * @param oldInstance
+ */
+ @SuppressWarnings("javadoc")
+ public AppcProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+ org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523.AppcProviderModule oldModule,
+ java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ /**
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523.AbstractAppcProviderModule#customValidation()
+ */
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ /**
+ * This method is manually updated to actually invoke the provider implementation
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523.AbstractAppcProviderModule#createInstance()
+ */
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+
+ final AppcProvider provider =
+ new AppcProvider(getDataBrokerDependency(), getNotificationServiceDependency(), getRpcRegistryDependency());
+ return new AutoCloseable() {
+
+ @Override
+ public void close() throws Exception {
+ provider.close();
+ }
+ };
+
+ }
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModuleFactory.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModuleFactory.java
new file mode 100644
index 000000000..d91f057a7
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/impl/rev140523/AppcProviderModuleFactory.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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=========================================================
+ */
+
+/**
+ * Generated file Generated from: yang module name: appc-provider-impl yang module local name: appc-provider-impl
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator Generated at: Tue Sep 01
+ * 13:56:34 CDT 2015 Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523;
+
+/**
+ * Generated code
+ *
+ */
+public class AppcProviderModuleFactory extends
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.impl.rev140523.AbstractAppcProviderModuleFactory {
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java
new file mode 100644
index 000000000..ac98cb894
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModule.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.opendaylight.yang.gen.v1.org.openecomp.appc.provider.lcm.impl.rev160108;
+
+import org.openecomp.appc.provider.AppcProviderLcm;
+
+public class AppcProviderLcmModule extends org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.lcm.impl.rev160108.AbstractAppcProviderLcmModule {
+ public AppcProviderLcmModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public AppcProviderLcmModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.lcm.impl.rev160108.AppcProviderLcmModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ final AppcProviderLcm provider =
+ new AppcProviderLcm(getDataBrokerDependency(), getNotificationServiceDependency(), getRpcRegistryDependency());
+ return new AutoCloseable() {
+
+ @Override
+ public void close() throws Exception {
+ provider.close();
+ }
+ };
+ }
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java
new file mode 100644
index 000000000..5f2c358a1
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/appc/provider/lcm/impl/rev160108/AppcProviderLcmModuleFactory.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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=========================================================
+ */
+
+/*
+* Generated file
+*
+* Generated from: yang module name: appc-provider-lcm-impl yang module local name: appc-provider-lcm-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Aug 16 10:40:21 IDT 2016
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.lcm.impl.rev160108;
+public class AppcProviderLcmModuleFactory extends org.opendaylight.yang.gen.v1.org.openecomp.appc.provider.lcm.impl.rev160108.AbstractAppcProviderLcmModuleFactory {
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
new file mode 100644
index 000000000..9826a5619
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProvider.java
@@ -0,0 +1,266 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider;
+
+import com.google.common.util.concurrent.Futures;
+import org.json.JSONObject;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.*;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.request.header.CommonRequestHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.responseattributes.StatusBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.responseheader.ResponseHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.executor.objects.LCMCommandStatus;
+import org.openecomp.appc.executor.objects.Params;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.provider.lcm.util.RequestInputBuilder;
+import org.openecomp.appc.provider.lcm.util.ValidationService;
+import org.openecomp.appc.provider.topology.TopologyService;
+import org.openecomp.appc.requesthandler.RequestHandler;
+import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
+import org.openecomp.appc.requesthandler.objects.RequestHandlerOutput;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.Action;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+/* ADDED FOR FUSION SERVICE CODE */
+
+@SuppressWarnings("JavaDoc")
+/**
+ * Defines the APPC service provider.
+ * <p>
+ * The rpc definition in the YANG model is shown below. This model is used to generate code to manage the inputs and
+ * outputs of the RPC service. For example, the input is defined by a class named {@link ConfigurationOperationInput},
+ * which is generated from the name of the RPC and the "input" definition of the RPC. This class encapsulates the
+ * various objects that are passed to the RPC and is used to obtain values from the input parameters.
+ * </p>
+ * <p>
+ * Likewise, the outputs are defined by a class named {@link ConfigurationOperationOutput}. This class encapsulates the
+ * defined outputs. To make construction of the outputs easier, there are also generated builder classes that are named
+ * for the various elements of the output they "build", such as {@link ConfigurationResponseBuilder}.
+ * </p>
+ *
+ * <pre>
+ * rpc configuration-operation {
+ * description "An operation to view, change, or audit the configuration of a VM";
+ * input {
+ * uses configuration-request-header;
+ * uses configuration-request;
+ * }
+ * output {
+ * uses common-response-header;
+ * uses configuration-response;
+ * }
+ * }
+ * </pre>
+ *
+ */
+public class AppcProvider implements AutoCloseable, AppcProviderService {
+
+ // private final Logger logger = LoggerFactory.getLogger(AppcProvider.class);
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(AppcProviderClient.class);
+
+ private final ExecutorService executor;
+
+ private ListenerRegistration<DataChangeListener> dclServices;
+
+ /**
+ * The ODL data store broker. Provides access to a conceptual data tree store and also provides the ability to
+ * subscribe for changes to data under a given branch of the tree.
+ */
+ protected DataBroker dataBroker;
+
+ /**
+ * ODL Notification Service that provides publish/subscribe capabilities for YANG modeled notifications.
+ */
+ protected NotificationProviderService notificationService;
+
+ /**
+ * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are defined in YANG models.
+ */
+ protected RpcProviderRegistry rpcRegistry;
+
+ /**
+ * Represents our RPC implementation registration
+ */
+ protected BindingAwareBroker.RpcRegistration<AppcProviderService> rpcRegistration;
+
+ /**
+ * The configuration
+ */
+ private Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ /**
+ * @param dataBroker2
+ * @param notificationProviderService
+ * @param rpcProviderRegistry
+ */
+ @SuppressWarnings({
+ "javadoc", "nls"
+ })
+ public AppcProvider(DataBroker dataBroker2, NotificationProviderService notificationProviderService,
+ RpcProviderRegistry rpcProviderRegistry) {
+
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.COMPONENT_INITIALIZING, appName, "provider");
+
+ executor = Executors.newFixedThreadPool(1);
+ dataBroker = dataBroker2;
+ notificationService = notificationProviderService;
+ rpcRegistry = rpcProviderRegistry;
+
+ if (rpcRegistry != null) {
+ rpcRegistration = rpcRegistry.addRpcImplementation(AppcProviderService.class, this);
+ }
+
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, "provider");
+ }
+
+ /**
+ * Implements the close of the service
+ *
+ * @see java.lang.AutoCloseable#close()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public void close() throws Exception {
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.COMPONENT_TERMINATING, appName, "provider");
+ executor.shutdown();
+ if (rpcRegistration != null) {
+ rpcRegistration.close();
+ }
+ logger.info(Msg.COMPONENT_TERMINATED, appName, "provider");
+ }
+
+
+public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input){
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ ConfigPayload data = input.getConfigPayload();
+ TopologyService topology = new TopologyService(this);
+ RpcResult<ModifyConfigOutput> result = topology.modifyConfig(hdr, data);
+ return Futures.immediateFuture(result);
+}
+ /**
+ * Rebuilds a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.AppcProviderService#rebuild(org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildInput)
+ */
+ @Override
+ public Future<RpcResult<RebuildOutput>> rebuild(RebuildInput input) {
+
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
+
+ TopologyService topology = new TopologyService(this);
+ RpcResult<RebuildOutput> result = topology.rebuild(hdr, vnf);
+ return Futures.immediateFuture(result);
+ }
+
+ /**
+ * Restarts a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.AppcProviderService#restart(org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartInput)
+ */
+ @Override
+ public Future<RpcResult<RestartOutput>> restart(RestartInput input) {
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
+
+ TopologyService topology = new TopologyService(this);
+ RpcResult<RestartOutput> result = topology.restart(hdr, vnf);
+ return Futures.immediateFuture(result);
+ }
+
+ /**
+ * Migrates a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.AppcProviderService#migrate(org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateInput)
+ */
+ @Override
+ public Future<RpcResult<MigrateOutput>> migrate(MigrateInput input) {
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
+
+ TopologyService topology = new TopologyService(this);
+ RpcResult<MigrateOutput> result = topology.migrate(hdr, vnf);
+ return Futures.immediateFuture(result);
+ }
+
+ /**
+ * Evacuates a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.EvacuateInput)
+ */
+ @Override
+ public Future<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) {
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
+
+ TopologyService topology = new TopologyService(this);
+ // RpcResult<RestartOutput> result = topology.restart(hdr, vnf);
+ return null;// Futures.immediateFuture(result);
+ }
+
+ /**
+ * Evacuates a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.AppcProviderService#evacuate(org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.EvacuateInput)
+ */
+ @Override
+ public Future<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) {
+ CommonRequestHeader hdr = input.getCommonRequestHeader();
+ VnfResource vnf = input.getVnfResource();
+
+ TopologyService topology = new TopologyService(this);
+ RpcResult<SnapshotOutput> result = topology.snapshot(hdr, vnf);
+ return Futures.immediateFuture(result);
+ }
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java
new file mode 100644
index 000000000..f294fd98f
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderClient.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider;
+
+import org.openecomp.appc.util.StringHelper;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+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 static com.att.eelf.configuration.Configuration.*;
+
+import java.util.Properties;
+
+public class AppcProviderClient {
+
+ //private static final Logger LOG = LoggerFactory.getLogger(AppcProviderClient.class);
+ private static EELFLogger LOG = EELFManager.getInstance().getApplicationLogger();
+ private static EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+
+ private SvcLogicService svcLogic = null;
+
+ public AppcProviderClient() {
+ BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
+
+ // Get SvcLogicService reference
+ ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
+ if (sref != null) {
+ svcLogic = (SvcLogicService) bctx.getService(sref);
+
+ } else {
+ LOG.warn("Cannot find service reference for " + SvcLogicService.NAME);
+
+ }
+ }
+
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
+ LOG.debug(String.format("Checking for graph. %s %s %s %s", module, rpc, version, mode));
+ return (svcLogic.hasGraph(module, rpc, version, mode));
+ }
+
+ public Properties execute(String module, String rpc, String version, String mode, Properties parms)
+ throws SvcLogicException {
+
+ LOG.debug("Parameters passed to SLI: " + StringHelper.propertiesToString(parms));
+ metricsLogger.info("Parameters passed to SLI: " + StringHelper.propertiesToString(parms));
+
+ Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
+
+ LOG.debug("Parameters returned by SLI: " + StringHelper.propertiesToString(respProps));
+ metricsLogger.info("Parameters returned by SLI: " + StringHelper.propertiesToString(respProps));
+
+ // No impact on flow. Not sure why it is here
+ // if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { return (respProps); }
+
+ return respProps;
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
new file mode 100644
index 000000000..5fe174e55
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java
@@ -0,0 +1,828 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider;
+
+import java.text.ParseException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.CheckLockInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.CheckLockOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.CheckLockOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.EvacuateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.EvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.EvacuateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.MigrateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.MigrateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RebuildInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RebuildOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RestartInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RestartOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.StatusBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.domainmodel.lcm.ResponseContext;
+import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
+import org.openecomp.appc.executor.objects.LCMCommandStatus;
+import org.openecomp.appc.executor.objects.Params;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.logging.LoggingConstants;
+import org.openecomp.appc.logging.LoggingUtils;
+import org.openecomp.appc.provider.lcm.util.RequestInputBuilder;
+import org.openecomp.appc.provider.lcm.util.ValidationService;
+import org.openecomp.appc.requesthandler.RequestHandler;
+import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
+import org.openecomp.appc.requesthandler.objects.RequestHandlerOutput;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+import com.google.common.util.concurrent.Futures;
+import org.slf4j.MDC;
+
+
+public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService {
+
+ private Configuration configuration = ConfigurationFactory.getConfiguration();
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(AppcProviderLcm.class);
+
+ private final ExecutorService executor;
+
+ private final String COMMON_ERROR_MESSAGE_TEMPLATE = "Error processing %s input : %s";
+
+ /**
+ * The ODL data store broker. Provides access to a conceptual data tree store and also provides the ability to
+ * subscribe for changes to data under a given branch of the tree.
+ */
+ protected DataBroker dataBroker;
+
+ /**
+ * ODL Notification Service that provides publish/subscribe capabilities for YANG modeled notifications.
+ */
+ protected NotificationProviderService notificationService;
+
+ /**
+ * Provides a registry for Remote Procedure Call (RPC) service implementations. The RPCs are defined in YANG models.
+ */
+ protected RpcProviderRegistry rpcRegistry;
+
+ /**
+ * Represents our RPC implementation registration
+ */
+ protected BindingAwareBroker.RpcRegistration<AppcProviderLcmService> rpcRegistration;
+
+
+ /**
+ * @param dataBroker
+ * @param notificationProviderService
+ * @param rpcProviderRegistry
+ */
+ @SuppressWarnings({
+ "javadoc", "nls"
+ })
+ public AppcProviderLcm(DataBroker dataBroker, NotificationProviderService notificationProviderService,
+ RpcProviderRegistry rpcProviderRegistry) {
+
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.COMPONENT_INITIALIZING, appName, "provider");
+
+ executor = Executors.newFixedThreadPool(1);
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationProviderService;
+ this.rpcRegistry = rpcProviderRegistry;
+
+ if (this.rpcRegistry != null) {
+ rpcRegistration = rpcRegistry.addRpcImplementation(AppcProviderLcmService.class, this);
+ }
+
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, "provider");
+ }
+
+ /**
+ * Implements the close of the service
+ *
+ * @see java.lang.AutoCloseable#close()
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public void close() throws Exception {
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.COMPONENT_TERMINATING, appName, "provider");
+ executor.shutdown();
+ if (rpcRegistration != null) {
+ rpcRegistration.close();
+ }
+ logger.info(Msg.COMPONENT_TERMINATED, appName, "provider");
+ }
+
+
+ /**
+ * Rebuilds a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#rebuild(RebuildInput)
+ */
+ @Override
+ public Future<RpcResult<RebuildOutput>> rebuild(RebuildInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ RebuildOutputBuilder outputBuilder = new RebuildOutputBuilder();
+ String action = Action.Rebuild.toString() ;
+ String rpcName = Action.Rebuild.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<RebuildOutput> result = RpcResultBuilder.<RebuildOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+
+ }
+
+
+ /**
+ * Restarts a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#restart(RestartInput)
+ */
+ @Override
+ public Future<RpcResult<RestartOutput>> restart(RestartInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ RestartOutputBuilder outputBuilder = new RestartOutputBuilder();
+ String action = Action.Restart.toString() ;
+ String rpcName = Action.Restart.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<RestartOutput> result = RpcResultBuilder.<RestartOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ /**
+ * Migrates a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#migrate(MigrateInput)
+ */
+ @Override
+ public Future<RpcResult<MigrateOutput>> migrate(MigrateInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ MigrateOutputBuilder outputBuilder = new MigrateOutputBuilder();
+ String action = Action.Migrate.toString() ;
+ String rpcName = Action.Migrate.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<MigrateOutput> result = RpcResultBuilder.<MigrateOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ /**
+ * Evacuates a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#evacuate(EvacuateInput)
+ */
+ @Override
+ public Future<RpcResult<EvacuateOutput>> evacuate(EvacuateInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ EvacuateOutputBuilder outputBuilder = new EvacuateOutputBuilder();
+ String action = Action.Evacuate.toString() ;
+ String rpcName = Action.Evacuate.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<EvacuateOutput> result = RpcResultBuilder.<EvacuateOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ /**
+ * Evacuates a specific VNF
+ *
+ * @see org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AppcProviderLcmService#snapshot(SnapshotInput)
+ */
+ @Override
+ public Future<RpcResult<SnapshotOutput>> snapshot(SnapshotInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ SnapshotOutputBuilder outputBuilder = new SnapshotOutputBuilder();
+ String action = Action.Snapshot.toString() ;
+ String rpcName = Action.Snapshot.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ String identityUrl = input.getIdentityUrl();
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).additionalContext("identity-url", identityUrl).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<SnapshotOutput> result = RpcResultBuilder.<SnapshotOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<RollbackOutput>> rollback(RollbackInput input) {
+ logger.debug("Input received : " + input.toString());
+
+ RollbackOutputBuilder outputBuilder = new RollbackOutputBuilder();
+ String rpcName = Action.Rollback.toString() ;
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), rpcName);
+ String identityUrl = input.getIdentityUrl();
+ String snapshotId = input.getSnapshotId();
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).additionalContext("identity-url", identityUrl).additionalContext("snapshot-id", snapshotId).action(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, rpcName, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<RollbackOutput> result = RpcResultBuilder.<RollbackOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<SyncOutput>> sync(SyncInput input) {
+ logger.debug("Input received : " + input.toString());
+ SyncOutputBuilder outputBuilder = new SyncOutputBuilder();
+ String action = Action.Sync.toString() ;
+ String rpcName = Action.Sync.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<SyncOutput> result = RpcResultBuilder.<SyncOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ private Status buildParsingErrorStatus(ParseException e){
+ LCMCommandStatus requestParsingFailure = LCMCommandStatus.REQUEST_PARSING_FAILED;
+ String errorMessage = e.getMessage() != null ? e.getMessage() : e.toString();
+ Params params = new Params().addParam("errorMsg", errorMessage);
+ return buildStatus(requestParsingFailure.getResponseCode(), requestParsingFailure.getFormattedMessage(params));
+ }
+
+ private Status buildStatus(Integer code,String message){
+ StatusBuilder status = new StatusBuilder();
+ status.setCode(code);
+ status.setMessage(message);
+ return status.build();
+ }
+
+ private Status buildStatusWithDispatcherOutput(RequestHandlerOutput requestHandlerOutput){
+ Integer statusCode = requestHandlerOutput.getResponseContext().getStatus().getCode();
+ String statusMessage = requestHandlerOutput.getResponseContext().getStatus().getMessage();
+ return buildStatus(statusCode, statusMessage);
+ }
+
+ private RequestHandlerOutput executeRequest(RequestHandlerInput request){
+
+ RequestHandler handler = getRequestHandler();
+ RequestHandlerOutput requestHandlerOutput=null;
+ try {
+ requestHandlerOutput = handler.handleRequest(request);
+ } catch (Exception e) {
+
+ final String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ final String reason = EELFResourceManager.format(Msg.EXCEPTION_CALLING_DG, e, appName, e.getClass().getSimpleName(), "", e.getMessage());
+
+ logger.info("UNEXPECTED FAILURE while executing " + request.getRequestContext().getAction().name());
+
+
+ final ResponseContext responseContext = new ResponseContext();
+ requestHandlerOutput = new RequestHandlerOutput();
+ requestHandlerOutput.setResponseContext(responseContext);
+ responseContext.setCommonHeader(request.getRequestContext().getCommonHeader());
+ final org.openecomp.appc.domainmodel.lcm.Status status = new org.openecomp.appc.domainmodel.lcm.Status();
+
+ responseContext.setStatus(status);
+
+ String errorMessage = e.getMessage() != null ? e.getMessage() : e.toString();
+ Params params = new Params().addParam("errorMsg", errorMessage);
+ status.setCode(LCMCommandStatus.UNEXPECTED_ERROR.getResponseCode());
+ status.setMessage(LCMCommandStatus.UNEXPECTED_ERROR.getFormattedMessage(params));
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ reason,
+ this.getClass().getName());
+
+
+ }
+ return requestHandlerOutput;
+ }
+
+ private RequestHandler getRequestHandler(){
+ RequestHandler handler ;
+ final BundleContext context = FrameworkUtil.getBundle(RequestHandler.class).getBundleContext();
+ final ServiceReference reference = context.getServiceReference(RequestHandler.class.getName());
+
+ if (reference != null) {
+ handler = (RequestHandler) context.getService(reference);
+ } else {
+ logger.error("Cannot find service reference for " + RequestHandler.class.getName());
+ throw new RuntimeException();
+ }
+ return handler ;
+ }
+
+
+ @Override
+ public Future<RpcResult<TerminateOutput>> terminate(TerminateInput input) {
+ logger.debug("Input received : " + input.toString());
+ TerminateOutputBuilder outputBuilder = new TerminateOutputBuilder();
+ String action = Action.Terminate.toString() ;
+ String rpcName = Action.Terminate.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<TerminateOutput> result = RpcResultBuilder.<TerminateOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+
+ @Override
+ public Future<RpcResult<ModifyConfigOutput>> modifyConfig(ModifyConfigInput input) {
+ logger.debug("Input received : " + input.toString());
+ ModifyConfigOutputBuilder outputBuilder = new ModifyConfigOutputBuilder();
+ String action = Action.ModifyConfig.toString() ;
+ String rpcName = "modify-config";
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<ModifyConfigOutput> result = RpcResultBuilder.<ModifyConfigOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<TestOutput>> test(TestInput input) {
+ logger.debug("Input received : " + input.toString());
+ TestOutputBuilder outputBuilder = new TestOutputBuilder();
+ String action = Action.Test.toString() ;
+ String rpcName = Action.Test.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<TestOutput> result = RpcResultBuilder.<TestOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ @Override
+ public Future<RpcResult<StopOutput>> stop(StopInput input) {
+ logger.debug("Input received : " + input.toString());
+ StopOutputBuilder outputBuilder = new StopOutputBuilder();
+ String action = Action.Stop.toString() ;
+ String rpcName = Action.Stop.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<StopOutput> result = RpcResultBuilder.<StopOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<AuditOutput>> audit(AuditInput input) {
+ logger.debug("Input received : " + input.toString());
+ AuditOutputBuilder outputBuilder = new AuditOutputBuilder();
+ String action = Action.Audit.toString();
+ String rpcName = Action.Audit.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<AuditOutput> result = RpcResultBuilder.<AuditOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<SoftwareUploadOutput>> softwareUpload(SoftwareUploadInput input) {
+ logger.debug("Input received : " + input.toString());
+ SoftwareUploadOutputBuilder outputBuilder = new SoftwareUploadOutputBuilder();
+ String action = Action.SoftwareUpload.toString() ;
+ String rpcName = convertActionNameToUrl(action);
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().
+ requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<SoftwareUploadOutput> result = RpcResultBuilder.<SoftwareUploadOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<HealthCheckOutput>> healthCheck(HealthCheckInput input) {
+ logger.debug("Input received : " + input.toString());
+ HealthCheckOutputBuilder outputBuilder = new HealthCheckOutputBuilder();
+ String action = Action.HealthCheck.toString() ;
+ String rpcName = convertActionNameToUrl(action);
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<HealthCheckOutput> result = RpcResultBuilder.<HealthCheckOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<LiveUpgradeOutput>> liveUpgrade(LiveUpgradeInput input) {
+ logger.debug("Input received : " + input.toString());
+ LiveUpgradeOutputBuilder outputBuilder = new LiveUpgradeOutputBuilder();
+ String action = Action.LiveUpgrade.toString() ;
+ String rpcName = convertActionNameToUrl(action);
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<LiveUpgradeOutput> result = RpcResultBuilder.<LiveUpgradeOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ @Override
+ public Future<RpcResult<LockOutput>> lock(LockInput input) {
+ logger.debug("Input received : " + input.toString());
+ LockOutputBuilder outputBuilder = new LockOutputBuilder();
+ String action = Action.Lock.toString() ;
+ String rpcName = Action.Lock.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<LockOutput> result = RpcResultBuilder.<LockOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+
+ @Override
+ public Future<RpcResult<UnlockOutput>> unlock(UnlockInput input) {
+ logger.debug("Input received : " + input.toString());
+ UnlockOutputBuilder outputBuilder = new UnlockOutputBuilder();
+ String action = Action.Unlock.toString() ;
+ String rpcName = Action.Unlock.name().toLowerCase();
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).payload(input.getPayload()).action(action).rpcName(rpcName).build();
+ status = buildStatusWithDispatcherOutput(executeRequest(request));
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ RpcResult<UnlockOutput> result = RpcResultBuilder.<UnlockOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public Future<RpcResult<CheckLockOutput>> checkLock(CheckLockInput input) {
+ logger.debug("Input received : " + input.toString());
+ CheckLockOutputBuilder outputBuilder = new CheckLockOutputBuilder();
+ String action = Action.CheckLock.toString() ;
+ String rpcName = Action.CheckLock.name().toLowerCase();
+ RequestHandlerOutput requestHandlerOutput=null;
+ Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
+ if(null == status) {
+ try {
+ RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build();
+ requestHandlerOutput=executeRequest(request);
+
+ status = buildStatusWithDispatcherOutput(requestHandlerOutput);
+ logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage()));
+ } catch (ParseException e) {
+ status = buildParsingErrorStatus(e);
+
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.APPC_PROVIDER,
+ String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
+ this.getClass().getName());
+
+ }
+ }
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ outputBuilder.setStatus(status);
+ if(requestHandlerOutput.getResponseContext().getStatus().getCode() == 400) {
+ outputBuilder.setLocked(CheckLockOutput.Locked.valueOf(requestHandlerOutput.getResponseContext().getAdditionalContext().get("locked").toUpperCase()));
+ }
+ RpcResult<CheckLockOutput> result = RpcResultBuilder.<CheckLockOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ private String convertActionNameToUrl(String action) {
+ String regex = "([a-z])([A-Z]+)";
+ String replacement = "$1-$2";
+ return action.replaceAll(regex, replacement)
+ .toLowerCase();
+ }
+
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/ResponseHeaderBuilder.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/ResponseHeaderBuilder.java
new file mode 100644
index 000000000..ea03074bd
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/ResponseHeaderBuilder.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider;
+
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.TIMESTAMP;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.response.header.CommonResponseHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.response.header.CommonResponseHeaderBuilder;
+import org.openecomp.appc.util.Time;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+
+/**
+ * Builds the responses from the APP-C services according to the YANG domainmodel
+ *
+ * @since Nov 16, 2015
+ * @version $Id$
+ */
+public class ResponseHeaderBuilder {
+
+ /**
+ * The date/time formatter to format timestamps.
+ */
+ @SuppressWarnings("nls")
+ public static final DateFormat FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
+ public static final DateFormat ZULU_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
+
+ /**
+ * Private default constructor prevents instantiation
+ */
+ private ResponseHeaderBuilder() {
+ }
+
+ /**
+ * This method builds the common response header and returns it to the caller for integration into the response
+ *
+ * @param success
+ * True or false indicating the outcome of the operation. True indicates that the operation was
+ * successful, false indicates it failed.
+ * @param requestId
+ * The original request id for the service
+ * @param reason
+ * The reason for the failure if the success flag is false. If success is true, the reason is not used.
+ * @param duration
+ * The duration of the request processing
+ * @return The common response header to be returned to the caller.
+ */
+ @SuppressWarnings("nls")
+ public static CommonResponseHeader buildHeader(Boolean success, String requestId, String reason, long duration) {
+ CommonResponseHeaderBuilder builder = new CommonResponseHeaderBuilder();
+
+ TIMESTAMP timestamp = new TIMESTAMP(FORMATTER.format(Time.utcDate()));
+ builder.setServiceRequestId(requestId);
+ builder.setCompleted(timestamp);
+ builder.setDuration(duration);
+ builder.setSuccess(success);
+
+ if (success.equals(Boolean.TRUE)) {
+ builder.setReason("Success");
+ } else {
+ builder.setReason(reason);
+ }
+
+ return builder.build();
+ }
+
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/LCMConstants.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/LCMConstants.java
new file mode 100644
index 000000000..bcb55bc75
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/LCMConstants.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider.lcm.util;
+
+public final class LCMConstants {
+ private LCMConstants() {
+ }
+
+ public static final String CODE = "Status";
+ public static final String VALUE = "Value";
+ //flags
+ public static final String FORCE = "FORCE";
+ public static final String MODE = "MODE";
+ public static final String TTL = "TTL";
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java
new file mode 100644
index 000000000..7af5f073d
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/RequestInputBuilder.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider.lcm.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags;
+import org.openecomp.appc.domainmodel.lcm.RequestContext;
+import org.openecomp.appc.domainmodel.lcm.VNFOperation;
+import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+
+
+public class RequestInputBuilder {
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+
+ private static final String FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
+
+ private RequestContext requestContext;
+ private String rpcName;
+
+ public RequestInputBuilder() {
+ }
+
+
+ public RequestInputBuilder requestContext() {
+ this.requestContext = new RequestContext();
+ return this;
+ }
+
+ public RequestInputBuilder action(String action) {
+ this.requestContext.setAction(VNFOperation.findByString(action));
+ return this;
+ }
+
+
+ public RequestInputBuilder additionalContext(String key, String value) {
+ this.requestContext.addKeyValueToAdditionalContext(key, value);
+ return this;
+ }
+
+ public RequestInputBuilder payload(Payload payload) {
+ if (payload != null) {
+ this.requestContext.setPayload(payload.getValue());
+ }
+ return this;
+ }
+
+ public RequestHandlerInput build (){
+ RequestHandlerInput request = new RequestHandlerInput();
+ request.setRequestContext(this.requestContext);
+ request.setRpcName(rpcName);
+ return request;
+ }
+
+ public RequestInputBuilder rpcName(String rpcName) {
+ this.rpcName = rpcName;
+ return this;
+ }
+
+ public RequestInputBuilder commonHeader(CommonHeader commonHeader) throws ParseException {
+ org.openecomp.appc.domainmodel.lcm.CommonHeader header = new org.openecomp.appc.domainmodel.lcm.CommonHeader();
+ this.requestContext.setCommonHeader(header);
+
+ try {
+ if(null != commonHeader.getTimestamp()) {
+ SimpleDateFormat format = new SimpleDateFormat(FORMAT);
+ format.setLenient(false);
+ header.setTimestamp(format.parse(commonHeader.getTimestamp().getValue()));
+ }else{
+ throw new ParseException("Missing mandatory parameter : timestamp " , 0);
+ }
+ } catch (ParseException e) {
+ logger.error(String.format("DATE format is incorrect: %s", e.getMessage()));
+ throw e;
+ }
+ header.setApiVer(commonHeader.getApiVer());
+ header.setRequestId(commonHeader.getRequestId());
+ header.setOriginatorId(commonHeader.getOriginatorId());
+ header.setSubRequestId(commonHeader.getSubRequestId());
+
+ Flags inFlags = commonHeader.getFlags();
+ org.openecomp.appc.domainmodel.lcm.Flags flags = new org.openecomp.appc.domainmodel.lcm.Flags();
+ if (inFlags != null) {
+
+ if(null != inFlags.getForce()) {
+ flags.setForce(Boolean.parseBoolean(inFlags.getForce().toString().toLowerCase()));
+ }
+ if(null!=inFlags.getMode()) {
+ flags.setMode(inFlags.getMode().name());
+ }
+ if(null!= inFlags.getTtl()) {
+ flags.setTtl(inFlags.getTtl());
+ }
+
+ }
+ this.requestContext.getCommonHeader().setFlags(flags);
+ return this;
+ }
+
+ public RequestInputBuilder actionIdentifiers(ActionIdentifiers actionIdentifiers) throws ParseException {
+ if(null!= actionIdentifiers) {
+ org.openecomp.appc.domainmodel.lcm.ActionIdentifiers actionIds = new org.openecomp.appc.domainmodel.lcm.ActionIdentifiers();
+ actionIds.setServiceInstanceId(actionIdentifiers.getServiceInstanceId());
+ actionIds.setVnfcName(actionIdentifiers.getVnfcName());
+ actionIds.setvServerId(actionIdentifiers.getVserverId());
+ actionIds.setVnfId(actionIdentifiers.getVnfId());
+ this.requestContext.setActionIdentifiers(actionIds);
+ return this;
+ }else{
+ throw new ParseException("Missing action identifier" , 0);
+ }
+ }
+
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java
new file mode 100644
index 000000000..fe2fdc142
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/lcm/util/ValidationService.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider.lcm.util;
+
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.StatusBuilder;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.executor.objects.LCMCommandStatus;
+import org.openecomp.appc.executor.objects.Params;
+import org.openecomp.appc.i18n.Msg;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+
+import javax.swing.*;
+
+
+
+public class ValidationService {
+
+ private static class ValidationServiceHolder {
+ private static final ValidationService INSTANCE = new ValidationService();
+ }
+
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(ValidationService.class);
+
+ private Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ public static ValidationService getInstance(){
+ return ValidationServiceHolder.INSTANCE;
+ }
+
+ public Status validateInput (CommonHeader commonHeader, Action action , String rpcName) {
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ String reason ;
+ StringBuilder paramName = new StringBuilder("");
+ if (!isEmpty(commonHeader) && !isEmpty(commonHeader.getApiVer())&& !isEmpty(commonHeader.getTimestamp()) && !isEmpty(commonHeader.getRequestId()) && !isEmpty(action) && !isEmpty(commonHeader.getOriginatorId())){
+ if(!action.toString().equalsIgnoreCase(rpcName)) logger.warn("action in input request '" + action.toString() + "' is different from endpoint '" + rpcName + "'");
+ return null;
+ } else{
+ if(isEmpty(commonHeader)){
+ paramName.append("common-header");
+ }else{
+ if (isEmpty(commonHeader.getApiVer())) paramName.append("api-ver");
+ if (isEmpty(commonHeader.getTimestamp())) paramName.append(isEmpty(paramName) ? "timestamp" : " , timestamp" );
+ if (isEmpty(commonHeader.getRequestId())) paramName.append(isEmpty(paramName) ? "request-id" : " , request-id" );
+ if (isEmpty(commonHeader.getOriginatorId())) paramName.append(isEmpty(paramName) ? "originator-id" : " , originator-id" );
+ }
+ if (isEmpty(action)) paramName.append(isEmpty(paramName) ? "action" : " , action" );
+ }
+
+
+
+ reason = EELFResourceManager.format(Msg.NULL_OR_INVALID_ARGUMENT, appName, rpcName, paramName.toString() , "");
+ logger.info("Mandatory parameter/s" + paramName.toString() + " is/are missing");
+ logger.error(reason);
+ LCMCommandStatus lcmCommandStatus = LCMCommandStatus.MISSING_MANDATORY_PARAMETER;
+ Params params = new Params().addParam("paramName", paramName.toString());
+ StatusBuilder status = new StatusBuilder();
+ status.setCode(lcmCommandStatus.getResponseCode());
+ status.setMessage(lcmCommandStatus.getFormattedMessage(params));
+ return status.build();
+ }
+
+ private boolean isEmpty (Object object){
+ return (null == object || "".equalsIgnoreCase(object.toString()));
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java
new file mode 100644
index 000000000..ea88982c1
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/topology/TopologyService.java
@@ -0,0 +1,718 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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.provider.topology;
+
+import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY;
+import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
+import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID;
+import static com.att.eelf.configuration.Configuration.MDC_REMOTE_HOST;
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
+import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
+
+import java.net.InetAddress;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.ModifyConfigOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.ModifyConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.MigrateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RebuildOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.RestartOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.SnapshotOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.SnapshotOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.UUID;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.common.request.header.CommonRequestHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.vnf.resource.VnfResource;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160104.config.payload.ConfigPayload;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.provider.AppcProvider;
+import org.openecomp.appc.provider.AppcProviderClient;
+import org.openecomp.appc.provider.ResponseHeaderBuilder;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.slf4j.MDC;
+
+/**
+ * This class is used to implement the topology services API and invoke the appropriate directed graphs based on the
+ * service being requested.
+ *
+ */
+public class TopologyService {
+
+ /**
+ * The loggers we are using
+ */
+ // private static EELFLogger logger = LoggerFactory.getLogger(TopologyService.class);
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+ private static EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger();
+ private static EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
+ private static EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ private static EELFLogger performanceLogger = EELFManager.getInstance().getPerformanceLogger();
+
+ /**
+ * The provider we are servicing
+ */
+ private AppcProvider provider;
+
+ /**
+ * The reason associated with the last DG call
+ */
+ private String reason;
+
+ /**
+ * The APPC configuration properties
+ */
+ private Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ /**
+ * Create the topology services implementation for the specific appc provider (api) implementation
+ *
+ * @param provider
+ * The provider we are servicing
+ */
+ public TopologyService(AppcProvider provider) {
+ this.provider = provider;
+ }
+
+ // /**
+ // * Processes the topology request
+ // *
+ // * @param input
+ // * The request to be processed
+ // * @return The result of processing
+ // */
+ // public RpcResult<TopologyOperationOutput> process(TopologyOperationInput input) {
+ // RpcResult<TopologyOperationOutput> response;
+ //
+ // String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ // logger.info(String.format("%s:topology operations called...", appName));
+ //
+ // /*
+ // * Properties used to pass information to the DG
+ // */
+ // Properties properties = new Properties();
+ //
+ // if (input == null || input.getTopologyRequest().getVmId() == null) {
+ // String msg =
+ // String.format("%s: topology operation failed, invalid input. Null or empty argument '%s'", appName,
+ // "vm_id");
+ // logger.debug(msg);
+ // response = generateTopologyOperationResponse(Boolean.FALSE, "UNKNOWN", msg, "UNDEFINED");
+ // } else {
+ // // CommonRequestHeader crh = input.getCommonRequestHeader();
+ // TopologyHeader hdr = input.getTopologyHeader();
+ // TopologyRequest req = input.getTopologyRequest();
+ //
+ // // String requestId = crh.getServiceRequestId();
+ // String requestId = hdr.getSvcRequestId();
+ // properties.put(Constants.CONTEXT_REQID, requestId);
+ //
+ // String infomsg = String.format("Topology request '%s' (%s) received.", requestId, hdr.getSvcAction());
+ //
+ // // switch (req.getSvcAction()) {
+ // switch (hdr.getSvcAction()) {
+ // case Restart:
+ // properties.put(Constants.CONTEXT_SERVICE, Constants.SERVICE_RESTART);
+ // response = restart(input, properties);
+ // logger.info(infomsg);
+ // break;
+ //
+ // case Rebuild:
+ // properties.put(Constants.CONTEXT_SERVICE, Constants.SERVICE_REBUILD);
+ // response = rebuild(input, properties);
+ // logger.info(infomsg);
+ // break;
+ //
+ // default:
+ // String msg = String.format("Invalid request type [%s] for request id [%s]", req, requestId);
+ // response = generateTopologyOperationResponse(Boolean.FALSE, requestId, msg, "N/A");
+ // }
+ // }
+ //
+ // return response;
+ // }
+
+ /**
+ * Restart a VM
+ *
+ * @param hdr
+ * The common request header
+ * @param vnf
+ * The identification of the VNF resource to be operated upon
+ * @return The rpc result of the restart operation
+ */
+ public RpcResult<ModifyConfigOutput> modifyConfig(CommonRequestHeader hdr, ConfigPayload data) {
+ long startTime = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+ df.setTimeZone(tz);
+ // String startTimeStr = String.valueOf(startTime);
+ String startTimeStr = df.format(new Date());
+ String requestId = hdr.getServiceRequestId();
+
+ //MDC.clear();
+ MDC.put(MDC_REMOTE_HOST, "");
+ MDC.put(MDC_KEY_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, "App-C Provider:Restart");
+ MDC.put(MDC_SERVICE_INSTANCE_ID, "");
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ MDC.put(MDC_INSTANCE_UUID, java.util.UUID.randomUUID().toString());
+ MDC.put(MDC_ALERT_SEVERITY, "0");
+ MDC.put("startTime", Long.toString(startTime));
+ MDC.put("target", "appc");
+ logger.info(String.format("Starting RESTART for request with id [%s]", requestId));
+ metricsLogger.info(String.format("Metrics Logger: App-C Restart initiated. Start Time: [%s]. Request ID: [%s]",
+ startTime, requestId));
+
+ /*
+ * Copy any needed inputs or other values into the properties to be passed to the DG model
+ */
+ //UUID vmId = vnf.getVmId();
+ Properties properties = new Properties();
+ properties.put(Constants.CONTEXT_ACTION, "modifyConfig");
+ properties.put(Constants.CONTEXT_REQID, requestId);
+ //properties.put(Constants.CONTEXT_VMID, vmId.getValue());
+ String url = configuration.getProperty("appc.provider.vfodl.url");
+ try{
+ if(url.contains("NODE_NAME")){
+ url = url.replace("NODE_NAME", data.getConfigUrl());
+ }
+ }catch(Exception e){
+ url = configuration.getProperty("appc.provider.vfodl.url");
+ }
+ logger.trace("Final URL to VF ODL: "+url);
+ properties.put("org.openecomp.appc.configURL", url);
+ properties.put("org.openecomp.appc.configJson", data.getConfigJson());
+
+ //UUID identityUrl = vnf.getIdentityUrl();
+ //if (identityUrl != null) {
+ // properties.put(Constants.CONTEXT_IDENTITY_URL, identityUrl.getValue());
+ //}
+ /*
+ * Attempt to call the DG with the appropriate properties
+ */
+ boolean success = callGraph(properties);
+
+
+ MDC.put("target", "appc");
+ String statusStr = success ? "SUCCESS" : "FAILURE";
+ String infomsg =
+ String.format("APPC0119I ModifyConfig '%s' finished with status %s. Reason: %s", requestId, statusStr, reason);
+ logger.info(infomsg);
+
+ ModifyConfigOutputBuilder rob = new ModifyConfigOutputBuilder();
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ String endTimeStr = String.valueOf(endTime);
+ String durationStr = String.valueOf(duration);
+ MDC.put("endTime", endTimeStr);
+ MDC.put("duration", durationStr);
+ rob.setCommonResponseHeader(ResponseHeaderBuilder.buildHeader(success, requestId, reason, duration));
+ //rob.setVmId(new UUID(vmId));
+
+ auditLogger.info(String.format(
+ "Audit Logger: APPC0119I Restart '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+ metricsLogger.info(String.format(
+ "Metrics Logger: APPC0119I Restart '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+
+ // Status must be set to true to indicate that our return is expected
+ RpcResult<ModifyConfigOutput> rpcResult =
+ RpcResultBuilder.<ModifyConfigOutput> status(true).withResult(rob.build()).build();
+ return rpcResult;
+
+ }
+
+
+
+
+ /**
+ * Restart a VM
+ *
+ * @param hdr
+ * The common request header
+ * @param vnf
+ * The identification of the VNF resource to be operated upon
+ * @return The rpc result of the restart operation
+ */
+ public RpcResult<MigrateOutput> migrate(CommonRequestHeader hdr, VnfResource vnf) {
+ long startTime = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+ df.setTimeZone(tz);
+ // String startTimeStr = String.valueOf(startTime);
+ String startTimeStr = df.format(new Date());
+ String requestId = hdr.getServiceRequestId();
+
+ //MDC.clear();
+ MDC.put(MDC_REMOTE_HOST, "");
+ MDC.put(MDC_KEY_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, "App-C Provider:Migrate");
+ MDC.put(MDC_SERVICE_INSTANCE_ID, "");
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ MDC.put(MDC_INSTANCE_UUID, java.util.UUID.randomUUID().toString());
+ MDC.put(MDC_ALERT_SEVERITY, "0");
+ MDC.put("startTime", startTimeStr);
+ MDC.put("target", "appc");
+ logger.info(String.format("Starting ANY for request with id [%s]", requestId));
+ metricsLogger.info(String.format("Metrics Logger: App-C Restart initiated. Start Time: [%s]. Request ID: [%s]",
+ startTime, requestId));
+
+ /*
+ * Copy any needed inputs or other values into the properties to be passed to the DG model
+ */
+ UUID vmId = vnf.getVmId();
+ Properties properties = new Properties();
+ properties.put(Constants.CONTEXT_ACTION, "migrate");
+ properties.put(Constants.CONTEXT_REQID, requestId);
+ properties.put(Constants.CONTEXT_VMID, vmId.getValue());
+
+ UUID identityUrl = vnf.getIdentityUrl();
+ if (identityUrl != null) {
+ properties.put(Constants.CONTEXT_IDENTITY_URL, identityUrl.getValue());
+ }
+
+ /*
+ * Attempt to call the DG with the appropriate properties
+ */
+ boolean success = callGraph(properties);
+
+ /*
+ * Generate the appropriate response
+ */
+ MDC.put("target", "appc");
+ String statusStr = success ? "SUCCESS" : "FAILURE";
+ String infomsg =
+ String.format("APPC0118I Migrate '%s' finished with status %s. Reason: %s", requestId, statusStr, reason);
+ logger.info(infomsg);
+
+ MigrateOutputBuilder mob = new MigrateOutputBuilder();
+
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ String endTimeStr = String.valueOf(endTime);
+ String durationStr = String.valueOf(duration);
+ MDC.put("endTime", endTimeStr);
+ MDC.put("duration", durationStr);
+ mob.setCommonResponseHeader(ResponseHeaderBuilder.buildHeader(success, requestId, reason, duration));
+ mob.setVmId(new UUID(vmId));
+
+ auditLogger.info(String.format(
+ "Audit Logger: APPC0118I Migrate '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+ metricsLogger.info(String.format(
+ "Metrics Logger: APPC0118I Migrate '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+
+ // Status must be set to true to indicate that our return is expected
+ RpcResult<MigrateOutput> rpcResult =
+ RpcResultBuilder.<MigrateOutput> status(true).withResult(mob.build()).build();
+ return rpcResult;
+ }
+
+ /**
+ * Restart a VM
+ *
+ * @param hdr
+ * The common request header
+ * @param vnf
+ * The identification of the VNF resource to be operated upon
+ * @return The rpc result of the restart operation
+ */
+ public RpcResult<RestartOutput> restart(CommonRequestHeader hdr, VnfResource vnf) {
+ long startTime = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+ df.setTimeZone(tz);
+ // String startTimeStr = String.valueOf(startTime);
+ String startTimeStr = df.format(new Date());
+ String requestId = hdr.getServiceRequestId();
+
+ //MDC.clear();
+ MDC.put(MDC_REMOTE_HOST, "");
+ MDC.put(MDC_KEY_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, "App-C Provider:Restart");
+ MDC.put(MDC_SERVICE_INSTANCE_ID, "");
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ MDC.put(MDC_INSTANCE_UUID, java.util.UUID.randomUUID().toString());
+ MDC.put(MDC_ALERT_SEVERITY, "0");
+ MDC.put("startTime", Long.toString(startTime));
+ MDC.put("target", "appc");
+ logger.info(String.format("Starting RESTART for request with id [%s]", requestId));
+ metricsLogger.info(String.format("Metrics Logger: App-C Restart initiated. Start Time: [%s]. Request ID: [%s]",
+ startTime, requestId));
+
+ /*
+ * Copy any needed inputs or other values into the properties to be passed to the DG model
+ */
+ UUID vmId = vnf.getVmId();
+ Properties properties = new Properties();
+ properties.put(Constants.CONTEXT_ACTION, "restart");
+ properties.put(Constants.CONTEXT_REQID, requestId);
+ properties.put(Constants.CONTEXT_VMID, vmId.getValue());
+
+ UUID identityUrl = vnf.getIdentityUrl();
+ if (identityUrl != null) {
+ properties.put(Constants.CONTEXT_IDENTITY_URL, identityUrl.getValue());
+ }
+ /*
+ * Attempt to call the DG with the appropriate properties
+ */
+ boolean success = callGraph(properties);
+
+ /*
+ * Generate the appropriate response
+ */
+ MDC.put("target", "appc");
+ String statusStr = success ? "SUCCESS" : "FAILURE";
+ String infomsg =
+ String.format("APPC0119I Restart '%s' finished with status %s. Reason: %s", requestId, statusStr, reason);
+ logger.info(infomsg);
+
+ RestartOutputBuilder rob = new RestartOutputBuilder();
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ String endTimeStr = String.valueOf(endTime);
+ String durationStr = String.valueOf(duration);
+ MDC.put("endTime", endTimeStr);
+ MDC.put("duration", durationStr);
+ rob.setCommonResponseHeader(ResponseHeaderBuilder.buildHeader(success, requestId, reason, duration));
+ rob.setVmId(new UUID(vmId));
+
+ auditLogger.info(String.format(
+ "Audit Logger: APPC0119I Restart '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+ metricsLogger.info(String.format(
+ "Metrics Logger: APPC0119I Restart '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+
+ // Status must be set to true to indicate that our return is expected
+ RpcResult<RestartOutput> rpcResult =
+ RpcResultBuilder.<RestartOutput> status(true).withResult(rob.build()).build();
+ return rpcResult;
+ }
+
+ /**
+ * Rebuild a VM
+ *
+ * @param hdr
+ * The common request header
+ * @param vnf
+ * The identification of the VNF resource to be operated upon
+ * @return The rpc result of the rebuild operation
+ */
+ public RpcResult<RebuildOutput> rebuild(CommonRequestHeader hdr, VnfResource vnf) {
+ long startTime = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+ df.setTimeZone(tz);
+ // String startTimeStr = String.valueOf(startTime);
+ String startTimeStr = df.format(new Date());
+ String requestId = hdr.getServiceRequestId();
+
+ //MDC.clear();
+ MDC.put(MDC_REMOTE_HOST, "");
+ MDC.put(MDC_KEY_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, "App-C Provider:Rebuild");
+ MDC.put(MDC_SERVICE_INSTANCE_ID, "");
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ MDC.put(MDC_INSTANCE_UUID, java.util.UUID.randomUUID().toString());
+ MDC.put(MDC_ALERT_SEVERITY, "0");
+ MDC.put("startTime", startTimeStr);
+ MDC.put("target", "appc");
+ logger.info(String.format("Starting REBUILD for request with id [%s]", requestId));
+ metricsLogger.info(String.format("Metrics Logger: App-C Restart initiated. Start Time: [%s]. Request ID: [%s]",
+ startTime, requestId));
+
+ /*
+ * Copy any needed inputs or other values into the properties to be passed to the DG model
+ */
+ UUID vmId = vnf.getVmId();
+ Properties properties = new Properties();
+ properties.put(Constants.CONTEXT_ACTION, "rebuild");
+ properties.put(Constants.CONTEXT_REQID, requestId);
+ properties.put(Constants.CONTEXT_VMID, vmId.getValue());
+
+ UUID identityUrl = vnf.getIdentityUrl();
+ if (identityUrl != null) {
+ properties.put(Constants.CONTEXT_IDENTITY_URL, identityUrl.getValue());
+ }
+
+ /*
+ * Attempt to call the DG with the appropriate properties
+ */
+ boolean success = callGraph(properties);
+
+ /*
+ * Generate the appropriate response
+ */
+ MDC.put("target", "appc");
+ String statusStr = success ? "SUCCESS" : "FAILURE";
+ String infomsg =
+ String.format("APPC0120I Rebuild '%s' finished with status %s. Reason: %s", requestId, statusStr, reason);
+ logger.info(infomsg);
+
+ RebuildOutputBuilder rob = new RebuildOutputBuilder();
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ String endTimeStr = String.valueOf(endTime);
+ String durationStr = String.valueOf(duration);
+ MDC.put("endTime", endTimeStr);
+ MDC.put("duration", durationStr);
+ rob.setCommonResponseHeader(ResponseHeaderBuilder.buildHeader(success, requestId, reason, duration));
+ rob.setOriginalVmId(new UUID(vmId));
+ rob.setNewVmId(new UUID(vmId));
+
+ auditLogger.info(String.format(
+ "Audit Logger: APPC0120I Rebuild '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+ metricsLogger.info(String.format(
+ "Metrics Logger: APPC0120I Rebuild '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+
+ // Status must be set to true to indicate that our return is expected
+ RpcResult<RebuildOutput> rpcResult =
+ RpcResultBuilder.<RebuildOutput> status(true).withResult(rob.build()).build();
+ return rpcResult;
+ }
+
+ /**
+ * Snapshot a VM
+ *
+ * @param hdr
+ * The common request header
+ * @param vnf
+ * The identification of the VNF resource to be operated upon
+ * @return The rpc result of the restart operation
+ */
+ public RpcResult<SnapshotOutput> snapshot(CommonRequestHeader hdr, VnfResource vnf) {
+ long startTime = System.currentTimeMillis();
+ TimeZone tz = TimeZone.getTimeZone("UTC");
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
+ df.setTimeZone(tz);
+ // String startTimeStr = String.valueOf(startTime);
+ String startTimeStr = df.format(new Date());
+ String requestId = hdr.getServiceRequestId();
+
+ //MDC.clear();
+ MDC.put(MDC_REMOTE_HOST, "");
+ MDC.put(MDC_KEY_REQUEST_ID, requestId);
+ MDC.put(MDC_SERVICE_NAME, "App-C Provider:Snapshot");
+ MDC.put(MDC_SERVICE_INSTANCE_ID, "");
+ try {
+ MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
+ MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ MDC.put(MDC_INSTANCE_UUID, java.util.UUID.randomUUID().toString());
+ MDC.put(MDC_ALERT_SEVERITY, "0");
+ MDC.put("startTime", Long.toString(startTime));
+ MDC.put("target", "appc");
+ logger.info(String.format("Starting SNAPSHOT for request with id [%s]", requestId));
+ metricsLogger.info(String.format("Metrics Logger: App-C Snapshot initiated. Start Time: [%s]. Request ID: [%s]",
+ startTime, requestId));
+
+ /*
+ * Copy any needed inputs or other values into the properties to be passed to the DG model
+ */
+ UUID vmId = vnf.getVmId();
+ Properties properties = new Properties();
+ properties.put(Constants.CONTEXT_ACTION, "snapshot");
+ properties.put(Constants.CONTEXT_REQID, requestId);
+ properties.put(Constants.CONTEXT_VMID, vmId.getValue());
+
+ UUID identityUrl = vnf.getIdentityUrl();
+ if (identityUrl != null) {
+ properties.put(Constants.CONTEXT_IDENTITY_URL, identityUrl.getValue());
+ }
+ /*
+ * Attempt to call the DG with the appropriate properties
+ */
+ boolean success = callGraph(properties);
+
+ /*
+ * Generate the appropriate response
+ */
+ MDC.put("target", "appc");
+ String statusStr = success ? "SUCCESS" : "FAILURE";
+ String infomsg =
+ String.format("APPC0119I Snapshot '%s' finished with status %s. Reason: %s", requestId, statusStr, reason);
+ logger.info(infomsg);
+
+ SnapshotOutputBuilder sob = new SnapshotOutputBuilder();
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ String endTimeStr = String.valueOf(endTime);
+ String durationStr = String.valueOf(duration);
+ MDC.put("endTime", endTimeStr);
+ MDC.put("duration", durationStr);
+ sob.setCommonResponseHeader(ResponseHeaderBuilder.buildHeader(success, requestId, reason, duration));
+ sob.setVmId(new UUID(vmId));
+
+ auditLogger.info(String.format(
+ "Audit Logger: APPC0119I Snapshot '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+ metricsLogger.info(String.format(
+ "Metrics Logger: APPC0119I Snapshot '%s' finished with status %s. Start Time: [%s]. End Time: [%s]. Duration: [%s]. Request ID: [%s]. Reason:%s",
+ requestId, statusStr, startTime, endTime, duration, requestId, reason));
+
+ // Status must be set to true to indicate that our return is expected
+ RpcResult<SnapshotOutput> rpcResult =
+ RpcResultBuilder.<SnapshotOutput> status(true).withResult(sob.build()).build();
+ return rpcResult;
+ }
+
+ private boolean callGraph(Properties props) {
+ String moduleName = configuration.getProperty(Constants.PROPERTY_MODULE_NAME);
+ String methodName = configuration.getProperty(Constants.PROPERTY_TOPOLOGY_METHOD);
+ String version = configuration.getProperty(Constants.PROPERTY_TOPOLOGY_VERSION);
+ String mode = Constants.SYNC_MODE;
+ return callGraph(moduleName, methodName, version, mode, props);
+ }
+
+ /**
+ * Calls a specified directed graph with the specified properties and returns the response
+ *
+ * @param module
+ * The module name to be used to locate the graph
+ * @param method
+ * The method name to be executed (rpc)
+ * @param version
+ * The version of the graph to be used, or null for the latest
+ * @param mode
+ * the execution mode of the graph, sync or async
+ * @param props
+ * A set of name-value properties to be passed to the graph for context variables.
+ */
+ private boolean callGraph(String module, String method, String version, String mode, Properties props) {
+ String graphName = String.format(("%s:%s:%s"), module, method, version);
+ logger.debug(String.format("Calling Graph %s", graphName));
+ metricsLogger.info(String.format("Calling Graph %s", graphName));
+
+ boolean success = false;
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ AppcProviderClient svcLogicClient = new AppcProviderClient();
+ try {
+ if (svcLogicClient.hasGraph(module, method, version, mode)) {
+ try {
+ Properties respProps = svcLogicClient.execute(module, method, version, mode, props);
+ success = false; // Assume it failed unless proven otherwise
+ reason = "Failed"; // Assume it failed unless proven otherwise
+
+ logger.debug(EELFResourceManager.format(Msg.DEBUG_GRAPH_RESPONSE_HEADER, appName, graphName,
+ Integer.toString(respProps.size())));
+ for (String key : respProps.stringPropertyNames()) {
+ logger.debug(EELFResourceManager.format(Msg.DEBUG_GRAPH_RESPONSE_DETAIL, appName, graphName,
+ key, (String) respProps.get(key)));
+ }
+
+ // TODO - Find docs and see if there is a better way to handle this
+ // Bad requests have errors
+ if (respProps.containsKey(Constants.ATTRIBUTE_ERROR_CODE)) {
+ // || respProps.containsKey(Constants.ATTRIBUTE_ERROR_MESSAGE)) {
+ String errorCodeProperty = respProps.getProperty(Constants.ATTRIBUTE_ERROR_CODE).trim();
+ int errorCode = 200;
+ try {
+ errorCode = Integer.parseInt(errorCodeProperty);
+ if (errorCode >= 300) {
+ reason = EELFResourceManager.format(Msg.DG_FAILED_RESPONSE, appName, graphName,
+ errorCodeProperty, respProps.getProperty(Constants.ATTRIBUTE_ERROR_MESSAGE));
+ logger.error(reason);
+ success = false;
+ } else {
+ success = true;
+ reason = "Success";
+ }
+ } catch (NumberFormatException e) {
+ reason = EELFResourceManager.format(Msg.PARAMETER_NOT_NUMERIC, appName, graphName,
+ Constants.ATTRIBUTE_ERROR_CODE, errorCodeProperty);
+ logger.error(reason);
+ success = false;
+ }
+ } else {
+ /*
+ * Added code that requires error code to now be defined in ALL cases. If not, it is an error
+ * and the response will be set to failed regardless if the DG worked or not.
+ */
+ reason = EELFResourceManager.format(Msg.PARAMETER_IS_MISSING, appName, graphName,
+ Constants.ATTRIBUTE_ERROR_CODE);
+ logger.error(reason);
+ success = false;
+ }
+ } catch (Exception e) {
+ success = false;
+ reason = EELFResourceManager.format(Msg.EXCEPTION_CALLING_DG, e, appName,
+ e.getClass().getSimpleName(), graphName, e.getMessage());
+ logger.error(reason);
+ }
+ } else {
+ success = false;
+ reason = EELFResourceManager.format(Msg.GRAPH_NOT_FOUND, appName, graphName);
+ logger.error(reason);
+ }
+ } catch (Exception e) {
+ success = false;
+ reason = EELFResourceManager.format(Msg.EXCEPTION_CALLING_DG, e, appName, e.getClass().getSimpleName(),
+ graphName, e.getMessage());
+ logger.error(reason);
+ }
+
+ return success;
+ }
+
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..f98d23c0f
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+<!--<bean id="requestDispatcher" class="org.openecomp.appc.requesthandler.impl.RequestHandlerImpl" scope="singleton" >
+</bean>
+
+<service id="requestDispatcherService" interface="org.openecomp.appc.requesthandler.RequestHandler" ref="requestDispatcher"/>
+
+<reference id="aaiAdapter" availability="mandatory" activation="eager" interface="org.openecomp.appc.adapter.aai.AAIAdapter"/>-->
+
+</blueprint>
diff --git a/appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml b/appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml
new file mode 100644
index 000000000..524993b4c
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/resources/initial/appc-provider.xml
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : 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=========================================================
+ -->
+
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<snapshot>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+
+ <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang
+ file The prefix: inside type should match the prefix of the yang file. -->
+ <type xmlns:prefix="org:openecomp:appc:provider:impl">
+ prefix:appc-provider-impl
+ </type>
+ <name>appc-provider-impl</name>
+
+ <!-- The following sections contain bindings to services defined in
+ the *-provider-impl yang file. For example the rpc-registry is required because
+ we have a dependency (or augmentation) named "rpc-registry" and which binds
+ to the md-sa-binding-registry. If you remove those dependencies from the
+ yang file then you can remove them from here. -->
+ <rpc-registry>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+ <name>binding-rpc-broker</name>
+ </rpc-registry>
+
+ <data-broker>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+
+ <notification-service>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+ binding:binding-notification-service
+ </type>
+ <name>binding-notification-broker</name>
+ </notification-service>
+ </module>
+
+ <module>
+
+ <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang
+ file The prefix: inside type should match the prefix of the yang file. -->
+ <type xmlns:prefix="org:openecomp:appc:provider:lcm:impl">
+ prefix:appc-provider-lcm-impl
+ </type>
+ <name>appc-provider-lcm-impl</name>
+
+ <!-- The following sections contain bindings to services defined in
+ the *-provider-impl yang file. For example the rpc-registry is required because
+ we have a dependency (or augmentation) named "rpc-registry" and which binds
+ to the md-sa-binding-registry. If you remove those dependencies from the
+ yang file then you can remove them from here. -->
+ <rpc-registry>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+ <name>binding-rpc-broker</name>
+ </rpc-registry>
+
+ <data-broker>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+
+ <notification-service>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+ binding:binding-notification-service
+ </type>
+ <name>binding-notification-broker</name>
+ </notification-service>
+ </module>
+
+
+ </modules>
+ </data>
+
+ </configuration>
+
+ <!-- Required capabilities are basically a listing of all modules that need
+ to be imported before our service can be resolved. Capabilities for dependencies
+ defined above are implied which is why we do not have define a required capability
+ for the data broker, for example. -->
+ <!-- <required-capabilities> -->
+ <!-- <capability>appc:training:sample:provider:impl?module=sample-provider-impl&amp;revision=2014-05-23</capability> -->
+ <!-- </required-capabilities> -->
+ <required-capabilities>
+ <capability>org:openecomp:appc:provider:impl?module=appc-provider-impl&amp;revision=2014-05-23
+ </capability>
+ <capability>org:openecomp:appc:provider:lcm:impl?module=appc-provider-lcm-impl&amp;revision=2016-01-08
+ </capability>
+ </required-capabilities>
+
+</snapshot>
diff --git a/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..e9ee35ada
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,55 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : 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 property file supplies the configuration defaults for the APP-C controller
+#
+# Default values are supplied so that all defined properties have well-known values and are
+# valid even if a configuration file is not supplied. This is done to ensure that a runnable,
+# stable, and defined configuration exists at all times. The reason the defaults are supplied
+# via this property file and not in the code is so that the properties can be changed
+# easily if needed in the future. Use of the "getProperty(name, default)" method is
+# discouraged because if the default value needs to be changed, everywhere in the code it
+# is used would have to be changed. By loading the defaults in this property file, all
+# values can be defined in one place and support is easier. This does mean that all
+# properties that are defined must have a default value supplied here. Which also means
+# this file documents all defined properties (not a bad thing either).
+#
+#--------------------------------------------------------------------------------------------
+# The path and file used to load user-supplied configuration settings, if any
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# The path to search for logging configuration document, and the name of the document
+#
+org.openecomp.appc.logging.path=${user.home},etc,../etc,.
+org.openecomp.appc.logging.file=logback.xml
+
+#
+# The DG properties
+#
+appc.service.logic.module.name=APPC
+appc.topology.dg.method=topology-operation-all
+appc.topology.dg.version=2.0.0
+
diff --git a/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/logback.xml b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/logback.xml
new file mode 100644
index 000000000..8d47c6cae
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/logback.xml
@@ -0,0 +1,284 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : 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=========================================================
+ -->
+
+<configuration scan="true" scanPeriod="3 seconds" debug="true">
+ <!--<jmxConfigurator /> -->
+ <property name="logDirectory" value="logs" />
+ <property name="debugLogDirectory" value="debug-logs" />
+ <!-- Example evaluator filter applied against console appender -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <!-- ============================================================================ -->
+ <!-- CDP Appenders -->
+ <!-- ============================================================================ -->
+
+ <!-- The CDPAppender is used to record events to the general CDP application
+ log. This is the log file used by default as the application root log, if
+ no other log is defined or the application creates specialized loggers of
+ the form com.att.cdp.x.y.z where the name occupied by the "x" is NOT security,
+ perf, server, coordinator, gui, or policy. These are defined as specialization
+ loggers for various business purposes. -->
+ <appender name="CDP"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/cdp.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/cdp.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
+ %msg%n"</pattern> -->
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method}
+ %X{Path}] - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncCDP" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="CDP" />
+ </appender>
+
+ <!-- CDP Security Appender. This appender is used to record security events
+ to the security log file. Security events are separate from other loggers
+ in CDP so that security log records can be captured and managed in a secure
+ way separate from the other logs. This appender is set to never discard any
+ events. -->
+ <appender name="CDPSecurity"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/cdp-security.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/cdp-security.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
+ %msg%n"</pattern> -->
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method}
+ %X{Path}] - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncCDPSecurity" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <discardingThreshold>0</discardingThreshold>
+ <appender-ref ref="CDPSecurity" />
+ </appender>
+
+ <!-- CDP Performance Appender. This appender is used to record performance
+ records. -->
+ <appender name="CDPPerformance"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/cdp-performance.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/cdp-performance.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <outputPatternAsHeader>true</outputPatternAsHeader>
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method}
+ %X{Path}] - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncCDPPerformance" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="CDPPerformance" />
+ </appender>
+
+ <!-- CDP Server Appender. This appender is used to record Server related
+ logging events. The Server logger and appender are specializations of the
+ CDP application root logger and appender. This can be used to segregate Server
+ events from other components, or it can be eliminated to record these events
+ as part of the application root log. -->
+ <appender name="CDPServer"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/cdp-server.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/cdp-server.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
+ %msg%n"</pattern> -->
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger [%X{User} %X{RemoteHost} %X{RequestId} %X{Method}
+ %X{Path}] - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncCDPServer" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="CDPServer" />
+ </appender>
+
+ <!-- CDP Coordinator Appender. This appender is used to record Coordinator
+ related logging events. The Coordinator logger and appender are specializations
+ of the CDP application root logger and appender. This can be used to segregate
+ Coordinator events from other components, or it can be eliminated to record
+ these events as part of the application root log. -->
+ <appender name="CDPCoordinator"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/cdp-coordinator.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/cdp-coordinator.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
+ %msg%n"</pattern> -->
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncCDPCoordinator" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="CDPCoordinator" />
+ </appender>
+
+ <!-- CDP Policy Appender. This appender is used to record Policy engine
+ related logging events. The Policy logger and appender are specializations
+ of the CDP application root logger and appender. This can be used to segregate
+ Policy engine events from other components, or it can be eliminated to record
+ these events as part of the application root log. -->
+ <appender name="CDPPolicy"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDirectory}/cdp-policy.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/cdp-policy.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!-- <pattern>"%d{HH:mm:ss.SSS} [%thread] %-5level %logger{1024} -
+ %msg%n"</pattern> -->
+ <pattern>%d{MM/dd-HH:mm:ss.SSS} [%-16thread] %.-5level
+ %-36.36logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="asyncCDPPolicy" class="ch.qos.logback.classic.AsyncAppender">
+ <queueSize>256</queueSize>
+ <appender-ref ref="CDPPolicy" />
+ </appender>
+ <appender name="CommandExecutor"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${debugLogDirectory}/appc-debug.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+ <fileNamePattern>${logDirectory}/command-executor.%i.log.zip
+ </fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>9</maxIndex>
+ </rollingPolicy>
+ <triggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+ <maxFileSize>5MB</maxFileSize>
+ </triggeringPolicy>
+ <encoder>
+ <!--<Pattern>
+ %d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}|%X{RequestID}|%X{ServiceInstanceID}|%thread|%X{ServerName}|%X{ServiceName}|%X{UUID}|%-5.5p|%X{Severity}|%X{ServerIPAddress}|%X{Server}|%X{IPAddress}|[%c{3}]|%X{Timer}| - %msg%n
+ </Pattern>-->
+ <Pattern>
+ %d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServiceName} - %X{bundle.id} - %X{bundle.name} - %X{bundle.version}|%X{InstanceUUID}|%-5.5p|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{Timer}|[%c{3}]|%m%n
+ </Pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.openecomp.appc" level="DEBUG" additivity="false">
+ <appender-ref ref="CommandExecutor" />
+ </logger>
+
+ <!-- ============================================================================ -->
+ <!-- CDP loggers -->
+ <!-- ============================================================================ -->
+ <logger name="com.att.cdp" level="info" additivity="false">
+ <appender-ref ref="asyncCDP" />
+ </logger>
+ <logger name="com.att.cdp.security" level="info" additivity="false">
+ <appender-ref ref="asyncCDPSecurity" />
+ </logger>
+ <logger name="com.att.cdp.perf" level="info" additivity="false">
+ <appender-ref ref="asyncCDPPerformance" />
+ </logger>
+ <logger name="com.att.cdp.server" level="debug" additivity="false">
+ <appender-ref ref="asyncCDPServer" />
+ </logger>
+ <logger name="com.att.cdp.coordinator" level="info" additivity="false">
+ <appender-ref ref="asyncCDPCoordinator" />
+ </logger>
+ <logger name="com.att.cdp.policy" level="info" additivity="false">
+ <appender-ref ref="asyncCDPPolicy" />
+ </logger>
+
+ <!-- The OpenStack connector logger -->
+ <logger name="os" level="debug" additivity="false">
+ <appender-ref ref="asyncCDPServer" />
+ </logger>
+
+ <root level="WARN">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
diff --git a/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg
new file mode 100644
index 000000000..be5863291
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/resources/org/openecomp/appc/org.ops4j.pax.logging.cfg
@@ -0,0 +1,144 @@
+ ################################################################################
+ #
+ # Licensed to the Apache Software Foundation (ASF) under one or more
+ # contributor license agreements. See the NOTICE file distributed with
+ # this work for additional information regarding copyright ownership.
+ # The ASF licenses this file to You 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,
+ # WITH WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ #
+ ################################################################################
+
+ # Root
+ #log4j.rootLogger=TRACE, osgi:VmLogAppender
+ log4j.rootLogger=TRACE, out, sift, osgi:*
+ log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
+
+ # CONSOLE appender not used by default
+ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+ log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
+
+ # Async appender forwarding to file appender
+ log4j.appender.async=org.apache.log4j.AsyncAppender
+ log4j.appender.async.appenders=out
+
+ # Karaf appenders
+ # File appender
+ log4j.appender.out=org.apache.log4j.RollingFileAppender
+ log4j.appender.out.layout=org.apache.log4j.PatternLayout
+ log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
+ log4j.appender.out.file=${karaf.data}/log/karaf.log
+ log4j.appender.out.append=true
+ log4j.appender.out.maxFileSize=10MB
+ log4j.appender.out.maxBackupIndex=100
+
+
+ # Sift appender
+ log4j.appender.sift=org.apache.log4j.sift.MDCSiftingAppender
+ log4j.appender.sift.key=bundle.name
+ log4j.appender.sift.default=karaf
+ log4j.appender.sift.appender=org.apache.log4j.RollingFileAppender
+ log4j.appender.sift.appender.layout=org.apache.log4j.PatternLayout
+ log4j.appender.sift.appender.layout.ConversionPattern=%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServiceName} - %X{bundle.id} - %X{bundle.name} - %X{bundle.version}|%-5.5p|%X{AlertSeverity}|%X{ServerFQDN}|%X{ServerIPAddress}|[%c{3}]|%m%n
+ log4j.appender.sift.appender.file=${karaf.data}/log/eelf/karaf.log
+ log4j.appender.sift.appender.append=true
+
+ log4j.category.org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPusherImpl=DEBUG
+ log4j.category.org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPersisterActivator=DEBUG
+
+
+ #ECOMP Debug appender
+ log4j.appender.debug=org.apache.log4j.RollingFileAppender
+ log4j.appender.debug.key=bundle.name
+ log4j.appender.debug.default=karaf
+
+ log4j.appender.debug.appName=EELFDebug
+ log4j.appender.debug.layout=org.apache.log4j.PatternLayout
+ log4j.appender.debug.layout.ConversionPattern=%d{yyyy-MM-dd'T'hh:mm:ss.SSSXXX}|%X{RequestId}|%m%n
+ #log4j.appender.debug.filter.f1=org.apache.log4j.varia.LevelRangeFilter
+ #log4j.appender.debug.filter.f1.LevelMax=WARN
+ #log4j.appender.debug.filter.f1.LevelMin=TRACE
+
+
+ log4j.appender.debug.file=${karaf.data}/log/APPC/appc-debug.log
+ log4j.appender.debug.append=true
+ log4j.appender.debug.maxFileSize=100MB
+ log4j.appender.debug.maxBackupIndex=10
+
+
+ #Error appender
+ log4j.appender.error=org.apache.log4j.RollingFileAppender
+ log4j.appender.error.appName=EELFError
+ log4j.appender.error.File=${karaf.data}/log/APPC/appc-error.log
+ log4j.appender.error.Threshold=ERROR
+ log4j.appender.error.MaxBackupIndex=1
+ log4j.appender.error.MaxFileSize=100MB
+ log4j.appender.error.layout=org.apache.log4j.PatternLayout
+ log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd'T'hh:mm:ss.SSSXXX}|%X{RequestId}|%t|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%-5.5p|%X{ErrorCode}|%X{ErrorDescription}|%m%n
+
+ #Metrics appender
+ log4j.appender.metric=org.apache.log4j.RollingFileAppender
+ log4j.appender.metric.appName=EELFMetrics
+ log4j.appender.metric.File=${karaf.data}/log/APPC/appc-metric.log
+ log4j.appender.metric.MaxBackupIndex=1
+ log4j.appender.metric.MaxFileSize=100MB
+ log4j.appender.metric.layout=org.apache.log4j.PatternLayout
+ log4j.appender.metric.layout.ConversionPattern=%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%-5.5p|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}||%X{ProcessKey}|%X{TargetVirtualEntity}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%m%n
+
+ #Audit appender
+ log4j.appender.audit=org.apache.log4j.RollingFileAppender
+ log4j.appender.audit.appName=EELFAudit
+ log4j.appender.audit.File=${karaf.data}/log/APPC/appc-audit.log
+ log4j.appender.audit.MaxBackupIndex=1
+ log4j.appender.audit.MaxFileSize=100MB
+ log4j.appender.audit.layout=org.apache.log4j.PatternLayout
+ log4j.appender.audit.layout.ConversionPattern=%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%t|%X{ServerName}|%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%-5.5p|%X{Severity}|%X{ServerIPAddress}|%X{ElapsedTime}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ClassName}||%X{ProcessKey}|%X{CustomField1}|%X{CustomField2}|%X{CustomField3}|%X{CustomField4}|%m%n
+
+ #Loggers
+ #Routing of all messages from root logger
+ log4j.logger.com.att=TRACE, debug, error
+ #Store to the same log file messages from upper level appender or not
+ log4j.additivity.com.att=false
+
+ #EELFManager loggers
+ #EELF parent logger
+ log4j.logger.com.att.eelf=TRACE, debug
+ log4j.additivity.com.att.eelf=false
+
+ #Audit logger routing
+ log4j.logger.com.att.eelf.audit=DEBUG, audit
+ log4j.additivity.com.att.eelf.audit=false
+
+ #Metric logger routing
+ log4j.logger.com.att.eelf.metrics=DEBUG, metric
+ log4j.additivity.com.att.eelf.metrics=false
+
+ #Performance logger routing
+ log4j.logger.com.att.eelf.perf=DEBUG, metric
+ log4j.additivity.com.att.eelf.perf=false
+
+ #Server logger routing
+ log4j.logger.com.att.eelf.server=DEBUG, debug
+ log4j.additivity.com.att.eelf.server=false
+
+ #Policy logger routing
+ log4j.logger.com.att.eelf.policy=DEBUG, debug
+ log4j.additivity.com.att.eelf.policy=false
+
+ #Error logger routing
+ log4j.logger.com.att.eelf.error=DEBUG, error
+ log4j.additivity.com.att.eelf.error=false
+
+ #Debug logger routing
+ log4j.logger.com.att.eelf.debug=DEBUG, debug
+ log4j.additivity.com.att.eelf.debug=false
+
diff --git a/appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang b/appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang
new file mode 100644
index 000000000..ea085aba4
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/yang/appc-provider-lcm.yang
@@ -0,0 +1,61 @@
+module appc-provider-lcm-impl {
+
+ yang-version 1;
+ namespace "org:openecomp:appc:provider:lcm:impl";
+ prefix "appc-provider-lcm-impl";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+ description
+ "This module contains the base YANG definitions for
+ appc-provider-lcm implementation.";
+
+ revision "2016-01-08" {
+ description
+ "Initial revision.";
+ }
+
+ // This is the definition of the service implementation as a module identity.
+ identity appc-provider-lcm-impl {
+ base config:module-type;
+
+ // Specifies the prefix for generated java classes.
+ config:java-name-prefix AppcProviderLcm;
+ }
+
+ // Augments the 'configuration' choice node under modules/module.
+ // We consume the three main services, RPCs, DataStore, and Notifications
+ augment "/config:modules/config:module/config:configuration" {
+ case appc-provider-lcm-impl {
+ when "/config:modules/config:module/config:type = 'appc-provider-lcm-impl'";
+
+ container rpc-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-rpc-registry;
+ }
+ }
+ }
+
+ container notification-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-notification-service;
+ }
+ }
+ }
+
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity mdsal:binding-async-data-broker;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang b/appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang
new file mode 100644
index 000000000..95d90adaf
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/yang/appc-provider.yang
@@ -0,0 +1,61 @@
+module appc-provider-impl {
+
+ yang-version 1;
+ namespace "org:openecomp:appc:provider:impl";
+ prefix "appc-provider-impl";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+ description
+ "This module contains the base YANG definitions for
+ appc-provider implementation.";
+
+ revision "2014-05-23" {
+ description
+ "Initial revision.";
+ }
+
+ // This is the definition of the service implementation as a module identity.
+ identity appc-provider-impl {
+ base config:module-type;
+
+ // Specifies the prefix for generated java classes.
+ config:java-name-prefix AppcProvider;
+ }
+
+ // Augments the 'configuration' choice node under modules/module.
+ // We consume the three main services, RPCs, DataStore, and Notifications
+ augment "/config:modules/config:module/config:configuration" {
+ case appc-provider-impl {
+ when "/config:modules/config:module/config:type = 'appc-provider-impl'";
+
+ container rpc-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-rpc-registry;
+ }
+ }
+ }
+
+ container notification-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-notification-service;
+ }
+ }
+ }
+
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity mdsal:binding-async-data-broker;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java
new file mode 100644
index 000000000..3915c8da0
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/openecomp/appc/AppcProviderTest.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : 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;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.junit.After;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.openecomp.appc.provider.AppcProvider;
+
+/**
+ * Defines a unit test class which tests the provider. This class leverages the AbstractDataBrokerTest class which
+ * starts a real MD-SAL implementation to use inside of your unit tests. This is not an exhaustive test, but rather is
+ * used to illustrate how one can leverage the AbstractDataBrokerTest to test MD-SAL providers/listeners.
+ */
+public class AppcProviderTest extends AbstractDataBrokerTest {
+
+ private ExecutorService threadPool = Executors.newSingleThreadExecutor();
+ private AppcProvider provider;
+ private DataBroker dataBroker;
+
+ /**
+ * The @Before annotation is defined in the AbstractDataBrokerTest class. The method setupWithDataBroker is invoked
+ * from inside the @Before method and is used to initialize the databroker with objects for a test runs. In our case
+ * we use this oportunity to create an instance of our provider and initialize it (which registers it as a listener
+ * etc). This method runs before every @Test method below.
+ */
+ @Override
+ protected void setupWithDataBroker(DataBroker dataBroker) {
+ super.setupWithDataBroker(dataBroker);
+
+ this.dataBroker = dataBroker;
+ NotificationProviderService nps = null;
+ RpcProviderRegistry registry = null;
+
+ provider = new AppcProvider(dataBroker, nps, registry);
+ }
+
+ /**
+ * Shuts down our provider, testing close code. @After runs after every @Test method below.
+ */
+ @After
+ public void stop() throws Exception {
+ if (provider != null) {
+ provider.close();
+ }
+ }
+
+ /**
+ * This validates that when a task is created, the run count is initialized to 0
+ */
+ @Ignore
+ @Test
+ public void sampleUnitTest() {
+ // This is where you add your unit testing. You can access "DataBroker" as
+ // needed to create items etc.
+ // This a "Real" data broker.
+ }
+}