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
---
.../appc/adapter/ansible/AnsibleActivator.java | 126 +++
.../onap/appc/adapter/ansible/AnsibleAdapter.java | 60 ++
.../adapter/ansible/impl/AnsibleAdapterImpl.java | 501 ++++++++++++
.../adapter/ansible/impl/ConnectionBuilder.java | 224 +++++
.../ansible/model/AnsibleMessageParser.java | 364 +++++++++
.../appc/adapter/ansible/model/AnsibleResult.java | 87 ++
.../adapter/ansible/model/AnsibleResultCodes.java | 122 +++
.../ansible/model/AnsibleServerEmulator.java | 148 ++++
.../appc/adapter/ansible/AnsibleActivator.java | 126 ---
.../appc/adapter/ansible/AnsibleAdapter.java | 60 --
.../adapter/ansible/impl/AnsibleAdapterImpl.java | 501 ------------
.../adapter/ansible/impl/ConnectionBuilder.java | 224 -----
.../ansible/model/AnsibleMessageParser.java | 364 ---------
.../appc/adapter/ansible/model/AnsibleResult.java | 87 --
.../adapter/ansible/model/AnsibleResultCodes.java | 122 ---
.../ansible/model/AnsibleServerEmulator.java | 148 ----
.../resources/org/onap/appc/default.properties | 48 ++
.../org/openecomp/appc/default.properties | 48 --
.../ansible/impl/TestAnsibleAdapterImpl.java | 137 ++++
.../java/org/onap/appc/test/ExecutorHarness.java | 182 +++++
.../java/org/onap/appc/test/InterceptLogger.java | 454 +++++++++++
.../ansible/impl/TestAnsibleAdapterImpl.java | 137 ----
.../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 ---
.../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 ---
.../messaging/dmaap/AppcDmaapAdapterActivator.java | 106 +++
.../messaging/dmaap/http/CommonHttpClient.java | 108 +++
.../dmaap/http/HttpDmaapConsumerImpl.java | 167 ++++
.../dmaap/http/HttpDmaapProducerImpl.java | 138 ++++
.../messaging/dmaap/impl/DmaapConsumerImpl.java | 234 ++++++
.../messaging/dmaap/impl/DmaapProducerImpl.java | 223 +++++
.../adapter/messaging/dmaap/impl/DmaapUtil.java | 86 ++
.../messaging/dmaap/impl/EventSenderDmaapImpl.java | 178 ++++
.../messaging/dmaap/AppcDmaapAdapterActivator.java | 106 ---
.../messaging/dmaap/http/CommonHttpClient.java | 108 ---
.../dmaap/http/HttpDmaapConsumerImpl.java | 167 ----
.../dmaap/http/HttpDmaapProducerImpl.java | 138 ----
.../messaging/dmaap/impl/DmaapConsumerImpl.java | 234 ------
.../messaging/dmaap/impl/DmaapProducerImpl.java | 223 -----
.../adapter/messaging/dmaap/impl/DmaapUtil.java | 86 --
.../messaging/dmaap/impl/EventSenderDmaapImpl.java | 178 ----
.../resources/org/onap/appc/default.properties | 28 +
.../org/openecomp/appc/default.properties | 28 -
.../messaging/dmaap/SimpleExamplePublisher.java | 137 ++++
.../dmaap/TestAppcDmaapAdapterActivator.java | 50 ++
.../messaging/dmaap/TestDmaapConsuming.java | 87 ++
.../messaging/dmaap/TestDmaapEventSender.java | 172 ++++
.../messaging/dmaap/TestDmaapProducing.java | 83 ++
.../dmaap/impl/TestConsumerProducerImpl.java | 245 ++++++
.../messaging/dmaap/SimpleExamplePublisher.java | 137 ----
.../dmaap/TestAppcDmaapAdapterActivator.java | 50 --
.../messaging/dmaap/TestDmaapConsuming.java | 87 --
.../messaging/dmaap/TestDmaapEventSender.java | 172 ----
.../messaging/dmaap/TestDmaapProducing.java | 83 --
.../dmaap/impl/TestConsumerProducerImpl.java | 245 ------
.../resources/org/onap/appc/default.properties | 39 +
.../org/openecomp/appc/default.properties | 39 -
.../appc/adapter/message/CallableConsumer.java | 61 ++
.../org/onap/appc/adapter/message/Consumer.java | 73 ++
.../org/onap/appc/adapter/message/EventSender.java | 39 +
.../org/onap/appc/adapter/message/Manager.java | 48 ++
.../adapter/message/MessageAdapterFactory.java | 42 +
.../appc/adapter/message/MessageDestination.java | 29 +
.../org/onap/appc/adapter/message/Producer.java | 54 ++
.../appc/adapter/message/event/EventHeader.java | 66 ++
.../appc/adapter/message/event/EventMessage.java | 100 +++
.../appc/adapter/message/event/EventStatus.java | 58 ++
.../appc/adapter/message/CallableConsumer.java | 61 --
.../openecomp/appc/adapter/message/Consumer.java | 73 --
.../appc/adapter/message/EventSender.java | 39 -
.../openecomp/appc/adapter/message/Manager.java | 48 --
.../adapter/message/MessageAdapterFactory.java | 42 -
.../appc/adapter/message/MessageDestination.java | 29 -
.../openecomp/appc/adapter/message/Producer.java | 54 --
.../appc/adapter/message/event/EventHeader.java | 66 --
.../appc/adapter/message/event/EventMessage.java | 100 ---
.../appc/adapter/message/event/EventStatus.java | 58 --
.../resources/org/onap/appc/default.properties | 26 +
.../org/openecomp/appc/default.properties | 26 -
.../DmaapMessageAdapterFactoryActivator.java | 47 ++
.../factory/DmaapMessageAdapterFactoryImpl.java | 58 ++
.../onap/appc/adapter/factory/MessageService.java | 59 ++
.../DmaapMessageAdapterFactoryActivator.java | 47 --
.../factory/DmaapMessageAdapterFactoryImpl.java | 58 --
.../appc/adapter/factory/MessageService.java | 59 --
.../resources/org/onap/appc/default.properties | 26 +
.../org/openecomp/appc/default.properties | 26 -
.../adapter/iaas/AppcProviderAdapterActivator.java | 147 ++++
.../onap/appc/adapter/iaas/ProviderAdapter.java | 288 +++++++
.../onap/appc/adapter/iaas/impl/IdentityURL.java | 146 ++++
.../adapter/iaas/impl/ProviderAdapterImpl.java | 359 ++++++++
.../onap/appc/adapter/iaas/impl/ProviderCache.java | 165 ++++
.../appc/adapter/iaas/impl/RequestContext.java | 249 ++++++
.../adapter/iaas/impl/RequestFailedException.java | 255 ++++++
.../appc/adapter/iaas/impl/ServiceCatalog.java | 310 +++++++
.../adapter/iaas/impl/ServiceCatalogFactory.java | 70 ++
.../appc/adapter/iaas/impl/ServiceCatalogV2.java | 380 +++++++++
.../appc/adapter/iaas/impl/ServiceCatalogV3.java | 402 +++++++++
.../onap/appc/adapter/iaas/impl/TenantCache.java | 382 +++++++++
.../org/onap/appc/adapter/iaas/impl/VMURL.java | 175 ++++
.../provider/operation/api/IProviderOperation.java | 74 ++
.../operation/api/ProviderOperationFactory.java | 122 +++
.../operation/common/constants/Constants.java | 61 ++
.../operation/common/constants/Property.java | 41 +
.../provider/operation/common/enums/Operation.java | 96 +++
.../provider/operation/common/enums/Outcome.java | 41 +
.../provider/operation/impl/CreateSnapshot.java | 233 ++++++
.../provider/operation/impl/EvacuateServer.java | 355 ++++++++
.../iaas/provider/operation/impl/LookupServer.java | 121 +++
.../provider/operation/impl/MigrateServer.java | 240 ++++++
.../provider/operation/impl/RebuildServer.java | 434 ++++++++++
.../provider/operation/impl/RestartServer.java | 275 +++++++
.../iaas/provider/operation/impl/RestoreStack.java | 151 ++++
.../provider/operation/impl/SnapshotStack.java | 193 +++++
.../iaas/provider/operation/impl/StartServer.java | 184 +++++
.../iaas/provider/operation/impl/StopServer.java | 202 +++++
.../provider/operation/impl/TerminateServer.java | 245 ++++++
.../provider/operation/impl/TerminateStack.java | 128 +++
.../provider/operation/impl/VmStatuschecker.java | 159 ++++
.../operation/impl/base/ProviderOperation.java | 453 +++++++++++
.../impl/base/ProviderServerOperation.java | 560 +++++++++++++
.../impl/base/ProviderStackOperation.java | 194 +++++
.../adapter/openstack/heat/SnapshotResource.java | 75 ++
.../appc/adapter/openstack/heat/StackResource.java | 53 ++
.../openstack/heat/model/CreateSnapshotParams.java | 64 ++
.../appc/adapter/openstack/heat/model/Data.java | 229 ++++++
.../adapter/openstack/heat/model/Environment.java | 87 ++
.../adapter/openstack/heat/model/Metadata.java | 45 +
.../adapter/openstack/heat/model/Parameters.java | 45 +
.../adapter/openstack/heat/model/Properties.java | 64 ++
.../adapter/openstack/heat/model/ResourceData.java | 64 ++
.../openstack/heat/model/ResourceRegistry.java | 66 ++
.../adapter/openstack/heat/model/Resources.java | 45 +
.../adapter/openstack/heat/model/Resources_.java | 66 ++
.../adapter/openstack/heat/model/Resources__.java | 66 ++
.../adapter/openstack/heat/model/Snapshot.java | 166 ++++
.../openstack/heat/model/SnapshotDetails.java | 66 ++
.../heat/model/SnapshotRestoreResponse.java | 104 +++
.../adapter/openstack/heat/model/Template.java | 86 ++
.../appc/adapter/openstack/heat/model/Volume.java | 86 ++
.../appc/adapter/openstack/heat/model/Volume_.java | 187 +++++
.../org/onap/appc/adapter/utils/Constants.java | 34 +
.../adapter/iaas/AppcProviderAdapterActivator.java | 147 ----
.../appc/adapter/iaas/ProviderAdapter.java | 288 -------
.../appc/adapter/iaas/impl/IdentityURL.java | 146 ----
.../adapter/iaas/impl/ProviderAdapterImpl.java | 359 --------
.../appc/adapter/iaas/impl/ProviderCache.java | 165 ----
.../appc/adapter/iaas/impl/RequestContext.java | 249 ------
.../adapter/iaas/impl/RequestFailedException.java | 255 ------
.../appc/adapter/iaas/impl/ServiceCatalog.java | 310 -------
.../adapter/iaas/impl/ServiceCatalogFactory.java | 70 --
.../appc/adapter/iaas/impl/ServiceCatalogV2.java | 380 ---------
.../appc/adapter/iaas/impl/ServiceCatalogV3.java | 402 ---------
.../appc/adapter/iaas/impl/TenantCache.java | 382 ---------
.../openecomp/appc/adapter/iaas/impl/VMURL.java | 175 ----
.../provider/operation/api/IProviderOperation.java | 74 --
.../operation/api/ProviderOperationFactory.java | 122 ---
.../operation/common/constants/Constants.java | 61 --
.../operation/common/constants/Property.java | 41 -
.../provider/operation/common/enums/Operation.java | 96 ---
.../provider/operation/common/enums/Outcome.java | 41 -
.../provider/operation/impl/CreateSnapshot.java | 233 ------
.../provider/operation/impl/EvacuateServer.java | 355 --------
.../iaas/provider/operation/impl/LookupServer.java | 121 ---
.../provider/operation/impl/MigrateServer.java | 240 ------
.../provider/operation/impl/RebuildServer.java | 434 ----------
.../provider/operation/impl/RestartServer.java | 275 -------
.../iaas/provider/operation/impl/RestoreStack.java | 151 ----
.../provider/operation/impl/SnapshotStack.java | 193 -----
.../iaas/provider/operation/impl/StartServer.java | 184 -----
.../iaas/provider/operation/impl/StopServer.java | 202 -----
.../provider/operation/impl/TerminateServer.java | 245 ------
.../provider/operation/impl/TerminateStack.java | 128 ---
.../provider/operation/impl/VmStatuschecker.java | 159 ----
.../operation/impl/base/ProviderOperation.java | 453 -----------
.../impl/base/ProviderServerOperation.java | 560 -------------
.../impl/base/ProviderStackOperation.java | 194 -----
.../adapter/openstack/heat/SnapshotResource.java | 75 --
.../appc/adapter/openstack/heat/StackResource.java | 53 --
.../openstack/heat/model/CreateSnapshotParams.java | 64 --
.../appc/adapter/openstack/heat/model/Data.java | 229 ------
.../adapter/openstack/heat/model/Environment.java | 87 --
.../adapter/openstack/heat/model/Metadata.java | 45 -
.../adapter/openstack/heat/model/Parameters.java | 45 -
.../adapter/openstack/heat/model/Properties.java | 64 --
.../adapter/openstack/heat/model/ResourceData.java | 64 --
.../openstack/heat/model/ResourceRegistry.java | 66 --
.../adapter/openstack/heat/model/Resources.java | 45 -
.../adapter/openstack/heat/model/Resources_.java | 66 --
.../adapter/openstack/heat/model/Resources__.java | 66 --
.../adapter/openstack/heat/model/Snapshot.java | 166 ----
.../openstack/heat/model/SnapshotDetails.java | 66 --
.../heat/model/SnapshotRestoreResponse.java | 104 ---
.../adapter/openstack/heat/model/Template.java | 86 --
.../appc/adapter/openstack/heat/model/Volume.java | 86 --
.../appc/adapter/openstack/heat/model/Volume_.java | 187 -----
.../openecomp/appc/adapter/utils/Constants.java | 34 -
.../resources/org/onap/appc/default.properties | 112 +++
.../org/openecomp/appc/default.properties | 112 ---
.../appc/adapter/iaas/impl/TestIdentityUrl.java | 102 +++
.../adapter/iaas/impl/TestProviderAdapterImpl.java | 901 +++++++++++++++++++++
.../adapter/iaas/impl/TestProviderOperation.java | 162 ++++
.../appc/adapter/iaas/impl/TestRequestContext.java | 162 ++++
.../appc/adapter/iaas/impl/TestServiceCatalog.java | 105 +++
.../iaas/impl/TestServiceCatalogFactory.java | 89 ++
.../adapter/iaas/impl/TestServiceCatalogV2.java | 174 ++++
.../adapter/iaas/impl/TestServiceCatalogV3.java | 167 ++++
.../org/onap/appc/adapter/iaas/impl/TestVMURL.java | 130 +++
.../java/org/onap/appc/test/ExecutorHarness.java | 181 +++++
.../java/org/onap/appc/test/InterceptLogger.java | 449 ++++++++++
.../appc/adapter/iaas/impl/TestIdentityUrl.java | 102 ---
.../adapter/iaas/impl/TestProviderAdapterImpl.java | 901 ---------------------
.../adapter/iaas/impl/TestProviderOperation.java | 162 ----
.../appc/adapter/iaas/impl/TestRequestContext.java | 162 ----
.../appc/adapter/iaas/impl/TestServiceCatalog.java | 105 ---
.../iaas/impl/TestServiceCatalogFactory.java | 89 --
.../adapter/iaas/impl/TestServiceCatalogV2.java | 174 ----
.../adapter/iaas/impl/TestServiceCatalogV3.java | 167 ----
.../appc/adapter/iaas/impl/TestVMURL.java | 130 ---
.../org/openecomp/appc/test/ExecutorHarness.java | 181 -----
.../org/openecomp/appc/test/InterceptLogger.java | 449 ----------
.../resources/org/onap/appc/default.properties | 112 +++
.../org/openecomp/appc/default.properties | 112 ---
.../netconf/AppcNetconfAdapterActivator.java | 139 ++++
.../appc/adapter/netconf/ConnectionDetails.java | 67 ++
.../netconf/MockOperationalStateValidatorImpl.java | 48 ++
.../onap/appc/adapter/netconf/NetconfClient.java | 64 ++
.../appc/adapter/netconf/NetconfClientFactory.java | 43 +
.../adapter/netconf/NetconfClientRestconf.java | 68 ++
.../appc/adapter/netconf/NetconfClientType.java | 31 +
.../adapter/netconf/NetconfConnectionDetails.java | 95 +++
.../adapter/netconf/NetconfDataAccessService.java | 85 ++
.../adapter/netconf/OperationalStateValidator.java | 35 +
.../netconf/OperationalStateValidatorFactory.java | 55 ++
.../netconf/VNFOperationalStateValidatorImpl.java | 132 +++
.../org/onap/appc/adapter/netconf/VnfType.java | 58 ++
.../netconf/exception/DataAccessException.java | 47 ++
.../netconf/exception/NetconfDAOException.java | 47 ++
.../adapter/netconf/internal/NetconfAdapter.java | 132 +++
.../adapter/netconf/internal/NetconfAdapter2.java | 105 +++
.../netconf/internal/NetconfConstMessages.java | 56 ++
.../internal/NetconfDataAccessServiceImpl.java | 147 ++++
.../adapter/netconf/internal/NetconfMessage.java | 97 +++
.../onap/appc/adapter/netconf/jsch/JSchLogger.java | 63 ++
.../adapter/netconf/jsch/NetconfClientJsch.java | 170 ++++
.../odlconnector/NetconfClientRestconfImpl.java | 236 ++++++
.../onap/appc/adapter/netconf/util/Constants.java | 68 ++
.../netconf/AppcNetconfAdapterActivator.java | 139 ----
.../appc/adapter/netconf/ConnectionDetails.java | 67 --
.../netconf/MockOperationalStateValidatorImpl.java | 48 --
.../appc/adapter/netconf/NetconfClient.java | 64 --
.../appc/adapter/netconf/NetconfClientFactory.java | 43 -
.../adapter/netconf/NetconfClientRestconf.java | 68 --
.../appc/adapter/netconf/NetconfClientType.java | 31 -
.../adapter/netconf/NetconfConnectionDetails.java | 95 ---
.../adapter/netconf/NetconfDataAccessService.java | 85 --
.../adapter/netconf/OperationalStateValidator.java | 35 -
.../netconf/OperationalStateValidatorFactory.java | 55 --
.../netconf/VNFOperationalStateValidatorImpl.java | 132 ---
.../openecomp/appc/adapter/netconf/VnfType.java | 58 --
.../netconf/exception/DataAccessException.java | 47 --
.../netconf/exception/NetconfDAOException.java | 47 --
.../adapter/netconf/internal/NetconfAdapter.java | 132 ---
.../adapter/netconf/internal/NetconfAdapter2.java | 105 ---
.../netconf/internal/NetconfConstMessages.java | 56 --
.../internal/NetconfDataAccessServiceImpl.java | 147 ----
.../adapter/netconf/internal/NetconfMessage.java | 97 ---
.../appc/adapter/netconf/jsch/JSchLogger.java | 63 --
.../adapter/netconf/jsch/NetconfClientJsch.java | 170 ----
.../odlconnector/NetconfClientRestconfImpl.java | 236 ------
.../appc/adapter/netconf/util/Constants.java | 68 --
.../resources/org/onap/appc/default.properties | 44 +
.../org/openecomp/appc/default.properties | 44 -
.../netconf/internal/TestNetconfAdapter.java | 91 +++
.../adapter/netconf/jsch/TestGetRunningConfig.java | 63 ++
.../adapter/netconf/jsch/TestModifyConfig.java | 96 +++
.../adapter/netconf/jsch/TestModifyConfigMock.java | 96 +++
.../netconf/jsch/TestModifyConfigRouterMock.java | 94 +++
.../netconf/jsch/TestOperationalStates.java | 90 ++
.../netconf/internal/TestNetconfAdapter.java | 91 ---
.../adapter/netconf/jsch/TestGetRunningConfig.java | 63 --
.../adapter/netconf/jsch/TestModifyConfig.java | 96 ---
.../adapter/netconf/jsch/TestModifyConfigMock.java | 96 ---
.../netconf/jsch/TestModifyConfigRouterMock.java | 94 ---
.../netconf/jsch/TestOperationalStates.java | 90 --
.../org/onap/appc/adapter/rest/RequestFactory.java | 60 ++
.../org/onap/appc/adapter/rest/RestActivator.java | 145 ++++
.../org/onap/appc/adapter/rest/RestAdapter.java | 208 +++++
.../appc/adapter/rest/impl/RequestContext.java | 254 ++++++
.../adapter/rest/impl/RequestFailedException.java | 247 ++++++
.../appc/adapter/rest/impl/RestAdapterImpl.java | 244 ++++++
.../appc/adapter/rest/RequestFactory.java | 60 --
.../openecomp/appc/adapter/rest/RestActivator.java | 145 ----
.../openecomp/appc/adapter/rest/RestAdapter.java | 208 -----
.../appc/adapter/rest/impl/RequestContext.java | 254 ------
.../adapter/rest/impl/RequestFailedException.java | 247 ------
.../appc/adapter/rest/impl/RestAdapterImpl.java | 244 ------
.../resources/org/onap/appc/default.properties | 96 +++
.../org/openecomp/appc/default.properties | 96 ---
.../adapter/rest/impl/TestRestAdapterImpl.java | 140 ++++
.../java/org/onap/appc/test/ExecutorHarness.java | 183 +++++
.../java/org/onap/appc/test/InterceptLogger.java | 455 +++++++++++
.../adapter/rest/impl/TestRestAdapterImpl.java | 140 ----
.../org/openecomp/appc/test/ExecutorHarness.java | 183 -----
.../org/openecomp/appc/test/InterceptLogger.java | 455 -----------
.../resources/org/onap/appc/default.properties | 116 +++
.../org/openecomp/appc/default.properties | 116 ---
.../restHealthcheck/RestHealthcheckActivator.java | 116 +++
.../restHealthcheck/RestHealthcheckAdapter.java | 51 ++
.../restHealthcheck/impl/RequestContext.java | 249 ++++++
.../impl/RequestFailedException.java | 244 ++++++
.../impl/RestHealthcheckAdapterImpl.java | 311 +++++++
.../restHealthcheck/RestHealthcheckActivator.java | 116 ---
.../restHealthcheck/RestHealthcheckAdapter.java | 51 --
.../restHealthcheck/impl/RequestContext.java | 249 ------
.../impl/RequestFailedException.java | 244 ------
.../impl/RestHealthcheckAdapterImpl.java | 311 -------
.../resources/org/onap/appc/default.properties | 79 ++
.../org/openecomp/appc/default.properties | 79 --
.../impl/TestRestHealthcheckAdapterImpl.java | 119 +++
.../java/org/onap/appc/test/ExecutorHarness.java | 183 +++++
.../java/org/onap/appc/test/InterceptLogger.java | 455 +++++++++++
.../impl/TestRestHealthcheckAdapterImpl.java | 119 ---
.../org/openecomp/appc/test/ExecutorHarness.java | 183 -----
.../org/openecomp/appc/test/InterceptLogger.java | 455 -----------
.../resources/org/onap/appc/default.properties | 98 +++
.../org/openecomp/appc/default.properties | 98 ---
.../java/org/onap/appc/adapter/ssh/Constants.java | 120 +++
.../java/org/onap/appc/adapter/ssh/SshAdapter.java | 42 +
.../org/onap/appc/adapter/ssh/SshConnection.java | 75 ++
.../appc/adapter/ssh/SshConnectionDetails.java | 75 ++
.../appc/adapter/ssh/SshDataAccessException.java | 48 ++
.../appc/adapter/ssh/SshDataAccessService.java | 61 ++
.../org/onap/appc/adapter/ssh/SshException.java | 49 ++
.../org/openecomp/appc/adapter/ssh/Constants.java | 120 ---
.../org/openecomp/appc/adapter/ssh/SshAdapter.java | 42 -
.../openecomp/appc/adapter/ssh/SshConnection.java | 75 --
.../appc/adapter/ssh/SshConnectionDetails.java | 75 --
.../appc/adapter/ssh/SshDataAccessException.java | 48 --
.../appc/adapter/ssh/SshDataAccessService.java | 61 --
.../openecomp/appc/adapter/ssh/SshException.java | 49 --
.../onap/appc/adapter/ssh/sshd/SshAdapterSshd.java | 36 +
.../appc/adapter/ssh/sshd/SshConnectionSshd.java | 236 ++++++
.../adapter/ssh/sshd/SshdDataAccessService.java | 106 +++
.../appc/adapter/ssh/sshd/SshAdapterSshd.java | 36 -
.../appc/adapter/ssh/sshd/SshConnectionSshd.java | 236 ------
.../adapter/ssh/sshd/SshdDataAccessService.java | 106 ---
.../appc/adapter/ssh/sshd/SshAdapterSample.java | 59 ++
.../onap/appc/adapter/ssh/sshd/SshAdapterTest.java | 250 ++++++
.../appc/adapter/ssh/sshd/SshAdapterSample.java | 59 --
.../appc/adapter/ssh/sshd/SshAdapterTest.java | 250 ------
.../org/onap/appc/adapter/ssh/SshAdapterMock.java | 75 ++
.../onap/appc/adapter/ssh/SshConnectionMock.java | 163 ++++
.../openecomp/appc/adapter/ssh/SshAdapterMock.java | 75 --
.../appc/adapter/ssh/SshConnectionMock.java | 163 ----
390 files changed, 28642 insertions(+), 28642 deletions(-)
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/ConnectionBuilder.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResult.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResultCodes.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleServerEmulator.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleActivator.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleAdapter.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/ConnectionBuilder.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleMessageParser.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResult.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResultCodes.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleServerEmulator.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
create mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
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
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapUtil.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapUtil.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapConsuming.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapEventSender.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapProducing.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapConsuming.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapEventSender.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapProducing.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/CallableConsumer.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Consumer.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/EventSender.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Manager.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageAdapterFactory.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageDestination.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Producer.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventHeader.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventMessage.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventStatus.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/CallableConsumer.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Consumer.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/EventSender.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Manager.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageAdapterFactory.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageDestination.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Producer.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventHeader.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventMessage.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventStatus.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/MessageService.java
create mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/AppcProviderAdapterActivator.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/IdentityURL.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderCache.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/RequestContext.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/RequestFailedException.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ServiceCatalog.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ServiceCatalogFactory.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ServiceCatalogV2.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ServiceCatalogV3.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/TenantCache.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/VMURL.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/IProviderOperation.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/constants/Constants.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/constants/Property.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Operation.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/common/enums/Outcome.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/LookupServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/MigrateServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RebuildServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RestartServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/RestoreStack.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/StartServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/StopServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/TerminateServer.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/TerminateStack.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/base/ProviderOperation.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/base/ProviderServerOperation.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/base/ProviderStackOperation.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/SnapshotResource.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/StackResource.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/CreateSnapshotParams.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Data.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Environment.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Metadata.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Parameters.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Properties.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/ResourceData.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/ResourceRegistry.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Resources.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Resources_.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Resources__.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Snapshot.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/SnapshotDetails.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Template.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Volume.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/openstack/heat/model/Volume_.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/utils/Constants.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/ProviderAdapter.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderAdapterImpl.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderCache.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestContext.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestFailedException.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalog.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogFactory.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV2.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalogV3.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/TenantCache.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/api/IProviderOperation.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/api/ProviderOperationFactory.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/constants/Constants.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/constants/Property.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/enums/Operation.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/common/enums/Outcome.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/LookupServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/MigrateServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RebuildServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestartServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestoreStack.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StartServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StopServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateServer.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateStack.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/base/ProviderOperation.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/base/ProviderServerOperation.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/base/ProviderStackOperation.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/SnapshotResource.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/StackResource.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/CreateSnapshotParams.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Data.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Environment.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Metadata.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Parameters.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Properties.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceData.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceRegistry.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources_.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources__.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Snapshot.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotDetails.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Template.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume_.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/utils/Constants.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestIdentityUrl.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestProviderOperation.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestRequestContext.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestServiceCatalog.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestServiceCatalogFactory.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestServiceCatalogV2.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestServiceCatalogV3.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/adapter/iaas/impl/TestVMURL.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderOperation.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogFactory.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV2.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalogV3.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
create mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/AppcNetconfAdapterActivator.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/ConnectionDetails.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/MockOperationalStateValidatorImpl.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClient.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientFactory.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientRestconf.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfClientType.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfConnectionDetails.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/NetconfDataAccessService.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidator.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/OperationalStateValidatorFactory.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/VnfType.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/DataAccessException.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/exception/NetconfDAOException.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfAdapter2.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfConstMessages.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfMessage.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/JSchLogger.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/jsch/NetconfClientJsch.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/util/Constants.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfAdapter.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestGetRunningConfig.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfig.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigMock.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestOperationalStates.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/RequestFactory.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/RestActivator.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/RestAdapter.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RequestContext.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RequestFailedException.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/impl/RestAdapterImpl.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RequestFactory.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestActivator.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestAdapter.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestContext.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestFailedException.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RestAdapterImpl.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/adapter/rest/impl/TestRestAdapterImpl.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/adapter/rest/impl/TestRestAdapterImpl.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
create mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckAdapter.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestContext.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RequestFailedException.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/openecomp/appc/adapter/restHealthcheck/RestHealthcheckActivator.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/openecomp/appc/adapter/restHealthcheck/RestHealthcheckAdapter.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/openecomp/appc/adapter/restHealthcheck/impl/RequestContext.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/openecomp/appc/adapter/restHealthcheck/impl/RequestFailedException.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/openecomp/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/adapter/restHealthcheck/impl/TestRestHealthcheckAdapterImpl.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/openecomp/appc/adapter/restHealthcheck/impl/TestRestHealthcheckAdapterImpl.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
create mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/resources/org/onap/appc/default.properties
delete mode 100644 appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/Constants.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/SshAdapter.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/SshConnection.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/SshConnectionDetails.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/SshDataAccessException.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/SshDataAccessService.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/SshException.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/Constants.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapter.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnection.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionDetails.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessException.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessService.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshException.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshAdapterSshd.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshConnectionSshd.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessService.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSshd.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshConnectionSshd.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshdDataAccessService.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshAdapterSample.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshAdapterTest.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSample.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterTest.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/onap/appc/adapter/ssh/SshAdapterMock.java
create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/onap/appc/adapter/ssh/SshConnectionMock.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapterMock.java
delete mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionMock.java
(limited to 'appc-adapters')
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java
new file mode 100644
index 000000000..d76cd50f1
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleActivator.java
@@ -0,0 +1,126 @@
+/*-
+ * ============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.ansible;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.ansible.impl.AnsibleAdapterImpl;
+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;
+
+/**
+ * This activator is used to initialize and terminate an instance of AnsibleAdapter class
+ */
+public class AnsibleActivator implements BundleActivator {
+
+ /**
+ * The bundle registration
+ */
+ private ServiceRegistration registration = null;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private AnsibleAdapter adapter;
+
+ /**
+ * The logger to be used
+ */
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(AnsibleActivator.class);
+
+ /**
+ * The configuration object used to configure this bundle
+ */
+ private final Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ /**
+ * 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());
+ String appName = "APPC: ";
+ logger.info(Msg.COMPONENT_INITIALIZING, appName, "Ansible Adapter");
+ adapter = new AnsibleAdapterImpl();
+
+ if (registration == null) {
+ logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
+ AnsibleAdapter.class.getSimpleName());
+ registration = context.registerService(AnsibleAdapter.class, adapter, null);
+ }
+
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, "Ansible 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, "Ansible adapter");
+ logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
+ registration.unregister();
+ registration = null;
+ logger.info(Msg.COMPONENT_TERMINATED, appName, "Ansible adapter");
+ }
+ }
+
+ public String getName() {
+ return "APPC Ansible Adapter";
+ }
+}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java
new file mode 100644
index 000000000..7bff184bc
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/AnsibleAdapter.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.ansible;
+
+import java.util.Map;
+
+import org.onap.appc.exceptions.APPCException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+/**
+ * This interface defines the operations that the Ansible adapter exposes.
+ *
+ */
+public interface AnsibleAdapter extends SvcLogicJavaPlugin {
+
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ */
+ String getAdapterName();
+
+
+ /* Method to post request for execution of Playbook */
+ void reqExec(Map params, SvcLogicContext ctx) throws SvcLogicException;
+
+ /* Method to get result of a playbook execution request */
+ void reqExecResult(Map params, SvcLogicContext ctx) throws SvcLogicException;
+
+
+ /* Method to get log of a playbook execution request */
+ void reqExecLog(Map params, SvcLogicContext ctx) throws SvcLogicException;
+
+
+}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
new file mode 100644
index 000000000..0b426bb26
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
@@ -0,0 +1,501 @@
+/*-
+ * ============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.ansible.impl;
+
+import java.util.Map;
+import java.util.Properties;
+import java.lang.*;
+
+
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.exceptions.APPCException;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+
+
+import org.json.JSONObject;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+
+
+import org.onap.appc.adapter.ansible.AnsibleAdapter;
+
+import org.onap.appc.adapter.ansible.model.AnsibleResult;
+import org.onap.appc.adapter.ansible.model.AnsibleMessageParser;
+import org.onap.appc.adapter.ansible.model.AnsibleResultCodes;
+import org.onap.appc.adapter.ansible.model.AnsibleServerEmulator;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import static com.att.eelf.configuration.Configuration.*;
+
+
+/**
+ * This class implements the {@link AnsibleAdapter} interface. This interface
+ * defines the behaviors that our service provides.
+ *
+ */
+public class AnsibleAdapterImpl implements AnsibleAdapter {
+
+ /**
+ * The constant used to define the adapter name in the mapped diagnostic
+ * context
+ */
+
+
+ @SuppressWarnings("nls")
+ public static final String MDC_ADAPTER = "Ansible Adapter";
+
+ /**
+ * The constant used to define the service name in the mapped diagnostic
+ * context
+ */
+ @SuppressWarnings("nls")
+ public static final String MDC_SERVICE = "service";
+
+ /**
+ * The constant for the status code for a failed outcome
+ */
+ @SuppressWarnings("nls")
+ public static final String OUTCOME_FAILURE = "failure";
+
+ /**
+ * The constant for the status code for a successful outcome
+ */
+ @SuppressWarnings("nls")
+ public static final String OUTCOME_SUCCESS = "success";
+
+ /**
+ Adapter Name
+ **/
+ private static final String ADAPTER_NAME = "Ansible Adapter";
+
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(AnsibleAdapterImpl.class);
+
+ /**
+ * A reference to the adapter configuration object.
+ */
+ private Configuration configuration;;
+
+ /** can Specify a X509 certificate file for use if required ...
+ Must be initialized with setCertFile
+ **/
+ private String certFile = "";
+
+
+ /**
+ * Connection object
+ **/
+ ConnectionBuilder http_client ;
+
+ /**
+ * Ansible API Message Handlers
+ **/
+ private AnsibleMessageParser messageProcessor;
+
+ /**
+ indicator whether in test mode
+ **/
+ private boolean testMode = false;
+
+ /**
+ server emulator object to be used if in test mode
+ **/
+ private AnsibleServerEmulator testServer;
+
+ /**
+ * This default constructor is used as a work around because the activator
+ * wasnt getting called
+ */
+ public AnsibleAdapterImpl() {
+ initialize();
+ }
+
+
+ /**
+ * @param props
+ * not used
+ */
+ public AnsibleAdapterImpl(Properties props) {
+ initialize();
+ }
+
+
+
+ /**
+ Used for jUnit test and testing interface
+ **/
+ public AnsibleAdapterImpl(boolean Mode){
+ testMode = Mode;
+ testServer = new AnsibleServerEmulator();
+ messageProcessor = new AnsibleMessageParser();
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.onap.appc.adapter.rest.AnsibleAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return ADAPTER_NAME;
+ }
+
+
+
+ /**
+ * @param rc
+ * Method posts info to Context memory in case of an error
+ * and throws a SvcLogicException causing SLI to register this as a failure
+ */
+ @SuppressWarnings("static-method")
+ private void doFailure(SvcLogicContext svcLogic, int code, String message) throws SvcLogicException {
+
+ svcLogic.setStatus(OUTCOME_FAILURE);
+ svcLogic.setAttribute("org.onap.appc.adapter.ansible.result.code",Integer.toString(code));
+ svcLogic.setAttribute("org.onap.appc.adapter.ansible.message",message);
+
+ throw new SvcLogicException("Ansible Adapter Error = " + message );
+ }
+
+
+ /**
+ * initialize the Ansible adapter based on default and over-ride configuration data
+ */
+ private void initialize() {
+
+ configuration = ConfigurationFactory.getConfiguration();
+ Properties props = configuration.getProperties();
+
+ // Create the message processor instance
+ messageProcessor = new AnsibleMessageParser();
+
+ // Create the http client instance
+ // type of client is extracted from the property file parameter
+ // org.onap.appc.adapter.ansible.clientType
+ // It can be :
+ // 1. TRUST_ALL (trust all SSL certs). To be used ONLY in dev
+ // 2. TRUST_CERT (trust only those whose certificates have been stored in the trustStore file)
+ // 3. DEFAULT (trust only well known certificates). This is standard behaviour to which it will
+ // revert. To be used in PROD
+
+ try{
+ String clientType = props.getProperty("org.onap.appc.adapter.ansible.clientType");
+ logger.info("Ansible http client type set to " + clientType);
+
+ if (clientType.equals("TRUST_ALL")){
+ logger.info("Creating http client to trust ALL ssl certificates. WARNING. This should be done only in dev environments");
+ http_client = new ConnectionBuilder(1);
+ }
+ else if (clientType.equals("TRUST_CERT")){
+ // set path to keystore file
+ String trustStoreFile = props.getProperty("org.onap.appc.adapter.ansible.trustStore");
+ String key = props.getProperty("org.onap.appc.adapter.ansible.trustStore.trustPasswd");
+ char [] trustStorePasswd = key.toCharArray();
+ String trustStoreType = "JKS";
+ logger.info("Creating http client with trustmanager from " + trustStoreFile);
+ http_client = new ConnectionBuilder(trustStoreFile, trustStorePasswd);
+ }
+ else{
+ logger.info("Creating http client with default behaviour");
+ http_client = new ConnectionBuilder(0);
+ }
+ }
+ catch (Exception e){
+ logger.error("Error Initializing Ansible Adapter due to Unknown Exception: reason = " + e.getMessage());
+ }
+
+ logger.info("Intitialized Ansible Adapter");
+
+ }
+
+
+ /** set the certificate file if not a trusted/known CA **/
+ private void setCertFile(String CertFile){
+ this.certFile = CertFile;
+ }
+
+
+
+ // Public Method to post request to execute playbook. Posts the following back
+ // to Svc context memory
+ // org.onap.appc.adapter.ansible.req.code : 100 if successful
+ // org.onap.appc.adapter.ansible.req.messge : any message
+ // org.onap.appc.adapter.ansible.req.Id : a unique uuid to reference the request
+
+ public void reqExec(Map params, SvcLogicContext ctx) throws SvcLogicException {
+
+ String PlaybookName = "";
+ String payload = "";
+ String AgentUrl = "";
+ String User = "";
+ String Password = "";
+ String Id = "";
+
+ JSONObject JsonPayload;
+
+ try{
+ // create json object to send request
+ JsonPayload = messageProcessor.ReqMessage(params);
+
+ AgentUrl = (String) JsonPayload.remove("AgentUrl");
+ User = (String) JsonPayload.remove("User");
+ Password = (String) JsonPayload.remove("Password");
+ Id = (String)JsonPayload.getString("Id");
+ payload = JsonPayload.toString();
+ logger.info("Updated Payload = " + payload);
+ }
+ catch(APPCException e){
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request for execution of playbook due to missing mandatory parameters. Reason = " + e.getMessage());
+ }
+ catch(JSONException e){
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request for execution of playbook due to invalid JSON block. Reason = " + e.getMessage());
+ }
+ catch(NumberFormatException e){
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request for execution of playbook due to invalid parameter values. Reason = " + e.getMessage());
+ }
+
+
+
+ int code = -1;
+ String message = "";
+
+ try{
+
+ // post the test request
+ //---------------------------------------
+ logger.info("Posting request = " + payload + " to url = " + AgentUrl );
+ AnsibleResult testresult = postExecRequest(AgentUrl, payload, User, Password);
+
+
+ // Process if HTTP was successfull
+ if(testresult.getStatusCode() == 200){
+ testresult = messageProcessor.parsePostResponse(testresult.getStatusMessage());
+ }
+ else{
+ doFailure(ctx, testresult.getStatusCode(), "Error posting request. Reason = " + testresult.getStatusMessage());
+ }
+
+
+ code = testresult.getStatusCode();
+ message = testresult.getStatusMessage();
+
+
+ // Check status of test request returned by Agent
+ //-----------------------------------------------
+ if (code == AnsibleResultCodes.PENDING.getValue()){
+ logger.info(String.format("Submission of Test %s successful.", PlaybookName));
+ // test request accepted. We are in asynchronous case
+ }
+ else{
+ doFailure(ctx, code, "Request for execution of playbook rejected. Reason = " + message);
+ }
+ }
+
+ catch(APPCException e){
+ doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(), "Exception encountered when posting request for execution of playbook. Reason = " + e.getMessage());
+ }
+
+
+ ctx.setAttribute("org.onap.appc.adapter.ansible.result.code", Integer.toString(code));
+ ctx.setAttribute("org.onap.appc.adapter.ansible.message", message );
+ ctx.setAttribute("org.onap.appc.adapter.ansible.Id", Id);
+
+ }
+
+
+ // Public method to query status of a specific request
+ // It blocks till the Ansible Server responds or the session times out
+
+ public void reqExecResult(Map params, SvcLogicContext ctx) throws SvcLogicException {
+
+
+ // Get uri
+ String ReqUri = "";
+
+ try{
+ ReqUri = messageProcessor.ReqUri_Result(params);
+ System.out.println("Got uri = " + ReqUri);
+ }
+ catch(APPCException e){
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request to retreive result due to missing parameters. Reason = " + e.getMessage());
+ return;
+ }
+ catch(NumberFormatException e){
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request to retreive result due to invalid parameters value. Reason = " + e.getMessage());
+ return;
+ }
+
+ int code = -1;
+ String message = "";
+ String results = "";
+
+ try{
+ // Try to retreive the test results (modify the url for that)
+ AnsibleResult testresult = queryServer(ReqUri, params.get("User"), params.get("Password"));
+ code = testresult.getStatusCode();
+ message = testresult.getStatusMessage();
+
+ if(code == 200){
+ logger.info("Parsing response from Server = " + message);
+ // Valid HTTP. process the Ansible message
+ testresult = messageProcessor.parseGetResponse(message);
+ code = testresult.getStatusCode();
+ message = testresult.getStatusMessage();
+ results = testresult.getResults();
+
+ }
+
+ logger.info("Request response = " + message);
+
+ }
+ catch (APPCException e){
+ doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(), "Exception encountered retreiving result : " + e.getMessage());
+ return;
+ }
+
+ // We were able to get and process the results. Determine if playbook succeeded
+
+ if (code == AnsibleResultCodes.FINAL_SUCCESS.getValue()){
+ message = String.format("Ansible Request %s finished with Result = %s, Message = %s", params.get("Id"), OUTCOME_SUCCESS, message);
+ logger.info(message);
+ }
+ else {
+ logger.info(String.format("Ansible Request %s finished with Result %s, Message = %s", params.get("Id"), OUTCOME_FAILURE, message));
+ ctx.setAttribute("org.onap.appc.adapter.ansible.results", results);
+ doFailure(ctx, code, message );
+ return;
+ }
+
+
+ ctx.setAttribute("org.onap.appc.adapter.ansible.result.code", Integer.toString(400));
+ ctx.setAttribute("org.onap.appc.adapter.ansible.message",message);
+ ctx.setAttribute("org.onap.appc.adapter.ansible.results", results);
+ ctx.setStatus(OUTCOME_SUCCESS);
+ }
+
+
+ // Public method to get logs from plyabook execution for a specifcic request
+ // It blocks till the Ansible Server responds or the session times out
+ // very similar to reqExecResult
+ // logs are returned in the DG context variable org.onap.appc.adapter.ansible.log
+
+ public void reqExecLog(Map params, SvcLogicContext ctx) throws SvcLogicException{
+
+
+ // Get uri
+ String ReqUri = "";
+ try{
+ ReqUri = messageProcessor.ReqUri_Log(params);
+ logger.info("Retreiving results from " + ReqUri);
+ }
+ catch(Exception e){
+ doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), e.getMessage());
+ }
+
+ int code = -1;
+ String message = "";
+ float Duration = -1;
+
+ try{
+ // Try to retreive the test results (modify the url for that)
+ AnsibleResult testresult = queryServer(ReqUri, params.get("User"), params.get("Password"));
+ code = testresult.getStatusCode();
+ message = testresult.getStatusMessage();
+
+ logger.info("Request output = " + message);
+
+ }
+ catch (Exception e){
+ doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(), "Exception encountered retreiving output : " + e.getMessage());
+ }
+
+ ctx.setAttribute("org.onap.appc.adapter.ansible.log",message);
+ ctx.setStatus(OUTCOME_SUCCESS);
+ }
+
+
+
+
+
+ /**
+ * Method that posts the request
+ **/
+
+ private AnsibleResult postExecRequest(String AgentUrl, String Payload, String User, String Password) {
+
+ String reqOutput = "UNKNOWN";
+ int reqStatus = -1;
+
+ AnsibleResult testresult;
+
+ if (!testMode){
+ http_client.setHttpContext(User, Password);
+ testresult = http_client.Post(AgentUrl, Payload);
+ }
+ else{
+ testresult = testServer.Post(AgentUrl, Payload);
+ }
+
+ return testresult;
+ }
+
+
+ /*
+ Method to query Ansible server
+
+ */
+ private AnsibleResult queryServer(String AgentUrl, String User, String Password) {
+
+ String testOutput = "UNKNOWN";
+ int testStatus = -1;
+ AnsibleResult testresult;
+
+ logger.info("Querying url = " + AgentUrl);
+
+ if (!testMode){
+ testresult = http_client.Get(AgentUrl);
+ }
+ else{
+ testresult = testServer.Get(AgentUrl);
+ }
+
+ return testresult;
+
+ }
+
+
+
+}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/ConnectionBuilder.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/ConnectionBuilder.java
new file mode 100644
index 000000000..e84a85a0c
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/ConnectionBuilder.java
@@ -0,0 +1,224 @@
+/*-
+ * ============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.ansible.impl;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.entity.StringEntity;
+
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.cert.CertificateException;
+import java.security.KeyManagementException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.NoSuchAlgorithmException;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLContext;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContexts;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+
+
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.adapter.ansible.model.AnsibleResult;
+import org.onap.appc.adapter.ansible.model.AnsibleResultCodes;
+
+
+/**
+ * Returns custom http client
+ - based on options
+ - can create one with ssl using an X509 certificate that does NOT have a known CA
+ - create one which trusts ALL SSL certificates
+ - return default httpclient (which only trusts known CAs from default cacerts file for process) -- this is the default option
+
+**/
+
+
+public class ConnectionBuilder {
+
+
+
+ private CloseableHttpClient http_client = null;
+ private HttpClientContext http_context = new HttpClientContext();
+
+
+
+
+ // Various constructors depending on how we want to instantiate the http ConnectionBuilder instance
+
+
+ /**
+ * Constructor that initializes an http client based on certificate
+ **/
+ public ConnectionBuilder(String CertFile) throws KeyStoreException, CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, APPCException{
+
+
+ /* Point to the certificate */
+ FileInputStream fs = new FileInputStream(CertFile);
+
+ /* Generate a certificate from the X509 */
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate)cf.generateCertificate(fs);
+
+ /* Create a keystore object and load the certificate there */
+ KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
+ keystore.load(null, null);
+ keystore.setCertificateEntry("cacert", cert);
+
+
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+ http_client = HttpClients.custom().setSSLSocketFactory(factory).build();
+ };
+
+
+ /**
+ * Constructor which trusts all certificates in a specific java keystore file (assumes a JKS file)
+ **/
+ public ConnectionBuilder(String trustStoreFile, char[] trustStorePasswd) throws KeyStoreException, IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException {
+
+
+ /* Load the specified trustStore */
+ KeyStore keystore = KeyStore.getInstance("JKS");
+ FileInputStream readStream = new FileInputStream(trustStoreFile);
+ keystore.load(readStream,trustStorePasswd);
+
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+ http_client = HttpClients.custom().setSSLSocketFactory(factory).build();
+ };
+
+ /**
+ * Constructor that trusts ALL SSl certificates (NOTE : ONLY FOR DEV TESTING) if Mode == 1
+ or Default if Mode == 0
+ */
+ public ConnectionBuilder(int Mode) throws SSLException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException{
+ if (Mode == 1){
+ SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
+ SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+
+ http_client = HttpClients.custom().setSSLSocketFactory(factory).build();
+ }
+
+ else{
+ http_client = HttpClients.createDefault();
+ }
+
+ };
+
+
+ // Use to create an http context with auth headers
+ public void setHttpContext(String User, String MyPassword){
+
+ // Are credential provided ? If so, set the context to be used
+ if (User != null && ! User.isEmpty() && MyPassword != null && ! MyPassword.isEmpty()){
+ UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(User, MyPassword);
+ AuthScope authscope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
+ BasicCredentialsProvider credsprovider = new BasicCredentialsProvider();
+ credsprovider.setCredentials(authscope, credentials);
+ http_context.setCredentialsProvider(credsprovider);
+ }
+
+
+ };
+
+
+ // Method posts to the ansible server and writes out response to
+ // Ansible result object
+ public AnsibleResult Post(String AgentUrl, String Payload){
+
+ AnsibleResult result = new AnsibleResult();
+ try{
+
+ HttpPost postObj = new HttpPost(AgentUrl);
+ StringEntity bodyParams = new StringEntity(Payload, "UTF-8");
+ postObj.setEntity(bodyParams);
+ postObj.addHeader("Content-type", "application/json");
+
+ HttpResponse response = http_client.execute(postObj, http_context);
+
+ HttpEntity entity = response.getEntity();
+ String responseOutput = entity != null ? EntityUtils.toString(entity) : null;
+ int responseCode = response.getStatusLine().getStatusCode();
+ result.setStatusCode(responseCode);
+ result.setStatusMessage(responseOutput);
+ }
+
+ catch(IOException io){
+ result.setStatusCode(AnsibleResultCodes.IO_EXCEPTION.getValue());
+ result.setStatusMessage(io.getMessage());
+ }
+
+
+
+ return result;
+
+ }
+
+ // Method gets information from an Ansible server and writes out response to
+ // Ansible result object
+
+ public AnsibleResult Get(String AgentUrl){
+
+ AnsibleResult result = new AnsibleResult();
+
+ try{
+ HttpGet getObj = new HttpGet(AgentUrl );
+ HttpResponse response = http_client.execute(getObj, http_context);
+
+
+ HttpEntity entity = response.getEntity();
+ String responseOutput = entity != null ? EntityUtils.toString(entity) : null;
+ int responseCode = response.getStatusLine().getStatusCode();
+ result.setStatusCode(responseCode);
+ result.setStatusMessage(responseOutput);
+
+ }
+ catch(IOException io){
+ result.setStatusCode(AnsibleResultCodes.IO_EXCEPTION.getValue());
+ result.setStatusMessage(io.getMessage());
+ }
+
+ return result;
+ };
+
+}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java
new file mode 100644
index 000000000..6bebd73fe
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleMessageParser.java
@@ -0,0 +1,364 @@
+/*-
+ * ============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.ansible.model;
+
+/**
+ * This module imples the APP-C/Ansible Server interface
+ * based on the REST API specifications
+ */
+
+import java.lang.NumberFormatException ;
+import java.util.*;
+import com.google.common.base.Strings;
+
+import org.json.JSONObject;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.adapter.ansible.model.AnsibleResult;
+
+
+/**
+ * Class that validates and constructs requests sent/received from
+ * Ansible Server
+ *
+ */
+public class AnsibleMessageParser {
+
+
+
+
+ // Accepts a map of strings and
+ // a) validates if all parameters are appropriate (else, throws an exception)
+ // and b) if correct returns a JSON object with appropriate key-value
+ // pairs to send to the server.
+ public JSONObject ReqMessage(Map params) throws APPCException, NumberFormatException, JSONException{
+
+ // Mandatory parameters, that must be in the supplied information to the Ansible Adapter
+ // 1. URL to connect to
+ // 2. credentials for URL (assume username password for now)
+ // 3. Playbook name
+ String[] mandatoryTestParams = {"AgentUrl", "PlaybookName", "User", "Password"};
+
+ // Optional testService parameters that may be provided in the request
+ String[] optionalTestParams = {"EnvParameters", "NodeList", "LocalParameters", "Timeout", "Version", "FileParameters", "Action"};
+
+ JSONObject JsonPayload = new JSONObject();
+ String payload = "";
+ JSONObject paramsJson;
+
+
+ // Verify all the mandatory parameters are there
+ for (String key: mandatoryTestParams){
+ if (! params.containsKey(key)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+ payload = params.get(key);
+ if (Strings.isNullOrEmpty(payload)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key % value is Null or Emtpy", key));
+ }
+
+ JsonPayload.put(key, payload);
+ }
+
+ // Iterate through optional parameters
+ // If null or empty omit it
+ for (String key : optionalTestParams){
+ if (params.containsKey(key)){
+ payload = params.get(key);
+ if(!Strings.isNullOrEmpty(payload)){
+
+ // different cases require different treatment
+ switch (key){
+ case "Timeout":
+ int Timeout = Integer.parseInt(payload);
+ if (Timeout < 0){
+ throw new NumberFormatException(" : specified negative integer for timeout = " + payload);
+ }
+ JsonPayload.put(key, payload);
+ break;
+
+ case "Version":
+ JsonPayload.put(key, payload);
+ break;
+
+ case "LocalParameters":
+ paramsJson = new JSONObject(payload);
+ JsonPayload.put(key, paramsJson);
+ break;
+
+ case "EnvParameters":
+ paramsJson = new JSONObject(payload);
+ JsonPayload.put(key, paramsJson);
+ break;
+
+ case "NodeList":
+ JSONArray paramsArray = new JSONArray(payload);
+ JsonPayload.put(key, paramsArray);
+ break;
+
+ case "FileParameters":
+ // Files may have strings with newlines. Escape them as appropriate
+ String formattedPayload = payload.replace("\n", "\\n").replace("\r", "\\r");
+ JSONObject fileParams = new JSONObject(formattedPayload);
+ JsonPayload.put(key, fileParams);
+ break;
+
+ }
+ }
+ }
+ }
+
+
+ // Generate a unique uuid for the test
+ String ReqId = UUID.randomUUID().toString();
+ JsonPayload.put("Id", ReqId);
+
+ return JsonPayload;
+
+ }
+
+
+
+ // method that validates that the Map has enough information
+ // to query Ansible server for a result . If so, it
+ // returns the appropriate url, else an empty string
+ public String ReqUri_Result(Map params) throws APPCException, NumberFormatException{
+
+ // Mandatory parameters, that must be in the request
+ String[] mandatoryTestParams = {"AgentUrl", "Id", "User", "Password" };
+
+ // Verify all the mandatory parameters are there
+ String payload = "";
+ String Uri = "";
+
+ for (String key: mandatoryTestParams){
+ if (! params.containsKey(key)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+
+ payload = params.get(key);
+ if (Strings.isNullOrEmpty(payload)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+
+ }
+
+ Uri = params.get("AgentUrl") + "?Id=" + params.get("Id") + "&Type=GetResult";
+
+ return Uri;
+
+ }
+
+
+
+ // method that validates that the Map has enough information
+ // to query Ansible server for logs. If so, it populates the appropriate
+ // returns the appropriate url, else an empty string
+ public String ReqUri_Output(Map params) throws APPCException, NumberFormatException{
+
+
+ // Mandatory parameters, that must be in the request
+ String[] mandatoryTestParams = {"AgentUrl", "Id", "User", "Password" };
+
+ // Verify all the mandatory parameters are there
+ String payload = "";
+ String Uri = "";
+
+ for (String key: mandatoryTestParams){
+ if (! params.containsKey(key)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+ payload = params.get(key);
+ if (Strings.isNullOrEmpty(payload)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+
+ }
+
+ Uri = params.get("AgentUrl") + "?Id=" + params.get("Id") + "&Type=GetOutput";
+ return Uri;
+
+ }
+
+ // method that validates that the Map has enough information
+ // to query Ansible server for logs. If so, it populates the appropriate
+ // returns the appropriate url, else an empty string
+ public String ReqUri_Log(Map params) throws APPCException, NumberFormatException{
+
+
+ // Mandatory parameters, that must be in the request
+ String[] mandatoryTestParams = {"AgentUrl", "Id", "User", "Password" };
+
+ // Verify all the mandatory parameters are there
+ String payload = "";
+ String Uri = "";
+
+ for (String key: mandatoryTestParams){
+ if (! params.containsKey(key)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+ payload = params.get(key);
+ if (Strings.isNullOrEmpty(payload)){
+ throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
+ }
+
+ }
+
+ Uri = params.get("AgentUrl") + "?Id=" + params.get("Id") + "&Type=GetLog";
+ return Uri;
+
+ }
+
+
+ /**
+ This method parses response from the
+ Ansible Server when we do a post
+ and returns an AnsibleResult object
+ **/
+
+ public AnsibleResult parsePostResponse(String Input) throws APPCException{
+
+ AnsibleResult ansibleResult = new AnsibleResult();
+
+ try{
+ //Jsonify it
+ JSONObject postResponse = new JSONObject(Input);
+
+ // Mandatory keys required are StatusCode and StatusMessage
+ int Code = postResponse.getInt("StatusCode");
+ String Message = postResponse.getString("StatusMessage");
+
+
+ // Status code must must be either 100 (accepted) or 101 (rejected)
+ boolean valCode = AnsibleResultCodes.CODE.checkValidCode(AnsibleResultCodes.INITRESPONSE.getValue(), Code);
+ if(!valCode){
+ throw new APPCException("Invalid InitResponse code = " + Code + " received. MUST be one of " + AnsibleResultCodes.CODE.getValidCodes(AnsibleResultCodes.INITRESPONSE.getValue()) );
+ }
+
+ ansibleResult.setStatusCode(Code);
+ ansibleResult.setStatusMessage(Message);
+
+ }
+ catch(JSONException e){
+ ansibleResult = new AnsibleResult(600, "Error parsing response = " + Input + ". Error = " + e.getMessage(), "");
+ }
+
+
+ return ansibleResult;
+ }
+
+
+ /** This method parses response from an Ansible server when we do a GET for a result
+ and returns an AnsibleResult object
+ **/
+ public AnsibleResult parseGetResponse(String Input) throws APPCException {
+
+ AnsibleResult ansibleResult = new AnsibleResult();
+ int FinalCode = AnsibleResultCodes.FINAL_SUCCESS.getValue();
+
+
+ try{
+
+ //Jsonify it
+ JSONObject postResponse = new JSONObject(Input);
+
+ // Mandatory keys required are Status and Message
+ int Code = postResponse.getInt("StatusCode");
+ String Message = postResponse.getString("StatusMessage");
+
+ // Status code must be valid
+ // Status code must must be either 100 (accepted) or 101 (rejected)
+ boolean valCode = AnsibleResultCodes.CODE.checkValidCode(AnsibleResultCodes.FINALRESPONSE.getValue(), Code);
+
+ if(!valCode){
+ throw new APPCException("Invalid FinalResponse code = " + Code + " received. MUST be one of " + AnsibleResultCodes.CODE.getValidCodes(AnsibleResultCodes.FINALRESPONSE.getValue()));
+ }
+
+
+ ansibleResult.setStatusCode(Code);
+ ansibleResult.setStatusMessage(Message);
+ System.out.println("Received response with code = " + Integer.toString(Code) + " Message = " + Message);
+
+ if(! postResponse.isNull("Results")){
+
+ // Results are available. process them
+ // Results is a dictionary of the form
+ // {host :{status:s, group:g, message:m, hostname:h}, ...}
+ System.out.println("Processing results in response");
+ JSONObject results = postResponse.getJSONObject("Results");
+ System.out.println("Get JSON dictionary from Results ..");
+ Iterator hosts = results.keys();
+ System.out.println("Iterating through hosts");
+
+ while(hosts.hasNext()){
+ String host = hosts.next();
+ System.out.println("Processing host = " + host);
+
+ try{
+ JSONObject host_response = results.getJSONObject(host);
+ int subCode = host_response.getInt("StatusCode");
+ String message = host_response.getString("StatusMessage");
+
+ System.out.println("Code = " + Integer.toString(subCode) + " Message = " + message);
+
+ if(subCode != 200 || ! message.equals("SUCCESS")){
+ FinalCode = AnsibleResultCodes.REQ_FAILURE.getValue();
+ }
+ }
+ catch(JSONException e){
+ ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
+ ansibleResult.setStatusMessage(String.format("Error processing response message = %s from host %s", results.getString(host), host));
+ break;
+ }
+ }
+
+ ansibleResult.setStatusCode(FinalCode);
+
+ // We return entire Results object as message
+ ansibleResult.setResults(results.toString());
+
+ }
+ else{
+ ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
+ ansibleResult.setStatusMessage("Results not found in GET for response");
+ }
+
+
+ }
+ catch(JSONException e){
+ ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error parsing response = " + Input + ". Error = " + e.getMessage(), "");
+ }
+
+
+ return ansibleResult;
+ }
+
+
+
+};
+
+
+
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResult.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResult.java
new file mode 100644
index 000000000..a4bbcbef8
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResult.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.ansible.model;
+
+
+/* Simple class to store code and message returned by POST/GET to an Ansible Server */
+public class AnsibleResult{
+ private int StatusCode;
+ private String StatusMessage;
+ private String Results;
+
+
+ public AnsibleResult(){
+ StatusCode = -1;
+ StatusMessage = "UNKNOWN";
+ Results = "UNKNOWN";
+
+ }
+
+ // constructor
+ public AnsibleResult(int code, String message, String result){
+ StatusCode = code;
+ StatusMessage = message;
+ Results = result;
+ }
+
+ //*************************************************
+ // Various set methods
+ public void setStatusCode(int code){
+ this.StatusCode = code;
+ }
+
+ public void setStatusMessage(String message){
+ this.StatusMessage = message;
+ }
+
+ public void setResults(String results){
+ this.Results = results;
+ }
+
+
+ void set(int code, String message, String results){
+ this.StatusCode = code;
+ this.StatusMessage = message;
+ this.Results = results;
+
+ }
+
+ //*********************************************
+ // Various get methods
+ public int getStatusCode(){
+ return this.StatusCode;
+ }
+
+ public String getStatusMessage(){
+ return this.StatusMessage;
+ }
+
+ public String getResults(){
+ return this.Results;
+ }
+
+
+}
+
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResultCodes.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResultCodes.java
new file mode 100644
index 000000000..986ad3e6a
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleResultCodes.java
@@ -0,0 +1,122 @@
+/*-
+ * ============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.ansible.model;
+
+
+import java.util.*;
+
+/**
+ * enum of the various codes that APP-C uses to resolve different
+ * status of response from Ansible Server
+ **/
+
+public enum AnsibleResultCodes{
+
+ SUCCESS(400),
+ KEYSTORE_EXCEPTION(622),
+ CERTIFICATE_ERROR(610),
+ IO_EXCEPTION (611),
+ HOST_UNKNOWN(625),
+ USER_UNAUTHORIZED(613),
+ UNKNOWN_EXCEPTION(699),
+ SSL_EXCEPTION(697),
+ INVALID_PAYLOAD(698),
+ INVALID_RESPONSE(601),
+ PENDING(100),
+ REJECTED(101),
+ FINAL_SUCCESS(200),
+ REQ_FAILURE(401),
+ MESSAGE(1),
+ CODE(0),
+ INITRESPONSE(0),
+ FINALRESPONSE(1);
+
+ private final Set InitCodes = new HashSet(Arrays.asList(100, 101));
+ private final Set FinalCodes = new HashSet(Arrays.asList(200, 500));
+ private final ArrayList>CodeSets = new ArrayList>(Arrays.asList(InitCodes, FinalCodes));
+
+ private final Set MessageSet = new HashSet(Arrays.asList("PENDING", "FINISHED", "TERMINATED"));
+
+ private final int value;
+
+ AnsibleResultCodes(int value){
+ this.value = value;
+ };
+
+
+ public int getValue(){
+ return this.value;
+ }
+
+
+ public boolean checkValidCode(int Type, int Code){
+ SetCodeSet = CodeSets.get(Type);
+ if (CodeSet.contains(Code)){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+
+ public String getValidCodes(int Type){
+ SetCodeSet = CodeSets.get(Type);
+
+ Iterator iter = CodeSet.iterator();
+ String ValidCodes = "[ ";
+ while(iter.hasNext()){
+ ValidCodes = ValidCodes + iter.next().toString() + ",";
+ }
+
+ ValidCodes = ValidCodes + "]";
+ return ValidCodes;
+ }
+
+
+ public boolean checkValidMessage(String Message){
+ if (MessageSet.contains(Message)){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+
+
+
+ public String getValidMessages(){
+ Iterator iter = MessageSet.iterator();
+ String ValidMessage = "[ ";
+ while(iter.hasNext()){
+ ValidMessage = ValidMessage + iter.next() + ",";
+ }
+
+ ValidMessage = ValidMessage + "]";
+ return ValidMessage;
+ }
+
+
+};
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleServerEmulator.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleServerEmulator.java
new file mode 100644
index 000000000..c430743ad
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/model/AnsibleServerEmulator.java
@@ -0,0 +1,148 @@
+/*-
+ * ============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=========================================================
+ */
+
+
+
+
+/* Class to emulate responses from the Ansible Server that is compliant with the APP-C Ansible Server
+ Interface. Used for jUnit tests to verify code is working. In tests it can be used
+ as a replacement for methods from ConnectionBuilder class
+*/
+
+package org.onap.appc.adapter.ansible.model;
+
+import java.util.*;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import com.google.common.base.Strings;
+
+import org.json.JSONObject;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.adapter.ansible.model.AnsibleResult;
+
+public class AnsibleServerEmulator {
+
+
+ private String playbookName = "test_playbook.yaml";
+ private String TestId;
+
+ /**
+ * Method that emulates the response from an Ansible Server
+ when presented with a request to execute a playbook
+ Returns an ansible object result. The response code is always the http code 200 (i.e connection successful)
+ payload is json string as would be sent back by Ansible Server
+ **/
+
+ public AnsibleResult Post(String AgentUrl, String payload){
+ AnsibleResult result = new AnsibleResult() ;
+
+ try{
+ // Request must be a JSON object
+
+ JSONObject message = new JSONObject(payload);
+ if (message.isNull("Id")){
+ RejectRequest(result, "Must provide a valid Id");
+ }
+ else if(message.isNull("PlaybookName")){
+ RejectRequest(result, "Must provide a playbook Name");
+ }
+ else if(!message.getString("PlaybookName").equals(playbookName)){
+ RejectRequest(result, "Playbook " + message.getString("PlaybookName") + " not found in catalog");
+ }
+ else{
+ AcceptRequest(result);
+ }
+ }
+ catch (JSONException e){
+ RejectRequest(result, e.getMessage());
+ }
+
+ return result;
+ }
+
+
+ /** Method to emulate response from an Ansible
+ Server when presented with a GET request
+ Returns an ansibl object result. The response code is always the http code 200 (i.e connection successful)
+ payload is json string as would be sent back by Ansible Server
+
+ **/
+ public AnsibleResult Get(String AgentUrl){
+
+ // Extract id
+ Pattern pattern = Pattern.compile(".*?\\?Id=(.*?)&Type.*");
+ Matcher matcher = pattern.matcher(AgentUrl);
+ String Id = "";
+
+ if (matcher.find()){
+ Id = matcher.group(1);
+ }
+
+ AnsibleResult get_result = new AnsibleResult();
+
+ JSONObject response = new JSONObject();
+ response.put("StatusCode", 200);
+ response.put("StatusMessage", "FINISHED");
+
+ JSONObject results = new JSONObject();
+
+ JSONObject vm_results = new JSONObject();
+ vm_results.put("StatusCode", 200);
+ vm_results.put("StatusMessage", "SUCCESS");
+ vm_results.put("Id", Id);
+ results.put("192.168.1.10", vm_results);
+
+
+ response.put("Results", results);
+
+ get_result.setStatusCode(200);
+ get_result.setStatusMessage(response.toString());
+
+ return get_result;
+
+ }
+
+
+ private void RejectRequest(AnsibleResult result, String Message){
+ result.setStatusCode(200);
+ JSONObject response = new JSONObject();
+ response.put("StatusCode", AnsibleResultCodes.REJECTED.getValue());
+ response.put("StatusMessage", Message);
+ result.setStatusMessage(response.toString());
+
+ }
+
+ private void AcceptRequest(AnsibleResult result){
+ result.setStatusCode(200);
+ JSONObject response = new JSONObject();
+ response.put("StatusCode", AnsibleResultCodes.PENDING.getValue());
+ response.put("StatusMessage", "PENDING");
+ result.setStatusMessage(response.toString());
+
+ }
+
+};
+
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleActivator.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleActivator.java
deleted file mode 100644
index d76cd50f1..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleActivator.java
+++ /dev/null
@@ -1,126 +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.ansible;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-import org.onap.appc.Constants;
-import org.onap.appc.adapter.ansible.impl.AnsibleAdapterImpl;
-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;
-
-/**
- * This activator is used to initialize and terminate an instance of AnsibleAdapter class
- */
-public class AnsibleActivator implements BundleActivator {
-
- /**
- * The bundle registration
- */
- private ServiceRegistration registration = null;
-
- /**
- * The reference to the actual implementation object that implements the services
- */
- private AnsibleAdapter adapter;
-
- /**
- * The logger to be used
- */
- private final EELFLogger logger = EELFManager.getInstance().getLogger(AnsibleActivator.class);
-
- /**
- * The configuration object used to configure this bundle
- */
- private final Configuration configuration = ConfigurationFactory.getConfiguration();
-
- /**
- * 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());
- String appName = "APPC: ";
- logger.info(Msg.COMPONENT_INITIALIZING, appName, "Ansible Adapter");
- adapter = new AnsibleAdapterImpl();
-
- if (registration == null) {
- logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
- AnsibleAdapter.class.getSimpleName());
- registration = context.registerService(AnsibleAdapter.class, adapter, null);
- }
-
- logger.info(Msg.COMPONENT_INITIALIZED, appName, "Ansible 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, "Ansible adapter");
- logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
- registration.unregister();
- registration = null;
- logger.info(Msg.COMPONENT_TERMINATED, appName, "Ansible adapter");
- }
- }
-
- public String getName() {
- return "APPC Ansible Adapter";
- }
-}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleAdapter.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleAdapter.java
deleted file mode 100644
index 7bff184bc..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/AnsibleAdapter.java
+++ /dev/null
@@ -1,60 +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.ansible;
-
-import java.util.Map;
-
-import org.onap.appc.exceptions.APPCException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-
-/**
- * This interface defines the operations that the Ansible adapter exposes.
- *
- */
-public interface AnsibleAdapter extends SvcLogicJavaPlugin {
-
-
- /**
- * Returns the symbolic name of the adapter
- *
- * @return The adapter name
- */
- String getAdapterName();
-
-
- /* Method to post request for execution of Playbook */
- void reqExec(Map params, SvcLogicContext ctx) throws SvcLogicException;
-
- /* Method to get result of a playbook execution request */
- void reqExecResult(Map params, SvcLogicContext ctx) throws SvcLogicException;
-
-
- /* Method to get log of a playbook execution request */
- void reqExecLog(Map params, SvcLogicContext ctx) throws SvcLogicException;
-
-
-}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/AnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
deleted file mode 100644
index 0b426bb26..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
+++ /dev/null
@@ -1,501 +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.ansible.impl;
-
-import java.util.Map;
-import java.util.Properties;
-import java.lang.*;
-
-
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.exceptions.APPCException;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-
-
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.json.JSONException;
-
-
-
-import org.onap.appc.adapter.ansible.AnsibleAdapter;
-
-import org.onap.appc.adapter.ansible.model.AnsibleResult;
-import org.onap.appc.adapter.ansible.model.AnsibleMessageParser;
-import org.onap.appc.adapter.ansible.model.AnsibleResultCodes;
-import org.onap.appc.adapter.ansible.model.AnsibleServerEmulator;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
-import static com.att.eelf.configuration.Configuration.*;
-
-
-/**
- * This class implements the {@link AnsibleAdapter} interface. This interface
- * defines the behaviors that our service provides.
- *
- */
-public class AnsibleAdapterImpl implements AnsibleAdapter {
-
- /**
- * The constant used to define the adapter name in the mapped diagnostic
- * context
- */
-
-
- @SuppressWarnings("nls")
- public static final String MDC_ADAPTER = "Ansible Adapter";
-
- /**
- * The constant used to define the service name in the mapped diagnostic
- * context
- */
- @SuppressWarnings("nls")
- public static final String MDC_SERVICE = "service";
-
- /**
- * The constant for the status code for a failed outcome
- */
- @SuppressWarnings("nls")
- public static final String OUTCOME_FAILURE = "failure";
-
- /**
- * The constant for the status code for a successful outcome
- */
- @SuppressWarnings("nls")
- public static final String OUTCOME_SUCCESS = "success";
-
- /**
- Adapter Name
- **/
- private static final String ADAPTER_NAME = "Ansible Adapter";
-
-
- /**
- * The logger to be used
- */
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(AnsibleAdapterImpl.class);
-
- /**
- * A reference to the adapter configuration object.
- */
- private Configuration configuration;;
-
- /** can Specify a X509 certificate file for use if required ...
- Must be initialized with setCertFile
- **/
- private String certFile = "";
-
-
- /**
- * Connection object
- **/
- ConnectionBuilder http_client ;
-
- /**
- * Ansible API Message Handlers
- **/
- private AnsibleMessageParser messageProcessor;
-
- /**
- indicator whether in test mode
- **/
- private boolean testMode = false;
-
- /**
- server emulator object to be used if in test mode
- **/
- private AnsibleServerEmulator testServer;
-
- /**
- * This default constructor is used as a work around because the activator
- * wasnt getting called
- */
- public AnsibleAdapterImpl() {
- initialize();
- }
-
-
- /**
- * @param props
- * not used
- */
- public AnsibleAdapterImpl(Properties props) {
- initialize();
- }
-
-
-
- /**
- Used for jUnit test and testing interface
- **/
- public AnsibleAdapterImpl(boolean Mode){
- testMode = Mode;
- testServer = new AnsibleServerEmulator();
- messageProcessor = new AnsibleMessageParser();
- }
-
- /**
- * Returns the symbolic name of the adapter
- *
- * @return The adapter name
- * @see org.onap.appc.adapter.rest.AnsibleAdapter#getAdapterName()
- */
- @Override
- public String getAdapterName() {
- return ADAPTER_NAME;
- }
-
-
-
- /**
- * @param rc
- * Method posts info to Context memory in case of an error
- * and throws a SvcLogicException causing SLI to register this as a failure
- */
- @SuppressWarnings("static-method")
- private void doFailure(SvcLogicContext svcLogic, int code, String message) throws SvcLogicException {
-
- svcLogic.setStatus(OUTCOME_FAILURE);
- svcLogic.setAttribute("org.onap.appc.adapter.ansible.result.code",Integer.toString(code));
- svcLogic.setAttribute("org.onap.appc.adapter.ansible.message",message);
-
- throw new SvcLogicException("Ansible Adapter Error = " + message );
- }
-
-
- /**
- * initialize the Ansible adapter based on default and over-ride configuration data
- */
- private void initialize() {
-
- configuration = ConfigurationFactory.getConfiguration();
- Properties props = configuration.getProperties();
-
- // Create the message processor instance
- messageProcessor = new AnsibleMessageParser();
-
- // Create the http client instance
- // type of client is extracted from the property file parameter
- // org.onap.appc.adapter.ansible.clientType
- // It can be :
- // 1. TRUST_ALL (trust all SSL certs). To be used ONLY in dev
- // 2. TRUST_CERT (trust only those whose certificates have been stored in the trustStore file)
- // 3. DEFAULT (trust only well known certificates). This is standard behaviour to which it will
- // revert. To be used in PROD
-
- try{
- String clientType = props.getProperty("org.onap.appc.adapter.ansible.clientType");
- logger.info("Ansible http client type set to " + clientType);
-
- if (clientType.equals("TRUST_ALL")){
- logger.info("Creating http client to trust ALL ssl certificates. WARNING. This should be done only in dev environments");
- http_client = new ConnectionBuilder(1);
- }
- else if (clientType.equals("TRUST_CERT")){
- // set path to keystore file
- String trustStoreFile = props.getProperty("org.onap.appc.adapter.ansible.trustStore");
- String key = props.getProperty("org.onap.appc.adapter.ansible.trustStore.trustPasswd");
- char [] trustStorePasswd = key.toCharArray();
- String trustStoreType = "JKS";
- logger.info("Creating http client with trustmanager from " + trustStoreFile);
- http_client = new ConnectionBuilder(trustStoreFile, trustStorePasswd);
- }
- else{
- logger.info("Creating http client with default behaviour");
- http_client = new ConnectionBuilder(0);
- }
- }
- catch (Exception e){
- logger.error("Error Initializing Ansible Adapter due to Unknown Exception: reason = " + e.getMessage());
- }
-
- logger.info("Intitialized Ansible Adapter");
-
- }
-
-
- /** set the certificate file if not a trusted/known CA **/
- private void setCertFile(String CertFile){
- this.certFile = CertFile;
- }
-
-
-
- // Public Method to post request to execute playbook. Posts the following back
- // to Svc context memory
- // org.onap.appc.adapter.ansible.req.code : 100 if successful
- // org.onap.appc.adapter.ansible.req.messge : any message
- // org.onap.appc.adapter.ansible.req.Id : a unique uuid to reference the request
-
- public void reqExec(Map params, SvcLogicContext ctx) throws SvcLogicException {
-
- String PlaybookName = "";
- String payload = "";
- String AgentUrl = "";
- String User = "";
- String Password = "";
- String Id = "";
-
- JSONObject JsonPayload;
-
- try{
- // create json object to send request
- JsonPayload = messageProcessor.ReqMessage(params);
-
- AgentUrl = (String) JsonPayload.remove("AgentUrl");
- User = (String) JsonPayload.remove("User");
- Password = (String) JsonPayload.remove("Password");
- Id = (String)JsonPayload.getString("Id");
- payload = JsonPayload.toString();
- logger.info("Updated Payload = " + payload);
- }
- catch(APPCException e){
- doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request for execution of playbook due to missing mandatory parameters. Reason = " + e.getMessage());
- }
- catch(JSONException e){
- doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request for execution of playbook due to invalid JSON block. Reason = " + e.getMessage());
- }
- catch(NumberFormatException e){
- doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request for execution of playbook due to invalid parameter values. Reason = " + e.getMessage());
- }
-
-
-
- int code = -1;
- String message = "";
-
- try{
-
- // post the test request
- //---------------------------------------
- logger.info("Posting request = " + payload + " to url = " + AgentUrl );
- AnsibleResult testresult = postExecRequest(AgentUrl, payload, User, Password);
-
-
- // Process if HTTP was successfull
- if(testresult.getStatusCode() == 200){
- testresult = messageProcessor.parsePostResponse(testresult.getStatusMessage());
- }
- else{
- doFailure(ctx, testresult.getStatusCode(), "Error posting request. Reason = " + testresult.getStatusMessage());
- }
-
-
- code = testresult.getStatusCode();
- message = testresult.getStatusMessage();
-
-
- // Check status of test request returned by Agent
- //-----------------------------------------------
- if (code == AnsibleResultCodes.PENDING.getValue()){
- logger.info(String.format("Submission of Test %s successful.", PlaybookName));
- // test request accepted. We are in asynchronous case
- }
- else{
- doFailure(ctx, code, "Request for execution of playbook rejected. Reason = " + message);
- }
- }
-
- catch(APPCException e){
- doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(), "Exception encountered when posting request for execution of playbook. Reason = " + e.getMessage());
- }
-
-
- ctx.setAttribute("org.onap.appc.adapter.ansible.result.code", Integer.toString(code));
- ctx.setAttribute("org.onap.appc.adapter.ansible.message", message );
- ctx.setAttribute("org.onap.appc.adapter.ansible.Id", Id);
-
- }
-
-
- // Public method to query status of a specific request
- // It blocks till the Ansible Server responds or the session times out
-
- public void reqExecResult(Map params, SvcLogicContext ctx) throws SvcLogicException {
-
-
- // Get uri
- String ReqUri = "";
-
- try{
- ReqUri = messageProcessor.ReqUri_Result(params);
- System.out.println("Got uri = " + ReqUri);
- }
- catch(APPCException e){
- doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request to retreive result due to missing parameters. Reason = " + e.getMessage());
- return;
- }
- catch(NumberFormatException e){
- doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error constructing request to retreive result due to invalid parameters value. Reason = " + e.getMessage());
- return;
- }
-
- int code = -1;
- String message = "";
- String results = "";
-
- try{
- // Try to retreive the test results (modify the url for that)
- AnsibleResult testresult = queryServer(ReqUri, params.get("User"), params.get("Password"));
- code = testresult.getStatusCode();
- message = testresult.getStatusMessage();
-
- if(code == 200){
- logger.info("Parsing response from Server = " + message);
- // Valid HTTP. process the Ansible message
- testresult = messageProcessor.parseGetResponse(message);
- code = testresult.getStatusCode();
- message = testresult.getStatusMessage();
- results = testresult.getResults();
-
- }
-
- logger.info("Request response = " + message);
-
- }
- catch (APPCException e){
- doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(), "Exception encountered retreiving result : " + e.getMessage());
- return;
- }
-
- // We were able to get and process the results. Determine if playbook succeeded
-
- if (code == AnsibleResultCodes.FINAL_SUCCESS.getValue()){
- message = String.format("Ansible Request %s finished with Result = %s, Message = %s", params.get("Id"), OUTCOME_SUCCESS, message);
- logger.info(message);
- }
- else {
- logger.info(String.format("Ansible Request %s finished with Result %s, Message = %s", params.get("Id"), OUTCOME_FAILURE, message));
- ctx.setAttribute("org.onap.appc.adapter.ansible.results", results);
- doFailure(ctx, code, message );
- return;
- }
-
-
- ctx.setAttribute("org.onap.appc.adapter.ansible.result.code", Integer.toString(400));
- ctx.setAttribute("org.onap.appc.adapter.ansible.message",message);
- ctx.setAttribute("org.onap.appc.adapter.ansible.results", results);
- ctx.setStatus(OUTCOME_SUCCESS);
- }
-
-
- // Public method to get logs from plyabook execution for a specifcic request
- // It blocks till the Ansible Server responds or the session times out
- // very similar to reqExecResult
- // logs are returned in the DG context variable org.onap.appc.adapter.ansible.log
-
- public void reqExecLog(Map params, SvcLogicContext ctx) throws SvcLogicException{
-
-
- // Get uri
- String ReqUri = "";
- try{
- ReqUri = messageProcessor.ReqUri_Log(params);
- logger.info("Retreiving results from " + ReqUri);
- }
- catch(Exception e){
- doFailure(ctx, AnsibleResultCodes.INVALID_PAYLOAD.getValue(), e.getMessage());
- }
-
- int code = -1;
- String message = "";
- float Duration = -1;
-
- try{
- // Try to retreive the test results (modify the url for that)
- AnsibleResult testresult = queryServer(ReqUri, params.get("User"), params.get("Password"));
- code = testresult.getStatusCode();
- message = testresult.getStatusMessage();
-
- logger.info("Request output = " + message);
-
- }
- catch (Exception e){
- doFailure(ctx, AnsibleResultCodes.UNKNOWN_EXCEPTION.getValue(), "Exception encountered retreiving output : " + e.getMessage());
- }
-
- ctx.setAttribute("org.onap.appc.adapter.ansible.log",message);
- ctx.setStatus(OUTCOME_SUCCESS);
- }
-
-
-
-
-
- /**
- * Method that posts the request
- **/
-
- private AnsibleResult postExecRequest(String AgentUrl, String Payload, String User, String Password) {
-
- String reqOutput = "UNKNOWN";
- int reqStatus = -1;
-
- AnsibleResult testresult;
-
- if (!testMode){
- http_client.setHttpContext(User, Password);
- testresult = http_client.Post(AgentUrl, Payload);
- }
- else{
- testresult = testServer.Post(AgentUrl, Payload);
- }
-
- return testresult;
- }
-
-
- /*
- Method to query Ansible server
-
- */
- private AnsibleResult queryServer(String AgentUrl, String User, String Password) {
-
- String testOutput = "UNKNOWN";
- int testStatus = -1;
- AnsibleResult testresult;
-
- logger.info("Querying url = " + AgentUrl);
-
- if (!testMode){
- testresult = http_client.Get(AgentUrl);
- }
- else{
- testresult = testServer.Get(AgentUrl);
- }
-
- return testresult;
-
- }
-
-
-
-}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/ConnectionBuilder.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/ConnectionBuilder.java
deleted file mode 100644
index e84a85a0c..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/impl/ConnectionBuilder.java
+++ /dev/null
@@ -1,224 +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.ansible.impl;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.entity.StringEntity;
-
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.cert.CertificateException;
-import java.security.KeyManagementException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.security.NoSuchAlgorithmException;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLContext;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-
-
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContexts;
-import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
-
-
-import org.onap.appc.exceptions.APPCException;
-import org.onap.appc.adapter.ansible.model.AnsibleResult;
-import org.onap.appc.adapter.ansible.model.AnsibleResultCodes;
-
-
-/**
- * Returns custom http client
- - based on options
- - can create one with ssl using an X509 certificate that does NOT have a known CA
- - create one which trusts ALL SSL certificates
- - return default httpclient (which only trusts known CAs from default cacerts file for process) -- this is the default option
-
-**/
-
-
-public class ConnectionBuilder {
-
-
-
- private CloseableHttpClient http_client = null;
- private HttpClientContext http_context = new HttpClientContext();
-
-
-
-
- // Various constructors depending on how we want to instantiate the http ConnectionBuilder instance
-
-
- /**
- * Constructor that initializes an http client based on certificate
- **/
- public ConnectionBuilder(String CertFile) throws KeyStoreException, CertificateException, IOException, KeyManagementException, NoSuchAlgorithmException, APPCException{
-
-
- /* Point to the certificate */
- FileInputStream fs = new FileInputStream(CertFile);
-
- /* Generate a certificate from the X509 */
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate)cf.generateCertificate(fs);
-
- /* Create a keystore object and load the certificate there */
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
- keystore.load(null, null);
- keystore.setCertificateEntry("cacert", cert);
-
-
- SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
- SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-
- http_client = HttpClients.custom().setSSLSocketFactory(factory).build();
- };
-
-
- /**
- * Constructor which trusts all certificates in a specific java keystore file (assumes a JKS file)
- **/
- public ConnectionBuilder(String trustStoreFile, char[] trustStorePasswd) throws KeyStoreException, IOException, KeyManagementException, NoSuchAlgorithmException, CertificateException {
-
-
- /* Load the specified trustStore */
- KeyStore keystore = KeyStore.getInstance("JKS");
- FileInputStream readStream = new FileInputStream(trustStoreFile);
- keystore.load(readStream,trustStorePasswd);
-
- SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(keystore).build();
- SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-
- http_client = HttpClients.custom().setSSLSocketFactory(factory).build();
- };
-
- /**
- * Constructor that trusts ALL SSl certificates (NOTE : ONLY FOR DEV TESTING) if Mode == 1
- or Default if Mode == 0
- */
- public ConnectionBuilder(int Mode) throws SSLException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException{
- if (Mode == 1){
- SSLContext sslcontext = SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build();
- SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
-
- http_client = HttpClients.custom().setSSLSocketFactory(factory).build();
- }
-
- else{
- http_client = HttpClients.createDefault();
- }
-
- };
-
-
- // Use to create an http context with auth headers
- public void setHttpContext(String User, String MyPassword){
-
- // Are credential provided ? If so, set the context to be used
- if (User != null && ! User.isEmpty() && MyPassword != null && ! MyPassword.isEmpty()){
- UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(User, MyPassword);
- AuthScope authscope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT);
- BasicCredentialsProvider credsprovider = new BasicCredentialsProvider();
- credsprovider.setCredentials(authscope, credentials);
- http_context.setCredentialsProvider(credsprovider);
- }
-
-
- };
-
-
- // Method posts to the ansible server and writes out response to
- // Ansible result object
- public AnsibleResult Post(String AgentUrl, String Payload){
-
- AnsibleResult result = new AnsibleResult();
- try{
-
- HttpPost postObj = new HttpPost(AgentUrl);
- StringEntity bodyParams = new StringEntity(Payload, "UTF-8");
- postObj.setEntity(bodyParams);
- postObj.addHeader("Content-type", "application/json");
-
- HttpResponse response = http_client.execute(postObj, http_context);
-
- HttpEntity entity = response.getEntity();
- String responseOutput = entity != null ? EntityUtils.toString(entity) : null;
- int responseCode = response.getStatusLine().getStatusCode();
- result.setStatusCode(responseCode);
- result.setStatusMessage(responseOutput);
- }
-
- catch(IOException io){
- result.setStatusCode(AnsibleResultCodes.IO_EXCEPTION.getValue());
- result.setStatusMessage(io.getMessage());
- }
-
-
-
- return result;
-
- }
-
- // Method gets information from an Ansible server and writes out response to
- // Ansible result object
-
- public AnsibleResult Get(String AgentUrl){
-
- AnsibleResult result = new AnsibleResult();
-
- try{
- HttpGet getObj = new HttpGet(AgentUrl );
- HttpResponse response = http_client.execute(getObj, http_context);
-
-
- HttpEntity entity = response.getEntity();
- String responseOutput = entity != null ? EntityUtils.toString(entity) : null;
- int responseCode = response.getStatusLine().getStatusCode();
- result.setStatusCode(responseCode);
- result.setStatusMessage(responseOutput);
-
- }
- catch(IOException io){
- result.setStatusCode(AnsibleResultCodes.IO_EXCEPTION.getValue());
- result.setStatusMessage(io.getMessage());
- }
-
- return result;
- };
-
-}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleMessageParser.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleMessageParser.java
deleted file mode 100644
index 6bebd73fe..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleMessageParser.java
+++ /dev/null
@@ -1,364 +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.ansible.model;
-
-/**
- * This module imples the APP-C/Ansible Server interface
- * based on the REST API specifications
- */
-
-import java.lang.NumberFormatException ;
-import java.util.*;
-import com.google.common.base.Strings;
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.onap.appc.exceptions.APPCException;
-import org.onap.appc.adapter.ansible.model.AnsibleResult;
-
-
-/**
- * Class that validates and constructs requests sent/received from
- * Ansible Server
- *
- */
-public class AnsibleMessageParser {
-
-
-
-
- // Accepts a map of strings and
- // a) validates if all parameters are appropriate (else, throws an exception)
- // and b) if correct returns a JSON object with appropriate key-value
- // pairs to send to the server.
- public JSONObject ReqMessage(Map params) throws APPCException, NumberFormatException, JSONException{
-
- // Mandatory parameters, that must be in the supplied information to the Ansible Adapter
- // 1. URL to connect to
- // 2. credentials for URL (assume username password for now)
- // 3. Playbook name
- String[] mandatoryTestParams = {"AgentUrl", "PlaybookName", "User", "Password"};
-
- // Optional testService parameters that may be provided in the request
- String[] optionalTestParams = {"EnvParameters", "NodeList", "LocalParameters", "Timeout", "Version", "FileParameters", "Action"};
-
- JSONObject JsonPayload = new JSONObject();
- String payload = "";
- JSONObject paramsJson;
-
-
- // Verify all the mandatory parameters are there
- for (String key: mandatoryTestParams){
- if (! params.containsKey(key)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
- payload = params.get(key);
- if (Strings.isNullOrEmpty(payload)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key % value is Null or Emtpy", key));
- }
-
- JsonPayload.put(key, payload);
- }
-
- // Iterate through optional parameters
- // If null or empty omit it
- for (String key : optionalTestParams){
- if (params.containsKey(key)){
- payload = params.get(key);
- if(!Strings.isNullOrEmpty(payload)){
-
- // different cases require different treatment
- switch (key){
- case "Timeout":
- int Timeout = Integer.parseInt(payload);
- if (Timeout < 0){
- throw new NumberFormatException(" : specified negative integer for timeout = " + payload);
- }
- JsonPayload.put(key, payload);
- break;
-
- case "Version":
- JsonPayload.put(key, payload);
- break;
-
- case "LocalParameters":
- paramsJson = new JSONObject(payload);
- JsonPayload.put(key, paramsJson);
- break;
-
- case "EnvParameters":
- paramsJson = new JSONObject(payload);
- JsonPayload.put(key, paramsJson);
- break;
-
- case "NodeList":
- JSONArray paramsArray = new JSONArray(payload);
- JsonPayload.put(key, paramsArray);
- break;
-
- case "FileParameters":
- // Files may have strings with newlines. Escape them as appropriate
- String formattedPayload = payload.replace("\n", "\\n").replace("\r", "\\r");
- JSONObject fileParams = new JSONObject(formattedPayload);
- JsonPayload.put(key, fileParams);
- break;
-
- }
- }
- }
- }
-
-
- // Generate a unique uuid for the test
- String ReqId = UUID.randomUUID().toString();
- JsonPayload.put("Id", ReqId);
-
- return JsonPayload;
-
- }
-
-
-
- // method that validates that the Map has enough information
- // to query Ansible server for a result . If so, it
- // returns the appropriate url, else an empty string
- public String ReqUri_Result(Map params) throws APPCException, NumberFormatException{
-
- // Mandatory parameters, that must be in the request
- String[] mandatoryTestParams = {"AgentUrl", "Id", "User", "Password" };
-
- // Verify all the mandatory parameters are there
- String payload = "";
- String Uri = "";
-
- for (String key: mandatoryTestParams){
- if (! params.containsKey(key)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
-
- payload = params.get(key);
- if (Strings.isNullOrEmpty(payload)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
-
- }
-
- Uri = params.get("AgentUrl") + "?Id=" + params.get("Id") + "&Type=GetResult";
-
- return Uri;
-
- }
-
-
-
- // method that validates that the Map has enough information
- // to query Ansible server for logs. If so, it populates the appropriate
- // returns the appropriate url, else an empty string
- public String ReqUri_Output(Map params) throws APPCException, NumberFormatException{
-
-
- // Mandatory parameters, that must be in the request
- String[] mandatoryTestParams = {"AgentUrl", "Id", "User", "Password" };
-
- // Verify all the mandatory parameters are there
- String payload = "";
- String Uri = "";
-
- for (String key: mandatoryTestParams){
- if (! params.containsKey(key)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
- payload = params.get(key);
- if (Strings.isNullOrEmpty(payload)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
-
- }
-
- Uri = params.get("AgentUrl") + "?Id=" + params.get("Id") + "&Type=GetOutput";
- return Uri;
-
- }
-
- // method that validates that the Map has enough information
- // to query Ansible server for logs. If so, it populates the appropriate
- // returns the appropriate url, else an empty string
- public String ReqUri_Log(Map params) throws APPCException, NumberFormatException{
-
-
- // Mandatory parameters, that must be in the request
- String[] mandatoryTestParams = {"AgentUrl", "Id", "User", "Password" };
-
- // Verify all the mandatory parameters are there
- String payload = "";
- String Uri = "";
-
- for (String key: mandatoryTestParams){
- if (! params.containsKey(key)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
- payload = params.get(key);
- if (Strings.isNullOrEmpty(payload)){
- throw new APPCException(String.format("Ansible: Mandatory AnsibleAdapter key %s not found in parameters provided by calling agent !", key));
- }
-
- }
-
- Uri = params.get("AgentUrl") + "?Id=" + params.get("Id") + "&Type=GetLog";
- return Uri;
-
- }
-
-
- /**
- This method parses response from the
- Ansible Server when we do a post
- and returns an AnsibleResult object
- **/
-
- public AnsibleResult parsePostResponse(String Input) throws APPCException{
-
- AnsibleResult ansibleResult = new AnsibleResult();
-
- try{
- //Jsonify it
- JSONObject postResponse = new JSONObject(Input);
-
- // Mandatory keys required are StatusCode and StatusMessage
- int Code = postResponse.getInt("StatusCode");
- String Message = postResponse.getString("StatusMessage");
-
-
- // Status code must must be either 100 (accepted) or 101 (rejected)
- boolean valCode = AnsibleResultCodes.CODE.checkValidCode(AnsibleResultCodes.INITRESPONSE.getValue(), Code);
- if(!valCode){
- throw new APPCException("Invalid InitResponse code = " + Code + " received. MUST be one of " + AnsibleResultCodes.CODE.getValidCodes(AnsibleResultCodes.INITRESPONSE.getValue()) );
- }
-
- ansibleResult.setStatusCode(Code);
- ansibleResult.setStatusMessage(Message);
-
- }
- catch(JSONException e){
- ansibleResult = new AnsibleResult(600, "Error parsing response = " + Input + ". Error = " + e.getMessage(), "");
- }
-
-
- return ansibleResult;
- }
-
-
- /** This method parses response from an Ansible server when we do a GET for a result
- and returns an AnsibleResult object
- **/
- public AnsibleResult parseGetResponse(String Input) throws APPCException {
-
- AnsibleResult ansibleResult = new AnsibleResult();
- int FinalCode = AnsibleResultCodes.FINAL_SUCCESS.getValue();
-
-
- try{
-
- //Jsonify it
- JSONObject postResponse = new JSONObject(Input);
-
- // Mandatory keys required are Status and Message
- int Code = postResponse.getInt("StatusCode");
- String Message = postResponse.getString("StatusMessage");
-
- // Status code must be valid
- // Status code must must be either 100 (accepted) or 101 (rejected)
- boolean valCode = AnsibleResultCodes.CODE.checkValidCode(AnsibleResultCodes.FINALRESPONSE.getValue(), Code);
-
- if(!valCode){
- throw new APPCException("Invalid FinalResponse code = " + Code + " received. MUST be one of " + AnsibleResultCodes.CODE.getValidCodes(AnsibleResultCodes.FINALRESPONSE.getValue()));
- }
-
-
- ansibleResult.setStatusCode(Code);
- ansibleResult.setStatusMessage(Message);
- System.out.println("Received response with code = " + Integer.toString(Code) + " Message = " + Message);
-
- if(! postResponse.isNull("Results")){
-
- // Results are available. process them
- // Results is a dictionary of the form
- // {host :{status:s, group:g, message:m, hostname:h}, ...}
- System.out.println("Processing results in response");
- JSONObject results = postResponse.getJSONObject("Results");
- System.out.println("Get JSON dictionary from Results ..");
- Iterator hosts = results.keys();
- System.out.println("Iterating through hosts");
-
- while(hosts.hasNext()){
- String host = hosts.next();
- System.out.println("Processing host = " + host);
-
- try{
- JSONObject host_response = results.getJSONObject(host);
- int subCode = host_response.getInt("StatusCode");
- String message = host_response.getString("StatusMessage");
-
- System.out.println("Code = " + Integer.toString(subCode) + " Message = " + message);
-
- if(subCode != 200 || ! message.equals("SUCCESS")){
- FinalCode = AnsibleResultCodes.REQ_FAILURE.getValue();
- }
- }
- catch(JSONException e){
- ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
- ansibleResult.setStatusMessage(String.format("Error processing response message = %s from host %s", results.getString(host), host));
- break;
- }
- }
-
- ansibleResult.setStatusCode(FinalCode);
-
- // We return entire Results object as message
- ansibleResult.setResults(results.toString());
-
- }
- else{
- ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
- ansibleResult.setStatusMessage("Results not found in GET for response");
- }
-
-
- }
- catch(JSONException e){
- ansibleResult = new AnsibleResult(AnsibleResultCodes.INVALID_PAYLOAD.getValue(), "Error parsing response = " + Input + ". Error = " + e.getMessage(), "");
- }
-
-
- return ansibleResult;
- }
-
-
-
-};
-
-
-
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResult.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResult.java
deleted file mode 100644
index a4bbcbef8..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResult.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.ansible.model;
-
-
-/* Simple class to store code and message returned by POST/GET to an Ansible Server */
-public class AnsibleResult{
- private int StatusCode;
- private String StatusMessage;
- private String Results;
-
-
- public AnsibleResult(){
- StatusCode = -1;
- StatusMessage = "UNKNOWN";
- Results = "UNKNOWN";
-
- }
-
- // constructor
- public AnsibleResult(int code, String message, String result){
- StatusCode = code;
- StatusMessage = message;
- Results = result;
- }
-
- //*************************************************
- // Various set methods
- public void setStatusCode(int code){
- this.StatusCode = code;
- }
-
- public void setStatusMessage(String message){
- this.StatusMessage = message;
- }
-
- public void setResults(String results){
- this.Results = results;
- }
-
-
- void set(int code, String message, String results){
- this.StatusCode = code;
- this.StatusMessage = message;
- this.Results = results;
-
- }
-
- //*********************************************
- // Various get methods
- public int getStatusCode(){
- return this.StatusCode;
- }
-
- public String getStatusMessage(){
- return this.StatusMessage;
- }
-
- public String getResults(){
- return this.Results;
- }
-
-
-}
-
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResultCodes.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResultCodes.java
deleted file mode 100644
index 986ad3e6a..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleResultCodes.java
+++ /dev/null
@@ -1,122 +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.ansible.model;
-
-
-import java.util.*;
-
-/**
- * enum of the various codes that APP-C uses to resolve different
- * status of response from Ansible Server
- **/
-
-public enum AnsibleResultCodes{
-
- SUCCESS(400),
- KEYSTORE_EXCEPTION(622),
- CERTIFICATE_ERROR(610),
- IO_EXCEPTION (611),
- HOST_UNKNOWN(625),
- USER_UNAUTHORIZED(613),
- UNKNOWN_EXCEPTION(699),
- SSL_EXCEPTION(697),
- INVALID_PAYLOAD(698),
- INVALID_RESPONSE(601),
- PENDING(100),
- REJECTED(101),
- FINAL_SUCCESS(200),
- REQ_FAILURE(401),
- MESSAGE(1),
- CODE(0),
- INITRESPONSE(0),
- FINALRESPONSE(1);
-
- private final Set InitCodes = new HashSet(Arrays.asList(100, 101));
- private final Set FinalCodes = new HashSet(Arrays.asList(200, 500));
- private final ArrayList>CodeSets = new ArrayList>(Arrays.asList(InitCodes, FinalCodes));
-
- private final Set MessageSet = new HashSet(Arrays.asList("PENDING", "FINISHED", "TERMINATED"));
-
- private final int value;
-
- AnsibleResultCodes(int value){
- this.value = value;
- };
-
-
- public int getValue(){
- return this.value;
- }
-
-
- public boolean checkValidCode(int Type, int Code){
- SetCodeSet = CodeSets.get(Type);
- if (CodeSet.contains(Code)){
- return true;
- }
- else{
- return false;
- }
- }
-
-
- public String getValidCodes(int Type){
- SetCodeSet = CodeSets.get(Type);
-
- Iterator iter = CodeSet.iterator();
- String ValidCodes = "[ ";
- while(iter.hasNext()){
- ValidCodes = ValidCodes + iter.next().toString() + ",";
- }
-
- ValidCodes = ValidCodes + "]";
- return ValidCodes;
- }
-
-
- public boolean checkValidMessage(String Message){
- if (MessageSet.contains(Message)){
- return true;
- }
- else{
- return false;
- }
- }
-
-
-
- public String getValidMessages(){
- Iterator iter = MessageSet.iterator();
- String ValidMessage = "[ ";
- while(iter.hasNext()){
- ValidMessage = ValidMessage + iter.next() + ",";
- }
-
- ValidMessage = ValidMessage + "]";
- return ValidMessage;
- }
-
-
-};
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleServerEmulator.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleServerEmulator.java
deleted file mode 100644
index c430743ad..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/openecomp/appc/adapter/ansible/model/AnsibleServerEmulator.java
+++ /dev/null
@@ -1,148 +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=========================================================
- */
-
-
-
-
-/* Class to emulate responses from the Ansible Server that is compliant with the APP-C Ansible Server
- Interface. Used for jUnit tests to verify code is working. In tests it can be used
- as a replacement for methods from ConnectionBuilder class
-*/
-
-package org.onap.appc.adapter.ansible.model;
-
-import java.util.*;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import com.google.common.base.Strings;
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.onap.appc.exceptions.APPCException;
-import org.onap.appc.adapter.ansible.model.AnsibleResult;
-
-public class AnsibleServerEmulator {
-
-
- private String playbookName = "test_playbook.yaml";
- private String TestId;
-
- /**
- * Method that emulates the response from an Ansible Server
- when presented with a request to execute a playbook
- Returns an ansible object result. The response code is always the http code 200 (i.e connection successful)
- payload is json string as would be sent back by Ansible Server
- **/
-
- public AnsibleResult Post(String AgentUrl, String payload){
- AnsibleResult result = new AnsibleResult() ;
-
- try{
- // Request must be a JSON object
-
- JSONObject message = new JSONObject(payload);
- if (message.isNull("Id")){
- RejectRequest(result, "Must provide a valid Id");
- }
- else if(message.isNull("PlaybookName")){
- RejectRequest(result, "Must provide a playbook Name");
- }
- else if(!message.getString("PlaybookName").equals(playbookName)){
- RejectRequest(result, "Playbook " + message.getString("PlaybookName") + " not found in catalog");
- }
- else{
- AcceptRequest(result);
- }
- }
- catch (JSONException e){
- RejectRequest(result, e.getMessage());
- }
-
- return result;
- }
-
-
- /** Method to emulate response from an Ansible
- Server when presented with a GET request
- Returns an ansibl object result. The response code is always the http code 200 (i.e connection successful)
- payload is json string as would be sent back by Ansible Server
-
- **/
- public AnsibleResult Get(String AgentUrl){
-
- // Extract id
- Pattern pattern = Pattern.compile(".*?\\?Id=(.*?)&Type.*");
- Matcher matcher = pattern.matcher(AgentUrl);
- String Id = "";
-
- if (matcher.find()){
- Id = matcher.group(1);
- }
-
- AnsibleResult get_result = new AnsibleResult();
-
- JSONObject response = new JSONObject();
- response.put("StatusCode", 200);
- response.put("StatusMessage", "FINISHED");
-
- JSONObject results = new JSONObject();
-
- JSONObject vm_results = new JSONObject();
- vm_results.put("StatusCode", 200);
- vm_results.put("StatusMessage", "SUCCESS");
- vm_results.put("Id", Id);
- results.put("192.168.1.10", vm_results);
-
-
- response.put("Results", results);
-
- get_result.setStatusCode(200);
- get_result.setStatusMessage(response.toString());
-
- return get_result;
-
- }
-
-
- private void RejectRequest(AnsibleResult result, String Message){
- result.setStatusCode(200);
- JSONObject response = new JSONObject();
- response.put("StatusCode", AnsibleResultCodes.REJECTED.getValue());
- response.put("StatusMessage", Message);
- result.setStatusMessage(response.toString());
-
- }
-
- private void AcceptRequest(AnsibleResult result){
- result.setStatusCode(200);
- JSONObject response = new JSONObject();
- response.put("StatusCode", AnsibleResultCodes.PENDING.getValue());
- response.put("StatusMessage", "PENDING");
- result.setStatusMessage(response.toString());
-
- }
-
-};
-
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/onap/appc/default.properties b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..d49c0396c
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,48 @@
+###
+# ============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 TestService 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=${user.home},/opt/opendaylight/current/properties
+
+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_ansible_adapter
+
+
+# Default truststore path and password
+org.onap.appc.adapter.ansible.trustStore=/opt/opendaylight/tls-client/mykeystore.js
+org.onap.appc.adapter.ansible.trustStore.trustPasswd=changeit
+org.onap.appc.adapter.ansible.clientType=DEFAULT
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index d49c0396c..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,48 +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 TestService 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=${user.home},/opt/opendaylight/current/properties
-
-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_ansible_adapter
-
-
-# Default truststore path and password
-org.onap.appc.adapter.ansible.trustStore=/opt/opendaylight/tls-client/mykeystore.js
-org.onap.appc.adapter.ansible.trustStore.trustPasswd=changeit
-org.onap.appc.adapter.ansible.clientType=DEFAULT
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
new file mode 100644
index 000000000..88425700e
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
@@ -0,0 +1,137 @@
+/*-
+ * ============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.ansible.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.appc.Constants;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.slf4j.MDC;
+
+import org.onap.appc.adapter.ansible.AnsibleAdapter;
+import org.onap.appc.adapter.ansible.impl.AnsibleAdapterImpl;
+
+public class TestAnsibleAdapterImpl {
+
+
+ private AnsibleAdapterImpl adapter;
+ private String TestId;
+ private boolean testMode = true;
+
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+
+ }
+
+ @Before
+ public void setup() throws IllegalArgumentException, IllegalAccessException {
+ testMode = true;
+ adapter = new AnsibleAdapterImpl(testMode);
+ }
+
+ @Test
+ public void testA() throws IOException, IllegalStateException, IllegalArgumentException,
+ APPCException {
+
+ Map params = new HashMap<>();
+ params.put("AgentUrl", "https://192.168.1.1");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("PlaybookName", "test_playbook.yaml");
+
+ SvcLogicContext svcContext = new SvcLogicContext();
+ try{
+ String Pending = "100";
+ adapter.reqExec(params, svcContext);
+ String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ TestId=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.Id");
+ System.out.println("Comparing " + Pending + " and " + status);
+ assertEquals(Pending,status);
+ }
+ catch(SvcLogicException e){
+ String message =svcContext.getAttribute("org.onap.appc.adapter.ansible.result.message");
+ String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ fail(e.getMessage() + " Code = " + status);
+ }
+ catch(Exception e){
+ fail(e.getMessage() + " Unknown exception encountered " );
+ }
+
+ }
+
+ @Test
+ public void testB() throws IOException, IllegalStateException, IllegalArgumentException,
+ APPCException {
+
+ Map params = new HashMap<>();
+
+ params.put("AgentUrl", "https://192.168.1.1");
+ params.put("User", "test");
+ params.put("Password", "test");
+ params.put("Id", "100");
+
+ for (String ukey: params.keySet()){
+ System.out.println(String.format("Ansible Parameter %s = %s", ukey, params.get(ukey)));
+ }
+
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ try{
+ adapter.reqExecResult(params, svcContext);
+ String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ assertEquals("400",status);
+ }
+ catch(SvcLogicException e){
+ String message = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.message");
+ String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
+ fail(e.getMessage() + " Code = " + status);
+ }
+ catch(Exception e){
+ fail(e.getMessage() + " Unknown exception encountered " );
+ }
+
+ }
+
+}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/test/ExecutorHarness.java
new file mode 100644
index 000000000..13b5fdfb3
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-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-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/test/InterceptLogger.java
new file mode 100644
index 000000000..b101ecee4
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-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-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
deleted file mode 100644
index 88425700e..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
+++ /dev/null
@@ -1,137 +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.ansible.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.Constants;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.exceptions.APPCException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.slf4j.MDC;
-
-import org.onap.appc.adapter.ansible.AnsibleAdapter;
-import org.onap.appc.adapter.ansible.impl.AnsibleAdapterImpl;
-
-public class TestAnsibleAdapterImpl {
-
-
- private AnsibleAdapterImpl adapter;
- private String TestId;
- private boolean testMode = true;
-
- @SuppressWarnings("nls")
- @BeforeClass
- public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
-
- }
-
- @Before
- public void setup() throws IllegalArgumentException, IllegalAccessException {
- testMode = true;
- adapter = new AnsibleAdapterImpl(testMode);
- }
-
- @Test
- public void testA() throws IOException, IllegalStateException, IllegalArgumentException,
- APPCException {
-
- Map params = new HashMap<>();
- params.put("AgentUrl", "https://192.168.1.1");
- params.put("User", "test");
- params.put("Password", "test");
- params.put("PlaybookName", "test_playbook.yaml");
-
- SvcLogicContext svcContext = new SvcLogicContext();
- try{
- String Pending = "100";
- adapter.reqExec(params, svcContext);
- String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
- TestId=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.Id");
- System.out.println("Comparing " + Pending + " and " + status);
- assertEquals(Pending,status);
- }
- catch(SvcLogicException e){
- String message =svcContext.getAttribute("org.onap.appc.adapter.ansible.result.message");
- String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
- fail(e.getMessage() + " Code = " + status);
- }
- catch(Exception e){
- fail(e.getMessage() + " Unknown exception encountered " );
- }
-
- }
-
- @Test
- public void testB() throws IOException, IllegalStateException, IllegalArgumentException,
- APPCException {
-
- Map params = new HashMap<>();
-
- params.put("AgentUrl", "https://192.168.1.1");
- params.put("User", "test");
- params.put("Password", "test");
- params.put("Id", "100");
-
- for (String ukey: params.keySet()){
- System.out.println(String.format("Ansible Parameter %s = %s", ukey, params.get(ukey)));
- }
-
- SvcLogicContext svcContext = new SvcLogicContext();
-
- try{
- adapter.reqExecResult(params, svcContext);
- String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
- assertEquals("400",status);
- }
- catch(SvcLogicException e){
- String message = svcContext.getAttribute("org.onap.appc.adapter.ansible.result.message");
- String status=svcContext.getAttribute("org.onap.appc.adapter.ansible.result.code");
- fail(e.getMessage() + " Code = " + status);
- }
- catch(Exception e){
- fail(e.getMessage() + " Unknown exception encountered " );
- }
-
- }
-
-}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
deleted file mode 100644
index 13b5fdfb3..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-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-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
deleted file mode 100644
index b101ecee4..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-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-ansible-adapter/appc-ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..bb888132a
--- /dev/null
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-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-ansible-adapter/appc-ansible-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index bb888132a..000000000
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-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
-
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
-
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java
new file mode 100644
index 000000000..812f80121
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java
@@ -0,0 +1,106 @@
+/*-
+ * ============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.messaging.dmaap;
+
+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 AppcDmaapAdapterActivator implements BundleActivator {
+ private ServiceRegistration registration = null;
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(AppcDmaapAdapterActivator.class);
+
+ /**
+ * 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 bundleContext
+ * 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(final BundleContext bundleContext) throws Exception {
+ LOG.info("Starting Bundle " + getName());
+ }
+
+ /**
+ * 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 ctx
+ * 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 ctx) throws Exception {
+ LOG.info("Stopped Bundle " + getName());
+ }
+
+ public String getName() {
+ return "DMaaP Adapter";
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java
new file mode 100644
index 000000000..76b050d8e
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/CommonHttpClient.java
@@ -0,0 +1,108 @@
+/*-
+ * ============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.messaging.dmaap.http;
+
+import java.net.URI;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.config.RequestConfig.Builder;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+
+public class CommonHttpClient {
+
+ public static final int HTTPS_PORT = 3905;
+
+ private String AUTH_STR;
+
+ protected void setBasicAuth(String username, String password) {
+ if (username != null && password != null) {
+ String plain = String.format("%s:%s", username, password);
+ AUTH_STR = Base64.encodeBase64String(plain.getBytes());
+ } else {
+ AUTH_STR = null;
+ }
+ }
+
+ public HttpGet getReq(URI uri, int timeoutMs) throws Exception {
+ HttpGet out = (uri == null) ? new HttpGet() : new HttpGet(uri);
+ if (AUTH_STR != null) {
+ out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
+ }
+ out.setConfig(getConfig(timeoutMs));
+ return out;
+ }
+
+ public HttpPost postReq(String url) throws Exception {
+ HttpPost out = (url == null) ? new HttpPost() : new HttpPost(url);
+ if (AUTH_STR != null) {
+ out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
+ }
+ out.setConfig(getConfig(0));
+ return out;
+ }
+
+ private RequestConfig getConfig(int timeoutMs) {
+ Builder builder = RequestConfig.custom();
+ builder.setSocketTimeout(timeoutMs + 5000);
+ return builder.build();
+ }
+
+ public CloseableHttpClient getClient() {
+ return getClient(false);
+ }
+
+ public CloseableHttpClient getClient(boolean useHttps) {
+ return HttpClientBuilder.create().build();
+ }
+
+ public String formatHostString(String host) {
+ return formatHostString(host, host.contains(String.valueOf(HTTPS_PORT)));
+ }
+
+ public String formatHostString(String host, boolean useHttps) {
+ // Trim trailing slash
+ String out = host.endsWith("/") ? host.substring(0, host.length() - 1) : host;
+
+ boolean hasProto = out.startsWith("http");
+ boolean hasPort = out.contains(":");
+
+ // Add protocol
+ if (!hasProto) {
+ out = String.format("%s%s", (useHttps) ? "https://" : "http://", out);
+ }
+
+ // Add port
+ if (!hasPort) {
+ out = String.format("%s:%d", out, (useHttps) ? 3905 : 3904);
+ }
+
+ return out;
+
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.java
new file mode 100644
index 000000000..df81e9718
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.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.messaging.dmaap.http;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.onap.appc.adapter.message.Consumer;
+
+public class HttpDmaapConsumerImpl extends CommonHttpClient implements Consumer {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(HttpDmaapConsumerImpl.class);
+
+ // Default values
+ private static final int DEFAULT_TIMEOUT_MS = 15000;
+ private static final int DEFAULT_LIMIT = 1000;
+ private static final String HTTPS_PORT = ":3905";
+ private static final String URL_TEMPLATE = "%s/events/%s/%s/%s";
+
+ private List urls;
+ private String filter;
+
+ private boolean useHttps = false;
+
+ public HttpDmaapConsumerImpl(Collection hosts, String topicName, String consumerName, String consumerId) {
+ this(hosts, topicName, consumerName, consumerId, null);
+ }
+
+ public HttpDmaapConsumerImpl(Collection hosts, String topicName, String consumerName, String consumerId,
+ String filter) {
+ this(hosts, topicName, consumerName, consumerId, filter, null, null);
+ }
+
+ public HttpDmaapConsumerImpl(Collection hosts, String topicName, String consumerName, String consumerId,
+ String filter, String user, String password) {
+ urls = new ArrayList();
+ for (String host : hosts) {
+ urls.add(String.format(URL_TEMPLATE, formatHostString(host), topicName, consumerName, consumerId));
+ }
+ this.filter = filter;
+ updateCredentials(user, password);
+ }
+
+ @Override
+ public void updateCredentials(String user, String pass) {
+ LOG.debug(String.format("Setting auth to %s for %s", user, this.toString()));
+ this.setBasicAuth(user, pass);
+ }
+
+ @Override
+ public List fetch(int waitMs, int limit) {
+ LOG.debug(String.format("Fetching up to %d records with %dms wait on %s", limit, waitMs, this.toString()));
+ List out = new ArrayList();
+ try {
+ List urlParams = new ArrayList();
+ urlParams.add(new BasicNameValuePair("timeout", String.valueOf(waitMs)));
+ urlParams.add(new BasicNameValuePair("limit", String.valueOf(limit)));
+ if (filter != null) {
+ urlParams.add(new BasicNameValuePair("filter", filter));
+ }
+
+ URIBuilder builder = new URIBuilder(urls.get(0));
+ builder.setParameters(urlParams);
+
+ URI uri = builder.build();
+ LOG.info(String.format("GET %s", uri));
+ HttpGet request = getReq(uri, waitMs);
+ CloseableHttpResponse response = getClient().execute(request);
+
+ int httpStatus = response.getStatusLine().getStatusCode();
+ HttpEntity entity = response.getEntity();
+ String body = (entity != null) ? EntityUtils.toString(entity) : null;
+
+ LOG.debug(String.format("Request to %s completed with status %d and a body size of %s", uri, httpStatus,
+ (body != null ? body.length() : "null")));
+
+ response.close();
+ if (httpStatus == 200 && body != null) {
+ JSONArray json = new JSONArray(body);
+ LOG.info(String.format("Got %d messages from DMaaP", json.length()));
+ for (int i = 0; i < json.length(); i++) {
+ out.add(json.getString(i));
+ }
+ } else {
+ LOG.error(String.format("Did not get 200 from DMaaP. Got %d - %s", httpStatus, body));
+ sleep(waitMs);
+ }
+ } catch (Exception e) {
+ if (urls.size() > 1) {
+ String failedUrl = urls.remove(0);
+ urls.add(failedUrl);
+ LOG.debug(String.format("Moving host %s to the end of the pool. New primary host is %s", failedUrl,
+ urls.get(0)));
+ }
+ LOG.error(String.format("Got exception while querying DMaaP. Message: %s", e.getMessage()), e);
+ sleep(waitMs);
+ }
+
+ return out;
+ }
+
+ @Override
+ public List fetch() {
+ return fetch(DEFAULT_TIMEOUT_MS, DEFAULT_LIMIT);
+ }
+
+ @Override
+ public String toString() {
+ String hostStr = (urls == null || urls.isEmpty()) ? "N/A" : urls.get(0);
+ return String.format("Consumer listening to [%s]", hostStr);
+ }
+
+ @Override
+ public void useHttps(boolean yes) {
+ useHttps = yes;
+ }
+
+ private void sleep(int ms) {
+ LOG.info(String.format("Sleeping for %ds after failed request", ms / 1000));
+ try {
+ Thread.sleep(ms);
+ } catch (InterruptedException e1) {
+ LOG.error("Interrupted while sleeping");
+ }
+ }
+
+ @Override
+ public void close() {
+ // Nothing to do
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java
new file mode 100644
index 000000000..560c09be4
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java
@@ -0,0 +1,138 @@
+/*-
+ * ============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.messaging.dmaap.http;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.onap.appc.adapter.message.Producer;
+
+public class HttpDmaapProducerImpl extends CommonHttpClient implements Producer {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(HttpDmaapProducerImpl.class);
+
+ private static final String CONTENT_TYPE = "application/cambria";
+ private static final String URL_TEMPLATE = "%s/events/%s";
+
+ private List hosts;
+ private Set topics;
+
+ private boolean useHttps = false;
+
+ public HttpDmaapProducerImpl(Collection urls, String topicName) {
+ hosts = new ArrayList();
+ topics = new HashSet();
+ topics.add(topicName);
+
+ for (String host : urls) {
+ hosts.add(formatHostString(host));
+ }
+ }
+
+ public HttpDmaapProducerImpl(Collection urls, Set topicNames) {
+ hosts = new ArrayList();
+ topics = topicNames;
+
+ for (String host : urls) {
+ hosts.add(formatHostString(host));
+ }
+ }
+
+ @Override
+ public void updateCredentials(String user, String pass) {
+ LOG.debug(String.format("Setting auth to %s for %s", user, this.toString()));
+ this.setBasicAuth(user, pass);
+ }
+
+ @Override
+ public boolean post(String partition, String data) {
+ int sent = 0;
+ try {
+ HttpPost request = postReq(null);
+ request.setHeader("Content-Type", CONTENT_TYPE);
+ request.setEntity(new StringEntity(bodyLine(partition, data)));
+
+ for (String topic : topics) {
+ String uriStr = String.format(URL_TEMPLATE, hosts.get(0), topic);
+ try {
+ request.setURI(new URI(uriStr));
+ CloseableHttpResponse response = getClient().execute(request);
+ if (response.getStatusLine().getStatusCode() == 200) {
+ sent++;
+ }
+ response.close();
+ } catch (Exception sendEx) {
+ LOG.error(String.format("Failed to send message to %s. Reason: %s", uriStr, sendEx.getMessage()),
+ sendEx);
+ if (hosts.size() > 1) {
+ String failedUrl = hosts.remove(0);
+ hosts.add(failedUrl);
+ LOG.debug(String.format("Moving host %s to the end of the pool. New primary host is %s",
+ failedUrl, hosts.get(0)));
+ }
+ }
+ }
+ } catch (Exception buildEx) {
+ LOG.error(
+ String.format("Failed to build request with string [%s]. Message not sent to any topic. Reason: %s",
+ data, buildEx.getMessage()),
+ buildEx);
+ }
+ return sent == topics.size();
+ }
+
+ @Override
+ public void useHttps(boolean yes) {
+ useHttps = yes;
+ }
+
+ /**
+ * Format the body for the application/cambria content type with no partitioning. See
+ *
+ * @param msg
+ * The message body to format
+ * @return A string in the application/cambria content type
+ */
+ private String bodyLine(String partition, String msg) {
+ String p = (partition == null) ? "" : partition;
+ String m = (msg == null) ? "" : msg;
+ return String.format("%d.%d.%s%s", p.length(), m.length(), p, m);
+ }
+
+ @Override
+ public void close() {
+ // Nothing to do
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java
new file mode 100644
index 000000000..ddf630545
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java
@@ -0,0 +1,234 @@
+/*-
+ * ============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.messaging.dmaap.impl;
+
+import java.io.IOException;
+import java.util.*;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+//import com.att.nsa.cambria.client.CambriaClientBuilders;
+//import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
+//import com.att.nsa.cambria.client.CambriaConsumer;
+
+import com.att.nsa.mr.client.MRClientFactory;
+import com.att.nsa.mr.client.MRConsumer;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.metricservice.MetricRegistry;
+import org.onap.appc.metricservice.MetricService;
+import org.onap.appc.metricservice.impl.MetricServiceImpl;
+import org.onap.appc.metricservice.metric.Metric;
+import org.onap.appc.metricservice.metric.MetricType;
+import org.onap.appc.metricservice.metric.DmaapRequestCounterMetric;
+import org.onap.appc.metricservice.policy.PublishingPolicy;
+import org.onap.appc.metricservice.publisher.LogPublisher;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+public class DmaapConsumerImpl implements Consumer {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(DmaapConsumerImpl.class);
+ private static final Configuration configuration = ConfigurationFactory.getConfiguration();
+ // Default values
+ private static final int DEFAULT_TIMEOUT_MS = 60000;
+ private static final int DEFAULT_LIMIT = 1000;
+ private static MetricRegistry metricRegistry;
+ private String topic;
+ private DmaapRequestCounterMetric dmaapKpiMetric;
+ private boolean isMetricEnabled=false;
+ private boolean useHttps = false;
+ private MRConsumer client = null;
+ private Properties props = null;
+
+
+ public DmaapConsumerImpl(Collection urls, String topicName, String consumerGroupName, String consumerId,String user, String password) {
+ this(urls, topicName, consumerGroupName, consumerId,user, password,null);
+
+ }
+
+ public DmaapConsumerImpl(Collection urls, String topicName, String consumerGroupName, String consumerId,String user, String password,String filter) {
+ this.topic = topicName;
+ this.props = new Properties();
+ String urlsStr = StringUtils.join(urls, ',');
+ props.setProperty("host",urlsStr);
+ props.setProperty("group",consumerGroupName);
+ props.setProperty("id",consumerId);
+ props.setProperty("username",user);
+ props.setProperty("password",password);
+ if(filter != null) {
+ props.setProperty("filter", filter);
+ }
+ }
+
+
+ private void initMetric() {
+ LOG.debug("Metric getting initialized");
+ MetricService metricService = getMetricservice();
+ metricRegistry = metricService.createRegistry("APPC");
+ dmaapKpiMetric = metricRegistry.metricBuilderFactory().
+ dmaapRequestCounterBuilder().
+ withName("DMAAP_KPI").withType(MetricType.COUNTER).
+ withRecievedMessage(0)
+ .withPublishedMessage(0)
+ .build();
+ if (metricRegistry.register(dmaapKpiMetric)) {
+ Metric[] metrics = new Metric[]{dmaapKpiMetric};
+ LogPublisher logPublisher = new LogPublisher(metricRegistry, metrics);
+ LogPublisher[] logPublishers = new LogPublisher[1];
+ logPublishers[0] = logPublisher;
+ PublishingPolicy manuallyScheduledPublishingPolicy = metricRegistry.policyBuilderFactory().
+ scheduledPolicyBuilder().withPublishers(logPublishers).
+ withMetrics(metrics).
+ build();
+ LOG.debug("Policy getting initialized");
+ manuallyScheduledPublishingPolicy.init();
+ LOG.debug("Metric initialized");
+ }
+ }
+ private MRConsumer getClient() {
+ return getClient(DEFAULT_TIMEOUT_MS, DEFAULT_LIMIT);
+ }
+
+ /**
+ * @return An instance of MRConsumer created from our class variables
+ */
+ private synchronized MRConsumer getClient(int waitMs, int limit) {
+ try {
+ props.setProperty("timeout",String.valueOf(waitMs));
+ props.setProperty("limit",String.valueOf(limit));
+ String topicProducerPropFileName = DmaapUtil.createConsumerPropFile(topic,props);
+ return MRClientFactory.createConsumer ( topicProducerPropFileName);
+ } catch (IOException e1) {
+ LOG.error("failed to createConsumer",e1);
+ return null;
+ }
+ }
+
+ @Override
+ public synchronized void updateCredentials(String key, String secret) {
+ LOG.info(String.format("Setting auth to %s for %s", key, this.toString()));
+ String user = key;
+ String password = secret;
+ props.setProperty("user",String.valueOf(user));
+ props.setProperty("password",String.valueOf(password));
+ client = null;
+ }
+
+ @Override
+ public List fetch(int waitMs, int limit) {
+ Properties properties=configuration.getProperties();
+ if(properties!=null && properties.getProperty("metric.enabled")!=null ){
+ isMetricEnabled=Boolean.valueOf(properties.getProperty("metric.enabled"));
+ }
+ if(isMetricEnabled){
+ initMetric();
+ }
+ LOG.debug(String.format("Fetching up to %d records with %dms wait on %s", limit, waitMs, this.toString()));
+ List out = new ArrayList();
+
+ // Create client once and reuse it on subsequent fetches. This is
+ // to support failover to other servers in the DMaaP cluster.
+ if (client == null) {
+ LOG.info("Getting DMaaP Client ...");
+ client = getClient(waitMs, limit);
+ }
+ try {
+ for (String s : client.fetch(waitMs, limit)) {
+ out.add(s);
+ if(isMetricEnabled){
+ ((DmaapRequestCounterMetric)metricRegistry.metric("DMAAP_KPI")).incrementRecievedMessage();
+ }
+ }
+ LOG.debug(String.format("Got %d records from %s", out.size(), this.toString()));
+ } catch (Exception e) {
+ // Connection exception
+ LOG.error(String.format("Dmaap Connection Issue Detected. %s", e.getMessage()));
+ e.printStackTrace();
+ try {
+ LOG.warn(String.format("Sleeping for %dms to compensate for connection failure", waitMs));
+ Thread.sleep(waitMs);
+ } catch (InterruptedException e2) {
+ LOG.warn(String.format("Failed to wait for %dms after bad fetch", waitMs));
+ }
+ }
+
+
+ return out;
+ }
+
+ /**
+ * Close consumer Dmaap client
+ */
+ @Override
+ public void close() {
+ LOG.debug("Closing Dmaap consumer client....");
+ if (client != null) {
+ client.close();
+ }
+ }
+
+ @Override
+ public List fetch() {
+ return fetch(DEFAULT_TIMEOUT_MS, DEFAULT_LIMIT);
+ }
+
+ @Override
+ public String toString() {
+ String hostStr = (props == null || props.getProperty("host") == null? "N/A" : props.getProperty("host"));
+ String group = (props == null || props.getProperty("group") == null? "N/A" : props.getProperty("group"));
+ String id = (props == null || props.getProperty("id") == null? "N/A" : props.getProperty("id"));
+ return String.format("Consumer %s/%s listening to %s on [%s]", group, id, topic, hostStr);
+ }
+
+ @Override
+ public void useHttps(boolean yes) {
+ useHttps = yes;
+ }
+
+
+ private MetricService getMetricservice() {
+ BundleContext bctx = FrameworkUtil.getBundle(MetricService.class).getBundleContext();
+ // Get AAIadapter reference
+ ServiceReference sref = bctx.getServiceReference(MetricService.class.getName());
+ if (sref != null) {
+ LOG.info("Metric Service from bundlecontext");
+ return (MetricServiceImpl) bctx.getService(sref);
+
+ } else {
+ LOG.info("Metric Service error from bundlecontext");
+ LOG.warn("Cannot find service reference for org.onap.appc.metricservice.MetricService");
+ return null;
+
+ }
+ }
+
+ public Metric getMetric(String name){
+ return metricRegistry.metric(name);
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java
new file mode 100644
index 000000000..7ed06a9e3
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java
@@ -0,0 +1,223 @@
+/*-
+ * ============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.messaging.dmaap.impl;
+
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+//import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+//import com.att.nsa.cambria.client.CambriaClientBuilders;
+//import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
+
+import com.att.nsa.mr.client.MRBatchingPublisher;
+import com.att.nsa.mr.client.MRClientFactory;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapUtil;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.metricservice.MetricRegistry;
+import org.onap.appc.metricservice.MetricService;
+import org.onap.appc.metricservice.metric.Metric;
+import org.onap.appc.metricservice.metric.MetricType;
+import org.onap.appc.metricservice.metric.DmaapRequestCounterMetric;
+import org.onap.appc.metricservice.policy.PublishingPolicy;
+import org.onap.appc.metricservice.publisher.LogPublisher;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+
+public class DmaapProducerImpl implements Producer {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(DmaapProducerImpl.class);
+ private static final Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ private Set topics = new HashSet();
+
+ private Properties props = null;
+ private static MetricRegistry metricRegistry;
+ private boolean useHttps = false;
+ private DmaapRequestCounterMetric dmaapKpiMetric;
+ private boolean isMetricEnabled=false;
+
+ private Set clients;
+
+
+ public DmaapProducerImpl(Collection urls, String topicName, String user, String password) {
+ this(urls, (Set)null, user, password);
+ this.topics = new HashSet<>();
+ if (topicName != null) {
+ for (String topic : topicName.split(",")) {
+ topics.add(topic);
+ }
+ }
+ }
+
+ public DmaapProducerImpl(Collection urls, Set topicNames, String user, String password) {
+ topics = topicNames;
+ if(urls == null || user == null || password == null){
+ throw new IllegalArgumentException("one of these mandaory argument is null: urls, user, password" );
+ }
+ this.props = new Properties();
+ String urlsStr = StringUtils.join(urls, ',');
+ props.setProperty("host",urlsStr);
+ props.setProperty("id", UUID.randomUUID().toString());
+ props.setProperty("username",user);
+ props.setProperty("password",password);
+ }
+ private void initMetric() {
+ LOG.debug("Metric getting initialized");
+ MetricService metricService = getMetricservice();
+ metricRegistry=metricService.createRegistry("APPC");
+ dmaapKpiMetric = metricRegistry.metricBuilderFactory().
+ dmaapRequestCounterBuilder().
+ withName("DMAAP_KPI").withType(MetricType.COUNTER).
+ withRecievedMessage(0)
+ .withPublishedMessage(0)
+ .build();
+ if(metricRegistry.register(dmaapKpiMetric)) {
+ Metric[] metrics = new Metric[]{dmaapKpiMetric};
+ LogPublisher logPublisher = new LogPublisher(metricRegistry, metrics);
+ LogPublisher[] logPublishers = new LogPublisher[1];
+ logPublishers[0] = logPublisher;
+ PublishingPolicy manuallyScheduledPublishingPolicy = metricRegistry.policyBuilderFactory().
+ scheduledPolicyBuilder().withPublishers(logPublishers).
+ withMetrics(metrics).
+ build();
+ LOG.debug("Policy getting initialized");
+ manuallyScheduledPublishingPolicy.init();
+ LOG.debug("Metric initialized");
+ }
+
+ }
+ private Set getClients() {
+ Set out = new HashSet();
+ for (String topic : topics) {
+ try {
+ String topicProducerPropFileName = DmaapUtil.createProducerPropFile(topic,props);
+ final MRBatchingPublisher client = MRClientFactory.createBatchingPublisher (topicProducerPropFileName);
+ out.add(client);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ return out;
+ }
+
+ @Override
+ public synchronized void updateCredentials(String key, String secret) {
+ LOG.info(String.format("Setting auth to %s for %s", key, this.toString()));
+ String user = key;
+ String password = secret;
+ props.setProperty("user",String.valueOf(user));
+ props.setProperty("password",String.valueOf(password));
+ clients = null;
+ }
+
+ @Override
+ public boolean post(String partition, String data) {
+ boolean success = true;
+ Properties properties=configuration.getProperties();
+ if(properties!=null && properties.getProperty("metric.enabled")!=null ){
+ isMetricEnabled=Boolean.valueOf(properties.getProperty("metric.enabled"));
+ }
+ if(isMetricEnabled){
+ initMetric();
+ }
+
+ // Create clients once and reuse them on subsequent posts. This is
+ // to support failover to other servers in the Dmaap cluster.
+ if ((clients == null) || (clients.isEmpty())) {
+ LOG.info("Getting CambriaBatchingPublisher Clients ...");
+ clients = getClients();
+ }
+
+ for (MRBatchingPublisher client : clients) {
+ try {
+ LOG.debug(String.format("Posting %s to %s", data, client));
+ client.send(partition, data);
+ } catch (IOException e) {
+ e.printStackTrace();
+ success = false;
+ }
+ }
+ if(isMetricEnabled){
+ ( (DmaapRequestCounterMetric) metricRegistry.metric("DMAAP_KPI")).incrementPublishedMessage();
+ }
+ return success;
+ }
+
+ /**
+ * Close producer Dmaap client
+ */
+ @Override
+ public void close() {
+ if ((clients == null) || (clients.isEmpty())) {
+ return;
+ }
+
+ LOG.debug("Closing Dmaap producer clients....");
+ for (MRBatchingPublisher client : clients) {
+ try {
+ client.close(1, TimeUnit.SECONDS);
+ } catch (IOException | InterruptedException e) {
+ LOG.warn(String.format("Failed to cleanly close Dmaap connection for [%s]", client));
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void useHttps(boolean yes) {
+ useHttps = yes;
+ }
+
+ private MetricService getMetricservice() {
+/*
+ return AppcDmaapAdapterActivator.getMetricService();
+*/
+
+ BundleContext bctx = FrameworkUtil.getBundle(MetricService.class).getBundleContext();
+ ServiceReference sref = bctx.getServiceReference(MetricService.class.getName());
+ if (sref != null) {
+ LOG.info("Metric Service from bundlecontext");
+ return (MetricService) bctx.getService(sref);
+
+ } else {
+ LOG.info("Metric Service error from bundlecontext");
+ LOG.warn("Cannot find service reference for org.onap.appc.metricservice.MetricService");
+ return null;
+
+ }
+ }
+
+ public Metric getMetric(String name){
+ return metricRegistry.metric(name);
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapUtil.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapUtil.java
new file mode 100644
index 000000000..da1b0fa38
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/DmaapUtil.java
@@ -0,0 +1,86 @@
+/*-
+ * ============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.messaging.dmaap.impl;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class DmaapUtil {
+ private final static String delimiter = "_";
+ private static String createPreferredRouteFileIfNotExist(String topic) throws IOException {
+ String topicPreferredRouteFileName = null;
+ topicPreferredRouteFileName = topic+"preferredRoute.properties";
+ File fo= new File(topicPreferredRouteFileName);
+ if(!fo.exists()) {
+ ClassLoader classLoader = DmaapUtil.class.getClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream("preferredRoute.txt");
+ Properties props = new Properties();
+ props.load(inputStream);
+ String fileName = topic != null ? topic+delimiter+"MR1" : delimiter+"MR1";
+ props.setProperty("preferredRouteKey", fileName);
+ topicPreferredRouteFileName = topic + "preferredRoute.properties";
+ props.store(new FileOutputStream(topicPreferredRouteFileName), "preferredRoute.properties file created on the fly for topic:" + topic + " on:" + System.currentTimeMillis());
+ }
+ return topicPreferredRouteFileName;
+ }
+
+ public static String createConsumerPropFile(String topic, Properties props)throws IOException {
+ String defaultProfFileName = "consumer.properties";
+ String topicConsumerPropFileName = createConsumerProducerPropFile(topic, defaultProfFileName,props);
+ return topicConsumerPropFileName;
+ }
+
+ public static String createProducerPropFile(String topic, Properties props)throws IOException {
+ String defaultProfFileName = "producer.properties";
+ String topicConsumerPropFileName = createConsumerProducerPropFile(topic, defaultProfFileName,props);
+ return topicConsumerPropFileName;
+ }
+
+ private static String createConsumerProducerPropFile(String topic, String defaultProfFileName, Properties props) throws IOException {
+ ClassLoader classLoader = DmaapUtil.class.getClassLoader();
+ InputStream inputStream = classLoader.getResourceAsStream(defaultProfFileName);
+ Properties defaultProps = new Properties();
+ defaultProps.load(inputStream);
+ defaultProps.setProperty("topic",topic);
+
+ String preferredRouteFileName = DmaapUtil.createPreferredRouteFileIfNotExist(topic);
+ if(props != null && !props.isEmpty()){
+ defaultProps.putAll(props);
+ }
+ defaultProps.setProperty("topic",topic);
+ defaultProps.setProperty("DME2preferredRouterFilePath",preferredRouteFileName);
+ String id = defaultProps.getProperty("id");
+ String topicConsumerPropFileName = defaultProfFileName;
+ topicConsumerPropFileName = id != null ? id+delimiter+topicConsumerPropFileName : delimiter+topicConsumerPropFileName;
+ topicConsumerPropFileName = topic != null ? topic+delimiter+topicConsumerPropFileName : delimiter+topicConsumerPropFileName;
+
+ defaultProps.store(new FileOutputStream(topicConsumerPropFileName), defaultProfFileName+" file created on the fly for topic:"+topic+" on:"+System.currentTimeMillis());
+ return topicConsumerPropFileName;
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java
new file mode 100644
index 000000000..bf7649026
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/onap/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java
@@ -0,0 +1,178 @@
+/*-
+ * ============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.messaging.dmaap.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.onap.appc.adapter.message.EventSender;
+import org.onap.appc.adapter.message.MessageDestination;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.message.event.EventHeader;
+import org.onap.appc.adapter.message.event.EventMessage;
+import org.onap.appc.adapter.message.event.EventStatus;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.exceptions.APPCException;
+
+public class EventSenderDmaapImpl implements EventSender
+{
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(EventSenderDmaapImpl.class);
+ public static final String EVENT_TOPIC_WRITE = "dmaap.event.topic.write";
+ public static final String DMAAP_USERNAME = "dmaap.appc.username";
+ public static final String DMAAP_PASSWORD = "dmaap.appc.password";
+ public static final String EVENT_POOL_MEMBERS = "dmaap.event.pool.members";
+
+ private static Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ private Map producerMap = new ConcurrentHashMap<>();
+
+ public Map getProducerMap() {
+ return producerMap;
+ }
+
+ public void setProducerMap(Map producerMap) {
+ this.producerMap = producerMap;
+ }
+
+ public EventSenderDmaapImpl(){
+
+ }
+
+ public void initialize(){
+ Properties properties = configuration.getProperties();
+ String writeTopic;
+ String username;
+ String password;
+ final List pool = new ArrayList<>();
+
+ for(MessageDestination destination: MessageDestination.values()){
+ writeTopic = properties.getProperty(destination + "." + EVENT_TOPIC_WRITE);
+ username = properties.getProperty(destination + "." + DMAAP_USERNAME);
+ password = properties.getProperty(destination + "." + DMAAP_PASSWORD);
+ String hostNames = properties.getProperty(destination + "." + EVENT_POOL_MEMBERS);
+
+ if (hostNames != null && !hostNames.isEmpty()) {
+ LOG.debug(String.format("hostNames = %s, taken from property: %s", hostNames, destination + "." + EVENT_POOL_MEMBERS));
+ Collections.addAll(pool, hostNames.split(","));
+ }
+
+ LOG.debug(String.format("pool = %s, taken from property: %s", pool, destination + "." + EVENT_POOL_MEMBERS));
+ LOG.debug(String.format("writeTopic = %s, taken from property: %s", writeTopic, destination + "." + EVENT_TOPIC_WRITE));
+ LOG.debug(String.format("username = %s, taken from property: %s", username, destination + "." + DMAAP_USERNAME));
+ Producer producer = new DmaapProducerImpl(pool, writeTopic,username, password);
+
+ for (String url : pool) {
+ if (url.contains("3905") || url.contains("https")) {
+ LOG.debug("Producer should use HTTPS");
+ producer.useHttps(true);
+ break;
+ }
+ }
+ producerMap.put(destination.toString(),producer);
+ }
+
+ }
+
+ @Override
+ public boolean sendEvent(MessageDestination destination, EventMessage msg) {
+ String jsonStr = msg.toJson();
+ String id = msg.getEventHeader().getEventId();
+ LOG.info(String.format("Posting Message [%s - %s]", id, jsonStr));
+ Producer producer = producerMap.get(destination.toString());
+ return producer.post(id, jsonStr);
+ }
+
+ @Override
+ public boolean sendEvent(MessageDestination destination, EventMessage msg, String eventTopicName) {
+ String jsonStr = msg.toJson();
+ String id = msg.getEventHeader().getEventId();
+ LOG.info(String.format("Posting Message [%s - %s]", id, jsonStr));
+ Producer producer = createProducer(destination, eventTopicName);
+ return producer.post(id, jsonStr);
+ }
+
+ private Producer createProducer(MessageDestination destination, String eventTopicName) {
+ Properties properties = configuration.getProperties();
+ final List pool = new ArrayList<>();
+ String username = properties.getProperty(destination + "." + DMAAP_USERNAME);
+ String password = properties.getProperty(destination + "." + DMAAP_PASSWORD);
+ String hostNames = properties.getProperty(destination + "." + EVENT_POOL_MEMBERS);
+
+ if (hostNames != null && !hostNames.isEmpty()) {
+ LOG.debug(String.format("hostNames = %s, taken from property: %s", hostNames, destination + "." + EVENT_POOL_MEMBERS));
+ Collections.addAll(pool, hostNames.split(","));
+ }
+
+ LOG.debug(String.format("pool = %s, taken from property: %s", pool, destination + "." + EVENT_POOL_MEMBERS));
+ LOG.debug(String.format("writeTopic = %s, taken from property: %s", eventTopicName, destination + "." + EVENT_TOPIC_WRITE));
+ LOG.debug(String.format("username = %s, taken from property: %s", username, destination + "." + DMAAP_USERNAME));
+ Producer producer = new DmaapProducerImpl(pool, eventTopicName,username, password);
+
+ for (String url : pool) {
+ if (url.contains("3905") || url.contains("https")) {
+ LOG.debug("Producer should use HTTPS");
+ producer.useHttps(true);
+ break;
+ }
+ }
+ return producer;
+ }
+
+ @Override
+ public boolean sendEvent(MessageDestination destination, Map params, SvcLogicContext ctx) throws APPCException {
+
+ if (params == null) {
+ String message = "Parameters map is empty (null)";
+ LOG.error(message);
+ throw new APPCException(message);
+ }
+ String eventTime = new Date(System.currentTimeMillis()).toString();
+ String apiVer = params.get("apiVer");
+ String eventId = params.get("eventId");
+ String reason = params.get("reason");
+ String entityId=params.get("entityId");
+ if(entityId!=null){
+ reason=reason+"("+entityId+")";
+ }
+ Integer code = Integer.getInteger(params.get("code"), 500);
+
+ if (eventTime == null || apiVer == null || eventId == null || reason == null) {
+ String message = String.format("Missing input parameters: %s", params);
+ LOG.error(message);
+ throw new APPCException(message);
+ }
+ EventMessage eventMessage = new EventMessage(
+ new EventHeader(eventTime, apiVer, eventId),
+ new EventStatus(code, reason));
+
+ return sendEvent(destination,eventMessage);
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java
deleted file mode 100644
index 812f80121..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/AppcDmaapAdapterActivator.java
+++ /dev/null
@@ -1,106 +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.messaging.dmaap;
-
-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 AppcDmaapAdapterActivator implements BundleActivator {
- private ServiceRegistration registration = null;
-
- /**
- * The logger to be used
- */
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(AppcDmaapAdapterActivator.class);
-
- /**
- * 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 bundleContext
- * 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(final BundleContext bundleContext) throws Exception {
- LOG.info("Starting Bundle " + getName());
- }
-
- /**
- * 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 ctx
- * 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 ctx) throws Exception {
- LOG.info("Stopped Bundle " + getName());
- }
-
- public String getName() {
- return "DMaaP Adapter";
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java
deleted file mode 100644
index 76b050d8e..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java
+++ /dev/null
@@ -1,108 +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.messaging.dmaap.http;
-
-import java.net.URI;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.config.RequestConfig.Builder;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-
-public class CommonHttpClient {
-
- public static final int HTTPS_PORT = 3905;
-
- private String AUTH_STR;
-
- protected void setBasicAuth(String username, String password) {
- if (username != null && password != null) {
- String plain = String.format("%s:%s", username, password);
- AUTH_STR = Base64.encodeBase64String(plain.getBytes());
- } else {
- AUTH_STR = null;
- }
- }
-
- public HttpGet getReq(URI uri, int timeoutMs) throws Exception {
- HttpGet out = (uri == null) ? new HttpGet() : new HttpGet(uri);
- if (AUTH_STR != null) {
- out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
- }
- out.setConfig(getConfig(timeoutMs));
- return out;
- }
-
- public HttpPost postReq(String url) throws Exception {
- HttpPost out = (url == null) ? new HttpPost() : new HttpPost(url);
- if (AUTH_STR != null) {
- out.setHeader("Authorization", String.format("Basic %s", AUTH_STR));
- }
- out.setConfig(getConfig(0));
- return out;
- }
-
- private RequestConfig getConfig(int timeoutMs) {
- Builder builder = RequestConfig.custom();
- builder.setSocketTimeout(timeoutMs + 5000);
- return builder.build();
- }
-
- public CloseableHttpClient getClient() {
- return getClient(false);
- }
-
- public CloseableHttpClient getClient(boolean useHttps) {
- return HttpClientBuilder.create().build();
- }
-
- public String formatHostString(String host) {
- return formatHostString(host, host.contains(String.valueOf(HTTPS_PORT)));
- }
-
- public String formatHostString(String host, boolean useHttps) {
- // Trim trailing slash
- String out = host.endsWith("/") ? host.substring(0, host.length() - 1) : host;
-
- boolean hasProto = out.startsWith("http");
- boolean hasPort = out.contains(":");
-
- // Add protocol
- if (!hasProto) {
- out = String.format("%s%s", (useHttps) ? "https://" : "http://", out);
- }
-
- // Add port
- if (!hasPort) {
- out = String.format("%s:%d", out, (useHttps) ? 3905 : 3904);
- }
-
- return out;
-
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.java
deleted file mode 100644
index df81e9718..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapConsumerImpl.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.messaging.dmaap.http;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.onap.appc.adapter.message.Consumer;
-
-public class HttpDmaapConsumerImpl extends CommonHttpClient implements Consumer {
-
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(HttpDmaapConsumerImpl.class);
-
- // Default values
- private static final int DEFAULT_TIMEOUT_MS = 15000;
- private static final int DEFAULT_LIMIT = 1000;
- private static final String HTTPS_PORT = ":3905";
- private static final String URL_TEMPLATE = "%s/events/%s/%s/%s";
-
- private List urls;
- private String filter;
-
- private boolean useHttps = false;
-
- public HttpDmaapConsumerImpl(Collection hosts, String topicName, String consumerName, String consumerId) {
- this(hosts, topicName, consumerName, consumerId, null);
- }
-
- public HttpDmaapConsumerImpl(Collection hosts, String topicName, String consumerName, String consumerId,
- String filter) {
- this(hosts, topicName, consumerName, consumerId, filter, null, null);
- }
-
- public HttpDmaapConsumerImpl(Collection hosts, String topicName, String consumerName, String consumerId,
- String filter, String user, String password) {
- urls = new ArrayList();
- for (String host : hosts) {
- urls.add(String.format(URL_TEMPLATE, formatHostString(host), topicName, consumerName, consumerId));
- }
- this.filter = filter;
- updateCredentials(user, password);
- }
-
- @Override
- public void updateCredentials(String user, String pass) {
- LOG.debug(String.format("Setting auth to %s for %s", user, this.toString()));
- this.setBasicAuth(user, pass);
- }
-
- @Override
- public List fetch(int waitMs, int limit) {
- LOG.debug(String.format("Fetching up to %d records with %dms wait on %s", limit, waitMs, this.toString()));
- List out = new ArrayList();
- try {
- List urlParams = new ArrayList();
- urlParams.add(new BasicNameValuePair("timeout", String.valueOf(waitMs)));
- urlParams.add(new BasicNameValuePair("limit", String.valueOf(limit)));
- if (filter != null) {
- urlParams.add(new BasicNameValuePair("filter", filter));
- }
-
- URIBuilder builder = new URIBuilder(urls.get(0));
- builder.setParameters(urlParams);
-
- URI uri = builder.build();
- LOG.info(String.format("GET %s", uri));
- HttpGet request = getReq(uri, waitMs);
- CloseableHttpResponse response = getClient().execute(request);
-
- int httpStatus = response.getStatusLine().getStatusCode();
- HttpEntity entity = response.getEntity();
- String body = (entity != null) ? EntityUtils.toString(entity) : null;
-
- LOG.debug(String.format("Request to %s completed with status %d and a body size of %s", uri, httpStatus,
- (body != null ? body.length() : "null")));
-
- response.close();
- if (httpStatus == 200 && body != null) {
- JSONArray json = new JSONArray(body);
- LOG.info(String.format("Got %d messages from DMaaP", json.length()));
- for (int i = 0; i < json.length(); i++) {
- out.add(json.getString(i));
- }
- } else {
- LOG.error(String.format("Did not get 200 from DMaaP. Got %d - %s", httpStatus, body));
- sleep(waitMs);
- }
- } catch (Exception e) {
- if (urls.size() > 1) {
- String failedUrl = urls.remove(0);
- urls.add(failedUrl);
- LOG.debug(String.format("Moving host %s to the end of the pool. New primary host is %s", failedUrl,
- urls.get(0)));
- }
- LOG.error(String.format("Got exception while querying DMaaP. Message: %s", e.getMessage()), e);
- sleep(waitMs);
- }
-
- return out;
- }
-
- @Override
- public List fetch() {
- return fetch(DEFAULT_TIMEOUT_MS, DEFAULT_LIMIT);
- }
-
- @Override
- public String toString() {
- String hostStr = (urls == null || urls.isEmpty()) ? "N/A" : urls.get(0);
- return String.format("Consumer listening to [%s]", hostStr);
- }
-
- @Override
- public void useHttps(boolean yes) {
- useHttps = yes;
- }
-
- private void sleep(int ms) {
- LOG.info(String.format("Sleeping for %ds after failed request", ms / 1000));
- try {
- Thread.sleep(ms);
- } catch (InterruptedException e1) {
- LOG.error("Interrupted while sleeping");
- }
- }
-
- @Override
- public void close() {
- // Nothing to do
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java
deleted file mode 100644
index 560c09be4..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java
+++ /dev/null
@@ -1,138 +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.messaging.dmaap.http;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.onap.appc.adapter.message.Producer;
-
-public class HttpDmaapProducerImpl extends CommonHttpClient implements Producer {
-
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(HttpDmaapProducerImpl.class);
-
- private static final String CONTENT_TYPE = "application/cambria";
- private static final String URL_TEMPLATE = "%s/events/%s";
-
- private List hosts;
- private Set topics;
-
- private boolean useHttps = false;
-
- public HttpDmaapProducerImpl(Collection urls, String topicName) {
- hosts = new ArrayList();
- topics = new HashSet();
- topics.add(topicName);
-
- for (String host : urls) {
- hosts.add(formatHostString(host));
- }
- }
-
- public HttpDmaapProducerImpl(Collection urls, Set topicNames) {
- hosts = new ArrayList();
- topics = topicNames;
-
- for (String host : urls) {
- hosts.add(formatHostString(host));
- }
- }
-
- @Override
- public void updateCredentials(String user, String pass) {
- LOG.debug(String.format("Setting auth to %s for %s", user, this.toString()));
- this.setBasicAuth(user, pass);
- }
-
- @Override
- public boolean post(String partition, String data) {
- int sent = 0;
- try {
- HttpPost request = postReq(null);
- request.setHeader("Content-Type", CONTENT_TYPE);
- request.setEntity(new StringEntity(bodyLine(partition, data)));
-
- for (String topic : topics) {
- String uriStr = String.format(URL_TEMPLATE, hosts.get(0), topic);
- try {
- request.setURI(new URI(uriStr));
- CloseableHttpResponse response = getClient().execute(request);
- if (response.getStatusLine().getStatusCode() == 200) {
- sent++;
- }
- response.close();
- } catch (Exception sendEx) {
- LOG.error(String.format("Failed to send message to %s. Reason: %s", uriStr, sendEx.getMessage()),
- sendEx);
- if (hosts.size() > 1) {
- String failedUrl = hosts.remove(0);
- hosts.add(failedUrl);
- LOG.debug(String.format("Moving host %s to the end of the pool. New primary host is %s",
- failedUrl, hosts.get(0)));
- }
- }
- }
- } catch (Exception buildEx) {
- LOG.error(
- String.format("Failed to build request with string [%s]. Message not sent to any topic. Reason: %s",
- data, buildEx.getMessage()),
- buildEx);
- }
- return sent == topics.size();
- }
-
- @Override
- public void useHttps(boolean yes) {
- useHttps = yes;
- }
-
- /**
- * Format the body for the application/cambria content type with no partitioning. See
- *
- * @param msg
- * The message body to format
- * @return A string in the application/cambria content type
- */
- private String bodyLine(String partition, String msg) {
- String p = (partition == null) ? "" : partition;
- String m = (msg == null) ? "" : msg;
- return String.format("%d.%d.%s%s", p.length(), m.length(), p, m);
- }
-
- @Override
- public void close() {
- // Nothing to do
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java
deleted file mode 100644
index ddf630545..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapConsumerImpl.java
+++ /dev/null
@@ -1,234 +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.messaging.dmaap.impl;
-
-import java.io.IOException;
-import java.util.*;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-//import com.att.nsa.cambria.client.CambriaClientBuilders;
-//import com.att.nsa.cambria.client.CambriaClientBuilders.ConsumerBuilder;
-//import com.att.nsa.cambria.client.CambriaConsumer;
-
-import com.att.nsa.mr.client.MRClientFactory;
-import com.att.nsa.mr.client.MRConsumer;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.appc.adapter.message.Consumer;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.metricservice.MetricRegistry;
-import org.onap.appc.metricservice.MetricService;
-import org.onap.appc.metricservice.impl.MetricServiceImpl;
-import org.onap.appc.metricservice.metric.Metric;
-import org.onap.appc.metricservice.metric.MetricType;
-import org.onap.appc.metricservice.metric.DmaapRequestCounterMetric;
-import org.onap.appc.metricservice.policy.PublishingPolicy;
-import org.onap.appc.metricservice.publisher.LogPublisher;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-
-public class DmaapConsumerImpl implements Consumer {
-
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(DmaapConsumerImpl.class);
- private static final Configuration configuration = ConfigurationFactory.getConfiguration();
- // Default values
- private static final int DEFAULT_TIMEOUT_MS = 60000;
- private static final int DEFAULT_LIMIT = 1000;
- private static MetricRegistry metricRegistry;
- private String topic;
- private DmaapRequestCounterMetric dmaapKpiMetric;
- private boolean isMetricEnabled=false;
- private boolean useHttps = false;
- private MRConsumer client = null;
- private Properties props = null;
-
-
- public DmaapConsumerImpl(Collection urls, String topicName, String consumerGroupName, String consumerId,String user, String password) {
- this(urls, topicName, consumerGroupName, consumerId,user, password,null);
-
- }
-
- public DmaapConsumerImpl(Collection urls, String topicName, String consumerGroupName, String consumerId,String user, String password,String filter) {
- this.topic = topicName;
- this.props = new Properties();
- String urlsStr = StringUtils.join(urls, ',');
- props.setProperty("host",urlsStr);
- props.setProperty("group",consumerGroupName);
- props.setProperty("id",consumerId);
- props.setProperty("username",user);
- props.setProperty("password",password);
- if(filter != null) {
- props.setProperty("filter", filter);
- }
- }
-
-
- private void initMetric() {
- LOG.debug("Metric getting initialized");
- MetricService metricService = getMetricservice();
- metricRegistry = metricService.createRegistry("APPC");
- dmaapKpiMetric = metricRegistry.metricBuilderFactory().
- dmaapRequestCounterBuilder().
- withName("DMAAP_KPI").withType(MetricType.COUNTER).
- withRecievedMessage(0)
- .withPublishedMessage(0)
- .build();
- if (metricRegistry.register(dmaapKpiMetric)) {
- Metric[] metrics = new Metric[]{dmaapKpiMetric};
- LogPublisher logPublisher = new LogPublisher(metricRegistry, metrics);
- LogPublisher[] logPublishers = new LogPublisher[1];
- logPublishers[0] = logPublisher;
- PublishingPolicy manuallyScheduledPublishingPolicy = metricRegistry.policyBuilderFactory().
- scheduledPolicyBuilder().withPublishers(logPublishers).
- withMetrics(metrics).
- build();
- LOG.debug("Policy getting initialized");
- manuallyScheduledPublishingPolicy.init();
- LOG.debug("Metric initialized");
- }
- }
- private MRConsumer getClient() {
- return getClient(DEFAULT_TIMEOUT_MS, DEFAULT_LIMIT);
- }
-
- /**
- * @return An instance of MRConsumer created from our class variables
- */
- private synchronized MRConsumer getClient(int waitMs, int limit) {
- try {
- props.setProperty("timeout",String.valueOf(waitMs));
- props.setProperty("limit",String.valueOf(limit));
- String topicProducerPropFileName = DmaapUtil.createConsumerPropFile(topic,props);
- return MRClientFactory.createConsumer ( topicProducerPropFileName);
- } catch (IOException e1) {
- LOG.error("failed to createConsumer",e1);
- return null;
- }
- }
-
- @Override
- public synchronized void updateCredentials(String key, String secret) {
- LOG.info(String.format("Setting auth to %s for %s", key, this.toString()));
- String user = key;
- String password = secret;
- props.setProperty("user",String.valueOf(user));
- props.setProperty("password",String.valueOf(password));
- client = null;
- }
-
- @Override
- public List fetch(int waitMs, int limit) {
- Properties properties=configuration.getProperties();
- if(properties!=null && properties.getProperty("metric.enabled")!=null ){
- isMetricEnabled=Boolean.valueOf(properties.getProperty("metric.enabled"));
- }
- if(isMetricEnabled){
- initMetric();
- }
- LOG.debug(String.format("Fetching up to %d records with %dms wait on %s", limit, waitMs, this.toString()));
- List out = new ArrayList();
-
- // Create client once and reuse it on subsequent fetches. This is
- // to support failover to other servers in the DMaaP cluster.
- if (client == null) {
- LOG.info("Getting DMaaP Client ...");
- client = getClient(waitMs, limit);
- }
- try {
- for (String s : client.fetch(waitMs, limit)) {
- out.add(s);
- if(isMetricEnabled){
- ((DmaapRequestCounterMetric)metricRegistry.metric("DMAAP_KPI")).incrementRecievedMessage();
- }
- }
- LOG.debug(String.format("Got %d records from %s", out.size(), this.toString()));
- } catch (Exception e) {
- // Connection exception
- LOG.error(String.format("Dmaap Connection Issue Detected. %s", e.getMessage()));
- e.printStackTrace();
- try {
- LOG.warn(String.format("Sleeping for %dms to compensate for connection failure", waitMs));
- Thread.sleep(waitMs);
- } catch (InterruptedException e2) {
- LOG.warn(String.format("Failed to wait for %dms after bad fetch", waitMs));
- }
- }
-
-
- return out;
- }
-
- /**
- * Close consumer Dmaap client
- */
- @Override
- public void close() {
- LOG.debug("Closing Dmaap consumer client....");
- if (client != null) {
- client.close();
- }
- }
-
- @Override
- public List fetch() {
- return fetch(DEFAULT_TIMEOUT_MS, DEFAULT_LIMIT);
- }
-
- @Override
- public String toString() {
- String hostStr = (props == null || props.getProperty("host") == null? "N/A" : props.getProperty("host"));
- String group = (props == null || props.getProperty("group") == null? "N/A" : props.getProperty("group"));
- String id = (props == null || props.getProperty("id") == null? "N/A" : props.getProperty("id"));
- return String.format("Consumer %s/%s listening to %s on [%s]", group, id, topic, hostStr);
- }
-
- @Override
- public void useHttps(boolean yes) {
- useHttps = yes;
- }
-
-
- private MetricService getMetricservice() {
- BundleContext bctx = FrameworkUtil.getBundle(MetricService.class).getBundleContext();
- // Get AAIadapter reference
- ServiceReference sref = bctx.getServiceReference(MetricService.class.getName());
- if (sref != null) {
- LOG.info("Metric Service from bundlecontext");
- return (MetricServiceImpl) bctx.getService(sref);
-
- } else {
- LOG.info("Metric Service error from bundlecontext");
- LOG.warn("Cannot find service reference for org.onap.appc.metricservice.MetricService");
- return null;
-
- }
- }
-
- public Metric getMetric(String name){
- return metricRegistry.metric(name);
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java
deleted file mode 100644
index 7ed06a9e3..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapProducerImpl.java
+++ /dev/null
@@ -1,223 +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.messaging.dmaap.impl;
-
-import java.io.*;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-//import com.att.nsa.cambria.client.CambriaBatchingPublisher;
-//import com.att.nsa.cambria.client.CambriaClientBuilders;
-//import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder;
-
-import com.att.nsa.mr.client.MRBatchingPublisher;
-import com.att.nsa.mr.client.MRClientFactory;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.appc.adapter.message.Producer;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapUtil;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.metricservice.MetricRegistry;
-import org.onap.appc.metricservice.MetricService;
-import org.onap.appc.metricservice.metric.Metric;
-import org.onap.appc.metricservice.metric.MetricType;
-import org.onap.appc.metricservice.metric.DmaapRequestCounterMetric;
-import org.onap.appc.metricservice.policy.PublishingPolicy;
-import org.onap.appc.metricservice.publisher.LogPublisher;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
-
-public class DmaapProducerImpl implements Producer {
-
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(DmaapProducerImpl.class);
- private static final Configuration configuration = ConfigurationFactory.getConfiguration();
-
- private Set topics = new HashSet();
-
- private Properties props = null;
- private static MetricRegistry metricRegistry;
- private boolean useHttps = false;
- private DmaapRequestCounterMetric dmaapKpiMetric;
- private boolean isMetricEnabled=false;
-
- private Set clients;
-
-
- public DmaapProducerImpl(Collection urls, String topicName, String user, String password) {
- this(urls, (Set)null, user, password);
- this.topics = new HashSet<>();
- if (topicName != null) {
- for (String topic : topicName.split(",")) {
- topics.add(topic);
- }
- }
- }
-
- public DmaapProducerImpl(Collection urls, Set topicNames, String user, String password) {
- topics = topicNames;
- if(urls == null || user == null || password == null){
- throw new IllegalArgumentException("one of these mandaory argument is null: urls, user, password" );
- }
- this.props = new Properties();
- String urlsStr = StringUtils.join(urls, ',');
- props.setProperty("host",urlsStr);
- props.setProperty("id", UUID.randomUUID().toString());
- props.setProperty("username",user);
- props.setProperty("password",password);
- }
- private void initMetric() {
- LOG.debug("Metric getting initialized");
- MetricService metricService = getMetricservice();
- metricRegistry=metricService.createRegistry("APPC");
- dmaapKpiMetric = metricRegistry.metricBuilderFactory().
- dmaapRequestCounterBuilder().
- withName("DMAAP_KPI").withType(MetricType.COUNTER).
- withRecievedMessage(0)
- .withPublishedMessage(0)
- .build();
- if(metricRegistry.register(dmaapKpiMetric)) {
- Metric[] metrics = new Metric[]{dmaapKpiMetric};
- LogPublisher logPublisher = new LogPublisher(metricRegistry, metrics);
- LogPublisher[] logPublishers = new LogPublisher[1];
- logPublishers[0] = logPublisher;
- PublishingPolicy manuallyScheduledPublishingPolicy = metricRegistry.policyBuilderFactory().
- scheduledPolicyBuilder().withPublishers(logPublishers).
- withMetrics(metrics).
- build();
- LOG.debug("Policy getting initialized");
- manuallyScheduledPublishingPolicy.init();
- LOG.debug("Metric initialized");
- }
-
- }
- private Set getClients() {
- Set out = new HashSet();
- for (String topic : topics) {
- try {
- String topicProducerPropFileName = DmaapUtil.createProducerPropFile(topic,props);
- final MRBatchingPublisher client = MRClientFactory.createBatchingPublisher (topicProducerPropFileName);
- out.add(client);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- return out;
- }
-
- @Override
- public synchronized void updateCredentials(String key, String secret) {
- LOG.info(String.format("Setting auth to %s for %s", key, this.toString()));
- String user = key;
- String password = secret;
- props.setProperty("user",String.valueOf(user));
- props.setProperty("password",String.valueOf(password));
- clients = null;
- }
-
- @Override
- public boolean post(String partition, String data) {
- boolean success = true;
- Properties properties=configuration.getProperties();
- if(properties!=null && properties.getProperty("metric.enabled")!=null ){
- isMetricEnabled=Boolean.valueOf(properties.getProperty("metric.enabled"));
- }
- if(isMetricEnabled){
- initMetric();
- }
-
- // Create clients once and reuse them on subsequent posts. This is
- // to support failover to other servers in the Dmaap cluster.
- if ((clients == null) || (clients.isEmpty())) {
- LOG.info("Getting CambriaBatchingPublisher Clients ...");
- clients = getClients();
- }
-
- for (MRBatchingPublisher client : clients) {
- try {
- LOG.debug(String.format("Posting %s to %s", data, client));
- client.send(partition, data);
- } catch (IOException e) {
- e.printStackTrace();
- success = false;
- }
- }
- if(isMetricEnabled){
- ( (DmaapRequestCounterMetric) metricRegistry.metric("DMAAP_KPI")).incrementPublishedMessage();
- }
- return success;
- }
-
- /**
- * Close producer Dmaap client
- */
- @Override
- public void close() {
- if ((clients == null) || (clients.isEmpty())) {
- return;
- }
-
- LOG.debug("Closing Dmaap producer clients....");
- for (MRBatchingPublisher client : clients) {
- try {
- client.close(1, TimeUnit.SECONDS);
- } catch (IOException | InterruptedException e) {
- LOG.warn(String.format("Failed to cleanly close Dmaap connection for [%s]", client));
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void useHttps(boolean yes) {
- useHttps = yes;
- }
-
- private MetricService getMetricservice() {
-/*
- return AppcDmaapAdapterActivator.getMetricService();
-*/
-
- BundleContext bctx = FrameworkUtil.getBundle(MetricService.class).getBundleContext();
- ServiceReference sref = bctx.getServiceReference(MetricService.class.getName());
- if (sref != null) {
- LOG.info("Metric Service from bundlecontext");
- return (MetricService) bctx.getService(sref);
-
- } else {
- LOG.info("Metric Service error from bundlecontext");
- LOG.warn("Cannot find service reference for org.onap.appc.metricservice.MetricService");
- return null;
-
- }
- }
-
- public Metric getMetric(String name){
- return metricRegistry.metric(name);
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapUtil.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapUtil.java
deleted file mode 100644
index da1b0fa38..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/DmaapUtil.java
+++ /dev/null
@@ -1,86 +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.messaging.dmaap.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-public class DmaapUtil {
- private final static String delimiter = "_";
- private static String createPreferredRouteFileIfNotExist(String topic) throws IOException {
- String topicPreferredRouteFileName = null;
- topicPreferredRouteFileName = topic+"preferredRoute.properties";
- File fo= new File(topicPreferredRouteFileName);
- if(!fo.exists()) {
- ClassLoader classLoader = DmaapUtil.class.getClassLoader();
- InputStream inputStream = classLoader.getResourceAsStream("preferredRoute.txt");
- Properties props = new Properties();
- props.load(inputStream);
- String fileName = topic != null ? topic+delimiter+"MR1" : delimiter+"MR1";
- props.setProperty("preferredRouteKey", fileName);
- topicPreferredRouteFileName = topic + "preferredRoute.properties";
- props.store(new FileOutputStream(topicPreferredRouteFileName), "preferredRoute.properties file created on the fly for topic:" + topic + " on:" + System.currentTimeMillis());
- }
- return topicPreferredRouteFileName;
- }
-
- public static String createConsumerPropFile(String topic, Properties props)throws IOException {
- String defaultProfFileName = "consumer.properties";
- String topicConsumerPropFileName = createConsumerProducerPropFile(topic, defaultProfFileName,props);
- return topicConsumerPropFileName;
- }
-
- public static String createProducerPropFile(String topic, Properties props)throws IOException {
- String defaultProfFileName = "producer.properties";
- String topicConsumerPropFileName = createConsumerProducerPropFile(topic, defaultProfFileName,props);
- return topicConsumerPropFileName;
- }
-
- private static String createConsumerProducerPropFile(String topic, String defaultProfFileName, Properties props) throws IOException {
- ClassLoader classLoader = DmaapUtil.class.getClassLoader();
- InputStream inputStream = classLoader.getResourceAsStream(defaultProfFileName);
- Properties defaultProps = new Properties();
- defaultProps.load(inputStream);
- defaultProps.setProperty("topic",topic);
-
- String preferredRouteFileName = DmaapUtil.createPreferredRouteFileIfNotExist(topic);
- if(props != null && !props.isEmpty()){
- defaultProps.putAll(props);
- }
- defaultProps.setProperty("topic",topic);
- defaultProps.setProperty("DME2preferredRouterFilePath",preferredRouteFileName);
- String id = defaultProps.getProperty("id");
- String topicConsumerPropFileName = defaultProfFileName;
- topicConsumerPropFileName = id != null ? id+delimiter+topicConsumerPropFileName : delimiter+topicConsumerPropFileName;
- topicConsumerPropFileName = topic != null ? topic+delimiter+topicConsumerPropFileName : delimiter+topicConsumerPropFileName;
-
- defaultProps.store(new FileOutputStream(topicConsumerPropFileName), defaultProfFileName+" file created on the fly for topic:"+topic+" on:"+System.currentTimeMillis());
- return topicConsumerPropFileName;
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java
deleted file mode 100644
index bf7649026..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/impl/EventSenderDmaapImpl.java
+++ /dev/null
@@ -1,178 +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.messaging.dmaap.impl;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onap.appc.adapter.message.EventSender;
-import org.onap.appc.adapter.message.MessageDestination;
-import org.onap.appc.adapter.message.Producer;
-import org.onap.appc.adapter.message.event.EventHeader;
-import org.onap.appc.adapter.message.event.EventMessage;
-import org.onap.appc.adapter.message.event.EventStatus;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.exceptions.APPCException;
-
-public class EventSenderDmaapImpl implements EventSender
-{
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(EventSenderDmaapImpl.class);
- public static final String EVENT_TOPIC_WRITE = "dmaap.event.topic.write";
- public static final String DMAAP_USERNAME = "dmaap.appc.username";
- public static final String DMAAP_PASSWORD = "dmaap.appc.password";
- public static final String EVENT_POOL_MEMBERS = "dmaap.event.pool.members";
-
- private static Configuration configuration = ConfigurationFactory.getConfiguration();
-
- private Map producerMap = new ConcurrentHashMap<>();
-
- public Map getProducerMap() {
- return producerMap;
- }
-
- public void setProducerMap(Map producerMap) {
- this.producerMap = producerMap;
- }
-
- public EventSenderDmaapImpl(){
-
- }
-
- public void initialize(){
- Properties properties = configuration.getProperties();
- String writeTopic;
- String username;
- String password;
- final List pool = new ArrayList<>();
-
- for(MessageDestination destination: MessageDestination.values()){
- writeTopic = properties.getProperty(destination + "." + EVENT_TOPIC_WRITE);
- username = properties.getProperty(destination + "." + DMAAP_USERNAME);
- password = properties.getProperty(destination + "." + DMAAP_PASSWORD);
- String hostNames = properties.getProperty(destination + "." + EVENT_POOL_MEMBERS);
-
- if (hostNames != null && !hostNames.isEmpty()) {
- LOG.debug(String.format("hostNames = %s, taken from property: %s", hostNames, destination + "." + EVENT_POOL_MEMBERS));
- Collections.addAll(pool, hostNames.split(","));
- }
-
- LOG.debug(String.format("pool = %s, taken from property: %s", pool, destination + "." + EVENT_POOL_MEMBERS));
- LOG.debug(String.format("writeTopic = %s, taken from property: %s", writeTopic, destination + "." + EVENT_TOPIC_WRITE));
- LOG.debug(String.format("username = %s, taken from property: %s", username, destination + "." + DMAAP_USERNAME));
- Producer producer = new DmaapProducerImpl(pool, writeTopic,username, password);
-
- for (String url : pool) {
- if (url.contains("3905") || url.contains("https")) {
- LOG.debug("Producer should use HTTPS");
- producer.useHttps(true);
- break;
- }
- }
- producerMap.put(destination.toString(),producer);
- }
-
- }
-
- @Override
- public boolean sendEvent(MessageDestination destination, EventMessage msg) {
- String jsonStr = msg.toJson();
- String id = msg.getEventHeader().getEventId();
- LOG.info(String.format("Posting Message [%s - %s]", id, jsonStr));
- Producer producer = producerMap.get(destination.toString());
- return producer.post(id, jsonStr);
- }
-
- @Override
- public boolean sendEvent(MessageDestination destination, EventMessage msg, String eventTopicName) {
- String jsonStr = msg.toJson();
- String id = msg.getEventHeader().getEventId();
- LOG.info(String.format("Posting Message [%s - %s]", id, jsonStr));
- Producer producer = createProducer(destination, eventTopicName);
- return producer.post(id, jsonStr);
- }
-
- private Producer createProducer(MessageDestination destination, String eventTopicName) {
- Properties properties = configuration.getProperties();
- final List pool = new ArrayList<>();
- String username = properties.getProperty(destination + "." + DMAAP_USERNAME);
- String password = properties.getProperty(destination + "." + DMAAP_PASSWORD);
- String hostNames = properties.getProperty(destination + "." + EVENT_POOL_MEMBERS);
-
- if (hostNames != null && !hostNames.isEmpty()) {
- LOG.debug(String.format("hostNames = %s, taken from property: %s", hostNames, destination + "." + EVENT_POOL_MEMBERS));
- Collections.addAll(pool, hostNames.split(","));
- }
-
- LOG.debug(String.format("pool = %s, taken from property: %s", pool, destination + "." + EVENT_POOL_MEMBERS));
- LOG.debug(String.format("writeTopic = %s, taken from property: %s", eventTopicName, destination + "." + EVENT_TOPIC_WRITE));
- LOG.debug(String.format("username = %s, taken from property: %s", username, destination + "." + DMAAP_USERNAME));
- Producer producer = new DmaapProducerImpl(pool, eventTopicName,username, password);
-
- for (String url : pool) {
- if (url.contains("3905") || url.contains("https")) {
- LOG.debug("Producer should use HTTPS");
- producer.useHttps(true);
- break;
- }
- }
- return producer;
- }
-
- @Override
- public boolean sendEvent(MessageDestination destination, Map params, SvcLogicContext ctx) throws APPCException {
-
- if (params == null) {
- String message = "Parameters map is empty (null)";
- LOG.error(message);
- throw new APPCException(message);
- }
- String eventTime = new Date(System.currentTimeMillis()).toString();
- String apiVer = params.get("apiVer");
- String eventId = params.get("eventId");
- String reason = params.get("reason");
- String entityId=params.get("entityId");
- if(entityId!=null){
- reason=reason+"("+entityId+")";
- }
- Integer code = Integer.getInteger(params.get("code"), 500);
-
- if (eventTime == null || apiVer == null || eventId == null || reason == null) {
- String message = String.format("Missing input parameters: %s", params);
- LOG.error(message);
- throw new APPCException(message);
- }
- EventMessage eventMessage = new EventMessage(
- new EventHeader(eventTime, apiVer, eventId),
- new EventStatus(code, reason));
-
- return sendEvent(destination,eventMessage);
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/onap/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..280b85c00
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,28 @@
+###
+# ============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=========================================================
+###
+
+# ${user.home} usually goes to /root if instantiation uses the appc-docker approach
+
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index 280b85c00..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,28 +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=========================================================
-###
-
-# ${user.home} usually goes to /root if instantiation uses the appc-docker approach
-
-org.onap.appc.bootstrap.file=appc.properties
-org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java
new file mode 100644
index 000000000..8c07c0b4a
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java
@@ -0,0 +1,137 @@
+/*-
+ * ============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.messaging.dmaap;
+
+import java.io.*;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import com.att.nsa.mr.client.MRConsumer;
+import org.json.JSONObject;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapUtil;
+
+import com.att.nsa.mr.client.MRBatchingPublisher;
+import com.att.nsa.mr.client.MRClientFactory;
+import com.att.nsa.mr.client.MRPublisher.message;
+
+
+/**
+ *An example of how to use the Java publisher.
+ */
+public class SimpleExamplePublisher
+{
+
+ public static void main(String []args) throws InterruptedException, Exception{
+ int msgCount = 1;
+ SimpleExamplePublisher publisher = new SimpleExamplePublisher();
+
+ int i=0;
+
+ String topicProducerPropFileName = DmaapUtil.createProducerPropFile("org.onap.appc.UNIT-TEST", null);
+ while (i< msgCount)
+ {
+ publisher.publishMessage(topicProducerPropFileName,i);
+ i++;
+ }
+
+ fetchMessage();
+ }
+
+
+ public void publishMessage( String producerFilePath,int count ) throws IOException, InterruptedException, Exception
+ {
+ // create our publisher
+ final MRBatchingPublisher pub = MRClientFactory.createBatchingPublisher (producerFilePath);
+ // publish some messages
+ final JSONObject msg1 = new JSONObject ();
+ msg1.put ( "Partition:2", "Message:" +count);
+ //msg1.put ( "greeting", "Hello .." );
+
+ pub.send ( "2", msg1.toString());
+ // close the publisher to make sure everything's sent before exiting. The batching
+ // publisher interface allows the app to get the set of unsent messages. It could
+ // write them to disk, for example, to try to send them later.
+ final List stuck = pub.close ( 20, TimeUnit.SECONDS );
+ if ( stuck.size () > 0 )
+ {
+ System.err.println ( stuck.size() + " messages unsent" );
+ }
+ else
+ {
+ System.out.println ( "Clean exit; all messages sent." );
+ }
+ }
+
+
+ public static void fetchMessage()
+ {
+ int count = 0;
+
+ try
+ {
+ String topic = "org.onap.appc.UNIT-TEST";
+ Properties props = new Properties();
+ props.put("id", "1");
+ props.put("group", "group1");
+ String topicConsumerPropFileName1 = DmaapUtil.createConsumerPropFile(topic,props);
+ final MRConsumer consumer1 = MRClientFactory.createConsumer ( topicConsumerPropFileName1);
+
+ props = new Properties();
+ props.put("id", "2");
+ props.put("group", "group2");
+ String topicConsumerPropFileName2 = DmaapUtil.createConsumerPropFile(topic,props);
+ final MRConsumer consumer2 = MRClientFactory.createConsumer ( topicConsumerPropFileName2);
+
+ for ( String msg : consumer1.fetch () )
+ {
+ count++;
+ System.out.println ( "consumer1 "+count + ": " + msg );
+ }
+ for ( String msg : consumer2.fetch () )
+ {
+ count++;
+ System.out.println ( "consumer1 "+count + ": " + msg );
+ }
+
+
+ }
+ catch ( Exception x )
+ {
+ System.out.println("inside cons exc");
+ System.err.println ( x.getClass().getName () + ": " + x.getMessage () );
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java
new file mode 100644
index 000000000..5473bf7e0
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java
@@ -0,0 +1,50 @@
+/*-
+ * ============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.messaging.dmaap;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.onap.appc.adapter.messaging.dmaap.AppcDmaapAdapterActivator;
+
+public class TestAppcDmaapAdapterActivator {
+
+ // TODO commented out to allow build to pass, need to analyze and fix
+// @Test
+ public void coverage() {
+ // This does nothing since the activator does nothing
+ AppcDmaapAdapterActivator appc = new AppcDmaapAdapterActivator();
+ try {
+ appc.start(null);
+ appc.stop(null);
+
+ } catch (Exception e) {
+ fail("Got exception when starting stopping. " + e.getMessage());
+ }
+ assertNotNull(appc.getName());
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapConsuming.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapConsuming.java
new file mode 100644
index 000000000..28c2bc4e2
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapConsuming.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.messaging.dmaap;
+
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.junit.Ignore;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Must have a DMaaP cluster or simulator up and running
+ * Update the hostname, topic, client properties in
+ * resources/org/onap/appc/default.properties
+ *
+ */
+public class TestDmaapConsuming {
+
+ private static Consumer dmaapConsumer;
+ private static Consumer httpConsumer;
+
+ @BeforeClass
+ public static void setUp() {
+
+ Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ List hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
+ String topic = configuration.getProperty("topic.read");
+ String consumerName = configuration.getProperty("client.name");
+ String consumerId = configuration.getProperty("client.name.id");
+ String msgFilter = configuration.getProperty("message.filter");
+ String user = configuration.getProperty("dmaap.appc.username");
+ String password = configuration.getProperty("dmaap.appc.password");
+
+ httpConsumer = new HttpDmaapConsumerImpl(hosts, topic, consumerName, consumerId, msgFilter);
+ dmaapConsumer = new DmaapConsumerImpl(hosts, topic, consumerName, consumerId,user,password,msgFilter);
+ }
+
+ @Test
+ @Ignore
+ public void testHttpFetchMessages() {
+ testFetchMessages(httpConsumer);
+ }
+
+ @Test
+ @Ignore
+ public void testFetchMessages() {
+ testFetchMessages(dmaapConsumer);
+ }
+
+ private void testFetchMessages(Consumer consumer) {
+ List messages = consumer.fetch(1000, 100);
+ Assert.assertNotNull(messages);
+ Assert.assertFalse(messages.isEmpty());
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapEventSender.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapEventSender.java
new file mode 100644
index 000000000..bdc786337
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapEventSender.java
@@ -0,0 +1,172 @@
+/*-
+ * ============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.messaging.dmaap;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.onap.appc.adapter.message.MessageDestination;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.message.event.EventHeader;
+import org.onap.appc.adapter.message.event.EventMessage;
+import org.onap.appc.adapter.message.event.EventStatus;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+import org.onap.appc.adapter.messaging.dmaap.impl.EventSenderDmaapImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.exceptions.APPCException;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+
+public class TestDmaapEventSender {
+
+ private static Properties props;
+ private static Map producerMap = new HashMap<>();
+ private static EventMessage eventMessage;
+
+ @BeforeClass
+ public static void setUp() {
+
+ Configuration configuration = ConfigurationFactory.getConfiguration(); // test.properties file placed in home dir.
+
+ props = new Properties();
+ props.setProperty(EventSenderDmaapImpl.EVENT_POOL_MEMBERS,
+ configuration.getProperty(EventSenderDmaapImpl.EVENT_POOL_MEMBERS) != null ?
+ configuration.getProperty(EventSenderDmaapImpl.EVENT_POOL_MEMBERS) : "member1,member2,member3");
+ props.setProperty(EventSenderDmaapImpl.EVENT_TOPIC_WRITE,
+ configuration.getProperty(EventSenderDmaapImpl.EVENT_TOPIC_WRITE) != null ?
+ configuration.getProperty(EventSenderDmaapImpl.EVENT_TOPIC_WRITE) : "topic1");
+
+ String eventClientKey = configuration.getProperty(EventSenderDmaapImpl.DMAAP_USERNAME);
+ if (eventClientKey != null) {
+ props.setProperty(EventSenderDmaapImpl.DMAAP_USERNAME,eventClientKey);
+ }
+ String eventClientSecret = configuration.getProperty(EventSenderDmaapImpl.DMAAP_PASSWORD);
+ if (eventClientSecret != null) {
+ props.setProperty(EventSenderDmaapImpl.DMAAP_PASSWORD, eventClientSecret);
+ }
+
+ Producer producer = Mockito.mock(DmaapProducerImpl.class);
+ producerMap.put(MessageDestination.DCAE.toString(),producer);
+ Mockito.when(producer.post(Matchers.anyString(), Matchers.anyString())).thenReturn(true);
+
+ eventMessage = new EventMessage(
+ new EventHeader("2016-03-15T10:59:33.79Z", "1.01", "17"),
+ new EventStatus(404, "No krokodil found"));
+ }
+
+ @Test
+ @Ignore // requires connection to a live DMaaP server
+ public void testDmaapEventSenderWithProperties() {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+ eventSender.initialize();
+ eventSender.setProducerMap(producerMap);
+ Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE, eventMessage));
+ }
+
+ @Test
+ public void testDmaapEventSenderWithNullProperties() {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+// eventSender.initialize();
+ eventSender.setProducerMap(producerMap);
+ Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE, eventMessage));
+ }
+
+ /*
+ * This test runs agains a real Dmaap (or a simulator) that should be cofigured in test.properties file.
+ */
+ @Test
+ @Ignore // requires connection to a live DMaaP server
+ public void testDmaapEventSenderWithDmaapSim() {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+ eventSender.initialize();
+ Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE, eventMessage));
+ }
+
+
+ @Test
+ @Ignore // requires connection to a live DMaaP server
+ public void testDmaapEventSenderDG() throws APPCException {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+ eventSender.initialize();
+ eventSender.setProducerMap(producerMap);
+ Map params = new HashMap<>();
+
+ params.put("eventTime", eventMessage.getEventHeader().getEventTime());
+ params.put("apiVer", eventMessage.getEventHeader().getApiVer());
+ params.put("eventId", eventMessage.getEventHeader().getEventId());
+ params.put("reason", eventMessage.getEventStatus().getReason());
+ params.put("code", "200");
+
+ Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext()));
+ }
+
+ @Test(expected = APPCException.class)
+ @Ignore // requires connection to a live DMaaP server
+ public void testDmaapEventSenderDGNoParams() throws APPCException {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+ eventSender.initialize();
+ eventSender.setProducerMap(producerMap);
+ Map params = new HashMap<>();
+
+ Assert.assertFalse(eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext()));
+ }
+
+
+ @Test(expected = APPCException.class)
+ @Ignore // requires connection to a live DMaaP server
+ public void testDmaapEventSenderDGNullParam() throws APPCException {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+ eventSender.initialize();
+ eventSender.setProducerMap(producerMap);
+ Map params = null;
+
+ Assert.assertFalse(eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext()));
+ }
+
+ @Test(expected = APPCException.class)
+ @Ignore // requires connection to a live DMaaP server
+ public void testDmaapEventSenderDGNoParam() throws APPCException {
+ EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
+ eventSender.initialize();
+ eventSender.setProducerMap(producerMap);
+ Map params = new HashMap<>();
+
+// params.put("apiVer", eventMessage.getEventHeader().getApiVer());
+ params.put("eventId", eventMessage.getEventHeader().getEventId());
+ params.put("reason", eventMessage.getEventStatus().getReason());
+ params.put("code", "200");
+
+ eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext());
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapProducing.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapProducing.java
new file mode 100644
index 000000000..bdfa93726
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/TestDmaapProducing.java
@@ -0,0 +1,83 @@
+/*-
+ * ============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.messaging.dmaap;
+
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Must have a DMaaP cluster or simulator up and running
+ * Update the hostname, topic, client properties in
+ * resources/org/onap/appc/default.properties
+ *
+ */
+public class TestDmaapProducing {
+
+ private static Producer httpProducer;
+ private static Producer dmaapProducer;
+
+ @BeforeClass
+ public static void setUp() {
+
+ Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ List hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
+ String topic = configuration.getProperty("topic.write");
+ String user = configuration.getProperty("dmaap.appc.username");
+ String password = configuration.getProperty("dmaap.appc.password");
+
+ dmaapProducer = new DmaapProducerImpl(hosts, topic,user,password);
+ httpProducer = new HttpDmaapProducerImpl(hosts, topic);
+ httpProducer.updateCredentials(user,password);
+ }
+
+ @Test
+ @Ignore
+ public void testHttpPostMessage() {
+ testPostMessage(httpProducer);
+ }
+
+ @Test
+ @Ignore
+ public void testPostMessages() {
+ testPostMessage(dmaapProducer);
+ }
+
+ private void testPostMessage(Producer producer) {
+ Assert.assertTrue(producer.post("partition", "{\"message\": \"Hello, world!\"}"));
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java
new file mode 100644
index 000000000..cb318dc4e
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/onap/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java
@@ -0,0 +1,245 @@
+/*-
+ * ============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.messaging.dmaap.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.*;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+
+public class TestConsumerProducerImpl {
+
+ private Collection urls;
+ private String topicRead;
+ private String topicWrite;
+ private String group;
+ private String groupId;
+ private String user;
+ private String password;
+
+ @Before
+ public void setup() {
+ System.out.println("setup entry...");
+// urls = new HashSet();
+// urls.add("dmaaphost1");
+// urls.add("dmaaphost2");
+// //remove unavailable dmaap instance for build
+// //urls.add("dmaaphost3");
+//
+// topicRead = "APPC-UNIT-TEST";
+// topicWrite = "APPC-UNIT-TEST";
+// group = "APPC-CLIENT";
+// groupId = "0";
+ Configuration configuration = ConfigurationFactory.getConfiguration();
+ List hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
+ urls = new HashSet(hosts);
+ topicRead = configuration.getProperty("topic.read");
+ topicWrite = configuration.getProperty("topic.write");
+ user = configuration.getProperty("dmaap.appc.username");
+ password = configuration.getProperty("dmaap.appc.password");
+ group = "APPC-CLIENT";
+ groupId = "0";
+
+
+ runoff();
+ }
+
+ /**
+ * Test that we can read and write and that the messages come back in order
+ */
+ @Ignore
+ @Test
+ public void testWriteRead() {
+ System.out.println("testWriteRead entry...");
+ Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
+
+ String s1 = UUID.randomUUID().toString();
+ String s2 = UUID.randomUUID().toString();
+ if (p.post("TEST", s1) == false) {
+ // try again - 2nd attempt may succeed if cambria client failed over
+ p.post("TEST", s1);
+ }
+ if (p.post("TEST", s2) == false) {
+ // try again - 2nd attempt may succeed if cambria client failed over
+ p.post("TEST", s2);
+ }
+
+ Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
+ List out = c.fetch();
+ // if fetch is empty, try again - a 2nd attempt may succeed if
+ // cambria client has failed over
+ if ((out == null) || out.isEmpty()) {
+ out = c.fetch();
+ }
+
+ assertNotNull(out);
+ assertEquals(2, out.size());
+ assertEquals(s1, out.get(0));
+ assertEquals(s2, out.get(1));
+
+ }
+
+ /**
+ * Test that we can read and write and that the messages come back in order
+ */
+ @Test
+ @Ignore // Https Not support on jenkins server
+ public void testWriteReadHttps() {
+ System.out.println("testWriteReadHttps entry...");
+ Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
+ p.useHttps(true);
+
+ String s1 = UUID.randomUUID().toString();
+ String s2 = UUID.randomUUID().toString();
+ if (p.post("TEST", s1) == false) {
+ // try again - 2nd attempt may succeed if cambria client failed over
+ p.post("TEST", s1);
+ }
+ if (p.post("TEST", s2) == false) {
+ // try again - 2nd attempt may succeed if cambria client failed over
+ p.post("TEST", s2);
+ }
+
+ Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
+ c.useHttps(true);
+
+ List out = c.fetch();
+ // if fetch is empty, try again - a 2nd attempt may succeed if
+ // cambria client has failed over
+ if ((out == null) || out.isEmpty()) {
+ out = c.fetch();
+ }
+
+ assertNotNull(out);
+ assertEquals(2, out.size());
+ assertEquals(s1, out.get(0));
+ assertEquals(s2, out.get(1));
+
+ }
+
+ @Test
+ @Ignore // requires connection to a live DMaaP server
+ public void testBadUrl() {
+ System.out.println("testBadUrl entry...");
+ urls.clear();
+ urls.add("something.local");
+
+ // Producer p = new DmaapProducerImpl(urls, topicWrite);
+ Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
+ List result = c.fetch(1000, 1000);
+
+ assertNotNull(result);
+ assertTrue(result.isEmpty());
+ }
+
+ @Test
+ @Ignore // requires connection to a live DMaaP server
+ public void testAuth() {
+ System.out.println("testAuth entry...");
+ Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
+ Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
+
+ p.updateCredentials("key", "secret");
+ c.updateCredentials("key", "secret");
+
+ // TODO - Do some protected dmaap queries when the apis are updated
+ }
+
+ /**
+ * Test DMaaP client failover to another server when a bad url is encountered
+
+ */
+ @Ignore
+ @Test
+ public void testFailover() {
+ System.out.println("testFailover entry...");
+ urls.clear();
+ urls.add("openecomp2.org"); // bad url
+ urls.add("dmaaphost2");
+ Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
+
+ String s1 = UUID.randomUUID().toString();
+ if (p.post("TEST", s1) == false) {
+ // try again - cambria client should have failed over
+ p.post("TEST", s1);
+ }
+
+ urls.clear();
+ urls.add("openecomp3.org"); // bad url
+ urls.add("dmaaphost3");
+
+ Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
+ List out = c.fetch(1000, 1000);
+ // if fetch is empty, try again - cambria client should have failed over
+ if ((out == null) || out.isEmpty()) {
+ out = c.fetch();
+ }
+
+ assertNotNull(out);
+ assertEquals(1, out.size());
+ assertEquals(s1, out.get(0));
+ }
+
+ /**
+ * Reads through the entire topic so it is clean for testing. WARNING - ONLY USE ON TOPICS WHERE YOU ARE THE ONLY
+ * WRITER. Could end in an infinite loop otherwise.
+ */
+ private void runoff() {
+ Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
+ List data;
+ do {
+ data = c.fetch(1000, 10000);
+ } while (!data.isEmpty() && data.size()!=1);
+ }
+
+ @Test
+ @Ignore
+ public void testFilter() {
+ System.out.println("testFilter entry...");
+ List res;
+ String filter = "{\"class\":\"Assigned\",\"field\":\"request\"}";
+ Consumer c = new DmaapConsumerImpl(urls, "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM", group, groupId,user,password,filter);
+ res = c.fetch(2000, 10);
+ assertFalse(res.isEmpty());
+
+ res.clear();
+ filter = "{\"class\":\"Assigned\",\"field\":\"response\"}";
+ c = new DmaapConsumerImpl(urls, "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM", group, groupId,user,password, filter);
+ res = c.fetch(2000, 10);
+ assertTrue(res.isEmpty());
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java
deleted file mode 100644
index 8c07c0b4a..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/SimpleExamplePublisher.java
+++ /dev/null
@@ -1,137 +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.messaging.dmaap;
-
-import java.io.*;
-import java.util.List;
-import java.util.Properties;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-
-import com.att.nsa.mr.client.MRConsumer;
-import org.json.JSONObject;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapUtil;
-
-import com.att.nsa.mr.client.MRBatchingPublisher;
-import com.att.nsa.mr.client.MRClientFactory;
-import com.att.nsa.mr.client.MRPublisher.message;
-
-
-/**
- *An example of how to use the Java publisher.
- */
-public class SimpleExamplePublisher
-{
-
- public static void main(String []args) throws InterruptedException, Exception{
- int msgCount = 1;
- SimpleExamplePublisher publisher = new SimpleExamplePublisher();
-
- int i=0;
-
- String topicProducerPropFileName = DmaapUtil.createProducerPropFile("org.onap.appc.UNIT-TEST", null);
- while (i< msgCount)
- {
- publisher.publishMessage(topicProducerPropFileName,i);
- i++;
- }
-
- fetchMessage();
- }
-
-
- public void publishMessage( String producerFilePath,int count ) throws IOException, InterruptedException, Exception
- {
- // create our publisher
- final MRBatchingPublisher pub = MRClientFactory.createBatchingPublisher (producerFilePath);
- // publish some messages
- final JSONObject msg1 = new JSONObject ();
- msg1.put ( "Partition:2", "Message:" +count);
- //msg1.put ( "greeting", "Hello .." );
-
- pub.send ( "2", msg1.toString());
- // close the publisher to make sure everything's sent before exiting. The batching
- // publisher interface allows the app to get the set of unsent messages. It could
- // write them to disk, for example, to try to send them later.
- final List stuck = pub.close ( 20, TimeUnit.SECONDS );
- if ( stuck.size () > 0 )
- {
- System.err.println ( stuck.size() + " messages unsent" );
- }
- else
- {
- System.out.println ( "Clean exit; all messages sent." );
- }
- }
-
-
- public static void fetchMessage()
- {
- int count = 0;
-
- try
- {
- String topic = "org.onap.appc.UNIT-TEST";
- Properties props = new Properties();
- props.put("id", "1");
- props.put("group", "group1");
- String topicConsumerPropFileName1 = DmaapUtil.createConsumerPropFile(topic,props);
- final MRConsumer consumer1 = MRClientFactory.createConsumer ( topicConsumerPropFileName1);
-
- props = new Properties();
- props.put("id", "2");
- props.put("group", "group2");
- String topicConsumerPropFileName2 = DmaapUtil.createConsumerPropFile(topic,props);
- final MRConsumer consumer2 = MRClientFactory.createConsumer ( topicConsumerPropFileName2);
-
- for ( String msg : consumer1.fetch () )
- {
- count++;
- System.out.println ( "consumer1 "+count + ": " + msg );
- }
- for ( String msg : consumer2.fetch () )
- {
- count++;
- System.out.println ( "consumer1 "+count + ": " + msg );
- }
-
-
- }
- catch ( Exception x )
- {
- System.out.println("inside cons exc");
- System.err.println ( x.getClass().getName () + ": " + x.getMessage () );
- }
- }
-}
-
-
-
-
-
-
-
-
-
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java
deleted file mode 100644
index 5473bf7e0..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestAppcDmaapAdapterActivator.java
+++ /dev/null
@@ -1,50 +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.messaging.dmaap;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-import org.onap.appc.adapter.messaging.dmaap.AppcDmaapAdapterActivator;
-
-public class TestAppcDmaapAdapterActivator {
-
- // TODO commented out to allow build to pass, need to analyze and fix
-// @Test
- public void coverage() {
- // This does nothing since the activator does nothing
- AppcDmaapAdapterActivator appc = new AppcDmaapAdapterActivator();
- try {
- appc.start(null);
- appc.stop(null);
-
- } catch (Exception e) {
- fail("Got exception when starting stopping. " + e.getMessage());
- }
- assertNotNull(appc.getName());
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapConsuming.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapConsuming.java
deleted file mode 100644
index 28c2bc4e2..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapConsuming.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.messaging.dmaap;
-
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.appc.adapter.message.Consumer;
-import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.junit.Ignore;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Must have a DMaaP cluster or simulator up and running
- * Update the hostname, topic, client properties in
- * resources/org/onap/appc/default.properties
- *
- */
-public class TestDmaapConsuming {
-
- private static Consumer dmaapConsumer;
- private static Consumer httpConsumer;
-
- @BeforeClass
- public static void setUp() {
-
- Configuration configuration = ConfigurationFactory.getConfiguration();
-
- List hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
- String topic = configuration.getProperty("topic.read");
- String consumerName = configuration.getProperty("client.name");
- String consumerId = configuration.getProperty("client.name.id");
- String msgFilter = configuration.getProperty("message.filter");
- String user = configuration.getProperty("dmaap.appc.username");
- String password = configuration.getProperty("dmaap.appc.password");
-
- httpConsumer = new HttpDmaapConsumerImpl(hosts, topic, consumerName, consumerId, msgFilter);
- dmaapConsumer = new DmaapConsumerImpl(hosts, topic, consumerName, consumerId,user,password,msgFilter);
- }
-
- @Test
- @Ignore
- public void testHttpFetchMessages() {
- testFetchMessages(httpConsumer);
- }
-
- @Test
- @Ignore
- public void testFetchMessages() {
- testFetchMessages(dmaapConsumer);
- }
-
- private void testFetchMessages(Consumer consumer) {
- List messages = consumer.fetch(1000, 100);
- Assert.assertNotNull(messages);
- Assert.assertFalse(messages.isEmpty());
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapEventSender.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapEventSender.java
deleted file mode 100644
index bdc786337..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapEventSender.java
+++ /dev/null
@@ -1,172 +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.messaging.dmaap;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.onap.appc.adapter.message.MessageDestination;
-import org.onap.appc.adapter.message.Producer;
-import org.onap.appc.adapter.message.event.EventHeader;
-import org.onap.appc.adapter.message.event.EventMessage;
-import org.onap.appc.adapter.message.event.EventStatus;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
-import org.onap.appc.adapter.messaging.dmaap.impl.EventSenderDmaapImpl;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-import org.onap.appc.exceptions.APPCException;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-
-public class TestDmaapEventSender {
-
- private static Properties props;
- private static Map producerMap = new HashMap<>();
- private static EventMessage eventMessage;
-
- @BeforeClass
- public static void setUp() {
-
- Configuration configuration = ConfigurationFactory.getConfiguration(); // test.properties file placed in home dir.
-
- props = new Properties();
- props.setProperty(EventSenderDmaapImpl.EVENT_POOL_MEMBERS,
- configuration.getProperty(EventSenderDmaapImpl.EVENT_POOL_MEMBERS) != null ?
- configuration.getProperty(EventSenderDmaapImpl.EVENT_POOL_MEMBERS) : "member1,member2,member3");
- props.setProperty(EventSenderDmaapImpl.EVENT_TOPIC_WRITE,
- configuration.getProperty(EventSenderDmaapImpl.EVENT_TOPIC_WRITE) != null ?
- configuration.getProperty(EventSenderDmaapImpl.EVENT_TOPIC_WRITE) : "topic1");
-
- String eventClientKey = configuration.getProperty(EventSenderDmaapImpl.DMAAP_USERNAME);
- if (eventClientKey != null) {
- props.setProperty(EventSenderDmaapImpl.DMAAP_USERNAME,eventClientKey);
- }
- String eventClientSecret = configuration.getProperty(EventSenderDmaapImpl.DMAAP_PASSWORD);
- if (eventClientSecret != null) {
- props.setProperty(EventSenderDmaapImpl.DMAAP_PASSWORD, eventClientSecret);
- }
-
- Producer producer = Mockito.mock(DmaapProducerImpl.class);
- producerMap.put(MessageDestination.DCAE.toString(),producer);
- Mockito.when(producer.post(Matchers.anyString(), Matchers.anyString())).thenReturn(true);
-
- eventMessage = new EventMessage(
- new EventHeader("2016-03-15T10:59:33.79Z", "1.01", "17"),
- new EventStatus(404, "No krokodil found"));
- }
-
- @Test
- @Ignore // requires connection to a live DMaaP server
- public void testDmaapEventSenderWithProperties() {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
- eventSender.initialize();
- eventSender.setProducerMap(producerMap);
- Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE, eventMessage));
- }
-
- @Test
- public void testDmaapEventSenderWithNullProperties() {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
-// eventSender.initialize();
- eventSender.setProducerMap(producerMap);
- Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE, eventMessage));
- }
-
- /*
- * This test runs agains a real Dmaap (or a simulator) that should be cofigured in test.properties file.
- */
- @Test
- @Ignore // requires connection to a live DMaaP server
- public void testDmaapEventSenderWithDmaapSim() {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
- eventSender.initialize();
- Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE, eventMessage));
- }
-
-
- @Test
- @Ignore // requires connection to a live DMaaP server
- public void testDmaapEventSenderDG() throws APPCException {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
- eventSender.initialize();
- eventSender.setProducerMap(producerMap);
- Map params = new HashMap<>();
-
- params.put("eventTime", eventMessage.getEventHeader().getEventTime());
- params.put("apiVer", eventMessage.getEventHeader().getApiVer());
- params.put("eventId", eventMessage.getEventHeader().getEventId());
- params.put("reason", eventMessage.getEventStatus().getReason());
- params.put("code", "200");
-
- Assert.assertTrue(eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext()));
- }
-
- @Test(expected = APPCException.class)
- @Ignore // requires connection to a live DMaaP server
- public void testDmaapEventSenderDGNoParams() throws APPCException {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
- eventSender.initialize();
- eventSender.setProducerMap(producerMap);
- Map params = new HashMap<>();
-
- Assert.assertFalse(eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext()));
- }
-
-
- @Test(expected = APPCException.class)
- @Ignore // requires connection to a live DMaaP server
- public void testDmaapEventSenderDGNullParam() throws APPCException {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
- eventSender.initialize();
- eventSender.setProducerMap(producerMap);
- Map params = null;
-
- Assert.assertFalse(eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext()));
- }
-
- @Test(expected = APPCException.class)
- @Ignore // requires connection to a live DMaaP server
- public void testDmaapEventSenderDGNoParam() throws APPCException {
- EventSenderDmaapImpl eventSender = new EventSenderDmaapImpl();
- eventSender.initialize();
- eventSender.setProducerMap(producerMap);
- Map params = new HashMap<>();
-
-// params.put("apiVer", eventMessage.getEventHeader().getApiVer());
- params.put("eventId", eventMessage.getEventHeader().getEventId());
- params.put("reason", eventMessage.getEventStatus().getReason());
- params.put("code", "200");
-
- eventSender.sendEvent(MessageDestination.DCAE,params, new SvcLogicContext());
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapProducing.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapProducing.java
deleted file mode 100644
index bdfa93726..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/TestDmaapProducing.java
+++ /dev/null
@@ -1,83 +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.messaging.dmaap;
-
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.adapter.message.Producer;
-import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Must have a DMaaP cluster or simulator up and running
- * Update the hostname, topic, client properties in
- * resources/org/onap/appc/default.properties
- *
- */
-public class TestDmaapProducing {
-
- private static Producer httpProducer;
- private static Producer dmaapProducer;
-
- @BeforeClass
- public static void setUp() {
-
- Configuration configuration = ConfigurationFactory.getConfiguration();
-
- List hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
- String topic = configuration.getProperty("topic.write");
- String user = configuration.getProperty("dmaap.appc.username");
- String password = configuration.getProperty("dmaap.appc.password");
-
- dmaapProducer = new DmaapProducerImpl(hosts, topic,user,password);
- httpProducer = new HttpDmaapProducerImpl(hosts, topic);
- httpProducer.updateCredentials(user,password);
- }
-
- @Test
- @Ignore
- public void testHttpPostMessage() {
- testPostMessage(httpProducer);
- }
-
- @Test
- @Ignore
- public void testPostMessages() {
- testPostMessage(dmaapProducer);
- }
-
- private void testPostMessage(Producer producer) {
- Assert.assertTrue(producer.post("partition", "{\"message\": \"Hello, world!\"}"));
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java
deleted file mode 100644
index cb318dc4e..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/messaging/dmaap/impl/TestConsumerProducerImpl.java
+++ /dev/null
@@ -1,245 +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.messaging.dmaap.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.*;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.adapter.message.Consumer;
-import org.onap.appc.adapter.message.Producer;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
-import org.onap.appc.configuration.Configuration;
-import org.onap.appc.configuration.ConfigurationFactory;
-
-public class TestConsumerProducerImpl {
-
- private Collection urls;
- private String topicRead;
- private String topicWrite;
- private String group;
- private String groupId;
- private String user;
- private String password;
-
- @Before
- public void setup() {
- System.out.println("setup entry...");
-// urls = new HashSet();
-// urls.add("dmaaphost1");
-// urls.add("dmaaphost2");
-// //remove unavailable dmaap instance for build
-// //urls.add("dmaaphost3");
-//
-// topicRead = "APPC-UNIT-TEST";
-// topicWrite = "APPC-UNIT-TEST";
-// group = "APPC-CLIENT";
-// groupId = "0";
- Configuration configuration = ConfigurationFactory.getConfiguration();
- List hosts = Arrays.asList(configuration.getProperty("poolMembers").split(","));
- urls = new HashSet(hosts);
- topicRead = configuration.getProperty("topic.read");
- topicWrite = configuration.getProperty("topic.write");
- user = configuration.getProperty("dmaap.appc.username");
- password = configuration.getProperty("dmaap.appc.password");
- group = "APPC-CLIENT";
- groupId = "0";
-
-
- runoff();
- }
-
- /**
- * Test that we can read and write and that the messages come back in order
- */
- @Ignore
- @Test
- public void testWriteRead() {
- System.out.println("testWriteRead entry...");
- Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
-
- String s1 = UUID.randomUUID().toString();
- String s2 = UUID.randomUUID().toString();
- if (p.post("TEST", s1) == false) {
- // try again - 2nd attempt may succeed if cambria client failed over
- p.post("TEST", s1);
- }
- if (p.post("TEST", s2) == false) {
- // try again - 2nd attempt may succeed if cambria client failed over
- p.post("TEST", s2);
- }
-
- Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
- List out = c.fetch();
- // if fetch is empty, try again - a 2nd attempt may succeed if
- // cambria client has failed over
- if ((out == null) || out.isEmpty()) {
- out = c.fetch();
- }
-
- assertNotNull(out);
- assertEquals(2, out.size());
- assertEquals(s1, out.get(0));
- assertEquals(s2, out.get(1));
-
- }
-
- /**
- * Test that we can read and write and that the messages come back in order
- */
- @Test
- @Ignore // Https Not support on jenkins server
- public void testWriteReadHttps() {
- System.out.println("testWriteReadHttps entry...");
- Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
- p.useHttps(true);
-
- String s1 = UUID.randomUUID().toString();
- String s2 = UUID.randomUUID().toString();
- if (p.post("TEST", s1) == false) {
- // try again - 2nd attempt may succeed if cambria client failed over
- p.post("TEST", s1);
- }
- if (p.post("TEST", s2) == false) {
- // try again - 2nd attempt may succeed if cambria client failed over
- p.post("TEST", s2);
- }
-
- Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
- c.useHttps(true);
-
- List out = c.fetch();
- // if fetch is empty, try again - a 2nd attempt may succeed if
- // cambria client has failed over
- if ((out == null) || out.isEmpty()) {
- out = c.fetch();
- }
-
- assertNotNull(out);
- assertEquals(2, out.size());
- assertEquals(s1, out.get(0));
- assertEquals(s2, out.get(1));
-
- }
-
- @Test
- @Ignore // requires connection to a live DMaaP server
- public void testBadUrl() {
- System.out.println("testBadUrl entry...");
- urls.clear();
- urls.add("something.local");
-
- // Producer p = new DmaapProducerImpl(urls, topicWrite);
- Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
- List result = c.fetch(1000, 1000);
-
- assertNotNull(result);
- assertTrue(result.isEmpty());
- }
-
- @Test
- @Ignore // requires connection to a live DMaaP server
- public void testAuth() {
- System.out.println("testAuth entry...");
- Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
- Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
-
- p.updateCredentials("key", "secret");
- c.updateCredentials("key", "secret");
-
- // TODO - Do some protected dmaap queries when the apis are updated
- }
-
- /**
- * Test DMaaP client failover to another server when a bad url is encountered
-
- */
- @Ignore
- @Test
- public void testFailover() {
- System.out.println("testFailover entry...");
- urls.clear();
- urls.add("openecomp2.org"); // bad url
- urls.add("dmaaphost2");
- Producer p = new DmaapProducerImpl(urls, topicWrite,user,password);
-
- String s1 = UUID.randomUUID().toString();
- if (p.post("TEST", s1) == false) {
- // try again - cambria client should have failed over
- p.post("TEST", s1);
- }
-
- urls.clear();
- urls.add("openecomp3.org"); // bad url
- urls.add("dmaaphost3");
-
- Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
- List out = c.fetch(1000, 1000);
- // if fetch is empty, try again - cambria client should have failed over
- if ((out == null) || out.isEmpty()) {
- out = c.fetch();
- }
-
- assertNotNull(out);
- assertEquals(1, out.size());
- assertEquals(s1, out.get(0));
- }
-
- /**
- * Reads through the entire topic so it is clean for testing. WARNING - ONLY USE ON TOPICS WHERE YOU ARE THE ONLY
- * WRITER. Could end in an infinite loop otherwise.
- */
- private void runoff() {
- Consumer c = new DmaapConsumerImpl(urls, topicRead, group, groupId,user,password);
- List data;
- do {
- data = c.fetch(1000, 10000);
- } while (!data.isEmpty() && data.size()!=1);
- }
-
- @Test
- @Ignore
- public void testFilter() {
- System.out.println("testFilter entry...");
- List res;
- String filter = "{\"class\":\"Assigned\",\"field\":\"request\"}";
- Consumer c = new DmaapConsumerImpl(urls, "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM", group, groupId,user,password,filter);
- res = c.fetch(2000, 10);
- assertFalse(res.isEmpty());
-
- res.clear();
- filter = "{\"class\":\"Assigned\",\"field\":\"response\"}";
- c = new DmaapConsumerImpl(urls, "DCAE-CLOSED-LOOP-EVENTS-DEV1510SIM", group, groupId,user,password, filter);
- res = c.fetch(2000, 10);
- assertTrue(res.isEmpty());
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/onap/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..dd594515c
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/onap/appc/default.properties
@@ -0,0 +1,39 @@
+###
+# ============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=========================================================
+###
+
+org.onap.appc.bootstrap.file=test.properties
+org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+# Properties commented out below are provided in appc.properties
+#poolMembers=:3904
+#event.pool.members=:3904
+
+topic.read=APPC-CL
+topic.read.timeout=5
+topic.write=APPC-CL
+event.topic.write=APPC-CL
+client.name=APPC-CLIENT-DMAAP-ADAPTER-TEST
+client.name.id=0
+
+metric.enabled=false;
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index dd594515c..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,39 +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=========================================================
-###
-
-org.onap.appc.bootstrap.file=test.properties
-org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
-
-# Properties commented out below are provided in appc.properties
-#poolMembers=:3904
-#event.pool.members=:3904
-
-topic.read=APPC-CL
-topic.read.timeout=5
-topic.write=APPC-CL
-event.topic.write=APPC-CL
-client.name=APPC-CLIENT-DMAAP-ADAPTER-TEST
-client.name.id=0
-
-metric.enabled=false;
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/CallableConsumer.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/CallableConsumer.java
new file mode 100644
index 000000000..1f6bb50fc
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/CallableConsumer.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.message;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class CallableConsumer implements Callable> {
+
+ private Consumer consumer;
+
+ private int timeout = 15000;
+ private int limit = 1000;
+
+ public CallableConsumer(Consumer c) {
+ this.consumer = c;
+ }
+
+ public CallableConsumer(Consumer c, int waitMs, int fetchSize) {
+ this.consumer = c;
+ this.timeout = waitMs;
+ this.limit = fetchSize;
+ }
+
+ @Override
+ public List call() {
+ return consumer.fetch(timeout, limit);
+ }
+
+ /**
+ * The maximum amount of time to keep a connection alive. Currently is set to waitMs + 10s
+ *
+ * @return An integer representing the maximum amount of time to keep this thread alive
+ */
+ public int getMaxLife() {
+ return 10000 + timeout;
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Consumer.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Consumer.java
new file mode 100644
index 000000000..92033064c
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Consumer.java
@@ -0,0 +1,73 @@
+/*-
+ * ============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.message;
+
+import java.util.List;
+
+public interface Consumer {
+
+ /**
+ * Gets a batch of messages from the topic. Defaults to 1000 messages with 15s wait for messages if empty.
+ *
+ * @return A list of strings representing the messages pulled from the topic.
+ */
+ public List fetch();
+
+ /**
+ * Gets a batch of messages from the topic.
+ *
+ * @param waitMs
+ * The amount of time to wait in milliseconds if the topic is empty for data to be written. Should be no
+ * less than 15000ms to prevent too many requests
+ * @param limit
+ * The amount of messages to fetch
+ * @return A list of strings representing the messages pulled from the topic.
+ */
+ public List fetch(int waitMs, int limit);
+
+ /**
+ * Updates the api credentials for making authenticated requests
+ *
+ * @param apiKey
+ * The public key to authenticate with
+ * @param apiSecret
+ * The secret key to authenticate with
+ */
+ public void updateCredentials(String apiKey, String apiSecret);
+
+ /**
+ * Creates a dmaap client using a https connection
+ *
+ * @param yes
+ * True if https should be used, false otherwise
+ */
+ public void useHttps(boolean yes);
+
+ /**
+ * Closes the dmaap client https connection
+ */
+ void close();
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/EventSender.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/EventSender.java
new file mode 100644
index 000000000..962f14774
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/EventSender.java
@@ -0,0 +1,39 @@
+/*-
+ * ============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.message;
+
+import org.onap.appc.exceptions.APPCException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
+
+import java.util.Map;
+
+import org.onap.appc.adapter.message.event.EventMessage;
+
+public interface EventSender extends SvcLogicJavaPlugin{
+ boolean sendEvent(MessageDestination destination, EventMessage msg);
+ boolean sendEvent(MessageDestination destination, EventMessage msg,String eventTopicName);
+ boolean sendEvent(MessageDestination destination, Map params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Manager.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Manager.java
new file mode 100644
index 000000000..aea2fddce
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Manager.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.message;
+
+import java.util.Set;
+
+public interface Manager {
+
+ /**
+ * Updates the api credentials for making authenticated requests
+ *
+ * @param apiKey
+ * The public key to authenticate with
+ * @param apiSecret
+ * The secret key to authenticate with
+ */
+ public void updateCredentials(String apiKey, String apiSecret);
+
+ /**
+ * Return a set of strings representing topics that the user can see
+ *
+ * @return A set of strings with topic names or an empty set if no topics are visible
+ */
+ public Set getTopics();
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageAdapterFactory.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageAdapterFactory.java
new file mode 100644
index 000000000..d7507dc85
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageAdapterFactory.java
@@ -0,0 +1,42 @@
+/*-
+ * ============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.message;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.message.Producer;
+
+public interface MessageAdapterFactory {
+
+ // TODO: how do you configure the MessageService type?
+
+ public Producer createProducer(Collection pools, String writeTopic, String apiKey, String apiSecret);
+
+ public Producer createProducer(Collection pools, Set writeTopics, String apiKey, String apiSecret);
+
+ public Consumer createConsumer(Collection pool, String readTopic,
+ String clientName, String clientId, String filter_json, String apiKey, String apiSecret);
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageDestination.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageDestination.java
new file mode 100644
index 000000000..cb84b5c4c
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/MessageDestination.java
@@ -0,0 +1,29 @@
+/*-
+ * ============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.message;
+
+public enum MessageDestination {
+ DCAE
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Producer.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Producer.java
new file mode 100644
index 000000000..52ead0253
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/Producer.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.message;
+
+public interface Producer {
+
+ public boolean post(String partition, String data);
+
+ /**
+ * Updates the api credentials for making authenticated requests
+ *
+ * @param apiKey
+ * The public key to authenticate with
+ * @param apiSecret
+ * The secret key to authenticate with
+ */
+ public void updateCredentials(String apiKey, String apiSecret);
+
+ /**
+ * Creates a dmaap client using a https connection
+ *
+ * @param yes
+ * True if https should be used, false otherwise
+ */
+ public void useHttps(boolean yes);
+
+ /**
+ * Closes the dmaap client https connection
+ */
+ void close();
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventHeader.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventHeader.java
new file mode 100644
index 000000000..2c4ab1fbf
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventHeader.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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.message.event;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class EventHeader {
+
+ @JsonProperty("eventTime")
+ private final String eventTime;
+
+ @JsonProperty("apiVer")
+ private final String apiVer;
+
+ @JsonProperty("eventId")
+ private final String eventId;
+
+ public EventHeader(String eventTime, String apiVer, String eventId) {
+ this.eventTime = eventTime;
+ this.apiVer = apiVer;
+ this.eventId = eventId;
+ }
+
+ public String getEventTime() {
+ return eventTime;
+ }
+
+ public String getApiVer() {
+ return apiVer;
+ }
+
+ public String getEventId() {
+ return eventId;
+ }
+
+ @Override
+ public String toString() {
+ return "EventHeader{" +
+ "eventTime='" + eventTime + '\'' +
+ ", apiVer='" + apiVer + '\'' +
+ ", eventId='" + eventId + '\'' +
+ '}';
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventMessage.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventMessage.java
new file mode 100644
index 000000000..d64d6d0ce
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventMessage.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.message.event;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/*
+ {
+ "EventHeader": {
+ "eventTime": "2016-03-15T10:59:33.79Z",
+ "apiVer": "1.01",
+ "EventId": "",
+ },
+ "EventStatus": {
+ "code": "NNN",
+ "reason": "A reason"
+ }
+ }
+*/
+
+
+@JsonSerialize(include = Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class EventMessage implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ @JsonProperty("eventHeader")
+ private EventHeader eventHeader;
+ @JsonProperty("eventStatus")
+ private EventStatus eventStatus;
+
+ public EventMessage(EventHeader eventHeader, EventStatus eventStatus) {
+ this.eventHeader = eventHeader;
+ this.eventStatus = eventStatus;
+ }
+
+ public EventHeader getEventHeader() {
+ return eventHeader;
+ }
+
+ public void setEventHeader(EventHeader eventHeader) {
+ this.eventHeader = eventHeader;
+ }
+
+ public EventStatus getEventStatus() {
+ return eventStatus;
+ }
+
+ public void setEventStatus(EventStatus eventStatus) {
+ this.eventStatus = eventStatus;
+ }
+
+ public String toJson() {
+ try {
+ return OBJECT_MAPPER.writeValueAsString(this);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "EventMessage{" +
+ "eventHeader=" + eventHeader +
+ ", eventStatus=" + eventStatus +
+ '}';
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventStatus.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventStatus.java
new file mode 100644
index 000000000..a5ac44e0b
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/onap/appc/adapter/message/event/EventStatus.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.message.event;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class EventStatus {
+
+ @JsonProperty("code")
+ private final Integer code;
+
+ @JsonProperty("reason")
+ private final String reason;
+
+ public EventStatus(Integer code, String aReason) {
+ this.code = code;
+ reason = aReason;
+ }
+
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public String getReason() {
+ return reason;
+ }
+
+ @Override
+ public String toString() {
+ return "EventStatus{" +
+ "code=" + code +
+ ", reason='" + reason + '\'' +
+ '}';
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/CallableConsumer.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/CallableConsumer.java
deleted file mode 100644
index 1f6bb50fc..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/CallableConsumer.java
+++ /dev/null
@@ -1,61 +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.message;
-
-import java.util.List;
-import java.util.concurrent.Callable;
-
-public class CallableConsumer implements Callable> {
-
- private Consumer consumer;
-
- private int timeout = 15000;
- private int limit = 1000;
-
- public CallableConsumer(Consumer c) {
- this.consumer = c;
- }
-
- public CallableConsumer(Consumer c, int waitMs, int fetchSize) {
- this.consumer = c;
- this.timeout = waitMs;
- this.limit = fetchSize;
- }
-
- @Override
- public List call() {
- return consumer.fetch(timeout, limit);
- }
-
- /**
- * The maximum amount of time to keep a connection alive. Currently is set to waitMs + 10s
- *
- * @return An integer representing the maximum amount of time to keep this thread alive
- */
- public int getMaxLife() {
- return 10000 + timeout;
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Consumer.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Consumer.java
deleted file mode 100644
index 92033064c..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Consumer.java
+++ /dev/null
@@ -1,73 +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.message;
-
-import java.util.List;
-
-public interface Consumer {
-
- /**
- * Gets a batch of messages from the topic. Defaults to 1000 messages with 15s wait for messages if empty.
- *
- * @return A list of strings representing the messages pulled from the topic.
- */
- public List fetch();
-
- /**
- * Gets a batch of messages from the topic.
- *
- * @param waitMs
- * The amount of time to wait in milliseconds if the topic is empty for data to be written. Should be no
- * less than 15000ms to prevent too many requests
- * @param limit
- * The amount of messages to fetch
- * @return A list of strings representing the messages pulled from the topic.
- */
- public List fetch(int waitMs, int limit);
-
- /**
- * Updates the api credentials for making authenticated requests
- *
- * @param apiKey
- * The public key to authenticate with
- * @param apiSecret
- * The secret key to authenticate with
- */
- public void updateCredentials(String apiKey, String apiSecret);
-
- /**
- * Creates a dmaap client using a https connection
- *
- * @param yes
- * True if https should be used, false otherwise
- */
- public void useHttps(boolean yes);
-
- /**
- * Closes the dmaap client https connection
- */
- void close();
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/EventSender.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/EventSender.java
deleted file mode 100644
index 962f14774..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/EventSender.java
+++ /dev/null
@@ -1,39 +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.message;
-
-import org.onap.appc.exceptions.APPCException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
-
-import java.util.Map;
-
-import org.onap.appc.adapter.message.event.EventMessage;
-
-public interface EventSender extends SvcLogicJavaPlugin{
- boolean sendEvent(MessageDestination destination, EventMessage msg);
- boolean sendEvent(MessageDestination destination, EventMessage msg,String eventTopicName);
- boolean sendEvent(MessageDestination destination, Map params, SvcLogicContext ctx) throws APPCException;
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Manager.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Manager.java
deleted file mode 100644
index aea2fddce..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Manager.java
+++ /dev/null
@@ -1,48 +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.message;
-
-import java.util.Set;
-
-public interface Manager {
-
- /**
- * Updates the api credentials for making authenticated requests
- *
- * @param apiKey
- * The public key to authenticate with
- * @param apiSecret
- * The secret key to authenticate with
- */
- public void updateCredentials(String apiKey, String apiSecret);
-
- /**
- * Return a set of strings representing topics that the user can see
- *
- * @return A set of strings with topic names or an empty set if no topics are visible
- */
- public Set getTopics();
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageAdapterFactory.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageAdapterFactory.java
deleted file mode 100644
index d7507dc85..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageAdapterFactory.java
+++ /dev/null
@@ -1,42 +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.message;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onap.appc.adapter.message.Consumer;
-import org.onap.appc.adapter.message.Producer;
-
-public interface MessageAdapterFactory {
-
- // TODO: how do you configure the MessageService type?
-
- public Producer createProducer(Collection pools, String writeTopic, String apiKey, String apiSecret);
-
- public Producer createProducer(Collection pools, Set writeTopics, String apiKey, String apiSecret);
-
- public Consumer createConsumer(Collection pool, String readTopic,
- String clientName, String clientId, String filter_json, String apiKey, String apiSecret);
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageDestination.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageDestination.java
deleted file mode 100644
index cb84b5c4c..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/MessageDestination.java
+++ /dev/null
@@ -1,29 +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.message;
-
-public enum MessageDestination {
- DCAE
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Producer.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Producer.java
deleted file mode 100644
index 52ead0253..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/Producer.java
+++ /dev/null
@@ -1,54 +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.message;
-
-public interface Producer {
-
- public boolean post(String partition, String data);
-
- /**
- * Updates the api credentials for making authenticated requests
- *
- * @param apiKey
- * The public key to authenticate with
- * @param apiSecret
- * The secret key to authenticate with
- */
- public void updateCredentials(String apiKey, String apiSecret);
-
- /**
- * Creates a dmaap client using a https connection
- *
- * @param yes
- * True if https should be used, false otherwise
- */
- public void useHttps(boolean yes);
-
- /**
- * Closes the dmaap client https connection
- */
- void close();
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventHeader.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventHeader.java
deleted file mode 100644
index 2c4ab1fbf..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventHeader.java
+++ /dev/null
@@ -1,66 +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.message.event;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class EventHeader {
-
- @JsonProperty("eventTime")
- private final String eventTime;
-
- @JsonProperty("apiVer")
- private final String apiVer;
-
- @JsonProperty("eventId")
- private final String eventId;
-
- public EventHeader(String eventTime, String apiVer, String eventId) {
- this.eventTime = eventTime;
- this.apiVer = apiVer;
- this.eventId = eventId;
- }
-
- public String getEventTime() {
- return eventTime;
- }
-
- public String getApiVer() {
- return apiVer;
- }
-
- public String getEventId() {
- return eventId;
- }
-
- @Override
- public String toString() {
- return "EventHeader{" +
- "eventTime='" + eventTime + '\'' +
- ", apiVer='" + apiVer + '\'' +
- ", eventId='" + eventId + '\'' +
- '}';
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventMessage.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventMessage.java
deleted file mode 100644
index d64d6d0ce..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventMessage.java
+++ /dev/null
@@ -1,100 +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.message.event;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-/*
- {
- "EventHeader": {
- "eventTime": "2016-03-15T10:59:33.79Z",
- "apiVer": "1.01",
- "EventId": "",
- },
- "EventStatus": {
- "code": "NNN",
- "reason": "A reason"
- }
- }
-*/
-
-
-@JsonSerialize(include = Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class EventMessage implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- @JsonProperty("eventHeader")
- private EventHeader eventHeader;
- @JsonProperty("eventStatus")
- private EventStatus eventStatus;
-
- public EventMessage(EventHeader eventHeader, EventStatus eventStatus) {
- this.eventHeader = eventHeader;
- this.eventStatus = eventStatus;
- }
-
- public EventHeader getEventHeader() {
- return eventHeader;
- }
-
- public void setEventHeader(EventHeader eventHeader) {
- this.eventHeader = eventHeader;
- }
-
- public EventStatus getEventStatus() {
- return eventStatus;
- }
-
- public void setEventStatus(EventStatus eventStatus) {
- this.eventStatus = eventStatus;
- }
-
- public String toJson() {
- try {
- return OBJECT_MAPPER.writeValueAsString(this);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public String toString() {
- return "EventMessage{" +
- "eventHeader=" + eventHeader +
- ", eventStatus=" + eventStatus +
- '}';
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventStatus.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventStatus.java
deleted file mode 100644
index a5ac44e0b..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/java/org/openecomp/appc/adapter/message/event/EventStatus.java
+++ /dev/null
@@ -1,58 +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.message.event;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class EventStatus {
-
- @JsonProperty("code")
- private final Integer code;
-
- @JsonProperty("reason")
- private final String reason;
-
- public EventStatus(Integer code, String aReason) {
- this.code = code;
- reason = aReason;
- }
-
-
- public Integer getCode() {
- return code;
- }
-
- public String getReason() {
- return reason;
- }
-
- @Override
- public String toString() {
- return "EventStatus{" +
- "code=" + code +
- ", reason='" + reason + '\'' +
- '}';
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/onap/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..a326faada
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,26 @@
+###
+# ============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=========================================================
+###
+
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index a326faada..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-api/src/main/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,26 +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=========================================================
-###
-
-org.onap.appc.bootstrap.file=appc.properties
-org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
new file mode 100644
index 000000000..1597c4256
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
@@ -0,0 +1,47 @@
+/*-
+ * ============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.factory;
+
+import org.onap.appc.adapter.message.MessageAdapterFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class DmaapMessageAdapterFactoryActivator implements BundleActivator {
+ private ServiceRegistration registration;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ registration = context.registerService(
+ MessageAdapterFactory.class.getName(),
+ new DmaapMessageAdapterFactoryImpl(),
+ null);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ registration.unregister();
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
new file mode 100644
index 000000000..19eb4cea8
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
@@ -0,0 +1,58 @@
+/*-
+ * ============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.factory;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.message.MessageAdapterFactory;
+import org.onap.appc.adapter.message.Producer;
+
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
+
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
+import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+
+public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory {
+
+ //Set to true if the HttpDmaap... should be used instead of the regular Dmaap...
+ private static final boolean HTTP = true;
+
+ public Producer createProducer(Collection pools, String writeTopic, String apiKey, String apiSecret) {
+ return HTTP ? new HttpDmaapProducerImpl(pools, writeTopic) : new DmaapProducerImpl(pools, writeTopic,apiKey, apiSecret);
+ }
+
+ public Producer createProducer(Collection pools, Set writeTopics, String apiKey, String apiSecret) {
+ return HTTP ? new HttpDmaapProducerImpl(pools, writeTopics) : new DmaapProducerImpl(pools, writeTopics, apiKey, apiSecret);
+ }
+
+ public Consumer createConsumer(Collection pool, String readTopic,
+ String clientName, String clientId, String filter_json, String apiKey, String apiSecret) {
+ return HTTP ? new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json) :
+ new DmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json);
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java
new file mode 100644
index 000000000..952f903b1
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/onap/appc/adapter/factory/MessageService.java
@@ -0,0 +1,59 @@
+/*-
+ * ============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.factory;
+/**
+ * The message service types that are available. Only DMaaP available
+ **/
+public enum MessageService {
+ DMaaP("dmaap");
+
+ private String val;
+
+ private MessageService(String val) {
+ this.val = val;
+ }
+
+ public String getValue() {
+ return val;
+ }
+
+ /**
+ * Tries to match a string to a MessageService. If no match is found, returns the default (DMaaP)
+ *
+ * @param input
+ * the string to try and match
+ * @return A MessasgeService
+ */
+ public static MessageService parse(String input) {
+ if (input != null) {
+ for (MessageService ms : MessageService.values()) {
+ if (ms.getValue().equals(input.toLowerCase())) {
+ return ms;
+ }
+ }
+ }
+ return MessageService.DMaaP; // Default
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
deleted file mode 100644
index 1597c4256..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryActivator.java
+++ /dev/null
@@ -1,47 +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.factory;
-
-import org.onap.appc.adapter.message.MessageAdapterFactory;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class DmaapMessageAdapterFactoryActivator implements BundleActivator {
- private ServiceRegistration registration;
-
- @Override
- public void start(BundleContext context) throws Exception {
- registration = context.registerService(
- MessageAdapterFactory.class.getName(),
- new DmaapMessageAdapterFactoryImpl(),
- null);
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- registration.unregister();
- }
-
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
deleted file mode 100644
index 19eb4cea8..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java
+++ /dev/null
@@ -1,58 +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.factory;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onap.appc.adapter.message.Consumer;
-import org.onap.appc.adapter.message.MessageAdapterFactory;
-import org.onap.appc.adapter.message.Producer;
-
-import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
-import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
-
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl;
-import org.onap.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
-
-public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory {
-
- //Set to true if the HttpDmaap... should be used instead of the regular Dmaap...
- private static final boolean HTTP = true;
-
- public Producer createProducer(Collection pools, String writeTopic, String apiKey, String apiSecret) {
- return HTTP ? new HttpDmaapProducerImpl(pools, writeTopic) : new DmaapProducerImpl(pools, writeTopic,apiKey, apiSecret);
- }
-
- public Producer createProducer(Collection pools, Set writeTopics, String apiKey, String apiSecret) {
- return HTTP ? new HttpDmaapProducerImpl(pools, writeTopics) : new DmaapProducerImpl(pools, writeTopics, apiKey, apiSecret);
- }
-
- public Consumer createConsumer(Collection pool, String readTopic,
- String clientName, String clientId, String filter_json, String apiKey, String apiSecret) {
- return HTTP ? new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json) :
- new DmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json);
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/MessageService.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/MessageService.java
deleted file mode 100644
index 952f903b1..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/MessageService.java
+++ /dev/null
@@ -1,59 +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.factory;
-/**
- * The message service types that are available. Only DMaaP available
- **/
-public enum MessageService {
- DMaaP("dmaap");
-
- private String val;
-
- private MessageService(String val) {
- this.val = val;
- }
-
- public String getValue() {
- return val;
- }
-
- /**
- * Tries to match a string to a MessageService. If no match is found, returns the default (DMaaP)
- *
- * @param input
- * the string to try and match
- * @return A MessasgeService
- */
- public static MessageService parse(String input) {
- if (input != null) {
- for (MessageService ms : MessageService.values()) {
- if (ms.getValue().equals(input.toLowerCase())) {
- return ms;
- }
- }
- }
- return MessageService.DMaaP; // Default
- }
-}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..a326faada
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,26 @@
+###
+# ============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=========================================================
+###
+
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/openecomp/appc/default.properties
deleted file mode 100644
index a326faada..000000000
--- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/resources/org/openecomp/appc/default.properties
+++ /dev/null
@@ -1,26 +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=========================================================
-###
-
-org.onap.appc.bootstrap.file=appc.properties
-org.onap.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/AppcProviderAdapterActivator.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/AppcProviderAdapterActivator.java
new file mode 100644
index 000000000..fbd650c39
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/AppcProviderAdapterActivator.java
@@ -0,0 +1,147 @@
+/*-
+ * ============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.iaas;
+
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.iaas.impl.ProviderAdapterImpl;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.i18n.Msg;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+/**
+ * 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 AppcProviderAdapterActivator implements BundleActivator {
+
+ /**
+ * The bundle registration
+ */
+ private ServiceRegistration registration = null;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private ProviderAdapter adapter;
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(AppcProviderAdapterActivator.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, "IAAS adapter");
+ try {
+ adapter = new ProviderAdapterImpl(configuration.getProperties());
+ } catch (Exception e) {
+ logger.error("Error initializing APPC IAAS ProviderAdapterImpl", e);
+ throw e;
+ }
+
+ if (registration == null) {
+ logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
+ ProviderAdapter.class.getSimpleName());
+ registration = context.registerService(ProviderAdapter.class, adapter, null);
+ }
+
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, "IAAS 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, "IAAS adapter");
+ logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
+ registration.unregister();
+ registration = null;
+ logger.info(Msg.COMPONENT_TERMINATED, appName, "IAAS adapter");
+ }
+ }
+
+ public String getName() {
+ return "APPC IaaS adapter";
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java
new file mode 100644
index 000000000..c14c936e0
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/ProviderAdapter.java
@@ -0,0 +1,288 @@
+/*-
+ * ============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.iaas;
+
+import java.util.Map;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.exceptions.UnknownProviderException;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Stack;
+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 ProviderAdapter 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";
+
+ /**
+ * The Rebuild VM flag is an optional payload parameter for the Evacuate API.
+ */
+ static final String PROPERTY_REBUILD_VM = "org.onap.appc.rebuildvm";
+
+ /**
+ * The target host id is an optional payload parameter for the Evacuate API.
+ */
+ static final String PROPERTY_TARGETHOST_ID = "org.onap.appc.targethost.id";
+
+ /**
+ * heat stack id to perform operation on stack
+ */
+ static final String PROPERTY_STACK_ID = "org.onap.appc.stack.id";
+
+ static final String PROPERTY_SNAPSHOT_ID = "snapshot.id";
+
+ static final String PROPERTY_INPUT_SNAPSHOT_ID = "org.onap.appc.snapshot.id";
+
+ static final String DG_OUTPUT_PARAM_NAMESPACE = "output.";
+
+ static final String SKIP_HYPERVISOR_CHECK = "org.onap.appc.skiphypervisorcheck";
+
+ /**
+ * 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;
+
+ /**
+ * This method is used to terminate 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 terminate, 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 terminate for some reason
+ */
+ Server terminateServer(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;
+
+ Server vmStatuschecker(Map params, SvcLogicContext ctx) throws APPCException;
+
+ Stack terminateStack(Map params, SvcLogicContext ctx) throws APPCException;
+
+ Stack snapshotStack(Map params, SvcLogicContext ctx) throws APPCException;
+
+ Stack restoreStack(Map params, SvcLogicContext ctx) throws APPCException;
+
+ /**
+ * This method is used to do the lookup of 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 lookup, 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 found for some reason
+ */
+ Server lookupServer(Map properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * The
+ *
+ * @param params A map of name-value pairs that supply the parameters needed by this method. The properties needed
+ * are defined above.
+ * @param ctx The service logic context of the graph being executed.
+ * @return The Image
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
+ */
+ Image createSnapshot(Map params, SvcLogicContext ctx) throws APPCException;
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/IdentityURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/IdentityURL.java
new file mode 100644
index 000000000..c98edc410
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/IdentityURL.java
@@ -0,0 +1,146 @@
+/*-
+ * ============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.iaas.impl;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * This class is used to parse the VM URL returned from OpenStack and extract all of the constituent parts.
+ */
+public class IdentityURL {
+ /**
+ * The regular expression pattern used to parse the URL. Capturing groups are used to identify and extract the
+ * various component parts of the URL.
+ */
+ private static Pattern pattern = Pattern.compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/(v[0-9\\.]+)/?");
+
+ /**
+ * The URL scheme or protocol, such as HTTP or HTTPS
+ */
+ private String scheme;
+
+ /**
+ * The host name or ip address
+ */
+ private String host;
+
+ /**
+ * The path of the service, or null if no path is defined
+ */
+ private String path;
+
+ /**
+ * The port number, or null if no port is defined
+ */
+ private String port;
+
+ /**
+ * The version of the service
+ */
+ private String version;
+
+ /**
+ * A private default constructor prevents instantiation by any method other than the factory method
+ *
+ * @see #parseURL(String)
+ */
+ private IdentityURL() {
+
+ }
+
+ /**
+ * This static method is used to parse the provided server URL string and return a parse results object (VMURL)
+ * which represents the state of the parse.
+ *
+ * @param serverUrl The server URL to be parsed
+ * @return The VMURL parse results object, or null if the URL was not valid or null.
+ */
+ public static IdentityURL parseURL(String identUrl) {
+ IdentityURL obj = null;
+ if (identUrl != null) {
+ Matcher matcher = pattern.matcher(identUrl.trim()); // http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/identity/v3
+ if (matcher.matches()) { // (\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/(v[0-9\\.]+)/?"
+ obj = new IdentityURL();
+ obj.scheme = matcher.group(1);
+ obj.host = matcher.group(2);
+ obj.port = matcher.group(3);
+ obj.path = matcher.group(4);
+ obj.version = matcher.group(5);
+ }
+ }
+
+ return obj;
+ }
+
+ /**
+ * @return The URL scheme
+ */
+ public String getScheme() {
+ return scheme;
+ }
+
+ /**
+ * @return The URL host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @return The URL path, or null if no path was defined
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * @return The URL port, or null if no port was defined
+ */
+ public String getPort() {
+ return port;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder str = new StringBuilder();
+
+ str.append(scheme + "://" + host);
+ if (port != null) {
+ str.append(":" + port);
+ }
+ if (path != null) {
+ str.append(path);
+ }
+ str.append("/" + version);
+
+ return str.toString();
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java
new file mode 100644
index 000000000..ba6c8c678
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderAdapterImpl.java
@@ -0,0 +1,359 @@
+/*-
+ * ============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.iaas.impl;
+
+import org.onap.appc.Constants;
+import org.onap.appc.adapter.iaas.ProviderAdapter;
+import org.onap.appc.adapter.iaas.provider.operation.api.IProviderOperation;
+import org.onap.appc.adapter.iaas.provider.operation.api.ProviderOperationFactory;
+import org.onap.appc.adapter.iaas.provider.operation.common.constants.Property;
+import org.onap.appc.adapter.iaas.provider.operation.common.enums.Operation;
+import org.onap.appc.adapter.iaas.provider.operation.impl.EvacuateServer;
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.util.StructuredPropertyHelper;
+import org.onap.appc.util.StructuredPropertyHelper.Node;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Stack;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * This class implements the {@link ProviderAdapter} interface. This interface defines the behaviors that our service
+ * provides.
+ *
+ * @since Aug 12, 2015
+ * @version $Id$
+ */
+@SuppressWarnings("javadoc")
+public class ProviderAdapterImpl implements ProviderAdapter {
+ /**
+ * The default domain name for authentication
+ */
+ public static final String DEFAULT_DOMAIN_NAME = "Default";
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(ProviderAdapterImpl.class);
+ /**
+ * A reference to the adapter configuration object.
+ */
+ private Configuration configuration;
+
+ /**
+ * reference to operation factory
+ */
+ ProviderOperationFactory factory = ProviderOperationFactory.getInstance();
+
+ /**
+ * A cache of providers that are predefined.
+ */
+ private Map providerCache;
+
+ /**
+ * The username, password, and domain to use for dynamically created connections
+ */
+ private static String DEFAULT_USER;
+ private static String DEFAULT_PASS;
+ private static String DEFAULT_DOMAIN;
+
+
+ /**
+ * This default constructor is used as a work around because the activator wasnt getting called
+ */
+ @SuppressWarnings("all")
+ public ProviderAdapterImpl() {
+ 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
+ */
+ @SuppressWarnings("all")
+ public ProviderAdapterImpl(boolean initialize) {
+ configuration = ConfigurationFactory.getConfiguration();
+ if (initialize) {
+ initialize();
+ }
+ }
+
+ /**
+ * @param props not used
+ */
+ public ProviderAdapterImpl(@SuppressWarnings("unused") Properties props) {
+ initialize();
+
+ }
+
+ @Override
+ public Server restartServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.RESTART_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server stopServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.STOP_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server startServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.START_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server rebuildServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.REBUILD_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server terminateServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.TERMINATE_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server evacuateServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.EVACUATE_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ // pass this object's reference to EvacuateServer to allow rebuild after evacuate
+ ((EvacuateServer) op).setProvideAdapterRef(this);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server migrateServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.MIGRATE_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server vmStatuschecker(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.VMSTATUSCHECK_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Stack terminateStack(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.TERMINATE_STACK);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Stack) op.doOperation(params, context);
+ }
+
+ @Override
+ public Stack snapshotStack(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.SNAPSHOT_STACK);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Stack) op.doOperation(params, context);
+ }
+
+ @Override
+ public Stack restoreStack(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.RESTORE_STACK);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Stack) op.doOperation(params, context);
+ }
+
+ @Override
+ public Server lookupServer(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.LOOKUP_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Server) op.doOperation(params, context);
+ }
+
+ @Override
+ public Image createSnapshot(Map params, SvcLogicContext context) throws APPCException {
+
+ IProviderOperation op = factory.getOperationObject(Operation.SNAPSHOT_SERVICE);
+ op.setProviderCache(this.providerCache);
+ op.setDefaultPass(DEFAULT_PASS);
+ op.setDefaultUser(DEFAULT_USER);
+ op.setDefaultDomain(DEFAULT_DOMAIN);
+ return (Image) op.doOperation(params, context);
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.onap.appc.adapter.iaas.ProviderAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
+ }
+
+
+ /**
+ * initialize the provider adapter by building the context cache
+ */
+ private void initialize() {
+ configuration = ConfigurationFactory.getConfiguration();
+
+ /*
+ * Initialize the provider cache for all defined providers. The definition of the providers uses a structured
+ * property set, where the names form a hierarchical name space (dotted notation, such as one.two.three). Each
+ * name in the name space can also be serialized by appending a sequence number. All nodes at the same level
+ * with the same serial number are grouped together in the namespace hierarchy. This allows a hierarchical
+ * multi-valued property to be defined, which can then be used to setup the provider and tenant caches. For
+ * example, the following definitions show how the namespace hierarchy is defined for two providers, with two
+ * tenants on the first provider and a single tenant for the second provider.
+ * provider1.type=OpenStackProvider provider1.name=ILAB provider1.identity=http://provider1:5000/v2.0
+ * provider1.tenant1.name=CDP-ONAP-APPC provider1.tenant1.userid=testUser
+ * provider1.tenant1.password=testPassword provider1.tenant2.name=TEST-TENANT provider1.tenant2.userid=testUser
+ * provider1.tenant2.password=testPassword provider2.type=OpenStackProvider provider2.name=PDK1
+ * provider2.identity=http://provider2:5000/v2.0 provider2.tenant1.name=someName
+ * provider2.tenant1.userid=someUser provider2.tenant1.password=somePassword
+ */
+ providerCache = new HashMap<>();
+ Properties properties = configuration.getProperties();
+ List providers = StructuredPropertyHelper.getStructuredProperties(properties, Property.PROVIDER);
+
+ for (Node provider : providers) {
+ ProviderCache cache = new ProviderCache();
+ List providerNodes = provider.getChildren();
+ for (Node node : providerNodes) {
+ if (node.getName().equals(Property.PROVIDER_TYPE)) {
+ cache.setProviderType(node.getValue());
+ } else if (node.getName().equals(Property.PROVIDER_IDENTITY)) {
+ cache.setIdentityURL(node.getValue());
+ cache.setProviderName(node.getValue());
+ } else if (node.getName().startsWith(Property.PROVIDER_TENANT)) {
+ String tenantName = null;
+ String userId = null;
+ String password = null;
+ // domain is not required so set a default
+ String domain = DEFAULT_DOMAIN_NAME;
+ for (Node node2 : node.getChildren()) {
+ switch (node2.getName()) {
+ case Property.PROVIDER_TENANT_NAME:
+ tenantName = node2.getValue();
+ break;
+ case Property.PROVIDER_TENANT_USERID:
+ userId = node2.getValue();
+ DEFAULT_USER = node2.getValue();
+ break;
+ case Property.PROVIDER_TENANT_PASSWORD:
+ password = node2.getValue();
+ DEFAULT_PASS = node2.getValue();
+ break;
+ case Property.PROVIDER_TENANT_DOMAIN:
+ domain = node2.getValue();
+ DEFAULT_DOMAIN = node2.getValue();
+ break;
+ }
+ }
+
+ cache.addTenant(null, tenantName, userId, password, domain);
+ }
+ }
+
+ /*
+ * Add the provider to the set of providers cached
+ */
+ if (cache.getIdentityURL() != null && cache.getProviderType() != null) {
+ providerCache.put(null, cache);
+ providerCache.put(cache.getIdentityURL(), cache);
+ }
+
+ /*
+ * Now, initialize the cache for the loaded provider
+ */
+ cache.initialize();
+ }
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderCache.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderCache.java
new file mode 100644
index 000000000..5453a9ec1
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/impl/ProviderCache.java
@@ -0,0 +1,165 @@
+/*-
+ * ============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.iaas.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class maintains a cache of information by provider, where a provider is identified by both a type and an
+ * identity URL used to connect to that provider.
+ *