From 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a Mon Sep 17 00:00:00 2001
From: Patrick Brady
Date: Wed, 13 Dec 2017 11:14:21 -0800
Subject: Second part of onap rename
This is the second commit of the rename. The folder structure
is renamed for appc-adapters and appc-config in this commit.
Change-Id: Iaa2b8c937ff1ca1b5d1178128961fb115ee65d9b
Signed-off-by: Patrick Brady
Issue-ID: APPC-13
---
.../org/onap/appc/adapter/chef/ChefActivator.java | 144 +++++++
.../org/onap/appc/adapter/chef/ChefAdapter.java | 220 ++++++++++
.../onap/appc/adapter/chef/chefapi/ApiMethod.java | 167 ++++++++
.../org/onap/appc/adapter/chef/chefapi/Delete.java | 36 ++
.../org/onap/appc/adapter/chef/chefapi/Get.java | 35 ++
.../org/onap/appc/adapter/chef/chefapi/Post.java | 46 ++
.../org/onap/appc/adapter/chef/chefapi/Put.java | 46 ++
.../adapter/chef/chefclient/ChefApiClient.java | 87 ++++
.../onap/appc/adapter/chef/chefclient/Utils.java | 102 +++++
.../appc/adapter/chef/impl/ChefAdapterImpl.java | 469 +++++++++++++++++++++
.../appc/adapter/chef/impl/RequestContext.java | 252 +++++++++++
.../openecomp/appc/adapter/chef/ChefActivator.java | 144 -------
.../openecomp/appc/adapter/chef/ChefAdapter.java | 220 ----------
.../appc/adapter/chef/chefapi/ApiMethod.java | 167 --------
.../appc/adapter/chef/chefapi/Delete.java | 36 --
.../openecomp/appc/adapter/chef/chefapi/Get.java | 35 --
.../openecomp/appc/adapter/chef/chefapi/Post.java | 46 --
.../openecomp/appc/adapter/chef/chefapi/Put.java | 46 --
.../adapter/chef/chefclient/ChefApiClient.java | 87 ----
.../appc/adapter/chef/chefclient/Utils.java | 102 -----
.../appc/adapter/chef/impl/ChefAdapterImpl.java | 469 ---------------------
.../appc/adapter/chef/impl/RequestContext.java | 252 -----------
.../resources/org/onap/appc/default.properties | 96 +++++
.../org/openecomp/appc/default.properties | 96 -----
.../adapter/chef/chefclient/TestChefApiClient.java | 107 +++++
.../adapter/chef/impl/TestChefAdapterImpl.java | 113 +++++
.../java/org/onap/appc/test/ExecutorHarness.java | 182 ++++++++
.../java/org/onap/appc/test/InterceptLogger.java | 454 ++++++++++++++++++++
.../adapter/chef/chefclient/TestChefApiClient.java | 107 -----
.../adapter/chef/impl/TestChefAdapterImpl.java | 113 -----
.../org/openecomp/appc/test/ExecutorHarness.java | 182 --------
.../org/openecomp/appc/test/InterceptLogger.java | 454 --------------------
.../resources/org/onap/appc/default.properties | 111 +++++
.../org/openecomp/appc/default.properties | 111 -----
34 files changed, 2667 insertions(+), 2667 deletions(-)
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefActivator.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefAdapter.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefActivator.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefAdapter.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Delete.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Post.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/ChefApiClient.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestContext.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/chefclient/TestChefApiClient.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/TestChefAdapterImpl.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
create mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
(limited to 'appc-adapters/appc-chef-adapter')
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefActivator.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefActivator.java
new file mode 100644
index 000000000..6c798b4b2
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefActivator.java
@@ -0,0 +1,144 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef;
+
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.chef.impl.ChefAdapterImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.i18n.Msg;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * This activator is used to initialize and terminate the connection pool to one or more providers.
+ *
+ * The CDP abstraction layer supports multiple types of providers, with each provider supporting multiple tenants. The
+ * "connection" to a specific tenant on a specific provider is represented by a "context" object. These context objects
+ * are authenticated to a specific tenant on the provider, but can be reused from one request to another. Contexts are
+ * slow to set up and are resource intensive, so they are cached. However, the contexts for a specific tenant on a
+ * specific provider must be cached separately.
+ *
+ *
+ * Activation of the bundle creates an empty cache which is organized first by provider type, then by tenant name, with
+ * the contents being an empty pool of contexts for that provider/tenant combination. The pool is created on first use,
+ * and retained for as long as the bundle is active.
+ *
+ *
+ * When the bundle is deactivated, the cache is torn down with all contexts being closed.
+ *
+ */
+public class ChefActivator implements BundleActivator {
+
+ /**
+ * The bundle registration
+ */
+ private ServiceRegistration registration = null;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private ChefAdapter adapter;
+
+ /**
+ * The logger to be used
+ */
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(ChefActivator.class);
+
+ /**
+ * The configuration object used to configure this bundle
+ */
+ private Configuration configuration;
+
+ /**
+ * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start
+ * this bundle. This method can be used to register services or to allocate any resources that this bundle needs.
+ *
+ * This method must complete and return to its caller in a timely manner.
+ *
+ *
+ * @param context
+ * The execution context of the bundle being started.
+ * @throws java.lang.Exception
+ * If this method throws an exception, this bundle is marked as stopped and the Framework will remove
+ * this bundle's listeners, unregister all services registered by this bundle, and release all services
+ * used by this bundle.
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ logger.info("Starting bundle " + getName());
+ configuration = ConfigurationFactory.getConfiguration();
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.COMPONENT_INITIALIZING, appName, "chef adapter");
+ adapter = new ChefAdapterImpl();
+ if (registration == null) {
+ logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
+ ChefAdapter.class.getSimpleName());
+ registration = context.registerService(ChefAdapter.class, adapter, null);
+ }
+
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, "CHEF adapter");
+ }
+
+ /**
+ * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop
+ * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There
+ * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not
+ * call any Framework objects.
+ *
+ * This method must complete and return to its caller in a timely manner.
+ *
+ *
+ * @param context
+ * The execution context of the bundle being stopped.
+ * @throws java.lang.Exception
+ * If this method throws an exception, the bundle is still marked as stopped, and the Framework will
+ * remove the bundle's listeners, unregister all services registered by the bundle, and release all
+ * services used by the bundle. *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ logger.info("Stopping bundle " + getName());
+
+ if (registration != null) {
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.COMPONENT_TERMINATING, appName, "CHEF adapter");
+ logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
+ registration.unregister();
+ registration = null;
+ logger.info(Msg.COMPONENT_TERMINATED, appName, "CHEF adapter");
+ }
+ }
+
+ public String getName() {
+ return "APPC IaaS adapter";
+ }
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefAdapter.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefAdapter.java
new file mode 100644
index 000000000..d11db1c14
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/ChefAdapter.java
@@ -0,0 +1,220 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef;
+
+import java.util.Map;
+
+import org.onap.appc.exceptions.APPCException;
+import com.att.cdp.zones.model.Server;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+/**
+ * This interface defines the operations that the provider adapter exposes.
+ *
+ * This interface defines static constant property values that can be used to configure the adapter. These constants are
+ * prefixed with the name PROPERTY_ to indicate that they are configuration properties. These properties are read from
+ * the configuration file for the adapter and are used to define the providers, identity service URLs, and other
+ * information needed by the adapter to interface with an IaaS provider.
+ *
+ */
+public interface ChefAdapter extends SvcLogicJavaPlugin {
+
+ /**
+ * The type of provider to be accessed to locate and operate on a virtual machine instance. This is used to load the
+ * correct provider support through the CDP IaaS abstraction layer and can be OpenStackProvider, BareMetalProvider,
+ * or any other supported provider type.
+ */
+ static final String PROPERTY_PROVIDER_TYPE = "org.onap.appc.provider.type";
+
+ /**
+ * The adapter maintains a cache of providers organized by the name of the provider, not its type. This is
+ * equivalent to the system or installation name. All regions within the same installation are assumed to be the
+ * same type.
+ */
+ static final String PROPERTY_PROVIDER_NAME = "org.onap.appc.provider.name";
+
+ /**
+ * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
+ */
+ static final String PROPERTY_INSTANCE_URL = "org.onap.appc.instance.url";
+
+ /**
+ * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
+ */
+ static final String PROPERTY_IDENTITY_URL = "org.onap.appc.identity.url";
+
+ /**
+ * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
+ *
+ * This method is invoked from a directed graph as an Executor
node. This means that the parameters
+ * passed to the method are passed as properties in a map. This method expects the following properties to be
+ * defined:
+ *
+ * - org.onap.appc.provider.type
+ * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
+ * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
+ * provider types are legal.
+ * - org.onap.appc.instance.url
+ * - The fully qualified URL of the instance to be restarted, as it is known to the provider (i.e., the self-link
+ * URL of the server)
+ *
+ *
+ *
+ * @param properties
+ * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
+ * defined above.
+ * @param context
+ * The service logic context of the graph being executed.
+ * @return The Server
object that represents the VM being restarted. The returned server object can be
+ * inspected for the final state of the server once the restart has been completed. The method does not
+ * return until the restart has either completed or has failed.
+ * @throws APPCException
+ * If the server cannot be restarted for some reason
+ */
+ // Server restartServer(Map properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to stop the indicated server
+ *
+ * This method is invoked from a directed graph as an Executor
node. This means that the parameters
+ * passed to the method are passed as properties in a map. This method expects the following properties to be
+ * defined:
+ *
+ * - org.onap.appc.provider.type
+ * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
+ * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
+ * provider types are legal.
+ * - org.onap.appc.instance.url
+ * - The fully qualified URL of the instance to be stopped, as it is known to the provider (i.e., the self-link
+ * URL of the server)
+ *
+ *
+ *
+ * @param properties
+ * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
+ * defined above.
+ * @param context
+ * The service logic context of the graph being executed.
+ * @return The Server
object that represents the VM being stopped. The returned server object can be
+ * inspected for the final state of the server once the stop has been completed. The method does not return
+ * until the stop has either completed or has failed.
+ * @throws APPCException
+ * If the server cannot be stopped for some reason
+ */
+ //Server stopServer(Map properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to start the indicated server
+ *
+ * This method is invoked from a directed graph as an Executor
node. This means that the parameters
+ * passed to the method are passed as properties in a map. This method expects the following properties to be
+ * defined:
+ *
+ * - org.onap.appc.provider.type
+ * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
+ * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
+ * provider types are legal.
+ * - org.onap.appc.instance.url
+ * - The fully qualified URL of the instance to be started, as it is known to the provider (i.e., the self-link
+ * URL of the server)
+ *
+ *
+ *
+ * @param properties
+ * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
+ * defined above.
+ * @param context
+ * The service logic context of the graph being executed.
+ * @return The Server
object that represents the VM being started. The returned server object can be
+ * inspected for the final state of the server once the start has been completed. The method does not return
+ * until the start has either completed or has failed.
+ * @throws APPCException
+ * If the server cannot be started for some reason
+ */
+ // Server startServer(Map properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to rebuild the indicated server
+ *
+ * This method is invoked from a directed graph as an Executor
node. This means that the parameters
+ * passed to the method are passed as properties in a map. This method expects the following properties to be
+ * defined:
+ *
+ * - org.onap.appc.provider.type
+ * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
+ * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
+ * provider types are legal.
+ * - org.onap.appc.instance.url
+ * - The fully qualified URL of the instance to be rebuilt, as it is known to the provider (i.e., the self-link
+ * URL of the server)
+ *
+ *
+ *
+ * @param properties
+ * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
+ * defined above.
+ * @param context
+ * The service logic context of the graph being executed.
+ * @return The Server
object that represents the VM being rebuilt. The returned server object can be
+ * inspected for the final state of the server once the rebuild has been completed. The method does not
+ * return until the rebuild has either completed or has failed.
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // Server rebuildServer(Map properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ */
+ String getAdapterName();
+
+ // Server evacuateServer(Map params, SvcLogicContext ctx) throws APPCException;
+
+ //Server migrateServer(Map params, SvcLogicContext ctx) throws APPCException;
+
+ void trigger(Map params, SvcLogicContext ctx) ;
+
+ void chefGet(Map params, SvcLogicContext ctx) ;
+
+ void chefPut(Map params, SvcLogicContext ctx) ;
+
+ void chefPost(Map params, SvcLogicContext ctx) ;
+
+ void chefDelete(Map params, SvcLogicContext ctx) ;
+
+ void nodeObejctBuilder(Map params, SvcLogicContext ctx) ;
+
+ void checkPushJob(Map params, SvcLogicContext ctx) ;
+
+ void pushJob(Map params, SvcLogicContext ctx) ;
+
+ void retrieveData (Map params, SvcLogicContext ctx) ;
+
+ void combineStrings (Map params, SvcLogicContext ctx) ;
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java
new file mode 100644
index 000000000..38c4dd354
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/ApiMethod.java
@@ -0,0 +1,167 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefapi;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.Header;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.util.EntityUtils;
+import org.onap.appc.adapter.chef.chefclient.Utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.impl.client.HttpClients;
+
+public class ApiMethod {
+ private HttpClient client = null;
+ protected HttpRequestBase method = null;
+ protected HttpResponse response = null;
+ protected String reqBody = "";
+ protected String userId = "";
+ protected String pemPath = "";
+ protected String chefPath = "";
+ protected String organizations = "";
+ protected int resCode=0;
+ protected String responseBody="";
+ private String methodName = "GET";
+ public String test = "";
+ private int returnCode;
+
+ public ApiMethod(String methodName) {
+ client=HttpClients.createDefault();
+ this.methodName = methodName;
+ }
+
+ public ApiMethod createRequest(){
+ String hashedPath = Utils.sha1AndBase64("/organizations/"+organizations+chefPath);
+ String hashedBody = Utils.sha1AndBase64(reqBody);
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String timeStamp = sdf.format(new Date());
+ timeStamp = timeStamp.replace(" ", "T");
+ timeStamp = timeStamp + "Z";
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("Method:").append(methodName).append("\n");
+ sb.append("Hashed Path:").append(hashedPath).append("\n");
+ sb.append("X-Ops-Content-Hash:").append(hashedBody).append("\n");
+ sb.append("X-Ops-Timestamp:").append(timeStamp).append("\n");
+ sb.append("X-Ops-UserId:").append(userId);
+ test = test + "sb " + sb + "\n";
+
+ String auth_String = Utils.signWithRSA(sb.toString(), pemPath);
+ String[] auth_headers = Utils.splitAs60(auth_String);
+
+ method.addHeader("Content-type", "application/json");
+ method.addHeader("X-Ops-Timestamp", timeStamp);
+ method.addHeader("X-Ops-Userid", userId);
+ method.addHeader("X-Chef-Version", "12.4.1");
+ method.addHeader("Accept", "application/json");
+ method.addHeader("X-Ops-Content-Hash", hashedBody);
+ method.addHeader("X-Ops-Sign", "version=1.0");
+
+ for (int i = 0; i < auth_headers.length; i++) {
+ method.addHeader("X-Ops-Authorization-" + (i + 1), auth_headers[i]);
+ }
+ /*
+ * test=test+this.method.getMethod()+"\n"; Header[]
+ * RHS=this.method.getHeaders(); for (int i = 0; i < RHS.length; i++) {
+ * test=test+RHS[i]+"\n"; } test=test+this.reqBody+"\n";
+ */
+ return this;
+ }
+
+ public ApiMethod execute() {
+ try{
+ response = client.execute(method);
+ resCode = response.getStatusLine().getStatusCode();
+ HttpEntity entity1 = response.getEntity();
+ responseBody = EntityUtils.toString(entity1);}
+ catch(Exception ex){
+ resCode=500;
+ responseBody=ex.getMessage();
+ }
+ return this;
+ }
+
+ public void setHeaders(Header[] headers) {
+ for (Header header : headers) {
+ this.method.addHeader(header);
+ }
+ }
+
+ public String getResponseBodyAsString() {
+ return responseBody;
+ }
+
+ public int getReturnCode() {
+ return resCode;
+ }
+
+ public String getReqBody() {
+ return reqBody;
+ }
+
+ public void setReqBody(String body) {
+ this.reqBody = body;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getPemPath() {
+ return pemPath;
+ }
+
+ public void setPemPath(String pemPath) {
+ this.pemPath = pemPath;
+ }
+
+ public String getChefPath() {
+ return chefPath;
+ }
+
+ public void setChefPath(String chefPath) {
+ this.chefPath = chefPath;
+ }
+
+ public String getOrganizations() {
+ return organizations;
+ }
+
+ public void setOrganizations(String organizations) {
+ this.organizations = organizations;
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java
new file mode 100644
index 000000000..5fa8a3fae
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Delete.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefapi;
+
+import org.apache.http.client.methods.HttpDelete;
+
+public class Delete extends ApiMethod{
+
+ public Delete(HttpDelete method) {
+ super("DELETE");
+ this.method = method;
+ }
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java
new file mode 100644
index 000000000..da37236a7
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Get.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefapi;
+
+import org.apache.http.client.methods.HttpGet;
+
+public class Get extends ApiMethod{
+
+ public Get(HttpGet method) {
+ super("GET");
+ this.method = method;
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java
new file mode 100644
index 000000000..3234eeefa
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Post.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefapi;
+
+import org.apache.http.client.methods.*;
+import org.apache.http.entity.StringEntity;
+
+public class Post extends ApiMethod{
+
+ public Post(HttpRequestBase method) {
+ super("POST");
+ this.method = method;
+ }
+
+ public ApiMethod body(String body){
+ this.reqBody = body;
+ StringEntity params =new StringEntity (body,"UTF-8");
+ params.setContentType("application/json");
+ HttpPost post = (HttpPost) method;
+ post.setEntity(params);
+ return this;
+ }
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java
new file mode 100644
index 000000000..c96fc64d1
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefapi/Put.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefapi;
+
+import org.apache.http.client.methods.*;
+import org.apache.http.entity.StringEntity;
+
+public class Put extends ApiMethod{
+
+ public Put(HttpRequestBase method) {
+ super("PUT");
+ this.method = method;
+ }
+
+ public ApiMethod body(String body){
+ this.reqBody = body;
+ StringEntity params =new StringEntity (body,"UTF-8");
+ params.setContentType("application/json");
+ HttpPut put = (HttpPut) method;
+ put.setEntity(params);
+ return this;
+ }
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java
new file mode 100644
index 000000000..d7080fc12
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/ChefApiClient.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefclient;
+import org.apache.http.client.methods.*;
+import org.onap.appc.adapter.chef.chefapi.*;
+
+public class ChefApiClient {
+ private String endpoint;
+ private String userId;
+ private String pemPath;
+ private String organizations;
+
+ /**
+ *
+ * @param userId user name correspond to the pem key
+ * @param pemPath path of the auth key
+ * @param endpoint chef api server address
+ */
+ public ChefApiClient(String userId, String pemPath, String endpoint,String organizations){
+ this.userId = userId;
+ this.pemPath = pemPath;
+ this.endpoint = endpoint;
+ this.organizations=organizations;
+ }
+
+ /**
+ *
+ * @param path in the endpoint. e.g /clients
+ * @return
+ */
+ public Get get(String path){
+ Get get = new Get(new HttpGet(endpoint+path));
+ get.setPemPath(pemPath);
+ get.setUserId(userId);
+ get.setOrganizations(organizations);
+ get.setChefPath(path);
+ return get;
+ }
+
+ public Put put(String path){
+ Put put = new Put(new HttpPut(endpoint+path));
+ put.setPemPath(pemPath);
+ put.setUserId(userId);
+ put.setOrganizations(organizations);
+ put.setChefPath(path);
+ return put;
+ }
+ public Post post(String path){
+ Post post = new Post(new HttpPost(endpoint+path));
+ post.setPemPath(pemPath);
+ post.setUserId(userId);
+ post.setOrganizations(organizations);
+ post.setChefPath(path);
+ return post;
+ }
+
+ public Delete delete(String path){
+ Delete del = new Delete(new HttpDelete(endpoint+path));
+ del.setPemPath(pemPath);
+ del.setUserId(userId);
+ del.setOrganizations(organizations);
+ del.setChefPath(path);
+ return del;
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java
new file mode 100644
index 000000000..71182c497
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/chefclient/Utils.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.chefclient;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.Security;
+import java.security.Signature;
+import java.security.SignatureException;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PEMParser;
+import org.bouncycastle.util.encoders.Base64;
+import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
+import org.bouncycastle.openssl.PEMKeyPair;
+
+public class Utils {
+ private Utils(){}
+
+ public static String sha1AndBase64(String inStr) {
+ MessageDigest md = null;
+ String outStr = null;
+ byte[] outbty = null;
+ try {
+ md = MessageDigest.getInstance("SHA-1");
+ byte[] digest = md.digest(inStr.getBytes());
+ outbty = Base64.encode(digest);
+ } catch (NoSuchAlgorithmException nsae) {
+ nsae.printStackTrace();
+ }
+ return new String(outbty);
+ }
+
+ public static String signWithRSA(String inStr, String pemPath) {
+ byte[] outStr = null;
+ try ( BufferedReader br = new BufferedReader(new FileReader(pemPath))) {
+ Security.addProvider(new BouncyCastleProvider());
+ PEMParser pemParser = new PEMParser(br);
+ JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
+ Object object = pemParser.readObject();
+ KeyPair kp = converter.getKeyPair((PEMKeyPair) object);;
+ PrivateKey privateKey = kp.getPrivate();
+ Signature instance = Signature.getInstance("RSA");
+ instance.initSign(privateKey);
+ instance.update(inStr.getBytes());
+ byte[] signature = instance.sign();
+ outStr = Base64.encode(signature);
+ } catch (InvalidKeyException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (SignatureException e) {
+ e.printStackTrace();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return new String(outStr);
+ }
+
+ public static String[] splitAs60(String inStr) {
+ int count = inStr.length() / 60;
+ String[] out = new String[count + 1];
+
+ for (int i = 0; i < count; i++) {
+ String tmp = inStr.substring(i * 60, i * 60 + 60);
+ out[i] = tmp;
+ }
+ if (inStr.length() > count * 60) {
+ String tmp = inStr.substring(count * 60, inStr.length());
+ out[count] = tmp;
+ }
+ return out;
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
new file mode 100644
index 000000000..824a6af95
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
@@ -0,0 +1,469 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.impl;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.chef.ChefAdapter;
+import org.onap.appc.adapter.chef.chefapi.ApiMethod;
+import org.onap.appc.adapter.chef.chefclient.ChefApiClient;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * This class implements the {@link ChefAdapter} interface. This interface
+ * defines the behaviors that our service provides.
+ */
+public class ChefAdapterImpl implements ChefAdapter {
+ // chef server Initialize variable
+ private String clientName = "";
+ private String clientPrivatekey = "";
+ private String chefserver = "";
+ private String serverAddress = "";
+ private String organizations = "";
+
+
+ /**
+ * The constant for the status code for a successful outcome
+ */
+ private static final String OUTCOME_SUCCESS = "success";
+
+ /**
+ * The logger to be used
+ */
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(ChefAdapterImpl.class);
+
+ private final String CANNOT_FIND_PRIVATE_KEY_STR = "Cannot find the private key in the APPC file system, please load the private key to ";
+ private final String CHEF_ACTION_STR = "org.onap.appc.instance.chefAction";
+ private final String ORGANIZATIONS_STR = "/organizations/";
+ /**
+ * A reference to the adapter configuration object.
+ */
+ private Configuration configuration;
+
+ /**
+ * This default constructor is used as a work around because the activator wasnt
+ * getting called
+ */
+ public ChefAdapterImpl() {
+ initialize();
+ }
+
+ /**
+ * This constructor is used primarily in the test cases to bypass initialization
+ * of the adapter for isolated, disconnected testing
+ *
+ * @param initialize
+ * True if the adapter is to be initialized, can false if not
+ */
+ public ChefAdapterImpl(boolean initialize) {
+ configuration = ConfigurationFactory.getConfiguration();
+ if (initialize) {
+ initialize();
+ }
+ }
+
+ public ChefAdapterImpl(String key) {
+ initialize(key);
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.onap.appc.adapter.chef.ChefAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
+ }
+
+ /**
+ * build node object
+ */
+ @Override
+ public void nodeObejctBuilder(Map params, SvcLogicContext ctx) {
+ logger.info("nodeObejctBuilder");
+ String name = params.get("org.onap.appc.instance.nodeobject.name");
+ String normal = params.get("org.onap.appc.instance.nodeobject.normal");
+ String overrides = params.get("org.onap.appc.instance.nodeobject.overrides");
+ String defaults = params.get("org.onap.appc.instance.nodeobject.defaults");
+ String runList = params.get("org.onap.appc.instance.nodeobject.run_list");
+ String chefEnvironment = params.get("org.onap.appc.instance.nodeobject.chef_environment");
+ String nodeObject = "{\"json_class\":\"Chef::Node\",\"default\":{" + defaults
+ + "},\"chef_type\":\"node\",\"run_list\":[" + runList + "],\"override\":{" + overrides
+ + "},\"normal\": {" + normal + "},\"automatic\":{},\"name\":\"" + name + "\",\"chef_environment\":\""
+ + chefEnvironment + "\"}";
+ logger.info(nodeObject);
+
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setAttribute("org.onap.appc.chef.nodeObject", nodeObject);
+ }
+
+ /**
+ * send get request to chef server
+ */
+ public void chefInfo(Map params) {
+ clientName = params.get("org.onap.appc.instance.username");
+ serverAddress = params.get("org.onap.appc.instance.serverAddress");
+ organizations = params.get("org.onap.appc.instance.organizations");
+ chefserver = "https://" + serverAddress + ORGANIZATIONS_STR + organizations;
+ if (params.containsKey("org.onap.appc.instance.pemPath")) {
+ clientPrivatekey = params.get("org.onap.appc.instance.pemPath");
+ } else {
+ clientPrivatekey = "/opt/app/bvc/chef/" + serverAddress + "/" + organizations + "/" + clientName + ".pem";
+ }
+ }
+
+ public Boolean privateKeyCheck() {
+ File f = new File(clientPrivatekey);
+ return f.exists();
+ }
+
+ @Override
+ public void retrieveData(Map params, SvcLogicContext ctx) {
+ String allConfigData = params.get("org.onap.appc.instance.allConfig");
+ String key = params.get("org.onap.appc.instance.key");
+ String dgContext = params.get("org.onap.appc.instance.dgContext");
+ JSONObject josnConfig = new JSONObject(allConfigData);
+
+ String contextData;
+ try {
+ contextData = josnConfig.getString(key);
+ } catch (Exception ex) {
+ try {
+ contextData = josnConfig.getJSONObject(key).toString();
+ } catch (Exception exc) {
+ contextData = josnConfig.getJSONArray(key).toString();
+ }
+ }
+
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setAttribute(dgContext, contextData);
+ }
+
+ @Override
+ public void combineStrings(Map params, SvcLogicContext ctx) {
+
+ String string1 = params.get("org.onap.appc.instance.String1");
+ String string2 = params.get("org.onap.appc.instance.String2");
+ String dgContext = params.get("org.onap.appc.instance.dgContext");
+ String contextData = string1 + string2;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setAttribute(dgContext, contextData);
+ }
+
+ /**
+ * Send GET request to chef server
+ */
+ @Override
+ public void chefGet(Map params, SvcLogicContext ctx) {
+ logger.info("chef get method");
+ chefInfo(params);
+ String chefAction = params.get(CHEF_ACTION_STR);
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ int code;
+ String message;
+ if (privateKeyCheck()) {
+ ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
+ ApiMethod am = cac.get(chefAction);
+ am.execute();
+ code = am.getReturnCode();
+ message = am.getResponseBodyAsString();
+ } else {
+ code = 500;
+ message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
+ }
+ chefServerResult(rc, Integer.toString(code), message);
+ }
+
+ /**
+ * Send PUT request to chef server
+ */
+ @Override
+ public void chefPut(Map params, SvcLogicContext ctx) {
+ chefInfo(params);
+ String chefAction = params.get(CHEF_ACTION_STR);
+ String chefNodeStr = params.get("org.onap.appc.instance.chefRequestBody");
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ int code;
+ String message;
+ if (privateKeyCheck()) {
+ ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
+
+ ApiMethod am = cac.put(chefAction).body(chefNodeStr);
+ am.execute();
+ code = am.getReturnCode();
+ message = am.getResponseBodyAsString();
+ } else {
+ code = 500;
+ message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
+ }
+ logger.info(code + " " + message);
+ chefServerResult(rc, Integer.toString(code), message);
+ }
+
+ /**
+ * send Post request to chef server
+ */
+ @Override
+ public void chefPost(Map params, SvcLogicContext ctx) {
+ chefInfo(params);
+ logger.info("chef Post method");
+ logger.info(clientName + " " + clientPrivatekey + " " + chefserver + " " + organizations);
+ String chefNodeStr = params.get("org.onap.appc.instance.chefRequestBody");
+ String chefAction = params.get(CHEF_ACTION_STR);
+
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ int code;
+ String message;
+ // should load pem from somewhere else
+ if (privateKeyCheck()) {
+ ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
+
+ // need pass path into it
+ // "/nodes/testnode"
+ ApiMethod am = cac.post(chefAction).body(chefNodeStr);
+ am.execute();
+ code = am.getReturnCode();
+ message = am.getResponseBodyAsString();
+ } else {
+ code = 500;
+ message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
+ }
+ logger.info(code + " " + message);
+ chefServerResult(rc, Integer.toString(code), message);
+ }
+
+ /**
+ * send delete request to chef server
+ */
+ @Override
+ public void chefDelete(Map params, SvcLogicContext ctx) {
+ logger.info("chef delete method");
+ chefInfo(params);
+ String chefAction = params.get(CHEF_ACTION_STR);
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ int code;
+ String message;
+ if (privateKeyCheck()) {
+ ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
+ ApiMethod am = cac.delete(chefAction);
+ am.execute();
+ code = am.getReturnCode();
+ message = am.getResponseBodyAsString();
+ } else {
+ code = 500;
+ message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
+ }
+ logger.info(code + " " + message);
+ chefServerResult(rc, Integer.toString(code), message);
+ }
+
+ /**
+ * Trigger target vm run chef
+ */
+ @Override
+ public void trigger(Map params, SvcLogicContext ctx) {
+ logger.info("Run trigger method");
+ String tVmIp = params.get("org.onap.appc.instance.ip");
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+ HttpGet httpGet = new HttpGet(tVmIp);
+ HttpResponse response;
+ response = httpClient.execute(httpGet);
+ int responseCode = response.getStatusLine().getStatusCode();
+ HttpEntity entity = response.getEntity();
+ String responseOutput = EntityUtils.toString(entity);
+ chefClientResult(rc, Integer.toString(responseCode), responseOutput);
+ doSuccess(rc);
+ } catch (Exception ex) {
+ doFailure(rc, 500, ex.toString());
+ }
+ }
+
+ @Override
+ public void checkPushJob(Map params, SvcLogicContext ctx) {
+ chefInfo(params);
+ String jobID = params.get("org.onap.appc.instance.jobid");
+ int retryTimes = Integer.parseInt(params.get("org.onap.appc.instance.retryTimes"));
+ int retryInterval = Integer.parseInt(params.get("org.onap.appc.instance.retryInterval"));
+ String chefAction = "/pushy/jobs/" + jobID;
+
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ String message = "";
+ String status = "";
+ for (int i = 0; i < retryTimes; i++) {
+ try {
+ Thread.sleep(retryInterval); // 1000 milliseconds is one second.
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
+ ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
+ ApiMethod am = cac.get(chefAction);
+ am.execute();
+ int code = am.getReturnCode();
+ message = am.getResponseBodyAsString();
+ JSONObject obj = new JSONObject(message);
+ status = obj.getString("status");
+ if (!"running".equals(status)) {
+ logger.info(i + " time " + code + " " + status);
+ break;
+ }
+
+ }
+ if ("complete".equals(status)) {
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.code", "200");
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.message", message);
+ } else {
+ if ("running".equals(status)) {
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.code", "202");
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.message", "chef client runtime out");
+ } else {
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.code", "500");
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.message", message);
+ }
+ }
+ }
+
+ @Override
+ public void pushJob(Map params, SvcLogicContext ctx) {
+ chefInfo(params);
+ String pushRequest = params.get("org.onap.appc.instance.pushRequest");
+ String chefAction = "/pushy/jobs";
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
+ ApiMethod am = cac.post(chefAction).body(pushRequest);
+
+ am.execute();
+ int code = am.getReturnCode();
+ String message = am.getResponseBodyAsString();
+ if (code == 201) {
+ int startIndex = message.indexOf("jobs") + 6;
+ int endIndex = message.length() - 2;
+ String jobID = message.substring(startIndex, endIndex);
+ svcLogic.setAttribute("org.onap.appc.jobID", jobID);
+ logger.info(jobID);
+ }
+ chefServerResult(rc, Integer.toString(code), message);
+ }
+
+ private void doFailure(RequestContext rc, int code, String message) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ String msg = (message == null) ? Integer.toString(code) : message;
+ if (msg.contains("\n")) {
+ msg = msg.substring(msg.indexOf("\n"));
+ }
+
+ String status;
+ try {
+ status = Integer.toString(code);
+ } catch (Exception e) {
+ logger.info("Couldn't covert " + code + " to an Integer, defaulting status to 500", e);
+ status = "500";
+ }
+ svcLogic.setAttribute("org.onap.appc.chefAgent.code", status);
+ svcLogic.setAttribute("org.onap.appc.chefAgent.message", msg);
+ }
+
+ /**
+ * @param rc
+ * The request context that manages the state and recovery of the
+ * request for the life of its processing.
+ */
+ private void doSuccess(RequestContext rc) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setAttribute("org.onap.appc.chefAgent.code", "200");
+ }
+
+ private void chefServerResult(RequestContext rc, String code, String message) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.code", code);
+ svcLogic.setAttribute("org.onap.appc.chefServerResult.message", message);
+ }
+
+ private void chefClientResult(RequestContext rc, String code, String message) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute("org.onap.appc.chefClientResult.code", code);
+ svcLogic.setAttribute("org.onap.appc.chefClientResult.message", message);
+ }
+
+ /**
+ * initialize the provider adapter by building the context cache
+ */
+ private void initialize() {
+ configuration = ConfigurationFactory.getConfiguration();
+ // need to fetch data from appc configurator or form some file in the appc vms
+ clientName = "testnode";
+ clientPrivatekey = System.getProperty("user.dir") + "/src/test/resources/testclient.pem";
+ serverAddress = "http://example.com";
+ organizations = "test";
+ chefserver = serverAddress + ORGANIZATIONS_STR + organizations;
+ logger.info("Initialize Chef Adapter");
+ }
+
+ private void initialize(String key) {
+ configuration = ConfigurationFactory.getConfiguration();
+ // need to fetch data from appc configurator or form some file in the appc vms
+ clientName = "testnode";
+ clientPrivatekey = key;
+ serverAddress = "http://example.com";
+ organizations = "test";
+ chefserver = serverAddress + ORGANIZATIONS_STR + organizations;
+ logger.info("Initialize Chef Adapter");
+ }
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java
new file mode 100644
index 000000000..3c0e00a6a
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/RequestContext.java
@@ -0,0 +1,252 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.impl;
+
+import org.onap.appc.Constants;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+/**
+ * This class is used to track and maintain recovery and time-to-live information for a request as it is being
+ * processed.
+ */
+public class RequestContext {
+ /**
+ * The number of seconds of wait time between successive attempts to connect to the provider. This is used to
+ * recover from provider outages or failures. It is not used to recover from logical errors, such as an invalid
+ * request, server not found, etc.
+ */
+ private Integer retryDelay;
+
+ /**
+ * The number of times we will attempt to connect to the provider. This is used to recover from provider outages or
+ * failures. It is not used to recover from logical errors, such as an invalid request, server not found, etc.
+ */
+ private Integer retryLimit;
+
+ /**
+ * The total time, in milliseconds, that the provider can have to process this request. If the accumulated time
+ * exceeds the time to live, then the request is failed with a timeout exception, regardless of the state of the
+ * provider. Note that the caller may supply this as a value in seconds, in which case it must be converted to
+ * milliseconds for the request context.
+ */
+ private Long timeToLive;
+
+ /**
+ * The accumulated time, in milliseconds, that has been used so far to process the request. This is compared to the
+ * time to live each time it is updated. If the accumulated time exceeds the time to live, then the request is
+ * failed with a timeout exception, regardless of the state of the provider.
+ */
+ private long accumulatedTime;
+
+ /**
+ * The total number of retries attempted so far
+ */
+ private int attempt;
+
+ /**
+ * The time when the stopwatch was started
+ */
+ private long startTime = -1;
+
+ /**
+ * The service logic (DG) context from the SLI
+ */
+ private SvcLogicContext svcLogicContext;
+
+ /**
+ * The configuration
+ */
+ private Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ /**
+ * Set to true whenever the retry limit has been exceeded, reset to false when reset() is called.
+ */
+ private boolean retryFailed;
+
+ /**
+ * Creates the request context
+ *
+ * @param context
+ * The service logic (SLI) context associated with the current DG
+ */
+ public RequestContext(SvcLogicContext context) {
+ setSvcLogicContext(context);
+ }
+
+ /**
+ * @return The retry delay, in seconds. If zero, then no retry is to be performed
+ */
+ public int getRetryDelay() {
+ if (retryDelay == null) {
+ int value = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_DELAY);
+ retryDelay = Integer.valueOf(value);
+ }
+
+ return retryDelay.intValue();
+ }
+
+ /**
+ * This method is a helper that allows the caller to delay for the retry interval time and not have to handle the
+ * thread interruption, timer handling, etc.
+ */
+ public void delay() {
+ long time = getRetryDelay() * 1000L;
+ long future = System.currentTimeMillis() + time;
+ if (time != 0) {
+ while (System.currentTimeMillis() < future && time > 0) {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ /*
+ * This is rare, but it can happen if another thread interrupts us while we are sleeping. In that
+ * case, the thread is resumed before the delay time has actually expired, so re-calculate the
+ * amount of delay time needed and reenter the sleep until we get to the future time.
+ */
+ time = future - System.currentTimeMillis();
+ }
+ }
+ }
+ }
+
+ /**
+ * @return The number of retries that are allowed per connection
+ */
+ public int getRetryLimit() {
+ if (retryLimit == null) {
+ int value = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_LIMIT);
+ retryLimit = Integer.valueOf(value);
+ }
+
+ return retryLimit.intValue();
+ }
+
+ /**
+ * Check and count the connection attempt.
+ *
+ * @return True if the connection should be attempted. False indicates that the number of retries has been exhausted
+ * and it should NOT be attempted.
+ */
+ public boolean attempt() {
+ if (retryFailed || attempt >= getRetryLimit()) {
+ retryFailed = true;
+ return false;
+ }
+ attempt++;
+
+ return true;
+ }
+
+ /**
+ * @return The number of retry attempts so far
+ */
+ public int getAttempts() {
+ return attempt;
+ }
+
+ /**
+ * @return True if the retry limit has been exceeded, false otherwise
+ */
+ public boolean isFailed() {
+ return retryFailed;
+ }
+
+ /**
+ * This method both checks the time to live to see if it has been exceeded and accumulates the total time used so
+ * far.
+ *
+ * Each time this method is called it accumulates the total duration since the last time it was called to the total
+ * time accumulator. It then checks the total time to the time to live and if greater, it returns false. As long as
+ * the total time used is less than or equal to the time to live limit, the method returns true. It is important to
+ * call this method at the very beginning of the process so that all parts of the process are tracked.
+ *
+ *
+ * @return True if the total time to live has not been exceeded. False indicates that the total time to live has
+ * been exceeded and no further processing should be performed.
+ */
+ public boolean isAlive() {
+ long now = System.currentTimeMillis();
+ if (startTime == -1) {
+ startTime = now;
+ return true;
+ }
+ accumulatedTime += (now - startTime);
+ startTime = now;
+ if (accumulatedTime > timeToLive) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @return The total amount of time used, in milliseconds.
+ */
+ public long getTotalDuration() {
+ return accumulatedTime;
+ }
+
+ /**
+ * This method is called to reset the retry counters. It has no effect on the time to live accumulator.
+ */
+ public void reset() {
+ attempt = 0;
+ }
+
+ /**
+ * Sets the time to live to the value, expressed in seconds
+ *
+ * @param time
+ * The time to live, in seconds
+ */
+ public void setTimeToLiveSeconds(int time) {
+ setTimeToLiveMS(time * 1000L);
+ }
+
+ /**
+ * Sets the time to live to the value, expressed in milliseconds
+ *
+ * @param time
+ * The time to live, in milliseconds
+ */
+ public void setTimeToLiveMS(long time) {
+ this.timeToLive = time;
+ }
+
+ /**
+ * @return The service logic context associated with this request
+ */
+ public SvcLogicContext getSvcLogicContext() {
+ return svcLogicContext;
+ }
+
+ /**
+ * @param svcLogicContext
+ * The service logic context to be associated with this request
+ */
+ public void setSvcLogicContext(SvcLogicContext svcLogicContext) {
+ this.svcLogicContext = svcLogicContext;
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefActivator.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefActivator.java
deleted file mode 100644
index 6c798b4b2..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefActivator.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef;
-
-import org.onap.appc.Constants;
-import org.onap.appc.adapter.chef.impl.ChefAdapterImpl;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.i18n.Msg;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * This activator is used to initialize and terminate the connection pool to one or more providers.
- *
- * The CDP abstraction layer supports multiple types of providers, with each provider supporting multiple tenants. The
- * "connection" to a specific tenant on a specific provider is represented by a "context" object. These context objects
- * are authenticated to a specific tenant on the provider, but can be reused from one request to another. Contexts are
- * slow to set up and are resource intensive, so they are cached. However, the contexts for a specific tenant on a
- * specific provider must be cached separately.
- *
- *
- * Activation of the bundle creates an empty cache which is organized first by provider type, then by tenant name, with
- * the contents being an empty pool of contexts for that provider/tenant combination. The pool is created on first use,
- * and retained for as long as the bundle is active.
- *
- *
- * When the bundle is deactivated, the cache is torn down with all contexts being closed.
- *
- */
-public class ChefActivator implements BundleActivator {
-
- /**
- * The bundle registration
- */
- private ServiceRegistration registration = null;
-
- /**
- * The reference to the actual implementation object that implements the services
- */
- private ChefAdapter adapter;
-
- /**
- * The logger to be used
- */
- private final EELFLogger logger = EELFManager.getInstance().getLogger(ChefActivator.class);
-
- /**
- * The configuration object used to configure this bundle
- */
- private Configuration configuration;
-
- /**
- * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start
- * this bundle. This method can be used to register services or to allocate any resources that this bundle needs.
- *
- * This method must complete and return to its caller in a timely manner.
- *
- *
- * @param context
- * The execution context of the bundle being started.
- * @throws java.lang.Exception
- * If this method throws an exception, this bundle is marked as stopped and the Framework will remove
- * this bundle's listeners, unregister all services registered by this bundle, and release all services
- * used by this bundle.
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- logger.info("Starting bundle " + getName());
- configuration = ConfigurationFactory.getConfiguration();
- String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
- logger.info(Msg.COMPONENT_INITIALIZING, appName, "chef adapter");
- adapter = new ChefAdapterImpl();
- if (registration == null) {
- logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
- ChefAdapter.class.getSimpleName());
- registration = context.registerService(ChefAdapter.class, adapter, null);
- }
-
- logger.info(Msg.COMPONENT_INITIALIZED, appName, "CHEF adapter");
- }
-
- /**
- * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop
- * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There
- * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not
- * call any Framework objects.
- *
- * This method must complete and return to its caller in a timely manner.
- *
- *
- * @param context
- * The execution context of the bundle being stopped.
- * @throws java.lang.Exception
- * If this method throws an exception, the bundle is still marked as stopped, and the Framework will
- * remove the bundle's listeners, unregister all services registered by the bundle, and release all
- * services used by the bundle. *
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- logger.info("Stopping bundle " + getName());
-
- if (registration != null) {
- String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
- logger.info(Msg.COMPONENT_TERMINATING, appName, "CHEF adapter");
- logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
- registration.unregister();
- registration = null;
- logger.info(Msg.COMPONENT_TERMINATED, appName, "CHEF adapter");
- }
- }
-
- public String getName() {
- return "APPC IaaS adapter";
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefAdapter.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefAdapter.java
deleted file mode 100644
index d11db1c14..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefAdapter.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef;
-
-import java.util.Map;
-
-import org.onap.appc.exceptions.APPCException;
-import com.att.cdp.zones.model.Server;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
-/**
- * This interface defines the operations that the provider adapter exposes.
- *
- * This interface defines static constant property values that can be used to configure the adapter. These constants are
- * prefixed with the name PROPERTY_ to indicate that they are configuration properties. These properties are read from
- * the configuration file for the adapter and are used to define the providers, identity service URLs, and other
- * information needed by the adapter to interface with an IaaS provider.
- *
- */
-public interface ChefAdapter extends SvcLogicJavaPlugin {
-
- /**
- * The type of provider to be accessed to locate and operate on a virtual machine instance. This is used to load the
- * correct provider support through the CDP IaaS abstraction layer and can be OpenStackProvider, BareMetalProvider,
- * or any other supported provider type.
- */
- static final String PROPERTY_PROVIDER_TYPE = "org.onap.appc.provider.type";
-
- /**
- * The adapter maintains a cache of providers organized by the name of the provider, not its type. This is
- * equivalent to the system or installation name. All regions within the same installation are assumed to be the
- * same type.
- */
- static final String PROPERTY_PROVIDER_NAME = "org.onap.appc.provider.name";
-
- /**
- * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
- */
- static final String PROPERTY_INSTANCE_URL = "org.onap.appc.instance.url";
-
- /**
- * The fully-qualified URL of the instance to be manipulated as it is known to the provider.
- */
- static final String PROPERTY_IDENTITY_URL = "org.onap.appc.identity.url";
-
- /**
- * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
- *
- * This method is invoked from a directed graph as an Executor
node. This means that the parameters
- * passed to the method are passed as properties in a map. This method expects the following properties to be
- * defined:
- *
- * - org.onap.appc.provider.type
- * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
- * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
- * provider types are legal.
- * - org.onap.appc.instance.url
- * - The fully qualified URL of the instance to be restarted, as it is known to the provider (i.e., the self-link
- * URL of the server)
- *
- *
- *
- * @param properties
- * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
- * defined above.
- * @param context
- * The service logic context of the graph being executed.
- * @return The Server
object that represents the VM being restarted. The returned server object can be
- * inspected for the final state of the server once the restart has been completed. The method does not
- * return until the restart has either completed or has failed.
- * @throws APPCException
- * If the server cannot be restarted for some reason
- */
- // Server restartServer(Map properties, SvcLogicContext context) throws APPCException;
-
- /**
- * This method is used to stop the indicated server
- *
- * This method is invoked from a directed graph as an Executor
node. This means that the parameters
- * passed to the method are passed as properties in a map. This method expects the following properties to be
- * defined:
- *
- * - org.onap.appc.provider.type
- * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
- * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
- * provider types are legal.
- * - org.onap.appc.instance.url
- * - The fully qualified URL of the instance to be stopped, as it is known to the provider (i.e., the self-link
- * URL of the server)
- *
- *
- *
- * @param properties
- * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
- * defined above.
- * @param context
- * The service logic context of the graph being executed.
- * @return The Server
object that represents the VM being stopped. The returned server object can be
- * inspected for the final state of the server once the stop has been completed. The method does not return
- * until the stop has either completed or has failed.
- * @throws APPCException
- * If the server cannot be stopped for some reason
- */
- //Server stopServer(Map properties, SvcLogicContext context) throws APPCException;
-
- /**
- * This method is used to start the indicated server
- *
- * This method is invoked from a directed graph as an Executor
node. This means that the parameters
- * passed to the method are passed as properties in a map. This method expects the following properties to be
- * defined:
- *
- * - org.onap.appc.provider.type
- * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
- * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
- * provider types are legal.
- * - org.onap.appc.instance.url
- * - The fully qualified URL of the instance to be started, as it is known to the provider (i.e., the self-link
- * URL of the server)
- *
- *
- *
- * @param properties
- * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
- * defined above.
- * @param context
- * The service logic context of the graph being executed.
- * @return The Server
object that represents the VM being started. The returned server object can be
- * inspected for the final state of the server once the start has been completed. The method does not return
- * until the start has either completed or has failed.
- * @throws APPCException
- * If the server cannot be started for some reason
- */
- // Server startServer(Map properties, SvcLogicContext context) throws APPCException;
-
- /**
- * This method is used to rebuild the indicated server
- *
- * This method is invoked from a directed graph as an Executor
node. This means that the parameters
- * passed to the method are passed as properties in a map. This method expects the following properties to be
- * defined:
- *
- * - org.onap.appc.provider.type
- * - The appropriate provider type, such as
OpenStackProvider
. This is used by the CDP IaaS
- * abstraction layer to dynamically load and open a connection to the appropriate provider type. All CDP supported
- * provider types are legal.
- * - org.onap.appc.instance.url
- * - The fully qualified URL of the instance to be rebuilt, as it is known to the provider (i.e., the self-link
- * URL of the server)
- *
- *
- *
- * @param properties
- * A map of name-value pairs that supply the parameters needed by this method. The properties needed are
- * defined above.
- * @param context
- * The service logic context of the graph being executed.
- * @return The Server
object that represents the VM being rebuilt. The returned server object can be
- * inspected for the final state of the server once the rebuild has been completed. The method does not
- * return until the rebuild has either completed or has failed.
- * @throws APPCException
- * If the server cannot be rebuilt for some reason
- */
- // Server rebuildServer(Map properties, SvcLogicContext context) throws APPCException;
-
- /**
- * Returns the symbolic name of the adapter
- *
- * @return The adapter name
- */
- String getAdapterName();
-
- // Server evacuateServer(Map params, SvcLogicContext ctx) throws APPCException;
-
- //Server migrateServer(Map params, SvcLogicContext ctx) throws APPCException;
-
- void trigger(Map params, SvcLogicContext ctx) ;
-
- void chefGet(Map params, SvcLogicContext ctx) ;
-
- void chefPut(Map params, SvcLogicContext ctx) ;
-
- void chefPost(Map params, SvcLogicContext ctx) ;
-
- void chefDelete(Map params, SvcLogicContext ctx) ;
-
- void nodeObejctBuilder(Map params, SvcLogicContext ctx) ;
-
- void checkPushJob(Map params, SvcLogicContext ctx) ;
-
- void pushJob(Map params, SvcLogicContext ctx) ;
-
- void retrieveData (Map params, SvcLogicContext ctx) ;
-
- void combineStrings (Map params, SvcLogicContext ctx) ;
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java
deleted file mode 100644
index 38c4dd354..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.Header;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.util.EntityUtils;
-import org.onap.appc.adapter.chef.chefclient.Utils;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.impl.client.HttpClients;
-
-public class ApiMethod {
- private HttpClient client = null;
- protected HttpRequestBase method = null;
- protected HttpResponse response = null;
- protected String reqBody = "";
- protected String userId = "";
- protected String pemPath = "";
- protected String chefPath = "";
- protected String organizations = "";
- protected int resCode=0;
- protected String responseBody="";
- private String methodName = "GET";
- public String test = "";
- private int returnCode;
-
- public ApiMethod(String methodName) {
- client=HttpClients.createDefault();
- this.methodName = methodName;
- }
-
- public ApiMethod createRequest(){
- String hashedPath = Utils.sha1AndBase64("/organizations/"+organizations+chefPath);
- String hashedBody = Utils.sha1AndBase64(reqBody);
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- String timeStamp = sdf.format(new Date());
- timeStamp = timeStamp.replace(" ", "T");
- timeStamp = timeStamp + "Z";
-
- StringBuilder sb = new StringBuilder();
- sb.append("Method:").append(methodName).append("\n");
- sb.append("Hashed Path:").append(hashedPath).append("\n");
- sb.append("X-Ops-Content-Hash:").append(hashedBody).append("\n");
- sb.append("X-Ops-Timestamp:").append(timeStamp).append("\n");
- sb.append("X-Ops-UserId:").append(userId);
- test = test + "sb " + sb + "\n";
-
- String auth_String = Utils.signWithRSA(sb.toString(), pemPath);
- String[] auth_headers = Utils.splitAs60(auth_String);
-
- method.addHeader("Content-type", "application/json");
- method.addHeader("X-Ops-Timestamp", timeStamp);
- method.addHeader("X-Ops-Userid", userId);
- method.addHeader("X-Chef-Version", "12.4.1");
- method.addHeader("Accept", "application/json");
- method.addHeader("X-Ops-Content-Hash", hashedBody);
- method.addHeader("X-Ops-Sign", "version=1.0");
-
- for (int i = 0; i < auth_headers.length; i++) {
- method.addHeader("X-Ops-Authorization-" + (i + 1), auth_headers[i]);
- }
- /*
- * test=test+this.method.getMethod()+"\n"; Header[]
- * RHS=this.method.getHeaders(); for (int i = 0; i < RHS.length; i++) {
- * test=test+RHS[i]+"\n"; } test=test+this.reqBody+"\n";
- */
- return this;
- }
-
- public ApiMethod execute() {
- try{
- response = client.execute(method);
- resCode = response.getStatusLine().getStatusCode();
- HttpEntity entity1 = response.getEntity();
- responseBody = EntityUtils.toString(entity1);}
- catch(Exception ex){
- resCode=500;
- responseBody=ex.getMessage();
- }
- return this;
- }
-
- public void setHeaders(Header[] headers) {
- for (Header header : headers) {
- this.method.addHeader(header);
- }
- }
-
- public String getResponseBodyAsString() {
- return responseBody;
- }
-
- public int getReturnCode() {
- return resCode;
- }
-
- public String getReqBody() {
- return reqBody;
- }
-
- public void setReqBody(String body) {
- this.reqBody = body;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getPemPath() {
- return pemPath;
- }
-
- public void setPemPath(String pemPath) {
- this.pemPath = pemPath;
- }
-
- public String getChefPath() {
- return chefPath;
- }
-
- public void setChefPath(String chefPath) {
- this.chefPath = chefPath;
- }
-
- public String getOrganizations() {
- return organizations;
- }
-
- public void setOrganizations(String organizations) {
- this.organizations = organizations;
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Delete.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Delete.java
deleted file mode 100644
index 5fa8a3fae..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Delete.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.HttpDelete;
-
-public class Delete extends ApiMethod{
-
- public Delete(HttpDelete method) {
- super("DELETE");
- this.method = method;
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java
deleted file mode 100644
index da37236a7..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.HttpGet;
-
-public class Get extends ApiMethod{
-
- public Get(HttpGet method) {
- super("GET");
- this.method = method;
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Post.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Post.java
deleted file mode 100644
index 3234eeefa..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Post.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.*;
-import org.apache.http.entity.StringEntity;
-
-public class Post extends ApiMethod{
-
- public Post(HttpRequestBase method) {
- super("POST");
- this.method = method;
- }
-
- public ApiMethod body(String body){
- this.reqBody = body;
- StringEntity params =new StringEntity (body,"UTF-8");
- params.setContentType("application/json");
- HttpPost post = (HttpPost) method;
- post.setEntity(params);
- return this;
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java
deleted file mode 100644
index c96fc64d1..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefapi;
-
-import org.apache.http.client.methods.*;
-import org.apache.http.entity.StringEntity;
-
-public class Put extends ApiMethod{
-
- public Put(HttpRequestBase method) {
- super("PUT");
- this.method = method;
- }
-
- public ApiMethod body(String body){
- this.reqBody = body;
- StringEntity params =new StringEntity (body,"UTF-8");
- params.setContentType("application/json");
- HttpPut put = (HttpPut) method;
- put.setEntity(params);
- return this;
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/ChefApiClient.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/ChefApiClient.java
deleted file mode 100644
index d7080fc12..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/ChefApiClient.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefclient;
-import org.apache.http.client.methods.*;
-import org.onap.appc.adapter.chef.chefapi.*;
-
-public class ChefApiClient {
- private String endpoint;
- private String userId;
- private String pemPath;
- private String organizations;
-
- /**
- *
- * @param userId user name correspond to the pem key
- * @param pemPath path of the auth key
- * @param endpoint chef api server address
- */
- public ChefApiClient(String userId, String pemPath, String endpoint,String organizations){
- this.userId = userId;
- this.pemPath = pemPath;
- this.endpoint = endpoint;
- this.organizations=organizations;
- }
-
- /**
- *
- * @param path in the endpoint. e.g /clients
- * @return
- */
- public Get get(String path){
- Get get = new Get(new HttpGet(endpoint+path));
- get.setPemPath(pemPath);
- get.setUserId(userId);
- get.setOrganizations(organizations);
- get.setChefPath(path);
- return get;
- }
-
- public Put put(String path){
- Put put = new Put(new HttpPut(endpoint+path));
- put.setPemPath(pemPath);
- put.setUserId(userId);
- put.setOrganizations(organizations);
- put.setChefPath(path);
- return put;
- }
- public Post post(String path){
- Post post = new Post(new HttpPost(endpoint+path));
- post.setPemPath(pemPath);
- post.setUserId(userId);
- post.setOrganizations(organizations);
- post.setChefPath(path);
- return post;
- }
-
- public Delete delete(String path){
- Delete del = new Delete(new HttpDelete(endpoint+path));
- del.setPemPath(pemPath);
- del.setUserId(userId);
- del.setOrganizations(organizations);
- del.setChefPath(path);
- return del;
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java
deleted file mode 100644
index 71182c497..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.chefclient;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.KeyPair;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.Security;
-import java.security.Signature;
-import java.security.SignatureException;
-
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMParser;
-import org.bouncycastle.util.encoders.Base64;
-import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
-import org.bouncycastle.openssl.PEMKeyPair;
-
-public class Utils {
- private Utils(){}
-
- public static String sha1AndBase64(String inStr) {
- MessageDigest md = null;
- String outStr = null;
- byte[] outbty = null;
- try {
- md = MessageDigest.getInstance("SHA-1");
- byte[] digest = md.digest(inStr.getBytes());
- outbty = Base64.encode(digest);
- } catch (NoSuchAlgorithmException nsae) {
- nsae.printStackTrace();
- }
- return new String(outbty);
- }
-
- public static String signWithRSA(String inStr, String pemPath) {
- byte[] outStr = null;
- try ( BufferedReader br = new BufferedReader(new FileReader(pemPath))) {
- Security.addProvider(new BouncyCastleProvider());
- PEMParser pemParser = new PEMParser(br);
- JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
- Object object = pemParser.readObject();
- KeyPair kp = converter.getKeyPair((PEMKeyPair) object);;
- PrivateKey privateKey = kp.getPrivate();
- Signature instance = Signature.getInstance("RSA");
- instance.initSign(privateKey);
- instance.update(inStr.getBytes());
- byte[] signature = instance.sign();
- outStr = Base64.encode(signature);
- } catch (InvalidKeyException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (SignatureException e) {
- e.printStackTrace();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- }
- return new String(outStr);
- }
-
- public static String[] splitAs60(String inStr) {
- int count = inStr.length() / 60;
- String[] out = new String[count + 1];
-
- for (int i = 0; i < count; i++) {
- String tmp = inStr.substring(i * 60, i * 60 + 60);
- out[i] = tmp;
- }
- if (inStr.length() > count * 60) {
- String tmp = inStr.substring(count * 60, inStr.length());
- out[count] = tmp;
- }
- return out;
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
deleted file mode 100644
index 824a6af95..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.impl;
-
-import java.io.File;
-import java.util.Map;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONObject;
-import org.onap.appc.Constants;
-import org.onap.appc.adapter.chef.ChefAdapter;
-import org.onap.appc.adapter.chef.chefapi.ApiMethod;
-import org.onap.appc.adapter.chef.chefclient.ChefApiClient;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-/**
- * This class implements the {@link ChefAdapter} interface. This interface
- * defines the behaviors that our service provides.
- */
-public class ChefAdapterImpl implements ChefAdapter {
- // chef server Initialize variable
- private String clientName = "";
- private String clientPrivatekey = "";
- private String chefserver = "";
- private String serverAddress = "";
- private String organizations = "";
-
-
- /**
- * The constant for the status code for a successful outcome
- */
- private static final String OUTCOME_SUCCESS = "success";
-
- /**
- * The logger to be used
- */
- private final EELFLogger logger = EELFManager.getInstance().getLogger(ChefAdapterImpl.class);
-
- private final String CANNOT_FIND_PRIVATE_KEY_STR = "Cannot find the private key in the APPC file system, please load the private key to ";
- private final String CHEF_ACTION_STR = "org.onap.appc.instance.chefAction";
- private final String ORGANIZATIONS_STR = "/organizations/";
- /**
- * A reference to the adapter configuration object.
- */
- private Configuration configuration;
-
- /**
- * This default constructor is used as a work around because the activator wasnt
- * getting called
- */
- public ChefAdapterImpl() {
- initialize();
- }
-
- /**
- * This constructor is used primarily in the test cases to bypass initialization
- * of the adapter for isolated, disconnected testing
- *
- * @param initialize
- * True if the adapter is to be initialized, can false if not
- */
- public ChefAdapterImpl(boolean initialize) {
- configuration = ConfigurationFactory.getConfiguration();
- if (initialize) {
- initialize();
- }
- }
-
- public ChefAdapterImpl(String key) {
- initialize(key);
- }
-
- /**
- * Returns the symbolic name of the adapter
- *
- * @return The adapter name
- * @see org.onap.appc.adapter.chef.ChefAdapter#getAdapterName()
- */
- @Override
- public String getAdapterName() {
- return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
- }
-
- /**
- * build node object
- */
- @Override
- public void nodeObejctBuilder(Map params, SvcLogicContext ctx) {
- logger.info("nodeObejctBuilder");
- String name = params.get("org.onap.appc.instance.nodeobject.name");
- String normal = params.get("org.onap.appc.instance.nodeobject.normal");
- String overrides = params.get("org.onap.appc.instance.nodeobject.overrides");
- String defaults = params.get("org.onap.appc.instance.nodeobject.defaults");
- String runList = params.get("org.onap.appc.instance.nodeobject.run_list");
- String chefEnvironment = params.get("org.onap.appc.instance.nodeobject.chef_environment");
- String nodeObject = "{\"json_class\":\"Chef::Node\",\"default\":{" + defaults
- + "},\"chef_type\":\"node\",\"run_list\":[" + runList + "],\"override\":{" + overrides
- + "},\"normal\": {" + normal + "},\"automatic\":{},\"name\":\"" + name + "\",\"chef_environment\":\""
- + chefEnvironment + "\"}";
- logger.info(nodeObject);
-
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- svcLogic.setAttribute("org.onap.appc.chef.nodeObject", nodeObject);
- }
-
- /**
- * send get request to chef server
- */
- public void chefInfo(Map params) {
- clientName = params.get("org.onap.appc.instance.username");
- serverAddress = params.get("org.onap.appc.instance.serverAddress");
- organizations = params.get("org.onap.appc.instance.organizations");
- chefserver = "https://" + serverAddress + ORGANIZATIONS_STR + organizations;
- if (params.containsKey("org.onap.appc.instance.pemPath")) {
- clientPrivatekey = params.get("org.onap.appc.instance.pemPath");
- } else {
- clientPrivatekey = "/opt/app/bvc/chef/" + serverAddress + "/" + organizations + "/" + clientName + ".pem";
- }
- }
-
- public Boolean privateKeyCheck() {
- File f = new File(clientPrivatekey);
- return f.exists();
- }
-
- @Override
- public void retrieveData(Map params, SvcLogicContext ctx) {
- String allConfigData = params.get("org.onap.appc.instance.allConfig");
- String key = params.get("org.onap.appc.instance.key");
- String dgContext = params.get("org.onap.appc.instance.dgContext");
- JSONObject josnConfig = new JSONObject(allConfigData);
-
- String contextData;
- try {
- contextData = josnConfig.getString(key);
- } catch (Exception ex) {
- try {
- contextData = josnConfig.getJSONObject(key).toString();
- } catch (Exception exc) {
- contextData = josnConfig.getJSONArray(key).toString();
- }
- }
-
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- svcLogic.setAttribute(dgContext, contextData);
- }
-
- @Override
- public void combineStrings(Map params, SvcLogicContext ctx) {
-
- String string1 = params.get("org.onap.appc.instance.String1");
- String string2 = params.get("org.onap.appc.instance.String2");
- String dgContext = params.get("org.onap.appc.instance.dgContext");
- String contextData = string1 + string2;
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- svcLogic.setAttribute(dgContext, contextData);
- }
-
- /**
- * Send GET request to chef server
- */
- @Override
- public void chefGet(Map params, SvcLogicContext ctx) {
- logger.info("chef get method");
- chefInfo(params);
- String chefAction = params.get(CHEF_ACTION_STR);
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- int code;
- String message;
- if (privateKeyCheck()) {
- ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
- ApiMethod am = cac.get(chefAction);
- am.execute();
- code = am.getReturnCode();
- message = am.getResponseBodyAsString();
- } else {
- code = 500;
- message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
- }
- chefServerResult(rc, Integer.toString(code), message);
- }
-
- /**
- * Send PUT request to chef server
- */
- @Override
- public void chefPut(Map params, SvcLogicContext ctx) {
- chefInfo(params);
- String chefAction = params.get(CHEF_ACTION_STR);
- String chefNodeStr = params.get("org.onap.appc.instance.chefRequestBody");
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- int code;
- String message;
- if (privateKeyCheck()) {
- ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
-
- ApiMethod am = cac.put(chefAction).body(chefNodeStr);
- am.execute();
- code = am.getReturnCode();
- message = am.getResponseBodyAsString();
- } else {
- code = 500;
- message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
- }
- logger.info(code + " " + message);
- chefServerResult(rc, Integer.toString(code), message);
- }
-
- /**
- * send Post request to chef server
- */
- @Override
- public void chefPost(Map params, SvcLogicContext ctx) {
- chefInfo(params);
- logger.info("chef Post method");
- logger.info(clientName + " " + clientPrivatekey + " " + chefserver + " " + organizations);
- String chefNodeStr = params.get("org.onap.appc.instance.chefRequestBody");
- String chefAction = params.get(CHEF_ACTION_STR);
-
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- int code;
- String message;
- // should load pem from somewhere else
- if (privateKeyCheck()) {
- ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
-
- // need pass path into it
- // "/nodes/testnode"
- ApiMethod am = cac.post(chefAction).body(chefNodeStr);
- am.execute();
- code = am.getReturnCode();
- message = am.getResponseBodyAsString();
- } else {
- code = 500;
- message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
- }
- logger.info(code + " " + message);
- chefServerResult(rc, Integer.toString(code), message);
- }
-
- /**
- * send delete request to chef server
- */
- @Override
- public void chefDelete(Map params, SvcLogicContext ctx) {
- logger.info("chef delete method");
- chefInfo(params);
- String chefAction = params.get(CHEF_ACTION_STR);
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- int code;
- String message;
- if (privateKeyCheck()) {
- ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
- ApiMethod am = cac.delete(chefAction);
- am.execute();
- code = am.getReturnCode();
- message = am.getResponseBodyAsString();
- } else {
- code = 500;
- message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
- }
- logger.info(code + " " + message);
- chefServerResult(rc, Integer.toString(code), message);
- }
-
- /**
- * Trigger target vm run chef
- */
- @Override
- public void trigger(Map params, SvcLogicContext ctx) {
- logger.info("Run trigger method");
- String tVmIp = params.get("org.onap.appc.instance.ip");
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
-
- try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
- HttpGet httpGet = new HttpGet(tVmIp);
- HttpResponse response;
- response = httpClient.execute(httpGet);
- int responseCode = response.getStatusLine().getStatusCode();
- HttpEntity entity = response.getEntity();
- String responseOutput = EntityUtils.toString(entity);
- chefClientResult(rc, Integer.toString(responseCode), responseOutput);
- doSuccess(rc);
- } catch (Exception ex) {
- doFailure(rc, 500, ex.toString());
- }
- }
-
- @Override
- public void checkPushJob(Map params, SvcLogicContext ctx) {
- chefInfo(params);
- String jobID = params.get("org.onap.appc.instance.jobid");
- int retryTimes = Integer.parseInt(params.get("org.onap.appc.instance.retryTimes"));
- int retryInterval = Integer.parseInt(params.get("org.onap.appc.instance.retryInterval"));
- String chefAction = "/pushy/jobs/" + jobID;
-
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- String message = "";
- String status = "";
- for (int i = 0; i < retryTimes; i++) {
- try {
- Thread.sleep(retryInterval); // 1000 milliseconds is one second.
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- }
- ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
- ApiMethod am = cac.get(chefAction);
- am.execute();
- int code = am.getReturnCode();
- message = am.getResponseBodyAsString();
- JSONObject obj = new JSONObject(message);
- status = obj.getString("status");
- if (!"running".equals(status)) {
- logger.info(i + " time " + code + " " + status);
- break;
- }
-
- }
- if ("complete".equals(status)) {
- svcLogic.setAttribute("org.onap.appc.chefServerResult.code", "200");
- svcLogic.setAttribute("org.onap.appc.chefServerResult.message", message);
- } else {
- if ("running".equals(status)) {
- svcLogic.setAttribute("org.onap.appc.chefServerResult.code", "202");
- svcLogic.setAttribute("org.onap.appc.chefServerResult.message", "chef client runtime out");
- } else {
- svcLogic.setAttribute("org.onap.appc.chefServerResult.code", "500");
- svcLogic.setAttribute("org.onap.appc.chefServerResult.message", message);
- }
- }
- }
-
- @Override
- public void pushJob(Map params, SvcLogicContext ctx) {
- chefInfo(params);
- String pushRequest = params.get("org.onap.appc.instance.pushRequest");
- String chefAction = "/pushy/jobs";
- RequestContext rc = new RequestContext(ctx);
- rc.isAlive();
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- ChefApiClient cac = new ChefApiClient(clientName, clientPrivatekey, chefserver, organizations);
- ApiMethod am = cac.post(chefAction).body(pushRequest);
-
- am.execute();
- int code = am.getReturnCode();
- String message = am.getResponseBodyAsString();
- if (code == 201) {
- int startIndex = message.indexOf("jobs") + 6;
- int endIndex = message.length() - 2;
- String jobID = message.substring(startIndex, endIndex);
- svcLogic.setAttribute("org.onap.appc.jobID", jobID);
- logger.info(jobID);
- }
- chefServerResult(rc, Integer.toString(code), message);
- }
-
- private void doFailure(RequestContext rc, int code, String message) {
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- String msg = (message == null) ? Integer.toString(code) : message;
- if (msg.contains("\n")) {
- msg = msg.substring(msg.indexOf("\n"));
- }
-
- String status;
- try {
- status = Integer.toString(code);
- } catch (Exception e) {
- logger.info("Couldn't covert " + code + " to an Integer, defaulting status to 500", e);
- status = "500";
- }
- svcLogic.setAttribute("org.onap.appc.chefAgent.code", status);
- svcLogic.setAttribute("org.onap.appc.chefAgent.message", msg);
- }
-
- /**
- * @param rc
- * The request context that manages the state and recovery of the
- * request for the life of its processing.
- */
- private void doSuccess(RequestContext rc) {
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- svcLogic.setAttribute("org.onap.appc.chefAgent.code", "200");
- }
-
- private void chefServerResult(RequestContext rc, String code, String message) {
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- svcLogic.setStatus(OUTCOME_SUCCESS);
- svcLogic.setAttribute("org.onap.appc.chefServerResult.code", code);
- svcLogic.setAttribute("org.onap.appc.chefServerResult.message", message);
- }
-
- private void chefClientResult(RequestContext rc, String code, String message) {
- SvcLogicContext svcLogic = rc.getSvcLogicContext();
- svcLogic.setStatus(OUTCOME_SUCCESS);
- svcLogic.setAttribute("org.onap.appc.chefClientResult.code", code);
- svcLogic.setAttribute("org.onap.appc.chefClientResult.message", message);
- }
-
- /**
- * initialize the provider adapter by building the context cache
- */
- private void initialize() {
- configuration = ConfigurationFactory.getConfiguration();
- // need to fetch data from appc configurator or form some file in the appc vms
- clientName = "testnode";
- clientPrivatekey = System.getProperty("user.dir") + "/src/test/resources/testclient.pem";
- serverAddress = "http://example.com";
- organizations = "test";
- chefserver = serverAddress + ORGANIZATIONS_STR + organizations;
- logger.info("Initialize Chef Adapter");
- }
-
- private void initialize(String key) {
- configuration = ConfigurationFactory.getConfiguration();
- // need to fetch data from appc configurator or form some file in the appc vms
- clientName = "testnode";
- clientPrivatekey = key;
- serverAddress = "http://example.com";
- organizations = "test";
- chefserver = serverAddress + ORGANIZATIONS_STR + organizations;
- logger.info("Initialize Chef Adapter");
- }
-
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestContext.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestContext.java
deleted file mode 100644
index 3c0e00a6a..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestContext.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.impl;
-
-import org.onap.appc.Constants;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-/**
- * This class is used to track and maintain recovery and time-to-live information for a request as it is being
- * processed.
- */
-public class RequestContext {
- /**
- * The number of seconds of wait time between successive attempts to connect to the provider. This is used to
- * recover from provider outages or failures. It is not used to recover from logical errors, such as an invalid
- * request, server not found, etc.
- */
- private Integer retryDelay;
-
- /**
- * The number of times we will attempt to connect to the provider. This is used to recover from provider outages or
- * failures. It is not used to recover from logical errors, such as an invalid request, server not found, etc.
- */
- private Integer retryLimit;
-
- /**
- * The total time, in milliseconds, that the provider can have to process this request. If the accumulated time
- * exceeds the time to live, then the request is failed with a timeout exception, regardless of the state of the
- * provider. Note that the caller may supply this as a value in seconds, in which case it must be converted to
- * milliseconds for the request context.
- */
- private Long timeToLive;
-
- /**
- * The accumulated time, in milliseconds, that has been used so far to process the request. This is compared to the
- * time to live each time it is updated. If the accumulated time exceeds the time to live, then the request is
- * failed with a timeout exception, regardless of the state of the provider.
- */
- private long accumulatedTime;
-
- /**
- * The total number of retries attempted so far
- */
- private int attempt;
-
- /**
- * The time when the stopwatch was started
- */
- private long startTime = -1;
-
- /**
- * The service logic (DG) context from the SLI
- */
- private SvcLogicContext svcLogicContext;
-
- /**
- * The configuration
- */
- private Configuration configuration = ConfigurationFactory.getConfiguration();
-
- /**
- * Set to true whenever the retry limit has been exceeded, reset to false when reset() is called.
- */
- private boolean retryFailed;
-
- /**
- * Creates the request context
- *
- * @param context
- * The service logic (SLI) context associated with the current DG
- */
- public RequestContext(SvcLogicContext context) {
- setSvcLogicContext(context);
- }
-
- /**
- * @return The retry delay, in seconds. If zero, then no retry is to be performed
- */
- public int getRetryDelay() {
- if (retryDelay == null) {
- int value = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_DELAY);
- retryDelay = Integer.valueOf(value);
- }
-
- return retryDelay.intValue();
- }
-
- /**
- * This method is a helper that allows the caller to delay for the retry interval time and not have to handle the
- * thread interruption, timer handling, etc.
- */
- public void delay() {
- long time = getRetryDelay() * 1000L;
- long future = System.currentTimeMillis() + time;
- if (time != 0) {
- while (System.currentTimeMillis() < future && time > 0) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
- /*
- * This is rare, but it can happen if another thread interrupts us while we are sleeping. In that
- * case, the thread is resumed before the delay time has actually expired, so re-calculate the
- * amount of delay time needed and reenter the sleep until we get to the future time.
- */
- time = future - System.currentTimeMillis();
- }
- }
- }
- }
-
- /**
- * @return The number of retries that are allowed per connection
- */
- public int getRetryLimit() {
- if (retryLimit == null) {
- int value = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_LIMIT);
- retryLimit = Integer.valueOf(value);
- }
-
- return retryLimit.intValue();
- }
-
- /**
- * Check and count the connection attempt.
- *
- * @return True if the connection should be attempted. False indicates that the number of retries has been exhausted
- * and it should NOT be attempted.
- */
- public boolean attempt() {
- if (retryFailed || attempt >= getRetryLimit()) {
- retryFailed = true;
- return false;
- }
- attempt++;
-
- return true;
- }
-
- /**
- * @return The number of retry attempts so far
- */
- public int getAttempts() {
- return attempt;
- }
-
- /**
- * @return True if the retry limit has been exceeded, false otherwise
- */
- public boolean isFailed() {
- return retryFailed;
- }
-
- /**
- * This method both checks the time to live to see if it has been exceeded and accumulates the total time used so
- * far.
- *
- * Each time this method is called it accumulates the total duration since the last time it was called to the total
- * time accumulator. It then checks the total time to the time to live and if greater, it returns false. As long as
- * the total time used is less than or equal to the time to live limit, the method returns true. It is important to
- * call this method at the very beginning of the process so that all parts of the process are tracked.
- *
- *
- * @return True if the total time to live has not been exceeded. False indicates that the total time to live has
- * been exceeded and no further processing should be performed.
- */
- public boolean isAlive() {
- long now = System.currentTimeMillis();
- if (startTime == -1) {
- startTime = now;
- return true;
- }
- accumulatedTime += (now - startTime);
- startTime = now;
- if (accumulatedTime > timeToLive) {
- return false;
- }
- return true;
- }
-
- /**
- * @return The total amount of time used, in milliseconds.
- */
- public long getTotalDuration() {
- return accumulatedTime;
- }
-
- /**
- * This method is called to reset the retry counters. It has no effect on the time to live accumulator.
- */
- public void reset() {
- attempt = 0;
- }
-
- /**
- * Sets the time to live to the value, expressed in seconds
- *
- * @param time
- * The time to live, in seconds
- */
- public void setTimeToLiveSeconds(int time) {
- setTimeToLiveMS(time * 1000L);
- }
-
- /**
- * Sets the time to live to the value, expressed in milliseconds
- *
- * @param time
- * The time to live, in milliseconds
- */
- public void setTimeToLiveMS(long time) {
- this.timeToLive = time;
- }
-
- /**
- * @return The service logic context associated with this request
- */
- public SvcLogicContext getSvcLogicContext() {
- return svcLogicContext;
- }
-
- /**
- * @param svcLogicContext
- * The service logic context to be associated with this request
- */
- public void setSvcLogicContext(SvcLogicContext svcLogicContext) {
- this.svcLogicContext = svcLogicContext;
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/onap/appc/default.properties b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..c00220dd6
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,96 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# 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.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+#
+# Default properties for the APP-C Provider Adapter
+#
+# -------------------------------------------------------------------------------------------------
+#
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
+# to supply configuration options
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.onap.appc.resources=org/onap/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.onap.appc.provider.adaptor.name=org.onap.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.onap.appc.logging.file=org/onap/appc/logback.xml
+org.onap.appc.logging.path=${user.home};etc;../etc
+org.onap.appc.logger=org.onap.appc
+org.onap.appc.security.logger=org.onap.appc.security
+#
+# The minimum and maximum provider/tenant context pool sizes. Min=1 means that as soon
+# as the provider/tenant is referenced a Context is opened and added to the pool. Max=0
+# means that the upper bound on the pool is unbounded.
+org.onap.appc.provider.min.pool=1
+org.onap.appc.provider.max.pool=0
+
+#
+# The following properties are used to configure the retry logic for connection to the
+# IaaS provider(s). The retry delay property is the amount of time, in seconds, the
+# application waits between retry attempts. The retry limit is the number of retries
+# that are allowed before the request is failed.
+org.onap.appc.provider.retry.delay = 30
+org.onap.appc.provider.retry.limit = 10
+
+#
+# The trusted hosts list for SSL access when a certificate is not provided.
+#
+provider.trusted.hosts=*
+#
+# The amount of time, in seconds, to wait for a server state change (start->stop, stop->start, etc).
+# If the server does not change state to a valid state within the alloted time, the operation
+# fails.
+org.onap.appc.server.state.change.timeout=300
+#
+# The amount of time to wait, in seconds, between subsequent polls to the OpenStack provider
+# to refresh the status of a resource we are waiting on.
+#
+org.onap.appc.openstack.poll.interval=20
+#
+# The connection information to connect to the provider we are using. These properties
+# are "structured" properties, in that the name is a compound name, where the nodes
+# of the name can be ordered (1, 2, 3, ...). All of the properties with the same ordinal
+# position are defining the same entity. For example, provider1.type and provider1.name
+# are defining the same provider, whereas provider2.name and provider2.type are defining
+# the values for a different provider. Any number of providers can be defined in this
+# way.
+#
+# Don't change these 2 right now since they are hard coded in the DG
+#provider1.type=appc
+#provider1.name=appc
+
+#These you can change
+#provider1.identity=appc
+#provider1.tenant1.name=appc
+#provider1.tenant1.userid=appc
+#provider1.tenant1.password=appc
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index c00220dd6..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,96 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP : APPC
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Copyright (C) 2017 Amdocs
-# =============================================================================
-# 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.
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# ============LICENSE_END=========================================================
-###
-
-#
-# Default properties for the APP-C Provider Adapter
-#
-# -------------------------------------------------------------------------------------------------
-#
-# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
-# to supply configuration options
-org.onap.appc.bootstrap.file=appc.properties
-org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
-
-appc.application.name=APPC
-
-#
-# Define the message resource bundle name to be loaded
-org.onap.appc.resources=org/onap/appc/i18n/MessageResources
-#
-# The name of the adapter.
-org.onap.appc.provider.adaptor.name=org.onap.appc.appc_provider_adapter
-#
-# Set up the logging environment
-#
-org.onap.appc.logging.file=org/onap/appc/logback.xml
-org.onap.appc.logging.path=${user.home};etc;../etc
-org.onap.appc.logger=org.onap.appc
-org.onap.appc.security.logger=org.onap.appc.security
-#
-# The minimum and maximum provider/tenant context pool sizes. Min=1 means that as soon
-# as the provider/tenant is referenced a Context is opened and added to the pool. Max=0
-# means that the upper bound on the pool is unbounded.
-org.onap.appc.provider.min.pool=1
-org.onap.appc.provider.max.pool=0
-
-#
-# The following properties are used to configure the retry logic for connection to the
-# IaaS provider(s). The retry delay property is the amount of time, in seconds, the
-# application waits between retry attempts. The retry limit is the number of retries
-# that are allowed before the request is failed.
-org.onap.appc.provider.retry.delay = 30
-org.onap.appc.provider.retry.limit = 10
-
-#
-# The trusted hosts list for SSL access when a certificate is not provided.
-#
-provider.trusted.hosts=*
-#
-# The amount of time, in seconds, to wait for a server state change (start->stop, stop->start, etc).
-# If the server does not change state to a valid state within the alloted time, the operation
-# fails.
-org.onap.appc.server.state.change.timeout=300
-#
-# The amount of time to wait, in seconds, between subsequent polls to the OpenStack provider
-# to refresh the status of a resource we are waiting on.
-#
-org.onap.appc.openstack.poll.interval=20
-#
-# The connection information to connect to the provider we are using. These properties
-# are "structured" properties, in that the name is a compound name, where the nodes
-# of the name can be ordered (1, 2, 3, ...). All of the properties with the same ordinal
-# position are defining the same entity. For example, provider1.type and provider1.name
-# are defining the same provider, whereas provider2.name and provider2.type are defining
-# the values for a different provider. Any number of providers can be defined in this
-# way.
-#
-# Don't change these 2 right now since they are hard coded in the DG
-#provider1.type=appc
-#provider1.name=appc
-
-#These you can change
-#provider1.identity=appc
-#provider1.tenant1.name=appc
-#provider1.tenant1.userid=appc
-#provider1.tenant1.password=appc
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java
new file mode 100644
index 000000000..5ea152a8d
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/chefclient/TestChefApiClient.java
@@ -0,0 +1,107 @@
+package org.onap.appc.adapter.chef.chefclient;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.regex.Pattern;
+
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.adapter.chef.chefapi.ApiMethod;
+import org.onap.appc.adapter.chef.chefapi.Delete;
+import org.onap.appc.adapter.chef.chefapi.Get;
+import org.onap.appc.adapter.chef.chefapi.Post;
+import org.onap.appc.adapter.chef.chefapi.Put;
+
+public class TestChefApiClient {
+
+ private ChefApiClient client;
+ private Properties props;
+
+ @Before
+ public void setup() throws IllegalArgumentException, IllegalAccessException {
+ props = new Properties();
+ InputStream propStr = getClass().getResourceAsStream("/test.properties");
+ if (propStr == null) {
+ fail("src/test/resources/test.properties missing");
+ }
+
+ try {
+ props.load(propStr);
+ propStr.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Could not initialize properties");
+ }
+ client = new ChefApiClient(
+ props.getProperty("org.onap.appc.adapter.chef.chefclient.userId"),
+ System.getProperty("user.dir") +
+ props.getProperty("org.onap.appc.adapter.chef.chefclient.pemPath"),
+ props.getProperty("org.onap.appc.adapter.chef.chefclient.endPoint"),
+ props.getProperty("org.onap.appc.adapter.chef.chefclient.organizations"));
+ }
+
+ @Test
+ public void testGet(){
+ Get get = client.get(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
+ ApiMethod method = get.createRequest();
+ String[] response = method.test.split("\n");
+
+ thenStringShouldMatch("GET", response);
+ }
+
+ @Test
+ public void testPut(){
+ Put put = client.put(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
+ ApiMethod method = put.createRequest();
+ String[] response = method.test.split("\n");
+
+ thenStringShouldMatch("PUT", response);
+ }
+
+ @Test
+ public void testPost() {
+ Post post = client.post(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
+ ApiMethod method = post.createRequest();
+ String[] response = method.test.split("\n");
+
+ thenStringShouldMatch("POST", response);
+ }
+
+ @Test
+ public void testDelete(){
+ Delete delete = client.delete(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
+ ApiMethod method = delete.createRequest();
+ String[] response = method.test.split("\n");
+
+ thenStringShouldMatch("DELETE", response);
+ }
+
+ private String timestamp(){
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String timeStamp = sdf.format(new Date());
+ timeStamp = timeStamp.replace(" ", "T");
+ timeStamp = timeStamp + "Z";
+ return timeStamp;
+ }
+
+ private void thenStringShouldMatch(String method, String[] response){
+ assertEquals("sb Method:" + method, response[0]);
+ assertEquals("Hashed Path:+JEk1y2gXwqZRweNjXYtx4ojxW8=", response[1]);
+ assertEquals("X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=", response[2]);
+ String timestamp = timestamp().substring(0, timestamp().length() - 3);
+ String regEx = "X-Ops-Timestamp:" +
+ timestamp +
+ "...";
+ assertTrue(Pattern.matches(regEx, response[3]));
+ assertEquals("X-Ops-UserId:test", response[4]);
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java
new file mode 100644
index 000000000..687ba8338
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/adapter/chef/impl/TestChefAdapterImpl.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.adapter.chef.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.exceptions.APPCException;
+import com.att.cdp.exceptions.ZoneException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+public class TestChefAdapterImpl {
+ private SvcLogicContext svcContext;
+
+ private ChefAdapterImpl adapter;
+
+ private Map params;
+ private String getAttribute;
+
+ @Before
+ public void setup() {
+ adapter = new ChefAdapterImpl(Boolean.TRUE);
+ params = new HashMap<>();
+ params.put("org.onap.appc.instance.pemPath",
+ "/src/test/resources/testclient.pem");
+ }
+
+ @After
+ public void tearDown() {
+ params = null;
+ svcContext = null;
+ getAttribute = null;
+ }
+
+ @Test
+ public void testChefGetFail() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+ params.put("org.onap.appc.instance.chefAction", "/nodes");
+
+ givenParams(params, "chefGet");
+ thenResponseShouldFail();
+ }
+
+ @Test
+ public void testChefPutFail() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+ params.put("org.onap.appc.instance.chefAction", "/nodes/testnode");
+ params.put("org.onap.appc.instance.runList", "recipe[commandtest]");
+ params.put("org.onap.appc.instance.attributes", "");
+ params.put("org.onap.appc.instance.chefRequestBody", "Test Body");
+
+ givenParams(params, "chefPut");
+ thenResponseShouldFail();
+ }
+
+ @Test
+ public void testTriggerFail() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+ params.put("org.onap.appc.instance.ip", "");
+
+ givenParams(params, "trigger");
+ thenResponseShouldFail();
+ }
+
+ private void givenParams(Map adapterParams, String method) {
+ svcContext = new SvcLogicContext();
+ if (method == "chefGet"){
+ adapter.chefGet(adapterParams, svcContext);
+ getAttribute = "org.onap.appc.chefServerResult.code";
+ }
+ if (method == "chefPut"){
+ adapter.chefPut(adapterParams, svcContext);
+ getAttribute = "org.onap.appc.chefServerResult.code";
+ }
+ if (method == "trigger"){
+ adapter.trigger(adapterParams, svcContext);
+ getAttribute = "org.onap.appc.chefAgent.code";
+ }
+ }
+
+ private void thenResponseShouldFail(){
+ String status = svcContext.getAttribute(this.getAttribute);
+ assertEquals("500", status);
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
new file mode 100644
index 000000000..13b5fdfb3
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
@@ -0,0 +1,182 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.appc.test;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.appc.test.InterceptLogger;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+/**
+ * This class is used as a test harness to wrap the call to an executor node.
+ */
+
+public class ExecutorHarness {
+
+ /**
+ * The executor to be tested
+ */
+ private SvcLogicJavaPlugin executor;
+
+ /**
+ * The collection of all exec methods found on the class
+ */
+ private Map methods;
+
+ /**
+ * The field of the class being tested that contains the reference to the logger to be used. This is modified to
+ * point to our interception logger for the test.
+ */
+ private Field contextLogger;
+
+ /**
+ * The interception logger that buffers all messages logged and allows us to look at them as part of the test case.
+ */
+ private InterceptLogger logger;
+
+ /**
+ * Create the harness and initialize it
+ *
+ * @throws SecurityException
+ * If a security manager, s, is present and any of the following conditions is met:
+ *
+ * - invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field
+ * - the caller's class loader is not the same as or an ancestor of the class loader for the current
+ * class and invocation of s.checkPackageAccess() denies access to the package of this class
+ *
+ * @throws NoSuchFieldException
+ * if a field with the specified name is not found.
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ */
+ @SuppressWarnings("nls")
+ public ExecutorHarness() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
+ IllegalAccessException {
+ methods = new HashMap<>();
+ new SvcLogicContext();
+
+ Class> contextClass = SvcLogicContext.class;
+ contextLogger = contextClass.getDeclaredField("LOG");
+ contextLogger.setAccessible(true);
+ logger = new InterceptLogger();
+ contextLogger.set(null, logger);
+ }
+
+ /**
+ * Convenience constructor
+ *
+ * @param executor
+ * The executor to be tested by the harness
+ * @throws SecurityException
+ * If a security manager, s, is present and any of the following conditions is met:
+ *
+ * - invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field
+ * - the caller's class loader is not the same as or an ancestor of the class loader for the current
+ * class and invocation of s.checkPackageAccess() denies access to the package of this class
+ *
+ * @throws NoSuchFieldException
+ * if a field with the specified name is not found.
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is either
+ * inaccessible or final.
+ * @throws IllegalArgumentException
+ * if the specified object is not an instance of the class or interface declaring the underlying field
+ * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
+ */
+ public ExecutorHarness(SvcLogicJavaPlugin executor) throws NoSuchFieldException, SecurityException,
+ IllegalArgumentException, IllegalAccessException {
+ this();
+ setExecutor(executor);
+ }
+
+ /**
+ * @param executor
+ * The java plugin class to be executed
+ */
+ public void setExecutor(SvcLogicJavaPlugin executor) {
+ this.executor = executor;
+ scanExecutor();
+ }
+
+ /**
+ * @return The java plugin class to be executed
+ */
+ public SvcLogicJavaPlugin getExecutor() {
+ return executor;
+ }
+
+ /**
+ * @return The set of all methods that meet the signature requirements
+ */
+ public List getExecMethodNames() {
+ List names = new ArrayList<>();
+ names.addAll(methods.keySet());
+ return names;
+ }
+
+ /**
+ * Returns an indication if the named method is a valid executor method that could be called from a DG execute node
+ *
+ * @param methodName
+ * The method name to be validated
+ * @return True if the method name meets the signature requirements, false if the method either does not exist or
+ * does not meet the requirements.
+ */
+ public boolean isExecMethod(String methodName) {
+ return methods.containsKey(methodName);
+ }
+
+ /**
+ * This method scans the executor class hierarchy to locate all methods that match the required signature of the
+ * executor and records these methods in a map.
+ */
+ private void scanExecutor() {
+ methods.clear();
+ Class> executorClass = executor.getClass();
+ Method[] publicMethods = executorClass.getMethods();
+ for (Method method : publicMethods) {
+ if (method.getReturnType().equals(Void.class)) {
+ Class>[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length == 2) {
+ if (Map.class.isAssignableFrom(paramTypes[0])
+ && SvcLogicContext.class.isAssignableFrom(paramTypes[1])) {
+ methods.put(method.getName(), method);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
new file mode 100644
index 000000000..b101ecee4
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
@@ -0,0 +1,454 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.appc.test;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Marker;
+
+import ch.qos.logback.classic.Level;
+
+/**
+ * This class is used as an intercept logger that can be used in testing to intercept and record all messages that are
+ * logged, thus allowing a junit test case to examine the log output and make assertions.
+ */
+public class InterceptLogger implements org.slf4j.Logger {
+
+ /**
+ * This inner class represents an intercepted log event
+ */
+ public class LogRecord {
+ private Level level;
+ private String message;
+ private long timestamp;
+ private Throwable t;
+
+ public LogRecord(Level level, String message) {
+ setLevel(level);
+ setTimestamp(System.currentTimeMillis());
+ setMessage(message);
+ }
+
+ public LogRecord(Level level, String message, Throwable t) {
+ this(level, message);
+ setThrowable(t);
+ }
+
+ /**
+ * @return the value of level
+ */
+ public Level getLevel() {
+ return level;
+ }
+
+ /**
+ * @return the value of message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * @return the value of timestamp
+ */
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * @param level
+ * the value for level
+ */
+ public void setLevel(Level level) {
+ this.level = level;
+ }
+
+ /**
+ * @param message
+ * the value for message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * @param timestamp
+ * the value for timestamp
+ */
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * @return the value of t
+ */
+ public Throwable getThrowable() {
+ return t;
+ }
+
+ /**
+ * @param t
+ * the value for t
+ */
+ public void setThrowable(Throwable t) {
+ this.t = t;
+ }
+
+ }
+
+ /**
+ * The list of all intercepted log events
+ */
+ private List events;
+
+ /**
+ * Create the intercept logger
+ */
+ public InterceptLogger() {
+ events = new ArrayList(1000);
+ }
+
+ /**
+ * @return Returns all intercepted log events
+ */
+ public List getLogRecords() {
+ return events;
+ }
+
+ /**
+ * Clears all log events
+ */
+ public void clear() {
+ events.clear();
+ }
+
+ @Override
+ public void debug(Marker marker, String msg) {
+ debug(msg);
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg) {
+ debug(MessageFormat.format(format, arg));
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object... arguments) {
+ debug(MessageFormat.format(format, arguments));
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg1, Object arg2) {
+ debug(MessageFormat.format(format, arg1, arg2));
+ }
+
+ @Override
+ public void debug(Marker marker, String msg, Throwable t) {
+ debug(msg, t);
+ }
+
+ @Override
+ public void debug(String msg) {
+ events.add(new LogRecord(Level.DEBUG, msg));
+ }
+
+ @Override
+ public void debug(String format, Object arg) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void debug(String format, Object... arguments) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void debug(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void debug(String msg, Throwable t) {
+ events.add(new LogRecord(Level.DEBUG, msg, t));
+ }
+
+ @Override
+ public void error(Marker marker, String msg) {
+ error(msg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg) {
+ error(format, arg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object... arguments) {
+ error(format, arguments);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg1, Object arg2) {
+ error(format, arg1, arg2);
+ }
+
+ @Override
+ public void error(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.ERROR, msg, t));
+ }
+
+ @Override
+ public void error(String msg) {
+ events.add(new LogRecord(Level.ERROR, msg));
+ }
+
+ @Override
+ public void error(String format, Object arg) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void error(String format, Object... arguments) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void error(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void error(String msg, Throwable t) {
+ events.add(new LogRecord(Level.ERROR, msg, t));
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public void info(Marker marker, String msg) {
+ info(msg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg) {
+ info(format, arg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object... arguments) {
+ info(format, arguments);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg1, Object arg2) {
+ info(format, arg1, arg2);
+ }
+
+ @Override
+ public void info(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.INFO, msg, t));
+ }
+
+ @Override
+ public void info(String msg) {
+ events.add(new LogRecord(Level.INFO, msg));
+ }
+
+ @Override
+ public void info(String format, Object arg) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void info(String format, Object... arguments) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void info(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void info(String msg, Throwable t) {
+ events.add(new LogRecord(Level.INFO, msg, t));
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isDebugEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isInfoEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isTraceEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isWarnEnabled(Marker marker) {
+ return true;
+ }
+
+ @Override
+ public void trace(Marker marker, String msg) {
+ trace(msg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg) {
+ trace(format, arg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object... argArray) {
+ trace(format, argArray);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg1, Object arg2) {
+ trace(format, arg1, arg2);
+ }
+
+ @Override
+ public void trace(Marker marker, String msg, Throwable t) {
+ trace(msg, t);
+ }
+
+ @Override
+ public void trace(String msg) {
+ events.add(new LogRecord(Level.TRACE, msg));
+ }
+
+ @Override
+ public void trace(String format, Object arg) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void trace(String format, Object... arguments) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void trace(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void trace(String msg, Throwable t) {
+ events.add(new LogRecord(Level.TRACE, msg, t));
+ }
+
+ @Override
+ public void warn(Marker marker, String msg) {
+ warn(msg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg) {
+ warn(format, arg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object... arguments) {
+ warn(format, arguments);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg1, Object arg2) {
+ warn(format, arg1, arg2);
+ }
+
+ @Override
+ public void warn(Marker marker, String msg, Throwable t) {
+ events.add(new LogRecord(Level.WARN, msg, t));
+ }
+
+ @Override
+ public void warn(String msg) {
+ events.add(new LogRecord(Level.WARN, msg));
+ }
+
+ @Override
+ public void warn(String format, Object arg) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg)));
+ }
+
+ @Override
+ public void warn(String format, Object... arguments) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arguments)));
+ }
+
+ @Override
+ public void warn(String format, Object arg1, Object arg2) {
+ events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg1, arg2)));
+ }
+
+ @Override
+ public void warn(String msg, Throwable t) {
+ events.add(new LogRecord(Level.WARN, msg, t));
+ }
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/chefclient/TestChefApiClient.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/chefclient/TestChefApiClient.java
deleted file mode 100644
index 5ea152a8d..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/chefclient/TestChefApiClient.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.onap.appc.adapter.chef.chefclient;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.regex.Pattern;
-
-
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.appc.adapter.chef.chefapi.ApiMethod;
-import org.onap.appc.adapter.chef.chefapi.Delete;
-import org.onap.appc.adapter.chef.chefapi.Get;
-import org.onap.appc.adapter.chef.chefapi.Post;
-import org.onap.appc.adapter.chef.chefapi.Put;
-
-public class TestChefApiClient {
-
- private ChefApiClient client;
- private Properties props;
-
- @Before
- public void setup() throws IllegalArgumentException, IllegalAccessException {
- props = new Properties();
- InputStream propStr = getClass().getResourceAsStream("/test.properties");
- if (propStr == null) {
- fail("src/test/resources/test.properties missing");
- }
-
- try {
- props.load(propStr);
- propStr.close();
- } catch (Exception e) {
- e.printStackTrace();
- fail("Could not initialize properties");
- }
- client = new ChefApiClient(
- props.getProperty("org.onap.appc.adapter.chef.chefclient.userId"),
- System.getProperty("user.dir") +
- props.getProperty("org.onap.appc.adapter.chef.chefclient.pemPath"),
- props.getProperty("org.onap.appc.adapter.chef.chefclient.endPoint"),
- props.getProperty("org.onap.appc.adapter.chef.chefclient.organizations"));
- }
-
- @Test
- public void testGet(){
- Get get = client.get(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
- ApiMethod method = get.createRequest();
- String[] response = method.test.split("\n");
-
- thenStringShouldMatch("GET", response);
- }
-
- @Test
- public void testPut(){
- Put put = client.put(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
- ApiMethod method = put.createRequest();
- String[] response = method.test.split("\n");
-
- thenStringShouldMatch("PUT", response);
- }
-
- @Test
- public void testPost() {
- Post post = client.post(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
- ApiMethod method = post.createRequest();
- String[] response = method.test.split("\n");
-
- thenStringShouldMatch("POST", response);
- }
-
- @Test
- public void testDelete(){
- Delete delete = client.delete(props.getProperty("org.onap.appc.adapter.chef.chefclient.path"));
- ApiMethod method = delete.createRequest();
- String[] response = method.test.split("\n");
-
- thenStringShouldMatch("DELETE", response);
- }
-
- private String timestamp(){
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- String timeStamp = sdf.format(new Date());
- timeStamp = timeStamp.replace(" ", "T");
- timeStamp = timeStamp + "Z";
- return timeStamp;
- }
-
- private void thenStringShouldMatch(String method, String[] response){
- assertEquals("sb Method:" + method, response[0]);
- assertEquals("Hashed Path:+JEk1y2gXwqZRweNjXYtx4ojxW8=", response[1]);
- assertEquals("X-Ops-Content-Hash:2jmj7l5rSw0yVb/vlWAYkK/YBwk=", response[2]);
- String timestamp = timestamp().substring(0, timestamp().length() - 3);
- String regEx = "X-Ops-Timestamp:" +
- timestamp +
- "...";
- assertTrue(Pattern.matches(regEx, response[3]));
- assertEquals("X-Ops-UserId:test", response[4]);
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/TestChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/TestChefAdapterImpl.java
deleted file mode 100644
index 687ba8338..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/TestChefAdapterImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.appc.adapter.chef.impl;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.appc.exceptions.APPCException;
-import com.att.cdp.exceptions.ZoneException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-public class TestChefAdapterImpl {
- private SvcLogicContext svcContext;
-
- private ChefAdapterImpl adapter;
-
- private Map params;
- private String getAttribute;
-
- @Before
- public void setup() {
- adapter = new ChefAdapterImpl(Boolean.TRUE);
- params = new HashMap<>();
- params.put("org.onap.appc.instance.pemPath",
- "/src/test/resources/testclient.pem");
- }
-
- @After
- public void tearDown() {
- params = null;
- svcContext = null;
- getAttribute = null;
- }
-
- @Test
- public void testChefGetFail() throws IOException, IllegalStateException, IllegalArgumentException,
- ZoneException, APPCException {
- params.put("org.onap.appc.instance.chefAction", "/nodes");
-
- givenParams(params, "chefGet");
- thenResponseShouldFail();
- }
-
- @Test
- public void testChefPutFail() throws IOException, IllegalStateException, IllegalArgumentException,
- ZoneException, APPCException {
- params.put("org.onap.appc.instance.chefAction", "/nodes/testnode");
- params.put("org.onap.appc.instance.runList", "recipe[commandtest]");
- params.put("org.onap.appc.instance.attributes", "");
- params.put("org.onap.appc.instance.chefRequestBody", "Test Body");
-
- givenParams(params, "chefPut");
- thenResponseShouldFail();
- }
-
- @Test
- public void testTriggerFail() throws IOException, IllegalStateException, IllegalArgumentException,
- ZoneException, APPCException {
- params.put("org.onap.appc.instance.ip", "");
-
- givenParams(params, "trigger");
- thenResponseShouldFail();
- }
-
- private void givenParams(Map adapterParams, String method) {
- svcContext = new SvcLogicContext();
- if (method == "chefGet"){
- adapter.chefGet(adapterParams, svcContext);
- getAttribute = "org.onap.appc.chefServerResult.code";
- }
- if (method == "chefPut"){
- adapter.chefPut(adapterParams, svcContext);
- getAttribute = "org.onap.appc.chefServerResult.code";
- }
- if (method == "trigger"){
- adapter.trigger(adapterParams, svcContext);
- getAttribute = "org.onap.appc.chefAgent.code";
- }
- }
-
- private void thenResponseShouldFail(){
- String status = svcContext.getAttribute(this.getAttribute);
- assertEquals("500", status);
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
deleted file mode 100644
index 13b5fdfb3..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.appc.test;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.appc.test.InterceptLogger;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
-/**
- * This class is used as a test harness to wrap the call to an executor node.
- */
-
-public class ExecutorHarness {
-
- /**
- * The executor to be tested
- */
- private SvcLogicJavaPlugin executor;
-
- /**
- * The collection of all exec methods found on the class
- */
- private Map methods;
-
- /**
- * The field of the class being tested that contains the reference to the logger to be used. This is modified to
- * point to our interception logger for the test.
- */
- private Field contextLogger;
-
- /**
- * The interception logger that buffers all messages logged and allows us to look at them as part of the test case.
- */
- private InterceptLogger logger;
-
- /**
- * Create the harness and initialize it
- *
- * @throws SecurityException
- * If a security manager, s, is present and any of the following conditions is met:
- *
- * - invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field
- * - the caller's class loader is not the same as or an ancestor of the class loader for the current
- * class and invocation of s.checkPackageAccess() denies access to the package of this class
- *
- * @throws NoSuchFieldException
- * if a field with the specified name is not found.
- * @throws IllegalAccessException
- * if this Field object is enforcing Java language access control and the underlying field is either
- * inaccessible or final.
- * @throws IllegalArgumentException
- * if the specified object is not an instance of the class or interface declaring the underlying field
- * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
- */
- @SuppressWarnings("nls")
- public ExecutorHarness() throws NoSuchFieldException, SecurityException, IllegalArgumentException,
- IllegalAccessException {
- methods = new HashMap<>();
- new SvcLogicContext();
-
- Class> contextClass = SvcLogicContext.class;
- contextLogger = contextClass.getDeclaredField("LOG");
- contextLogger.setAccessible(true);
- logger = new InterceptLogger();
- contextLogger.set(null, logger);
- }
-
- /**
- * Convenience constructor
- *
- * @param executor
- * The executor to be tested by the harness
- * @throws SecurityException
- * If a security manager, s, is present and any of the following conditions is met:
- *
- * - invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field
- * - the caller's class loader is not the same as or an ancestor of the class loader for the current
- * class and invocation of s.checkPackageAccess() denies access to the package of this class
- *
- * @throws NoSuchFieldException
- * if a field with the specified name is not found.
- * @throws IllegalAccessException
- * if this Field object is enforcing Java language access control and the underlying field is either
- * inaccessible or final.
- * @throws IllegalArgumentException
- * if the specified object is not an instance of the class or interface declaring the underlying field
- * (or a subclass or implementor thereof), or if an unwrapping conversion fails.
- */
- public ExecutorHarness(SvcLogicJavaPlugin executor) throws NoSuchFieldException, SecurityException,
- IllegalArgumentException, IllegalAccessException {
- this();
- setExecutor(executor);
- }
-
- /**
- * @param executor
- * The java plugin class to be executed
- */
- public void setExecutor(SvcLogicJavaPlugin executor) {
- this.executor = executor;
- scanExecutor();
- }
-
- /**
- * @return The java plugin class to be executed
- */
- public SvcLogicJavaPlugin getExecutor() {
- return executor;
- }
-
- /**
- * @return The set of all methods that meet the signature requirements
- */
- public List getExecMethodNames() {
- List names = new ArrayList<>();
- names.addAll(methods.keySet());
- return names;
- }
-
- /**
- * Returns an indication if the named method is a valid executor method that could be called from a DG execute node
- *
- * @param methodName
- * The method name to be validated
- * @return True if the method name meets the signature requirements, false if the method either does not exist or
- * does not meet the requirements.
- */
- public boolean isExecMethod(String methodName) {
- return methods.containsKey(methodName);
- }
-
- /**
- * This method scans the executor class hierarchy to locate all methods that match the required signature of the
- * executor and records these methods in a map.
- */
- private void scanExecutor() {
- methods.clear();
- Class> executorClass = executor.getClass();
- Method[] publicMethods = executorClass.getMethods();
- for (Method method : publicMethods) {
- if (method.getReturnType().equals(Void.class)) {
- Class>[] paramTypes = method.getParameterTypes();
- if (paramTypes.length == 2) {
- if (Map.class.isAssignableFrom(paramTypes[0])
- && SvcLogicContext.class.isAssignableFrom(paramTypes[1])) {
- methods.put(method.getName(), method);
- }
- }
- }
- }
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
deleted file mode 100644
index b101ecee4..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Copyright (C) 2017 Amdocs
- * =============================================================================
- * 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.
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.appc.test;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.slf4j.Marker;
-
-import ch.qos.logback.classic.Level;
-
-/**
- * This class is used as an intercept logger that can be used in testing to intercept and record all messages that are
- * logged, thus allowing a junit test case to examine the log output and make assertions.
- */
-public class InterceptLogger implements org.slf4j.Logger {
-
- /**
- * This inner class represents an intercepted log event
- */
- public class LogRecord {
- private Level level;
- private String message;
- private long timestamp;
- private Throwable t;
-
- public LogRecord(Level level, String message) {
- setLevel(level);
- setTimestamp(System.currentTimeMillis());
- setMessage(message);
- }
-
- public LogRecord(Level level, String message, Throwable t) {
- this(level, message);
- setThrowable(t);
- }
-
- /**
- * @return the value of level
- */
- public Level getLevel() {
- return level;
- }
-
- /**
- * @return the value of message
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * @return the value of timestamp
- */
- public long getTimestamp() {
- return timestamp;
- }
-
- /**
- * @param level
- * the value for level
- */
- public void setLevel(Level level) {
- this.level = level;
- }
-
- /**
- * @param message
- * the value for message
- */
- public void setMessage(String message) {
- this.message = message;
- }
-
- /**
- * @param timestamp
- * the value for timestamp
- */
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
- /**
- * @return the value of t
- */
- public Throwable getThrowable() {
- return t;
- }
-
- /**
- * @param t
- * the value for t
- */
- public void setThrowable(Throwable t) {
- this.t = t;
- }
-
- }
-
- /**
- * The list of all intercepted log events
- */
- private List events;
-
- /**
- * Create the intercept logger
- */
- public InterceptLogger() {
- events = new ArrayList(1000);
- }
-
- /**
- * @return Returns all intercepted log events
- */
- public List getLogRecords() {
- return events;
- }
-
- /**
- * Clears all log events
- */
- public void clear() {
- events.clear();
- }
-
- @Override
- public void debug(Marker marker, String msg) {
- debug(msg);
- }
-
- @Override
- public void debug(Marker marker, String format, Object arg) {
- debug(MessageFormat.format(format, arg));
- }
-
- @Override
- public void debug(Marker marker, String format, Object... arguments) {
- debug(MessageFormat.format(format, arguments));
- }
-
- @Override
- public void debug(Marker marker, String format, Object arg1, Object arg2) {
- debug(MessageFormat.format(format, arg1, arg2));
- }
-
- @Override
- public void debug(Marker marker, String msg, Throwable t) {
- debug(msg, t);
- }
-
- @Override
- public void debug(String msg) {
- events.add(new LogRecord(Level.DEBUG, msg));
- }
-
- @Override
- public void debug(String format, Object arg) {
- events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg)));
- }
-
- @Override
- public void debug(String format, Object... arguments) {
- events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arguments)));
- }
-
- @Override
- public void debug(String format, Object arg1, Object arg2) {
- events.add(new LogRecord(Level.DEBUG, MessageFormat.format(format, arg1, arg2)));
- }
-
- @Override
- public void debug(String msg, Throwable t) {
- events.add(new LogRecord(Level.DEBUG, msg, t));
- }
-
- @Override
- public void error(Marker marker, String msg) {
- error(msg);
- }
-
- @Override
- public void error(Marker marker, String format, Object arg) {
- error(format, arg);
- }
-
- @Override
- public void error(Marker marker, String format, Object... arguments) {
- error(format, arguments);
- }
-
- @Override
- public void error(Marker marker, String format, Object arg1, Object arg2) {
- error(format, arg1, arg2);
- }
-
- @Override
- public void error(Marker marker, String msg, Throwable t) {
- events.add(new LogRecord(Level.ERROR, msg, t));
- }
-
- @Override
- public void error(String msg) {
- events.add(new LogRecord(Level.ERROR, msg));
- }
-
- @Override
- public void error(String format, Object arg) {
- events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg)));
- }
-
- @Override
- public void error(String format, Object... arguments) {
- events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arguments)));
- }
-
- @Override
- public void error(String format, Object arg1, Object arg2) {
- events.add(new LogRecord(Level.ERROR, MessageFormat.format(format, arg1, arg2)));
- }
-
- @Override
- public void error(String msg, Throwable t) {
- events.add(new LogRecord(Level.ERROR, msg, t));
- }
-
- @Override
- public String getName() {
- return null;
- }
-
- @Override
- public void info(Marker marker, String msg) {
- info(msg);
- }
-
- @Override
- public void info(Marker marker, String format, Object arg) {
- info(format, arg);
- }
-
- @Override
- public void info(Marker marker, String format, Object... arguments) {
- info(format, arguments);
- }
-
- @Override
- public void info(Marker marker, String format, Object arg1, Object arg2) {
- info(format, arg1, arg2);
- }
-
- @Override
- public void info(Marker marker, String msg, Throwable t) {
- events.add(new LogRecord(Level.INFO, msg, t));
- }
-
- @Override
- public void info(String msg) {
- events.add(new LogRecord(Level.INFO, msg));
- }
-
- @Override
- public void info(String format, Object arg) {
- events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg)));
- }
-
- @Override
- public void info(String format, Object... arguments) {
- events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arguments)));
- }
-
- @Override
- public void info(String format, Object arg1, Object arg2) {
- events.add(new LogRecord(Level.INFO, MessageFormat.format(format, arg1, arg2)));
- }
-
- @Override
- public void info(String msg, Throwable t) {
- events.add(new LogRecord(Level.INFO, msg, t));
- }
-
- @Override
- public boolean isDebugEnabled() {
- return true;
- }
-
- @Override
- public boolean isDebugEnabled(Marker marker) {
- return true;
- }
-
- @Override
- public boolean isErrorEnabled() {
- return true;
- }
-
- @Override
- public boolean isErrorEnabled(Marker marker) {
- return true;
- }
-
- @Override
- public boolean isInfoEnabled() {
- return true;
- }
-
- @Override
- public boolean isInfoEnabled(Marker marker) {
- return true;
- }
-
- @Override
- public boolean isTraceEnabled() {
- return true;
- }
-
- @Override
- public boolean isTraceEnabled(Marker marker) {
- return true;
- }
-
- @Override
- public boolean isWarnEnabled() {
- return true;
- }
-
- @Override
- public boolean isWarnEnabled(Marker marker) {
- return true;
- }
-
- @Override
- public void trace(Marker marker, String msg) {
- trace(msg);
- }
-
- @Override
- public void trace(Marker marker, String format, Object arg) {
- trace(format, arg);
- }
-
- @Override
- public void trace(Marker marker, String format, Object... argArray) {
- trace(format, argArray);
- }
-
- @Override
- public void trace(Marker marker, String format, Object arg1, Object arg2) {
- trace(format, arg1, arg2);
- }
-
- @Override
- public void trace(Marker marker, String msg, Throwable t) {
- trace(msg, t);
- }
-
- @Override
- public void trace(String msg) {
- events.add(new LogRecord(Level.TRACE, msg));
- }
-
- @Override
- public void trace(String format, Object arg) {
- events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg)));
- }
-
- @Override
- public void trace(String format, Object... arguments) {
- events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arguments)));
- }
-
- @Override
- public void trace(String format, Object arg1, Object arg2) {
- events.add(new LogRecord(Level.TRACE, MessageFormat.format(format, arg1, arg2)));
- }
-
- @Override
- public void trace(String msg, Throwable t) {
- events.add(new LogRecord(Level.TRACE, msg, t));
- }
-
- @Override
- public void warn(Marker marker, String msg) {
- warn(msg);
- }
-
- @Override
- public void warn(Marker marker, String format, Object arg) {
- warn(format, arg);
- }
-
- @Override
- public void warn(Marker marker, String format, Object... arguments) {
- warn(format, arguments);
- }
-
- @Override
- public void warn(Marker marker, String format, Object arg1, Object arg2) {
- warn(format, arg1, arg2);
- }
-
- @Override
- public void warn(Marker marker, String msg, Throwable t) {
- events.add(new LogRecord(Level.WARN, msg, t));
- }
-
- @Override
- public void warn(String msg) {
- events.add(new LogRecord(Level.WARN, msg));
- }
-
- @Override
- public void warn(String format, Object arg) {
- events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg)));
- }
-
- @Override
- public void warn(String format, Object... arguments) {
- events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arguments)));
- }
-
- @Override
- public void warn(String format, Object arg1, Object arg2) {
- events.add(new LogRecord(Level.WARN, MessageFormat.format(format, arg1, arg2)));
- }
-
- @Override
- public void warn(String msg, Throwable t) {
- events.add(new LogRecord(Level.WARN, msg, t));
- }
-}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/onap/appc/default.properties b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..bb888132a
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/onap/appc/default.properties
@@ -0,0 +1,111 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# 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.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END=========================================================
+###
+
+#
+# Default properties for the APP-C Provider Adapter
+#
+# -------------------------------------------------------------------------------------------------
+#
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
+# to supply configuration options
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.onap.appc.resources=org/onap/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.onap.appc.provider.adaptor.name=org.onap.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.onap.appc.logging.file=org/onap/appc/logback.xml
+org.onap.appc.logging.path=${user.home};etc;../etc
+org.onap.appc.logger=org.onap.appc
+org.onap.appc.security.logger=org.onap.appc.security
+#
+# The minimum and maximum provider/tenant context pool sizes. Min=1 means that as soon
+# as the provider/tenant is referenced a Context is opened and added to the pool. Max=0
+# means that the upper bound on the pool is unbounded.
+org.onap.appc.provider.min.pool=1
+org.onap.appc.provider.max.pool=0
+
+#
+# The following properties are used to configure the retry logic for connection to the
+# IaaS provider(s). The retry delay property is the amount of time, in seconds, the
+# application waits between retry attempts. The retry limit is the number of retries
+# that are allowed before the request is failed.
+org.onap.appc.provider.retry.delay = 30
+org.onap.appc.provider.retry.limit = 10
+
+#
+# The trusted hosts list for SSL access when a certificate is not provided.
+#
+provider.trusted.hosts=*
+#
+# The amount of time, in seconds, to wait for a server state change (start->stop, stop->start, etc).
+# If the server does not change state to a valid state within the alloted time, the operation
+# fails.
+org.onap.appc.server.state.change.timeout=300
+#
+# The amount of time to wait, in seconds, between subsequent polls to the OpenStack provider
+# to refresh the status of a resource we are waiting on.
+#
+org.onap.appc.openstack.poll.interval=20
+#
+# The connection information to connect to the provider we are using. These properties
+# are "structured" properties, in that the name is a compound name, where the nodes
+# of the name can be ordered (1, 2, 3, ...). All of the properties with the same ordinal
+# position are defining the same entity. For example, provider1.type and provider1.name
+# are defining the same provider, whereas provider2.name and provider2.type are defining
+# the values for a different provider. Any number of providers can be defined in this
+# way.
+#
+
+# Don't change these 2 right now since they are hard coded in the DG
+#provider1.type=appc
+#provider1.name=appc
+
+#These you can change
+#provider1.identity=appc
+#provider1.tenant1.name=appc
+#provider1.tenant1.userid=appc
+#provider1.tenant1.password=appc
+
+# After a change to the provider make sure to recheck these values with an api call to provider1.identity/tokens
+test.expected-regions=1
+test.expected-endpoints=1
+
+#Your OpenStack IP
+#test.ip=192.168.1.2
+# Your OpenStack Platform's Keystone Port (default is 5000)
+#test.port=5000
+#test.tenantid=abcde12345fghijk6789lmnopq123rst
+#test.vmid=abc12345-1234-5678-890a-abcdefg12345
+# Port 8774 below is default port for OpenStack's Nova API Service
+#test.url=http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345
+
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index bb888132a..000000000
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,111 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP : APPC
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Copyright (C) 2017 Amdocs
-# =============================================================================
-# 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.
-#
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# ============LICENSE_END=========================================================
-###
-
-#
-# Default properties for the APP-C Provider Adapter
-#
-# -------------------------------------------------------------------------------------------------
-#
-# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
-# to supply configuration options
-org.onap.appc.bootstrap.file=appc.properties
-org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
-
-appc.application.name=APPC
-
-#
-# Define the message resource bundle name to be loaded
-org.onap.appc.resources=org/onap/appc/i18n/MessageResources
-#
-# The name of the adapter.
-org.onap.appc.provider.adaptor.name=org.onap.appc.appc_provider_adapter
-#
-# Set up the logging environment
-#
-org.onap.appc.logging.file=org/onap/appc/logback.xml
-org.onap.appc.logging.path=${user.home};etc;../etc
-org.onap.appc.logger=org.onap.appc
-org.onap.appc.security.logger=org.onap.appc.security
-#
-# The minimum and maximum provider/tenant context pool sizes. Min=1 means that as soon
-# as the provider/tenant is referenced a Context is opened and added to the pool. Max=0
-# means that the upper bound on the pool is unbounded.
-org.onap.appc.provider.min.pool=1
-org.onap.appc.provider.max.pool=0
-
-#
-# The following properties are used to configure the retry logic for connection to the
-# IaaS provider(s). The retry delay property is the amount of time, in seconds, the
-# application waits between retry attempts. The retry limit is the number of retries
-# that are allowed before the request is failed.
-org.onap.appc.provider.retry.delay = 30
-org.onap.appc.provider.retry.limit = 10
-
-#
-# The trusted hosts list for SSL access when a certificate is not provided.
-#
-provider.trusted.hosts=*
-#
-# The amount of time, in seconds, to wait for a server state change (start->stop, stop->start, etc).
-# If the server does not change state to a valid state within the alloted time, the operation
-# fails.
-org.onap.appc.server.state.change.timeout=300
-#
-# The amount of time to wait, in seconds, between subsequent polls to the OpenStack provider
-# to refresh the status of a resource we are waiting on.
-#
-org.onap.appc.openstack.poll.interval=20
-#
-# The connection information to connect to the provider we are using. These properties
-# are "structured" properties, in that the name is a compound name, where the nodes
-# of the name can be ordered (1, 2, 3, ...). All of the properties with the same ordinal
-# position are defining the same entity. For example, provider1.type and provider1.name
-# are defining the same provider, whereas provider2.name and provider2.type are defining
-# the values for a different provider. Any number of providers can be defined in this
-# way.
-#
-
-# Don't change these 2 right now since they are hard coded in the DG
-#provider1.type=appc
-#provider1.name=appc
-
-#These you can change
-#provider1.identity=appc
-#provider1.tenant1.name=appc
-#provider1.tenant1.userid=appc
-#provider1.tenant1.password=appc
-
-# After a change to the provider make sure to recheck these values with an api call to provider1.identity/tokens
-test.expected-regions=1
-test.expected-endpoints=1
-
-#Your OpenStack IP
-#test.ip=192.168.1.2
-# Your OpenStack Platform's Keystone Port (default is 5000)
-#test.port=5000
-#test.tenantid=abcde12345fghijk6789lmnopq123rst
-#test.vmid=abc12345-1234-5678-890a-abcdefg12345
-# Port 8774 below is default port for OpenStack's Nova API Service
-#test.url=http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345
-
--
cgit 1.2.3-korg