summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/main/java/org
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/main/java/org
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/main/java/org')
-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
12 files changed, 2456 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;
+ }
+
+}