aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters')
-rw-r--r--appc-adapters/.gitignore7
-rw-r--r--appc-adapters/appc-chef-adapter/.gitignore1
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/.gitignore3
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/pom.xml228
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefActivator.java143
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefAdapter.java203
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java185
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java33
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java43
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/ChefApiClient.java91
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java105
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java470
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestContext.java249
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestFailedException.java243
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/client.pem27
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties93
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/TestChefAdapterImpl.java119
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/client.pem27
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java179
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java451
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties108
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-features/.gitignore4
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-features/pom.xml122
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-features/src/main/resources/features.xml38
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/.gitignore2
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/pom.xml126
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--appc-adapters/appc-chef-adapter/pom.xml123
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml162
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/AppcDmaapAdapterActivator.java113
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CallableConsumer.java58
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CommonHttpClient.java105
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Consumer.java68
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapConsumer.java163
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapDestination.java26
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapProducer.java133
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/EventSender.java35
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Manager.java45
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Producer.java46
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventHeader.java64
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventMessage.java99
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventStatus.java56
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/impl/EventSenderImpl.java143
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml33
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties25
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/dmaap/TestAppcDmaapAdapterActivator.java47
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt18
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties36
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/test.properties35
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/pom.xml122
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/src/main/resources/features.xml40
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/.gitignore2
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/pom.xml133
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--appc-adapters/appc-dmaap-adapter/pom.xml105
-rw-r--r--appc-adapters/appc-iaas-adapter/.gitignore1
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/.gitignore4
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml222
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java143
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/ProviderAdapter.java294
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java120
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderAdapterImpl.java2723
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderCache.java164
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestContext.java250
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestFailedException.java277
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalog.java488
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/TenantCache.java378
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java138
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/SnapshotResource.java70
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/StackResource.java51
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/CreateSnapshotParams.java65
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Data.java253
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Environment.java91
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Metadata.java42
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Parameters.java42
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Properties.java65
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceData.java65
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceRegistry.java67
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources.java42
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources_.java67
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources__.java67
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Snapshot.java182
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotDetails.java67
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java111
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Template.java90
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume.java90
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume_.java206
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/com/att/cdp/default.properties158
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties102
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java54
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java943
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java170
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java159
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java147
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java107
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java181
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java451
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties109
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/.gitignore4
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/pom.xml122
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/src/main/resources/features.xml40
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/.gitignore2
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/pom.xml132
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--appc-adapters/appc-iaas-adapter/pom.xml125
-rw-r--r--appc-adapters/appc-netconf-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml189
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java130
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java64
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java45
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java61
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java40
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java70
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java28
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java92
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java82
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java32
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java52
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java132
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java55
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java44
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java44
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java129
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java103
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java53
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java154
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java94
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java60
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java171
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java233
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java64
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties41
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java197
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java88
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java60
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java93
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java93
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java91
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java87
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/pom.xml122
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/src/main/resources/features.xml37
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-installer/pom.xml130
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--appc-adapters/appc-netconf-adapter/pom.xml127
-rw-r--r--appc-adapters/appc-rest-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/.gitignore3
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml230
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestActivator.java143
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestAdapter.java205
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestContext.java251
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestFailedException.java244
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RestAdapterImpl.java491
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties93
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/adapter/rest/impl/TestRestAdapterImpl.java161
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java180
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java452
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties113
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-features/.gitignore4
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-features/pom.xml122
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-features/src/main/resources/features.xml37
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/.gitignore2
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/pom.xml132
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_installer_zip.xml59
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml47
-rw-r--r--appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/main/resources/scripts/install-feature.sh40
-rw-r--r--appc-adapters/appc-rest-adapter/pom.xml125
-rw-r--r--appc-adapters/appc-ssh-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/pom.xml47
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/Constants.java141
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapter.java39
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnection.java67
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionDetails.java72
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessException.java45
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessService.java58
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshException.java46
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/pom.xml72
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/src/main/resources/features.xml31
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/pom.xml62
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSshd.java33
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshConnectionSshd.java172
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshdDataAccessService.java106
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/resources/OSGI-INF/blueprint/blueprint.xml38
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSample.java56
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterTest.java247
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml18
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapterMock.java75
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionMock.java155
-rw-r--r--appc-adapters/appc-ssh-adapter/pom.xml19
-rw-r--r--appc-adapters/pom.xml21
201 files changed, 24029 insertions, 0 deletions
diff --git a/appc-adapters/.gitignore b/appc-adapters/.gitignore
new file mode 100644
index 000000000..02b972cc7
--- /dev/null
+++ b/appc-adapters/.gitignore
@@ -0,0 +1,7 @@
+target/
+META-INF/MANIFEST.MF
+logs/
+/bin/
+/.settings/
+/classes/
+**/*.iml
diff --git a/appc-adapters/appc-chef-adapter/.gitignore b/appc-adapters/appc-chef-adapter/.gitignore
new file mode 100644
index 000000000..d027396de
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/.gitignore
@@ -0,0 +1 @@
+/.settings/
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/.gitignore b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/.gitignore
new file mode 100644
index 000000000..755cdc373
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/.gitignore
@@ -0,0 +1,3 @@
+/bin/
+/target/
+/.settings/
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/pom.xml b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/pom.xml
new file mode 100644
index 000000000..00f59e4c9
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/pom.xml
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-chef-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-chef-adapter-bundle</artifactId>
+ <packaging>bundle</packaging>
+ <name>chef Adapter - bundle</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <!-- http://mvnrepository.com/artifact/commons-logging/commons-logging -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <!-- http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.4.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ <version>1.47</version>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ <version>1.47</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ <classifier>jar-with-dependencies</classifier>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ </dependency>
+<!-- <dependency>
+ <groupId>jce</groupId>
+ <artifactId>jce</artifactId>
+ <version>1_2-do</version>
+ <scope>compile</scope>
+ </dependency> -->
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-openstack</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ </dependency>
+
+ <!-- Jersey support needed for OpenStack connector and API version logic -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxp-api</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+
+ <!-- Needed to run test cases -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.12</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.31</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vmware</groupId>
+ <artifactId>vijava</artifactId>
+ <version>5.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-chef-adapter</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.adapter.chef.ChefActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.adapter.chef</Export-Package>
+ <Import-Package>org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.vmware.*,org.apache.xerces.*,javax.net.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.bind.*,javax.naming.*</Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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
new file mode 100644
index 000000000..2def2382b
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefActivator.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.chef.impl.ChefAdapterImpl;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.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.
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * When the bundle is deactivated, the cache is torn down with all contexts being closed.
+ * </p>
+ */
+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 static final Logger LOG = LoggerFactory.getLogger(ChefActivator.class);
+ private static 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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(configuration.getProperties());
+ 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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
new file mode 100644
index 000000000..907ded5d2
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/ChefAdapter.java
@@ -0,0 +1,203 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.cdp.zones.model.Server;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+/**
+ * This interface defines the operations that the provider adapter exposes.
+ * <p>
+ * 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.
+ * </p>
+ */
+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.openecomp.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.openecomp.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.openecomp.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.openecomp.appc.identity.url";
+
+ /**
+ * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to stop the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to start the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to rebuild the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ */
+ String getAdapterName();
+
+ // Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ //Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void trigger(Map<String, String> params, SvcLogicContext ctx) ;
+
+ void chefGet(Map<String, String> params, SvcLogicContext ctx) ;
+
+ void chefPut(Map<String, String> 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
new file mode 100644
index 000000000..d2a0eb26f
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/ApiMethod.java
@@ -0,0 +1,185 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef.chefapi;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.apache.http.*;
+import org.apache.http.client.*;
+import org.apache.http.client.methods.*;
+import org.apache.http.impl.client.*;
+import org.apache.http.util.EntityUtils;
+import org.openecomp.appc.adapter.chef.chefclient.Utils;
+
+import javax.net.ssl.SSLContext;
+import java.io.File;
+import org.apache.http.HttpEntity;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContexts;
+
+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;
+// final String KEY_STORE_PATH = "/tmp/chef/trusted_certs/mykeystore.jks";
+// final String KEY_STORE_PASSWORD = "changeit";
+
+ public ApiMethod(String methodName) {
+/* try {
+ SSLContext sslcontext = SSLContexts.custom()
+ .loadTrustMaterial(new File(KEY_STORE_PATH), KEY_STORE_PASSWORD.toCharArray(),
+ new TrustSelfSignedStrategy())
+ .build();
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
+ sslcontext,
+ new String[] { "TLSv1" },
+ null,
+ SSLConnectionSocketFactory.getDefaultHostnameVerifier());
+ client = HttpClients.custom()
+ .setSSLSocketFactory(sslsf)
+ .build();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }*/
+ client=HttpClients.createDefault();
+ this.methodName = methodName;
+ }
+
+ public ApiMethod execute() {
+ 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";
+ */
+ 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/Get.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java
new file mode 100644
index 000000000..add65f92e
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Get.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.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/Put.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java
new file mode 100644
index 000000000..597289809
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefapi/Put.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.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
new file mode 100644
index 000000000..f3cc44bb2
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/ChefApiClient.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef.chefclient;
+import org.apache.http.client.methods.*;
+import org.openecomp.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 PostMethod(endpoint+path));
+ post.setPemPath(pemPath);
+ post.setUserId(userId);
+ return post;
+ }
+
+ public Delete delete(String path){
+ Delete del = new Delete(new DeleteMethod(endpoint+path));
+ del.setPemPath(pemPath);
+ del.setUserId(userId);
+ return del;
+ }
+
+
+*/
+/* public Header[] buildHeaders(){
+
+ return null;
+ }
+*/
+}
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
new file mode 100644
index 000000000..d814762f8
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/chefclient/Utils.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef.chefclient;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+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.PEMReader;
+import org.bouncycastle.util.encoders.Base64;
+
+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;
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(pemPath));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ Security.addProvider(new BouncyCastleProvider());
+ try {
+
+ KeyPair kp = (KeyPair) new PEMReader(br).readObject();
+ PrivateKey privateKey = kp.getPrivate();
+ Signature instance = Signature.getInstance("RSA");
+ instance.initSign(privateKey);
+ instance.update(inStr.getBytes());
+
+ byte[] signature = instance.sign();
+ outStr = Base64.encode(signature);
+ String tmp = new String(outStr);
+ } 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
new file mode 100644
index 000000000..39447bb70
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/ChefAdapterImpl.java
@@ -0,0 +1,470 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.chef.ChefAdapter;
+import org.openecomp.appc.adapter.chef.chefapi.*;
+import org.openecomp.appc.adapter.chef.chefclient.*;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.pool.Pool;
+import org.openecomp.appc.pool.PoolExtensionException;
+import org.openecomp.appc.util.StructuredPropertyHelper;
+import org.openecomp.appc.util.StructuredPropertyHelper.Node;
+import com.att.cdp.exceptions.ContextConnectionException;
+import com.att.cdp.exceptions.ResourceNotFoundException;
+import com.att.cdp.exceptions.TimeoutException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.pal.util.StringHelper;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ImageService;
+import com.att.cdp.zones.Provider;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.ServerBootSource;
+import com.att.cdp.zones.model.Server.Status;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.slf4j.MDC;
+
+import java.net.InetAddress;
+import java.util.Locale;
+import java.util.UUID;
+
+import org.apache.http.*;
+import org.apache.http.client.*;
+import org.apache.http.client.methods.*;
+import org.apache.http.impl.client.*;
+import org.apache.http.util.EntityUtils;
+
+import static com.att.eelf.configuration.Configuration.*;
+
+import java.io.IOException;
+
+import java.net.InetAddress;
+/**
+ * This class implements the {@link ChefAdapter} interface. This interface
+ * defines the behaviors that our service provides.
+ */
+public class ChefAdapterImpl implements ChefAdapter {
+
+ /**
+ * The constant used to define the adapter name in the mapped diagnostic
+ * context
+ */
+
+ //chef server Initialize variable
+ public String clientName="";
+ public String clientPrivatekey="";
+ public String chefserver="";
+ public String serverAddress="";
+ public String organizations="";
+ @SuppressWarnings("nls")
+ public static final String MDC_ADAPTER = "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";
+
+ /**
+ * A constant for the property token "provider" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER = "provider";
+
+ /**
+ * A constant for the property token "identity" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_IDENTITY = "identity";
+
+ /**
+ * A constant for the property token "name" used in the structured property
+ * specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_NAME = "name";
+
+ /**
+ * A constant for the property token "tenant" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT = "tenant";
+
+ /**
+ * A constant for the property token "tenant name" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT_NAME = "name";
+
+ /**
+ * A constant for the property token "password" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT_PASSWORD = "password"; // NOSONAR
+
+ /**
+ * A constant for the property token "userid" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT_USERID = "userid";
+
+ /**
+ * A constant for the property token "type" used in the structured property
+ * specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TYPE = "type";
+
+ /**
+ * The name of the service to restart a server
+ */
+ @SuppressWarnings("nls")
+ public static final String PING_SERVICE = "pingServer";
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(ChefAdapterImpl.class);
+
+ /**
+ * The constant for a left parenthesis
+ */
+ private static final char LPAREN = '(';
+
+ /**
+ * The constant for a new line control code
+ */
+ private static final char NL = '\n';
+
+ /**
+ * The constant for a single quote
+ */
+ private static final char QUOTE = '\'';
+
+ /**
+ * The constant for a right parenthesis
+ */
+ private static final char RPAREN = ')';
+
+ /**
+ * The constant for a space
+ */
+ private static final char SPACE = ' ';
+
+ /**
+ * A reference to the adapter configuration object.
+ */
+ private Configuration configuration;
+
+ /**
+ * A cache of providers that are predefined.
+ */
+ // private Map<String /* provider name */, ProviderCache> providerCache;
+
+ /**
+ * 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();
+
+ }
+ }
+
+ /**
+ * @param props
+ * not used
+ */
+ public ChefAdapterImpl(Properties props) {
+ initialize();
+
+ }
+
+ public ChefAdapterImpl(String key) {
+ initialize(key);
+
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.openecomp.appc.adapter.chef.ChefAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
+ }
+
+ private void X__________________________________X() {
+ }
+
+ /**
+ * @see org.openecomp.appc.adapter.chef.ChefAdapter#evacuateServer(java.util.Map,
+ * org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+
+ private void X___________________________________X() {
+ }
+
+ /**
+ * @see org.openecomp.appc.adapter.chef.ProviderAdapter#rebuildServer(java.util.Map,
+ * org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+
+ /**
+ * Send GET request to chef server
+ */
+
+ @SuppressWarnings("nls")
+ @Override
+ public void chefGet(Map<String, String> params, SvcLogicContext ctx) {
+ logger.info("chef get method");
+ String chefAction= params.get("org.openecomp.appc.instance.chefAction");
+ // logger.info(vm_url);
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ //should load pem from somewhere else
+ ChefApiClient cac = new ChefApiClient(clientName,clientPrivatekey,chefserver,organizations);
+ // need pass path into it
+ //"/nodes"
+ ApiMethod am = cac.get(chefAction);
+ am.execute();
+ int code = am.getReturnCode();
+ String message = am.getResponseBodyAsString();
+ logger.info(code + " " + message);
+ chefServerResult(rc,Integer.toString(code),message);
+/* if (code == 200) {
+ doSuccess(rc);
+ } else {
+ String errorcode=code+" ";
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, errorcode);
+ }*/
+
+ }
+
+ /**
+ * Send PUT request to chef server
+ */
+
+ @SuppressWarnings("nls")
+ @Override
+ public void chefPut(Map<String, String> params, SvcLogicContext ctx) {
+
+ //String tVmIp = params.get("org.openecomp.appc.instance.ip");
+ //logger.info(tVmIp);
+ logger.info("chef PUT method");
+ logger.info(clientName+" "+clientPrivatekey+" "+chefserver+" "+organizations);
+ //String CHEF_NODE_STR= params.get("org.openecomp.appc.instance.chefRequestBody");
+ String chefAction= params.get("org.openecomp.appc.instance.chefAction");
+ String runList= params.get("org.openecomp.appc.instance.runList");
+ String attributes= params.get("org.openecomp.appc.instance.attributes");
+ logger.info(attributes);
+ //attributes="\"reconfig-test\":{\"secret\":\"newpass2\"}";
+ String CHEF_NODE_STR = "{\"json_class\":\"Chef::Node\",\"default\":{},\"chef_type\":\"node\",\"run_list\":[\""+runList+"\"],\"override\":{},\"automatic\":{},\"normal\":{"+attributes+"},\"name\":\"testnode\",\"chef_environment\":\"_default\"}";
+ //String CHEF_NODE_STR = "{\"json_class\":\"Chef::Node\"}";
+ // logger.info(vm_url);
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ //should load pem from somewhere else
+ ChefApiClient cac = new ChefApiClient(clientName,clientPrivatekey,chefserver,organizations);
+
+ // need pass path into it
+ //"/nodes/testnode"
+ ApiMethod am = cac.put(chefAction).body(CHEF_NODE_STR);
+ am.execute();
+ int code = am.getReturnCode();
+ String message = am.getResponseBodyAsString();
+ logger.info(code + " " + message);
+ chefServerResult(rc,Integer.toString(code),message);
+/* if (code == 200) {
+ logger.info("chef PUT method success");
+ doSuccess(rc);
+ } else {
+ String errorcode=code+" ";
+ logger.info("chef PUT method failure");
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, errorcode);
+ }*/
+
+ }
+
+
+
+ /**
+ * Trigger target vm run chef
+ */
+
+ @SuppressWarnings("nls")
+ @Override
+ public void trigger(Map<String, String> params, SvcLogicContext ctx) {
+ logger.info("Run trigger method");
+ String tVmIp = params.get("org.openecomp.appc.instance.ip");
+ //String tUrl = "http://" + tVmIp;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ try {
+ HttpGet httpGet = new HttpGet(tVmIp);
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpResponse response = null;
+ 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());
+ }
+ }
+
+
+
+
+ @SuppressWarnings("static-method")
+ 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) {
+ status = "500";
+ }
+ svcLogic.setAttribute("org.openecomp.appc.chefAgent.code", status);
+ svcLogic.setAttribute("org.openecomp.appc.chefAgent.message", msg);
+ }
+
+ /**
+ * @param rc
+ * The request context that manages the state and recovery of the
+ * request for the life of its processing.
+ */
+
+ @SuppressWarnings("static-method")
+ private void doSuccess(RequestContext rc) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setAttribute("org.openecomp.appc.chefAgent.code", "200");
+ }
+
+
+ @SuppressWarnings("static-method")
+ private void chefServerResult(RequestContext rc, String code ,String message) {
+ String msg = (message == null) ? " " : message;
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute("org.openecomp.appc.chefServerResult.code", code);
+ svcLogic.setAttribute("org.openecomp.appc.chefServerResult.message", message);
+ }
+
+ @SuppressWarnings("static-method")
+ private void chefClientResult(RequestContext rc, String code ,String message) {
+ String msg = (message == null) ? " " : message;
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute("org.openecomp.appc.chefClientResult.code", code);
+ svcLogic.setAttribute("org.openecomp.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="/etc/chef/client.pem";
+ serverAddress="http://example.com";
+ organizations="test";
+ chefserver=serverAddress+"/organizations/"+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/"+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
new file mode 100644
index 000000000..b651ad0cf
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestContext.java
@@ -0,0 +1,249 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef.impl;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.sdnc.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.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @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/impl/RequestFailedException.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestFailedException.java
new file mode 100644
index 000000000..047eb8b1f
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/openecomp/appc/adapter/chef/impl/RequestFailedException.java
@@ -0,0 +1,243 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.adapter.chef.impl;
+
+import org.glassfish.grizzly.http.util.HttpStatus;
+import com.att.cdp.zones.model.Server;
+
+/**
+ * This class is used to capture the exact cause and point of failure for the processing of a request. It is then used
+ * to encode the reason for the failure, status code, and anything else that needs to be captured and reported for
+ * diagnostic purposes.
+ */
+public class RequestFailedException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The operation that was being requested or performed at the time of the failure.
+ */
+ private String operation;
+
+ /**
+ * A message that details the reason for the failure
+ */
+ private String reason;
+
+ /**
+ * The server that was being operated upon
+ */
+ private Server server;
+
+ /**
+ * The id of the server being operated upon if the server object is not available (such as the server was not found)
+ */
+ private String serverId;
+
+ /**
+ * The most appropriate Http Status code that reflects the error
+ */
+ private HttpStatus status;
+
+ /**
+ *
+ */
+ public RequestFailedException() {
+ // intentionally empty
+ }
+
+ /**
+ * @param message
+ * The error message
+ */
+ public RequestFailedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the server we were processing.
+ *
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param server
+ * The server that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
+ super(operation + ":" + reason);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.server = server;
+ if (server != null) {
+ this.serverId = server.getId();
+ }
+ }
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the server we were processing.
+ *
+ * @param ex
+ * The exception that we are wrapping
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param server
+ * The server that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
+ super(operation + ":" + reason, ex);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.server = server;
+ if (server != null) {
+ this.serverId = server.getId();
+ }
+ }
+
+ /**
+ * @param message
+ * The error message
+ * @param cause
+ * A nested exception
+ */
+ public RequestFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ * The error message
+ * @param cause
+ * A nested exception
+ * @param enableSuppression
+ * whether or not suppression is enabled or disabled
+ * @param writableStackTrace
+ * whether or not the stack trace should be writable
+ */
+ public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ /**
+ * @param cause
+ * the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
+ * permitted, and indicates that the cause is nonexistent or unknown.)
+ */
+ public RequestFailedException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @return The operation being performed
+ */
+ public String getOperation() {
+ return operation;
+ }
+
+ /**
+ * @return The reason for the failure
+ */
+ public String getReason() {
+ return reason;
+ }
+
+ /**
+ * @return The server being operated upon
+ */
+ public Server getServer() {
+ return server;
+ }
+
+ /**
+ * @return The id of the server being operated upon
+ */
+ public String getServerId() {
+ return serverId;
+ }
+
+ /**
+ * @return The status code from the operation
+ */
+ public HttpStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @param operation
+ * The operation being performed
+ */
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ /**
+ * @param reason
+ * The reason for the failure
+ */
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ /**
+ * @param server
+ * The server being operated upon
+ */
+ public void setServer(Server server) {
+ this.server = server;
+ if (server != null) {
+ setServerId(server.getId());
+ }
+ }
+
+ /**
+ * @param serverId
+ * The id of the server being operated upon
+ */
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ /**
+ * @param status
+ * The status of the request
+ */
+ public void setStatus(HttpStatus status) {
+ this.status = status;
+ }
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/client.pem b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/client.pem
new file mode 100644
index 000000000..1a7b1bc69
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/client.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpQIBAAKCAQEAr3R64/1Z99kPfW9WV88/Pwxf/23ySf2ud1N1tmIj1gZXzzLa
+km92IB+MKuKwHYsB3vUVt7FXYLKC3iac4f/QsNy2ViTdvhBNcHhcDOL/xeaVmBUy
+V5X5/XqYJnlY+A2C4MQ97lgiaBVg7sE7s7nfO2J57mOLRInSPXFRoBlWIiaLWA6A
+TEnQBBf1gjdYo2O2iHmDJG4fpMCrhpuyoIbXs56czzAxu8ky5AAF+Z4AiZOWs2P9
+bVaG5ekLIuD0iXBzWF/oNlJ8LDxrdPLMwoMrqQ+P2fZpKROx11bXYp2InLIRoYKU
+g9oZbKcnLtKYUmcgD0GfOiC9XgbZ98EaaeSRdwIDAQABAoIBAGq8pKogDWRvAzJe
+0hsXNDWp1JiyjSwgDMwA1OKAL6bbMv4UxM1Cy4zdREsuns9KKng1huG6HBryXhTB
+Tr1Z/94oVzBuuwsOJd4fCni4e7sr/KOJeZe44F0pAHifZ9V3esA8AiUGLuA86Tw2
+B5jdoYUh8mVo32dxpJnGX07TOwgIgqlIxDUcDt0b7hYyTZpRJyf2y3tCfvzD7IiU
+XCHe7dg99gaJivrAOSZXRc8N+7oTWfjhfjIlZAUuzZgwQtzMVkNhV1ezXtdRIyBa
+yiYhDD4Ksh4UXRHDoxYLor4mpMOVCqozs3WEW6ZSWG/n1lGSPH/PQvDLM+bNGNzz
+PHkCicECgYEA3dGTZN1Dd4MaJHGp/D4lGUW8g9HO+WRMp8zXa/6pzhGWaD9SnN9v
+7fxxkypCaLBYXDIWO4DAMtLJBgmbu2azRtMFdsjks6f8utTxweCFRyMy1Bv71X2h
+/+AlflTgnnV3uUGNaUa69dnMwIqvgyd9puU/Tfw8XGUWG0Z5hl7h9yECgYEAyn3s
+4neVEpCgxK18bhGPljw/NoR+c7NWu5UIXcj3k9t5z5ToqS5wtOCRUVXG5XjU+tHg
+1KgYxULLwhhnjLfFDvxqIACK+ei+lFf5N+1EDYiPOV74XfahPMiq818ihYV7wtV8
+YPFeFU7kmwJr8nPymN1KyWRGric12aQpKmPLLZcCgYEAlmxYEw+FgBd08//ssXUH
+PYMwGwh93lvpK+XatI7HYkpFAD7o7B8NzYrjDlSbIllsImGI+CMQs6aD0kdTx5sW
+ulHCI9KKXVbvKVfc9ogmeZ5iCrtLZXTEFjxP0MMIbAzm+sd8eUcQ5EYl9vBVo5B1
+Qme2LVF/MX0Pp8F8CeZwQGECgYEAonVNbJTMgUyP77vQrO5h6QMFJFRAr8setvjm
+8XefSn03yZeK4tFjk3rom/zZypmbJnDklTkYRotEtsCls3xtGYziCDLnTYGyBYpf
+ZMNzafg6EKllUt3glsfYf9G//KgPl014sL514Vqehs72lFr6NDK3IcTWADttNORE
+MsJF7JkCgYEAukPXhEO+0BBHNf/tBS4DhzVUn9t4js7vLsui+OpYTXkvnwLV/JRV
+uyFRaqwrnuZn9gSdy77fSt49XlQHO4YTUz3+zeqrnpun58pR6lCmlAIRgJF8Ge98
+gHku/iQZjjeahwRkR6s5fNoZboYipkq4iNXWdTTy3uuLTK3Vy9MgG4M=
+-----END RSA PRIVATE KEY-----
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
new file mode 100644
index 000000000..3d4f9b373
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,93 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# 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.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.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.openecomp.appc.provider.min.pool=1
+org.openecomp.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.openecomp.appc.provider.retry.delay = 30
+org.openecomp.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.openecomp.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.openecomp.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/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
new file mode 100644
index 000000000..da11eba4f
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/TestChefAdapterImpl.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.chef.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.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.chef.ChefAdapter;
+import org.openecomp.appc.adapter.chef.impl.ChefAdapterImpl;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ContextFactory;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Server.Status;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.slf4j.MDC;
+
+@Ignore
+public class TestChefAdapterImpl {
+
+
+ private ChefAdapterImpl adapter;
+
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+
+ }
+
+ @Before
+ public void setup() throws IllegalArgumentException, IllegalAccessException {
+
+ adapter = new ChefAdapterImpl(System.getProperty("user.dir")+"/src/main/resources/client.pem");
+ }
+
+ @Test
+ public void testChefGet() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.chefAction", "/nodes");
+
+
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.chefGet(params, svcContext);
+ String status=svcContext.getAttribute("org.openecomp.appc.chefServerResult.code");
+ assertEquals("200",status);
+
+ }
+
+ @Test
+ public void testChefPut() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.chefAction", "/nodes/testnode");
+ params.put("org.openecomp.appc.instance.runList", "recipe[commandtest]");
+ params.put("org.openecomp.appc.instance.attributes", "");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.chefPut(params, svcContext);
+ String status=svcContext.getAttribute("org.openecomp.appc.chefServerResult.code");
+ assertEquals("200",status);
+
+ }
+
+ @Test
+ public void testTrigger() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.ip", "http://example.com/test");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.trigger(params, svcContext);
+ String status=svcContext.getAttribute("org.openecomp.appc.chefAgent.code");
+ assertEquals("200",status);
+
+ }
+
+
+}
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/client.pem b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/client.pem
new file mode 100644
index 000000000..1a7b1bc69
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/adapter/chef/impl/client.pem
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpQIBAAKCAQEAr3R64/1Z99kPfW9WV88/Pwxf/23ySf2ud1N1tmIj1gZXzzLa
+km92IB+MKuKwHYsB3vUVt7FXYLKC3iac4f/QsNy2ViTdvhBNcHhcDOL/xeaVmBUy
+V5X5/XqYJnlY+A2C4MQ97lgiaBVg7sE7s7nfO2J57mOLRInSPXFRoBlWIiaLWA6A
+TEnQBBf1gjdYo2O2iHmDJG4fpMCrhpuyoIbXs56czzAxu8ky5AAF+Z4AiZOWs2P9
+bVaG5ekLIuD0iXBzWF/oNlJ8LDxrdPLMwoMrqQ+P2fZpKROx11bXYp2InLIRoYKU
+g9oZbKcnLtKYUmcgD0GfOiC9XgbZ98EaaeSRdwIDAQABAoIBAGq8pKogDWRvAzJe
+0hsXNDWp1JiyjSwgDMwA1OKAL6bbMv4UxM1Cy4zdREsuns9KKng1huG6HBryXhTB
+Tr1Z/94oVzBuuwsOJd4fCni4e7sr/KOJeZe44F0pAHifZ9V3esA8AiUGLuA86Tw2
+B5jdoYUh8mVo32dxpJnGX07TOwgIgqlIxDUcDt0b7hYyTZpRJyf2y3tCfvzD7IiU
+XCHe7dg99gaJivrAOSZXRc8N+7oTWfjhfjIlZAUuzZgwQtzMVkNhV1ezXtdRIyBa
+yiYhDD4Ksh4UXRHDoxYLor4mpMOVCqozs3WEW6ZSWG/n1lGSPH/PQvDLM+bNGNzz
+PHkCicECgYEA3dGTZN1Dd4MaJHGp/D4lGUW8g9HO+WRMp8zXa/6pzhGWaD9SnN9v
+7fxxkypCaLBYXDIWO4DAMtLJBgmbu2azRtMFdsjks6f8utTxweCFRyMy1Bv71X2h
+/+AlflTgnnV3uUGNaUa69dnMwIqvgyd9puU/Tfw8XGUWG0Z5hl7h9yECgYEAyn3s
+4neVEpCgxK18bhGPljw/NoR+c7NWu5UIXcj3k9t5z5ToqS5wtOCRUVXG5XjU+tHg
+1KgYxULLwhhnjLfFDvxqIACK+ei+lFf5N+1EDYiPOV74XfahPMiq818ihYV7wtV8
+YPFeFU7kmwJr8nPymN1KyWRGric12aQpKmPLLZcCgYEAlmxYEw+FgBd08//ssXUH
+PYMwGwh93lvpK+XatI7HYkpFAD7o7B8NzYrjDlSbIllsImGI+CMQs6aD0kdTx5sW
+ulHCI9KKXVbvKVfc9ogmeZ5iCrtLZXTEFjxP0MMIbAzm+sd8eUcQ5EYl9vBVo5B1
+Qme2LVF/MX0Pp8F8CeZwQGECgYEAonVNbJTMgUyP77vQrO5h6QMFJFRAr8setvjm
+8XefSn03yZeK4tFjk3rom/zZypmbJnDklTkYRotEtsCls3xtGYziCDLnTYGyBYpf
+ZMNzafg6EKllUt3glsfYf9G//KgPl014sL514Vqehs72lFr6NDK3IcTWADttNORE
+MsJF7JkCgYEAukPXhEO+0BBHNf/tBS4DhzVUn9t4js7vLsui+OpYTXkvnwLV/JRV
+uyFRaqwrnuZn9gSdy77fSt49XlQHO4YTUz3+zeqrnpun58pR6lCmlAIRgJF8Ge98
+gHku/iQZjjeahwRkR6s5fNoZboYipkq4iNXWdTTy3uuLTK3Vy9MgG4M=
+-----END RSA PRIVATE KEY-----
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
new file mode 100644
index 000000000..fba794670
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
@@ -0,0 +1,179 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.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.openecomp.appc.test.InterceptLogger;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.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<String, Method> 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:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>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</li>
+ * </ul>
+ * @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:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>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</li>
+ * </ul>
+ * @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<String> getExecMethodNames() {
+ List<String> 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
new file mode 100644
index 000000000..912ea5ceb
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
@@ -0,0 +1,451 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.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<LogRecord> events;
+
+ /**
+ * Create the intercept logger
+ */
+ public InterceptLogger() {
+ events = new ArrayList<LogRecord>(1000);
+ }
+
+ /**
+ * @return Returns all intercepted log events
+ */
+ public List<LogRecord> 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/openecomp/appc/default.properties b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..5e55d6c59
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,108 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# 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.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.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.openecomp.appc.provider.min.pool=1
+org.openecomp.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.openecomp.appc.provider.retry.delay = 30
+org.openecomp.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.openecomp.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.openecomp.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-features/.gitignore b/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/.gitignore
new file mode 100644
index 000000000..615a76bbc
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/bin/
+/classes/
+/.settings/
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/pom.xml b/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/pom.xml
new file mode 100644
index 000000000..62033e256
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-chef-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-chef-adapter-features</artifactId>
+ <name>Chef Adaptor - Features</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-chef-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <type>zip</type>
+ </dependency>
+
+<!-- <dependency> -->
+<!-- Required for launching the feature tests -->
+<!-- <groupId>org.opendaylight.yangtools</groupId> -->
+<!-- <artifactId>features-test</artifactId> -->
+<!-- <scope>test</scope> -->
+<!-- </dependency> -->
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- launches the feature test, which validates that your karaf feature
+ can be installed inside of a karaf container. It doesn't validate that your
+ functionality works correctly, just that you have all of the dependent bundles
+ defined correctly. -->
+ <!-- <plugin> -->
+ <!-- <groupId>org.apache.maven.plugins</groupId> -->
+ <!-- <artifactId>maven-surefire-plugin</artifactId> -->
+ <!-- <version>2.16</version> -->
+ <!-- <configuration> -->
+ <!-- <systemPropertyVariables> -->
+ <!-- <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId> -->
+ <!-- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId> -->
+ <!-- <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version> -->
+ <!-- </systemPropertyVariables> -->
+ <!-- <dependenciesToScan> -->
+ <!-- <dependency>org.opendaylight.yangtools:features-test</dependency> -->
+ <!-- </dependenciesToScan> -->
+ <!-- </configuration> -->
+ <!-- </plugin> -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/src/main/resources/features.xml b/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/src/main/resources/features.xml
new file mode 100644
index 000000000..6ae5fc736
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-chef-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+<!-- <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features</repository> -->
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${features-mdsal.version}/xml/features</repository>
+
+ <feature name='appc-chef-adapter' description="appc-chef-adapter" version='${project.version}'>
+ <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
+ <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature>
+ <feature>sdnc-sli</feature>
+ <bundle>mvn:org.openecomp.appc/appc-chef-adapter-bundle/${project.version}</bundle>
+ </feature>
+
+</features>
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/.gitignore b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/.gitignore
new file mode 100644
index 000000000..731eb433c
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/.gitignore
@@ -0,0 +1,2 @@
+/target/
+/.settings/
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/pom.xml b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/pom.xml
new file mode 100644
index 000000000..ccecd4f99
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-chef-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-chef-adapter-installer</artifactId>
+ <name>Chef Adapter - Karaf Installer</name>
+ <packaging>pom</packaging>
+ <properties>
+ <application.name>appc-chef-adapter</application.name>
+ <features.boot>appc-chef-adapter</features.boot>
+ <features.repositories>mvn:org.openecomp.appc/appc-chef-adapter-features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-chef-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-chef-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <excludeGroupIds>org.opendaylight</excludeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_installer_zip.xml b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 000000000..9fbaad8c5
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 000000000..1ac5a82bc
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/main/resources/scripts/install-feature.sh b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 000000000..1d769fada
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/appc-adapters/appc-chef-adapter/pom.xml b/appc-adapters/appc-chef-adapter/pom.xml
new file mode 100644
index 000000000..d8e58e7d8
--- /dev/null
+++ b/appc-adapters/appc-chef-adapter/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-adapters</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-chef-adapter</artifactId>
+ <name>chef Adaptor</name>
+ <description>Abstraction to connect to and utilize the services of cloud providers such as OpenStack or VMWare.</description>
+ <packaging>pom</packaging>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.3</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc-no-fork</report>
+ <report>test-javadoc-no-fork</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>dual-report</id>
+ <configuration>
+ <type>range</type>
+ <range>30</range>
+ </configuration>
+ <reports>
+ <report>changelog</report>
+ <report>file-activity</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-chef-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-chef-adapter-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <modules>
+ <module>appc-chef-adapter-bundle</module>
+ <module>appc-chef-adapter-features</module>
+ <module>appc-chef-adapter-installer</module>
+ </modules>
+</project>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml
new file mode 100644
index 000000000..8f0a2ec2f
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/pom.xml
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <packaging>bundle</packaging>
+ <name>DMaaP Adapter - bundle</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-metric-bundle</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <classifier>jar-with-dependencies</classifier>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.objenesis</groupId>
+ <artifactId>objenesis</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>1.6.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-simple</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- DMaaP Client -->
+<!-- <dependency> -->
+<!-- <groupId>com.att.nsa</groupId> -->
+<!-- <artifactId>dmaapClient</artifactId> -->
+<!-- <version>${dmaap.client.version}</version> -->
+<!-- </dependency> -->
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ </dependencies>
+
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.openecomp.appc.adapter.dmaap</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.adapter.dmaap.AppcDmaapAdapterActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.adapter.dmaap.*</Export-Package>
+ <Export-Serice>org.openecomp.appc.adapter.dmaap.EventSender</Export-Serice>
+ <Import-Package>org.openecomp.appc.metricservice.*,com.att.nsa.*,org.openecomp.sdnc.sli.*,org.osgi.framework.*,!org.osgi.service.event.*,org.osgi.service.*,org.osgi.util.*,org.slf4j.*,com.vmware.*,org.apache.xerces.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.*,javax.naming.*,javax.crypto.*, com.sun.jersey.spi.container.servlet,org.eclipse.jetty.servlets</Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!appc-metric-bundle|sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis|pax-*</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ <Bundle-Blueprint>OSGI-INF/blueprint/blueprint.xml</Bundle-Blueprint>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/AppcDmaapAdapterActivator.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/AppcDmaapAdapterActivator.java
new file mode 100644
index 000000000..98b8aa158
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/AppcDmaapAdapterActivator.java
@@ -0,0 +1,113 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+import org.openecomp.appc.configuration.ConfigurationFactory;
+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;
+
+import java.util.Properties;
+
+/**
+ * This activator is used to initialize and terminate the connection pool to one or more providers.
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * When the bundle is deactivated, the cache is torn down with all contexts being closed.
+ * </p>
+ */
+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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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());
+
+ /* if (registration == null) {
+ Properties properties = ConfigurationFactory.getConfiguration().getProperties();
+ registration = bundleContext.registerService(EventSender.class, new EventSenderImpl(properties), null);
+ }*/
+ }
+
+ /**
+ * 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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 {
+ /*if (this.registration != null) {
+ this.registration.unregister();
+ }*/
+ 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/dmaap/CallableConsumer.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CallableConsumer.java
new file mode 100644
index 000000000..7c282911d
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CallableConsumer.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+import java.util.List;
+import java.util.concurrent.Callable;
+
+public class CallableConsumer implements Callable<List<String>> {
+
+ 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<String> 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-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CommonHttpClient.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CommonHttpClient.java
new file mode 100644
index 000000000..654ec6f7f
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/CommonHttpClient.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+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/dmaap/Consumer.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Consumer.java
new file mode 100644
index 000000000..32034e5fb
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Consumer.java
@@ -0,0 +1,68 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+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<String> 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<String> 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);
+
+ // TODO - Implement once Cambria allows you to set outside of constructor
+ // public void setFilter(String filter);
+
+ /**
+ * Creates a dmaap client using a https connection
+ *
+ * @param yes
+ * True if https should be used, false otherwise
+ */
+ public void useHttps(boolean yes);
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapConsumer.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapConsumer.java
new file mode 100644
index 000000000..6e16d896b
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapConsumer.java
@@ -0,0 +1,163 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+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;
+
+public class DmaapConsumer extends CommonHttpClient implements Consumer {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(DmaapConsumer.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<String> urls;
+ private String filter;
+
+ private boolean useHttps = false;
+
+ public DmaapConsumer(Collection<String> hosts, String topicName, String consumerName, String consumerId) {
+ this(hosts, topicName, consumerName, consumerId, null);
+ }
+
+ public DmaapConsumer(Collection<String> hosts, String topicName, String consumerName, String consumerId,
+ String filter) {
+ this(hosts, topicName, consumerName, consumerId, filter, null, null);
+ }
+
+ public DmaapConsumer(Collection<String> hosts, String topicName, String consumerName, String consumerId,
+ String filter, String user, String password) {
+ urls = new ArrayList<String>();
+ 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<String> fetch(int waitMs, int limit) {
+ LOG.debug(String.format("Fetching up to %d records with %dms wait on %s", limit, waitMs, this.toString()));
+ List<String> out = new ArrayList<String>();
+ try {
+ List<NameValuePair> urlParams = new ArrayList<NameValuePair>();
+ 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<String> 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");
+ }
+ }
+
+ public void close(){
+ //not used yet
+ }
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapDestination.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapDestination.java
new file mode 100644
index 000000000..efbe194ba
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapDestination.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+public enum DmaapDestination {
+ DCAE
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapProducer.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapProducer.java
new file mode 100644
index 000000000..6845177b1
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/DmaapProducer.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+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;
+
+public class DmaapProducer extends CommonHttpClient implements Producer {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(DmaapProducer.class);
+
+ private static final String CONTENT_TYPE = "application/cambria";
+ private static final String URL_TEMPLATE = "%s/events/%s";
+
+ private List<String> hosts;
+ private Set<String> topics;
+
+ private boolean useHttps = false;
+
+ public DmaapProducer(Collection<String> urls, String topicName) {
+ hosts = new ArrayList<String>();
+ topics = new HashSet<String>();
+ topics.add(topicName);
+
+ for (String host : urls) {
+ hosts.add(formatHostString(host));
+ }
+ }
+
+ public DmaapProducer(Collection<String> urls, Set<String> topicNames) {
+ hosts = new ArrayList<String>();
+ 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.
+ *
+ * @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);
+ }
+
+ public void close(){
+ //not used yet
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/EventSender.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/EventSender.java
new file mode 100644
index 000000000..7d4a7c090
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/EventSender.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+import java.util.Map;
+
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+public interface EventSender extends SvcLogicJavaPlugin{
+ boolean sendEvent(DmaapDestination destination, EventMessage msg);
+ boolean sendEvent(DmaapDestination destination, Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Manager.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Manager.java
new file mode 100644
index 000000000..183e618ba
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Manager.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+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<String> getTopics();
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Producer.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Producer.java
new file mode 100644
index 000000000..f19c516be
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/Producer.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+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);
+
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventHeader.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventHeader.java
new file mode 100644
index 000000000..dd951fe37
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventHeader.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap.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-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventMessage.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventMessage.java
new file mode 100644
index 000000000..af5cff2f9
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventMessage.java
@@ -0,0 +1,99 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap.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": "<ECOMP_EVENT_ID>",
+ },
+ "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-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventStatus.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventStatus.java
new file mode 100644
index 000000000..f5d7a59d4
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/event/EventStatus.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap.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-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/impl/EventSenderImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/impl/EventSenderImpl.java
new file mode 100644
index 000000000..0f7d40f5b
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/dmaap/impl/EventSenderImpl.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap.impl;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.openecomp.appc.adapter.dmaap.EventSender;
+import org.openecomp.appc.adapter.dmaap.Producer;
+import org.openecomp.appc.adapter.dmaap.DmaapDestination;
+import org.openecomp.appc.adapter.dmaap.event.EventHeader;
+import org.openecomp.appc.adapter.dmaap.event.EventMessage;
+import org.openecomp.appc.adapter.dmaap.event.EventStatus;
+import org.openecomp.appc.adapter.dmaap.DmaapProducer;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+public class EventSenderImpl implements EventSender
+{
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(EventSenderImpl.class);
+ public static final String EVENT_TOPIC_WRITE = "event.topic.write";
+ public static final String EVENT_CLIENT_KEY = "event.client.key";
+ public static final String EVENT_CLIENT_SECRET = "event.client.secret";
+ public static final String EVENT_POOL_MEMBERS = "event.pool.members";
+
+ private static Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ private Map<String,Producer> producerMap = new ConcurrentHashMap<>();
+
+ public Map<String, Producer> getProducerMap() {
+ return producerMap;
+ }
+
+ public void setProducerMap(Map<String, Producer> producerMap) {
+ this.producerMap = producerMap;
+ }
+
+ public EventSenderImpl(){
+
+ }
+
+ public void initialize(){
+ Properties properties = configuration.getProperties();
+ String writeTopic;
+ String apiKey;
+ String apiSecret;
+ final List<String> pool = new ArrayList<>();
+
+ for(DmaapDestination destination:DmaapDestination.values()){
+ writeTopic = properties.getProperty(destination + "." + EVENT_TOPIC_WRITE);
+ apiKey = properties.getProperty(destination + "." + EVENT_CLIENT_KEY);
+ apiSecret = properties.getProperty(destination + "." + EVENT_CLIENT_SECRET);
+ 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("apiKey = %s, taken from property: %s", apiKey, destination + "." + EVENT_CLIENT_KEY));
+ Producer producer = new DmaapProducer(pool, writeTopic);
+
+ if (apiKey != null && apiSecret != null) {
+ producer.updateCredentials(apiKey, apiSecret);
+ }
+
+ 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(DmaapDestination 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(DmaapDestination destination,Map<String, String> 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 dmaapEventMessage = new EventMessage(
+ new EventHeader(eventTime, apiVer, eventId),
+ new EventStatus(code, reason));
+
+ return sendEvent(destination,dmaapEventMessage);
+ }
+}
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..a8caf666f
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+ <bean id="eventSenderBean" class="org.openecomp.appc.adapter.dmaap.impl.EventSenderImpl"
+ init-method="initialize" scope="singleton">
+ </bean>
+
+ <service id="eventSenderService" interface="org.openecomp.appc.adapter.dmaap.EventSender" ref="eventSenderBean" />
+
+</blueprint>
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
new file mode 100644
index 000000000..5ac029b85
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,25 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# ${user.home} usually goes to /root if instantiation uses the appc-docker approach
+
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.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/openecomp/appc/adapter/dmaap/TestAppcDmaapAdapterActivator.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/dmaap/TestAppcDmaapAdapterActivator.java
new file mode 100644
index 000000000..e97014198
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/java/org/openecomp/appc/adapter/dmaap/TestAppcDmaapAdapterActivator.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.dmaap;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.openecomp.appc.adapter.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/resources/DCAEResponse.txt b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt
new file mode 100644
index 000000000..0d7ea2afa
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt
@@ -0,0 +1,18 @@
+{
+"requestTime": "0000-00-00 14:31:19.653787",
+"policyVersion": "13",
+"VMName": "123",
+"from": "test",
+"msgOid": ".1.3.6.1.4.1.193.183.4.1.3.5.1.4",
+"trapID": "1234567",
+"requestClient": "test",
+"message": "Abnormal condition detected",
+"time": "123567890",
+"policyName": "RESTART",
+"trapIDOID": ".1.3.6.1.4.1.193.183.4.1.3.5.1.3",
+"request": "Restart",
+"OPS_CL_timer": "15",
+"nOID": ".1.3.6.1.4.1.193.183.4.2.0.4",
+"AgentAddress": "192.168.1.2",
+"vmOID": ".1.3.6.1.4.1.193.183.4.1.2.1",
+} \ No newline at end of file
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
new file mode 100644
index 000000000..3692c92aa
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,36 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+org.openecomp.appc.bootstrap.file=test.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+# Properties commented out below are provided in appc.properties
+#poolMembers=<DMAAP_IP>:3904
+#event.pool.members=<DMAAP_IP>: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/test.properties b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/test.properties
new file mode 100644
index 000000000..1cadceee8
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/test.properties
@@ -0,0 +1,35 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+# Properties commented out below are provided in appc.properties
+#poolMembers=<DMAAP_IP>:3904
+#event.pool.members=<DMAAP_IP>:3904
+
+topic.read=APPC-TEST2
+topic.read.timeout=5
+topic.write=APPC-TEST2
+event.topic.write=APPC-TEST2
+client.name=APPC-CLIENT-DMAAP-ADAPTER-TEST
+client.name.id=0
+#client.key=fakeKey
+#client.secret=fakeSecret
+#event.client.key=fakeKey
+#event.client.secret=fakeSecret
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/pom.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/pom.xml
new file mode 100644
index 000000000..042b96d16
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-dmaap-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dmaap-adapter-features</artifactId>
+ <name>DMaaP Adapter - Features</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+<!-- <dependency> -->
+<!-- <groupId>org.opendaylight.controller</groupId> -->
+<!-- <artifactId>opendaylight-karaf-empty</artifactId> -->
+<!-- <type>zip</type> -->
+<!-- </dependency> -->
+
+<!-- <dependency> -->
+ <!-- Required for launching the feature tests -->
+<!-- <groupId>org.opendaylight.yangtools</groupId> -->
+<!-- <artifactId>features-test</artifactId> -->
+<!-- <scope>test</scope> -->
+<!-- </dependency> -->
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- launches the feature test, which validates that your karaf feature
+ can be installed inside of a karaf container. It doesn't validate that your
+ functionality works correctly, just that you have all of the dependent bundles
+ defined correctly. -->
+ <!-- <plugin> -->
+ <!-- <groupId>org.apache.maven.plugins</groupId> -->
+ <!-- <artifactId>maven-surefire-plugin</artifactId> -->
+ <!-- <version>2.16</version> -->
+ <!-- <configuration> -->
+ <!-- <systemPropertyVariables> -->
+ <!-- <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId> -->
+ <!-- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId> -->
+ <!-- <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version> -->
+ <!-- </systemPropertyVariables> -->
+ <!-- <dependenciesToScan> -->
+ <!-- <dependency>org.opendaylight.yangtools:features-test</dependency> -->
+ <!-- </dependenciesToScan> -->
+ <!-- </configuration> -->
+ <!-- </plugin> -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/src/main/resources/features.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/src/main/resources/features.xml
new file mode 100644
index 000000000..33b9ee3a7
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-dmaap-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+<!-- <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features</repository> -->
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${features-mdsal.version}/xml/features</repository>
+
+ <feature name='appc-dmaap-adapter' description="appc-dmaap-adapter" version='${project.version}'>
+ <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
+<!-- <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature> -->
+ <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature>
+<!-- <feature version="${sdnctl.sli.version}">sdnc-sli</feature> -->
+ <bundle>mvn:org.openecomp.appc/appc-dmaap-adapter-bundle/${project.version}</bundle>
+
+ </feature>
+
+</features>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/.gitignore b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/.gitignore
new file mode 100644
index 000000000..731eb433c
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/.gitignore
@@ -0,0 +1,2 @@
+/target/
+/.settings/
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/pom.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/pom.xml
new file mode 100644
index 000000000..8faef202f
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-dmaap-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-dmaap-adapter-installer</artifactId>
+ <name>dMaaP Adapter - Karaf Installer</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>appc-dmaap-adapter</application.name>
+ <features.boot>appc-dmaap-adapter</features.boot>
+ <features.repositories>mvn:org.openecomp.appc/appc-dmaap-adapter-features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter-features</artifactId>
+ <version>${project.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <excludeGroupIds>org.opendaylight</excludeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_installer_zip.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 000000000..9fbaad8c5
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 000000000..1ac5a82bc
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/main/resources/scripts/install-feature.sh b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 000000000..1d769fada
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/appc-adapters/appc-dmaap-adapter/pom.xml b/appc-adapters/appc-dmaap-adapter/pom.xml
new file mode 100644
index 000000000..8979e354e
--- /dev/null
+++ b/appc-adapters/appc-dmaap-adapter/pom.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-adapters</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-dmaap-adapter</artifactId>
+ <name>DMaaP Adapter</name>
+ <description>Adapter to read and write messages on the Universal Event Broker (Cambria).</description>
+ <packaging>pom</packaging>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.3</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc-no-fork</report>
+ <report>test-javadoc-no-fork</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>dual-report</id>
+ <configuration>
+ <type>range</type>
+ <range>30</range>
+ </configuration>
+ <reports>
+ <report>changelog</report>
+ <report>file-activity</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <modules>
+ <module>appc-dmaap-adapter-bundle</module>
+ <module>appc-dmaap-adapter-features</module>
+ <module>appc-dmaap-adapter-installer</module>
+ </modules>
+</project>
diff --git a/appc-adapters/appc-iaas-adapter/.gitignore b/appc-adapters/appc-iaas-adapter/.gitignore
new file mode 100644
index 000000000..d027396de
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/.gitignore
@@ -0,0 +1 @@
+/.settings/
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/.gitignore b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/.gitignore
new file mode 100644
index 000000000..b33175423
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/.gitignore
@@ -0,0 +1,4 @@
+/bin/
+/target/
+/.settings/
+/build/
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml
new file mode 100644
index 000000000..967c34858
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/pom.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-iaas-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-iaas-adapter-bundle</artifactId>
+ <packaging>bundle</packaging>
+ <name>IaaS Adapter - bundle</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ <classifier>jar-with-dependencies</classifier>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-openstack</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ </dependency>
+
+ <!-- Jersey support needed for OpenStack connector and API version logic -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxp-api</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+
+ <!-- Needed to run test cases -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.12</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.31</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vmware</groupId>
+ <artifactId>vijava</artifactId>
+ <version>5.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${apache.httpcomponents.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-iaas-adapter</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.adapter.iaas.AppcProviderAdapterActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.adapter.iaas</Export-Package>
+ <Import-Package>org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.vmware.*,org.apache.xerces.*,javax.net.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.bind.*,javax.naming.*</Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>NonSlowTests</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludedGroups>org.openecomp.appc.adapter.iaas.impl.TestProviderAdapterImpl</excludedGroups>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java
new file mode 100644
index 000000000..fa60c67a9
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.iaas.impl.ProviderAdapterImpl;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.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.
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * When the bundle is deactivated, the cache is torn down with all contexts being closed.
+ * </p>
+ */
+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 Logger LOG = LoggerFactory.getLogger(AppcProviderAdapterActivator.class);
+ 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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");
+ adapter = new ProviderAdapterImpl(configuration.getProperties());
+ 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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/openecomp/appc/adapter/iaas/ProviderAdapter.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/ProviderAdapter.java
new file mode 100644
index 000000000..f7a8b30ed
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/ProviderAdapter.java
@@ -0,0 +1,294 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.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.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+/**
+ * This interface defines the operations that the provider adapter exposes.
+ * <p>
+ * 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.
+ * </p>
+ */
+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.openecomp.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.openecomp.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.openecomp.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.openecomp.appc.identity.url";
+ /**
+ * heat stack id to perform operation on stack
+ */
+ static final String PROPERTY_STACK_ID = "org.openecomp.appc.stack.id";
+
+ static final String PROPERTY_SNAPSHOT_ID = "snapshot.id";
+
+ static final String PROPERTY_INPUT_SNAPSHOT_ID = "org.openecomp.appc.snapshot.id";
+
+ static final String DG_OUTPUT_PARAM_NAMESPACE = "output.";
+
+ /**
+ * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to stop the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to start the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to rebuild the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to terminate the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ */
+ String getAdapterName();
+
+ Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ Server vmStatuschecker(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ Stack terminateStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ Stack snapshotStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ Stack restoreStack(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ /**
+ * This method is used to do the lookup of the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> 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 <code>Image</code> 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<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
new file mode 100644
index 000000000..e9391fcb8
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.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 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 serverUrl) {
+ IdentityURL obj = null;
+ if (serverUrl != null) {
+ Matcher matcher = pattern.matcher(serverUrl.trim());
+ if (matcher.matches()) {
+ obj = new IdentityURL();
+ obj.scheme = matcher.group(1);
+ obj.host = matcher.group(2);
+ obj.port = matcher.group(3);
+ obj.version = matcher.group(4);
+ }
+ }
+
+ return obj;
+ }
+
+ /**
+ * @return The URL scheme
+ */
+ public String getScheme() {
+ return scheme;
+ }
+
+ /**
+ * @return The URL host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * @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() {
+ return String.format("%s://%s:%s/%s", scheme, host, port, version);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderAdapterImpl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderAdapterImpl.java
new file mode 100644
index 000000000..b1bba0918
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderAdapterImpl.java
@@ -0,0 +1,2723 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import com.woorea.openstack.base.client.OpenStackBaseException;
+import com.woorea.openstack.heat.Heat;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.iaas.ProviderAdapter;
+import org.openecomp.appc.adapter.openstack.heat.SnapshotResource;
+import org.openecomp.appc.adapter.openstack.heat.StackResource;
+import org.openecomp.appc.adapter.openstack.heat.model.CreateSnapshotParams;
+import org.openecomp.appc.adapter.openstack.heat.model.Snapshot;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.pool.Pool;
+import org.openecomp.appc.pool.PoolExtensionException;
+import org.openecomp.appc.util.StructuredPropertyHelper;
+import org.openecomp.appc.util.StructuredPropertyHelper.Node;
+import com.att.cdp.exceptions.*;
+import com.att.cdp.openstack.OpenStackContext;
+import com.att.cdp.openstack.connectors.HeatConnector;
+import com.att.cdp.openstack.util.ExceptionMapper;
+import com.att.cdp.pal.util.StringHelper;
+import com.att.cdp.zones.*;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.ServerBootSource;
+import com.att.cdp.zones.model.Stack;
+import com.att.cdp.zones.model.Server.Status;
+import com.att.cdp.zones.spi.AbstractService;
+import com.att.cdp.zones.spi.RequestState;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.slf4j.MDC;
+
+import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME;
+
+import java.io.IOException;
+import java.net.URI;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Pattern;
+
+/**
+ * This class implements the {@link ProviderAdapter} interface. This interface defines the behaviors that our service
+ * provides.
+ */
+@SuppressWarnings("javadoc")
+public class ProviderAdapterImpl implements ProviderAdapter {
+
+ /**
+ * The name of the adapter
+ */
+ @SuppressWarnings("nls")
+ private static final String ADAPTER_NAME = "Appc IaaS Adapter";
+
+ /**
+ * The username and password to use for dynamically created connections
+ */
+ private static String DEFAULT_USER;
+ private static String DEFAULT_PASS;
+
+ /**
+ * The constant used to define the adapter name in the mapped diagnostic context
+ */
+ @SuppressWarnings("nls")
+ private static final String MDC_ADAPTER = "adapter";
+
+ /**
+ * The constant used to define the service name in the mapped diagnostic context
+ */
+ @SuppressWarnings("nls")
+ static final String MDC_SERVICE = "service";
+
+ /**
+ * The constant for the status code for a failed outcome
+ */
+ @SuppressWarnings("nls")
+ private static final String OUTCOME_FAILURE = "failure";
+
+ /**
+ * The constant for the status code for a successful outcome
+ */
+ @SuppressWarnings("nls")
+ private static final String OUTCOME_SUCCESS = "success";
+
+ /**
+ * A constant for the property token "provider" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER = "provider";
+
+ /**
+ * A constant for the property token "identity" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER_IDENTITY = "identity";
+
+ /**
+ * A constant for the property token "tenant" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER_TENANT = "tenant";
+
+ /**
+ * A constant for the property token "tenant name" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER_TENANT_NAME = "name";
+
+ /**
+ * A constant for the property token "password" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER_TENANT_PASSWORD = "password"; // NOSONAR
+
+ /**
+ * A constant for the property token "userid" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER_TENANT_USERID = "userid";
+
+ /**
+ * A constant for the property token "type" used in the structured property specifications
+ */
+ @SuppressWarnings("nls")
+ private static final String PROPERTY_PROVIDER_TYPE = "type";
+
+ /**
+ * The name of the service to evacuate a server
+ */
+ @SuppressWarnings("nls")
+ private static final String EVACUATE_SERVICE = "evacuateServer";
+
+ /**
+ * The name of the service to migrate a server
+ */
+ @SuppressWarnings("nls")
+ private static final String MIGRATE_SERVICE = "migrateServer";
+
+ /**
+ * The name of the service to rebuild a server
+ */
+ @SuppressWarnings("nls")
+ private static final String REBUILD_SERVICE = "rebuildServer";
+
+ /**
+ * The name of the service to restart a server
+ */
+ @SuppressWarnings("nls")
+ private static final String RESTART_SERVICE = "restartServer";
+
+ /**
+ * The name of the service to check status of a server
+ */
+ @SuppressWarnings("nls")
+ private static final String VMSTATUSCHECK_SERVICE = "vmStatuschecker";
+
+
+ /**
+ * The name of the service to restart a server
+ */
+ @SuppressWarnings("nls")
+ private static final String SNAPSHOT_SERVICE = "createSnapshot";
+
+ /**
+ * The name of the service to terminate a stack
+ */
+ @SuppressWarnings("nls")
+ private static final String TERMINATE_STACK = "terminateStack";
+
+ /**
+ * The name of the service to snapshot a stack
+ */
+ @SuppressWarnings("nls")
+ private static final String SNAPSHOT_STACK = "snapshotStack";
+
+ /**
+ * The name of a service to start a server
+ */
+ @SuppressWarnings("nls")
+ private static final String START_SERVICE = "startServer";
+
+ /**
+ * The name of the service to stop a server
+ */
+ @SuppressWarnings("nls")
+ private static final String STOP_SERVICE = "stopServer";
+
+ /**
+ * The name of the service to stop a server
+ */
+ @SuppressWarnings("nls")
+ private static final String TERMINATE_SERVICE = "terminateServer";
+
+ /**
+ * The name of the service to lookup a server
+ */
+ @SuppressWarnings("nls")
+ private static final String LOOKUP_SERVICE = "lookupServer";
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(ProviderAdapterImpl.class);
+
+ private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+ /**
+ * The constant for a left parenthesis
+ */
+ private static final char LPAREN = '(';
+
+ /**
+ * The constant for a new line control code
+ */
+ private static final char NL = '\n';
+
+ /**
+ * The constant for a single quote
+ */
+ private static final char QUOTE = '\'';
+
+ /**
+ * The constant for a right parenthesis
+ */
+ private static final char RPAREN = ')';
+
+ /**
+ * The constant for a space
+ */
+ private static final char SPACE = ' ';
+
+ /**
+ * A reference to the adapter configuration object.
+ */
+ private Configuration configuration;
+
+ /**
+ * A cache of providers that are predefined.
+ */
+ private Map<String /* provider name */, ProviderCache> providerCache;
+
+ /**
+ * A list of valid initial VM statuses for a migrate operations
+ */
+ private static final Collection<Status> migratableStatuses = Arrays.asList(Status.READY, Status.RUNNING, Status.SUSPENDED);
+
+ /**
+ * 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();
+
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public Image createSnapshot(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Image snapshot = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, SNAPSHOT_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:Snapshot");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.SNAPSHOTING_SERVER, appName);
+ String msg;
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ debugParameters(params);
+ debugContext(ctx);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ Server server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+
+ if (hasImageAccess(rc, context)) {
+ snapshot = createSnapshot(rc, server);
+ doSuccess(rc);
+ } else {
+ msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED, server.getName(), server.getId(),
+ "Accessing Image Service Failed");
+ logger.error(msg);
+ doFailure(rc, HttpStatus.FORBIDDEN_403, msg);
+ }
+ context.close();
+ }
+ } catch (ResourceNotFoundException e) {
+ msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ SNAPSHOT_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+ return snapshot;
+ }
+
+ private boolean validateVM(RequestContext rc, String appName, String vm_url, VMURL vm)
+ throws RequestFailedException {
+ String msg;
+ if (vm == null) {
+ msg = EELFResourceManager.format(Msg.INVALID_SELF_LINK_URL, appName, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ return true;
+ }
+ validateVMURL(vm);
+ return false;
+ }
+
+ private Image createSnapshot(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ImageService service = context.getImageService(); // Already checked access by this point
+
+ String snapshotName = generateSnapshotName(server.getName());
+
+ logger.info(String.format("Creating snapshot of server %s (%s) with name %s", server.getName(), server.getId(),
+ snapshotName));
+
+ // Request Snapshot
+ String msg;
+ while (rc.attempt()) {
+ try {
+ server.createSnapshot(snapshotName);
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Stop Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+
+ // Locate snapshot image
+ Image snapshot = null;
+ while (rc.attempt()) {
+ try {
+ snapshot = service.getImageByName(snapshotName);
+ if (snapshot != null) {
+ break;
+ }
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Stop Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+
+ // Wait for it to be ready
+ waitForStateChange(rc, snapshot, Image.Status.ACTIVE);
+
+ return snapshot;
+ }
+
+ private String generateSnapshotName(String server) {
+ SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
+ return String.format("Snapshot of %s at %s", server, df.format(new Date()));
+ }
+
+ /**
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#evacuateServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, EVACUATE_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:Evacuate");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.EVACUATING_SERVER, appName);
+ String msg;
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ String providerName = params.get(ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ debugParameters(params);
+ debugContext(ctx);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, providerName);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ evacuateServer(rc, server);
+ server.refreshStatus();
+ context.close();
+ doSuccess(rc);
+ }
+ } catch (ResourceNotFoundException e) {
+ msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ EVACUATE_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ /**
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#migrateServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, MIGRATE_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:Migrate");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.MIGRATING_SERVER, appName);
+ String msg;
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ debugParameters(params);
+ debugContext(ctx);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ migrateServer(rc, server);
+ server.refreshStatus();
+ context.close();
+ doSuccess(rc);
+ }
+ } catch (ResourceNotFoundException e) {
+ msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ MIGRATE_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ private void evacuateServer(RequestContext rc, @SuppressWarnings("unused") Server server) throws ZoneException, RequestFailedException {
+ doFailure(rc, HttpStatus.NOT_IMPLEMENTED_501, "The operation 'EVACUATE' is not yet implemented");
+ }
+
+ private void migrateServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ String msg;
+ Context ctx = server.getContext();
+ ComputeService service = ctx.getComputeService();
+
+ // Init status will equal final status
+ Status initialStatus = server.getStatus();
+
+ if (initialStatus == null) {
+ throw new ZoneException("Failed to determine server's starting status");
+ }
+
+ // We can only migrate certain statuses
+ if (!migratableStatuses.contains(initialStatus)) {
+ throw new ZoneException(String.format("Cannot migrate server that is in %s state. Must be in one of [%s]",
+ initialStatus, migratableStatuses));
+ }
+
+ boolean inConfirmPhase = false;
+ try {
+ while (rc.attempt()) {
+ try {
+ if (!inConfirmPhase) {
+ // Initial migrate request
+ service.migrateServer(server.getId());
+ // Wait for change to verify resize
+ waitForStateChange(rc, server, Status.READY);
+ inConfirmPhase = true;
+ }
+
+ // Verify resize
+ service.processResize(server);
+ // Wait for complete. will go back to init status
+ waitForStateChange(rc, server, initialStatus);
+ logger.info("Completed migrate request successfully");
+ return;
+ } catch (ContextConnectionException e) {
+ msg = getConnectionExceptionMessage(rc, ctx, e);
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ } catch (ZoneException e) {
+ String phase = inConfirmPhase ? "VERIFY MIGRATE" : "REQUEST MIGRATE";
+ msg = EELFResourceManager.format(Msg.MIGRATE_SERVER_FAILED, server.getName(), server.getId(), phase,
+ e.getMessage());
+ generateEvent(rc, false, msg);
+ logger.error(msg, e);
+ throw new RequestFailedException("Migrate Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+ }
+
+ }
+
+ /**
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#rebuildServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server rebuildServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, REBUILD_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:Rebuild");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.REBUILDING_SERVER, appName);
+ String msg;
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ debugParameters(params);
+ debugContext(ctx);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+
+ // Manually checking image service until new PAL release
+ if (hasImageAccess(rc, context)) {
+ rebuildServer(rc, server);
+ doSuccess(rc);
+ } else {
+ msg = EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED, server.getName(), server.getId(),
+ "Accessing Image Service Failed");
+ logger.error(msg);
+ doFailure(rc, HttpStatus.FORBIDDEN_403, msg);
+ }
+ context.close();
+ }
+ } catch (ResourceNotFoundException e) {
+ msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ STOP_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ /**
+ * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
+ * <p>
+ * The fully qualified URL contains enough information to locate the appropriate server. The URL is of the form
+ * <pre>
+ * [scheme]://[host[:port]] / [path] / [tenant_id] / servers / [vm_id]
+ * </pre> Where the various parts of the URL can be parsed and extracted and used to locate the appropriate service
+ * in the provider service catalog. This then allows us to open a context using the CDP abstraction, obtain the
+ * server by its UUID, and then perform the restart.
+ * </p>
+ *
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IllegalArgumentException
+ * if the expected argument(s) are not defined or are invalid
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#restartServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server restartServer(Map<String, String> params, SvcLogicContext ctx)
+ throws UnknownProviderException, IllegalArgumentException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, RESTART_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:Restart");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.RESTARTING_SERVER, appName);
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ debugParameters(params);
+ debugContext(ctx);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ restartServer(rc, server);
+ context.close();
+ doSuccess(rc);
+ }
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ RESTART_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ /* *********************************************************************************/
+ /* DEVEN PANCHAL: This method is used to check the status of the VM */
+ /**********************************************************************************/
+ public Server vmStatuschecker(Map<String, String> params, SvcLogicContext ctx) throws UnknownProviderException, IllegalArgumentException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, VMSTATUSCHECK_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter: vmstatuscheck");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ debugParameters(params);
+ debugContext(ctx);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+
+ String statusvm;
+ switch (server.getStatus()) {
+ case DELETED:
+ statusvm = "deleted";
+ break;
+
+ case RUNNING:
+ statusvm = "running";
+ break;
+
+ case ERROR:
+ statusvm = "error";
+ break;
+
+ case READY:
+ statusvm = "ready";
+ break;
+
+ case PAUSED:
+ statusvm = "paused";
+ break;
+
+ case SUSPENDED:
+ statusvm = "suspended";
+ break;
+
+ case PENDING:
+ statusvm = "pending";
+ break;
+
+ default:
+ statusvm = "default-unknown state-should never occur";
+ break;
+ }
+
+
+ String statusofVM = statusvm;
+ context.close();
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute("org.openecomp.statusofvm", statusofVM);
+ svcLogic.setAttribute(Constants.STATUS_OF_VM, statusofVM);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_CODE, Integer.toString(HttpStatus.OK_200.getStatusCode()));
+ }
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ RESTART_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ /* *********************************************************************************/
+
+
+ /**
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#startServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server startServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, START_SERVICE);
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.RESTARTING_SERVER, appName);
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ debugParameters(params);
+ debugContext(ctx);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ String providerName = params.get(ProviderAdapter.PROPERTY_PROVIDER_NAME);
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, providerName);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ stopServer(rc, server);
+ server.refreshStatus();
+ context.close();
+ doSuccess(rc);
+ }
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ START_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ /**
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#stopServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server stopServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, STOP_SERVICE);
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ logger.info(Msg.STOPPING_SERVER, appName);
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ debugParameters(params);
+ debugContext(ctx);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ ctx.setAttribute("STOP_STATUS", "SUCCESS");
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ if (server.getStatus().equals(Status.PENDING)) {
+ throw new RequestFailedException("Server is in pending Status");
+ }
+ stopServer(rc, server);
+ server.refreshStatus();
+ if (server.getStatus().equals(Status.ERROR)) {
+ throw new RequestFailedException("Server is in ERROR state after operation");
+ }
+ context.close();
+ doSuccess(rc);
+ }else{
+ ctx.setAttribute("STOP_STATUS", "SERVER_NOT_FOUND");
+ }
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ ctx.setAttribute("STOP_STATUS", "SERVER_NOT_FOUND");
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ STOP_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ ctx.setAttribute("STOP_STATUS", "ERROR");
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ logger.error(EELFResourceManager.format(Msg.STOP_SERVER_FAILED, appName, "n/a", "n/a", e.getMessage()));
+ ctx.setAttribute("STOP_STATUS", "ERROR");
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+
+ return server;
+ }
+
+ /**
+ * This method is used to validate that the parameters contain all required property names, and that the values are
+ * non-null and non-empty strings. We are still not ensured that the value is valid, but at least it exists.
+ *
+ * @param ctx
+ * The request context object that manages the request
+ * @param parameters
+ * The parameters to be checked
+ * @param propertyNames
+ * The list of property names that are required to be present.
+ * @throws RequestFailedException
+ * If the parameters are not valid
+ */
+ @SuppressWarnings({
+ "nls", "static-method"
+ })
+ private void validateParametersExist(@SuppressWarnings("unused") RequestContext ctx, Map<String, String> parameters, String... propertyNames)
+ throws RequestFailedException {
+ boolean success = true;
+ StringBuilder msg = new StringBuilder(EELFResourceManager.format(Msg.MISSING_REQUIRED_PROPERTIES, MDC.get(MDC_SERVICE)));
+ msg.append(NL);
+ for (String propertyName : propertyNames) {
+ String value = parameters.get(propertyName);
+ if (value == null || value.trim().length() == 0) {
+ success = false;
+ msg.append(QUOTE);
+ msg.append(propertyName);
+ msg.append(QUOTE);
+ msg.append(SPACE);
+ }
+ }
+
+ if (!success) {
+ logger.error(msg.toString());
+ throw new RequestFailedException("Check Parameters", msg.toString(), HttpStatus.BAD_REQUEST_400, (Server)null);
+ }
+ }
+
+ /**
+ * This method is used to create a diagnostic dump of the context for the log
+ *
+ * @param context
+ * The context to be dumped
+ */
+ @SuppressWarnings({
+ "nls", "static-method"
+ })
+ private void debugContext(SvcLogicContext context) {
+ Set<String> keys = context.getAttributeKeySet();
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("Service Logic Context: Status ");
+ builder.append(LPAREN);
+ builder.append(context.getStatus());
+ builder.append(RPAREN);
+ builder.append(", Attribute count ");
+ builder.append(LPAREN);
+ builder.append(keys == null ? "none" : Integer.toString(keys.size()));
+ builder.append(RPAREN);
+ if (keys != null && !keys.isEmpty()) {
+ builder.append(NL);
+ for (String key : keys) {
+ String value = context.getAttribute(key);
+ builder.append("Attribute ");
+ builder.append(LPAREN);
+ builder.append(key);
+ builder.append(RPAREN);
+ builder.append(", value ");
+ builder.append(LPAREN);
+ builder.append(value == null ? "" : value);
+ builder.append(RPAREN);
+ builder.append(NL);
+ }
+ }
+
+ logger.debug(builder.toString());
+ }
+
+ void validateVMURL(VMURL vm) throws RequestFailedException {
+ String name = "vm-id";
+ if (vm == null) {
+ throw new RequestFailedException(String.format("The value %s cannot be null.", name));
+ }
+
+ // Check that its a good uri
+ // This will probably never get hit bc of an earlier check while parsing
+ // the string to a VMURL
+ try {
+ //noinspection ResultOfMethodCallIgnored
+ URI.create(vm.toString());
+ } catch (Exception e) {
+ throw new RequestFailedException(
+ String.format("The value %s is not well formed [%s].", name, vm.toString()));
+ }
+
+ // Check the tenant and vmid segments
+ String patternRegex = "([0-9a-f]{8}(-)?[0-9a-f]{4}(-)?[0-9a-f]{4}(-)?[0-9a-f]{4}(-)?[0-9a-f]{12})";
+ Pattern pattern = Pattern.compile(patternRegex, Pattern.CASE_INSENSITIVE);
+
+ if (!pattern.matcher(vm.getTenantId()).matches()) {
+ throw new RequestFailedException(
+ String.format("The value %s has an invalid tenantId [%s].", name, vm.getTenantId()));
+ }
+ if (!pattern.matcher(vm.getServerId()).matches()) {
+ throw new RequestFailedException(
+ String.format("The value %s has an invalid serverId [%s].", name, vm.getServerId()));
+ }
+ }
+
+ @SuppressWarnings("unused")
+ private void validateIdentityURL(IdentityURL id) throws RequestFailedException {
+ String name = "identity-url";
+ if (id == null) {
+ throw new RequestFailedException(String.format("The value %s cannot be null.", name));
+ }
+
+ // Check that its a good uri
+ // This will probably never get hit bc of an earlier check while parsing
+ // the string to a VMURL
+ try {
+ //noinspection ResultOfMethodCallIgnored
+ URI.create(id.toString());
+ } catch (Exception e) {
+ throw new RequestFailedException(
+ String.format("The value %s is not well formed [%s].", name, id.toString()));
+ }
+ }
+
+ /**
+ * This method is used to dump the value of the parameters to the log for debugging purposes.
+ *
+ * @param parameters
+ * The parameters to be printed to the log
+ */
+ @SuppressWarnings("static-method")
+ private void debugParameters(Map<String, String> parameters) {
+ for (String key : parameters.keySet()) {
+ logger.debug(Msg.PROPERTY_VALUE, key, parameters.get(key));
+ }
+ }
+
+ /**
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param code
+ * @param message
+ */
+ @SuppressWarnings("static-method")
+ private void doFailure(RequestContext rc, HttpStatus code, String message) {
+ try {
+ doFailure(rc, code, message, null);
+ } catch (APPCException ignored) {/* never happens */}
+ }
+
+
+ private void doFailure(RequestContext rc, HttpStatus code, String message, Throwable cause) throws APPCException {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ String msg = (message == null) ? code.getReasonPhrase() : message;
+ if (msg.contains("\n")) {
+ msg = msg.substring(0, msg.indexOf("\n"));
+ }
+ String status;
+ try {
+ status = Integer.toString(code.getStatusCode());
+ } catch (Exception e) {
+ status = "500";
+ }
+ svcLogic.setStatus(OUTCOME_FAILURE);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_CODE, status);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ svcLogic.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, msg);
+
+ if (null != cause) throw new APPCException(cause);
+ }
+
+ /**
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ */
+ @SuppressWarnings("static-method")
+ private void doSuccess(RequestContext rc) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_CODE, Integer.toString(HttpStatus.OK_200.getStatusCode()));
+ }
+
+ /**
+ * Generates the event indicating what happened
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param success
+ * True if the event represents a successful outcome
+ * @param msg
+ * The detailed message
+ */
+ private void generateEvent(@SuppressWarnings("unused") RequestContext rc, @SuppressWarnings("unused") boolean success, @SuppressWarnings("unused") String msg) {
+ // indication to the DG to generate the event?
+ }
+
+ /**
+ * This method is a general helper method used to locate a server given its fully-qualified self-link URL on a
+ * supported provider, regardless of region(s), and to return an opened context that can be used to access that
+ * server.
+ *
+ * @param rc
+ * The request context that wraps and manages the state of the request
+ * @param selfLinkURL
+ * The fully-qualified self-link URL of the server
+ * @param providerName
+ * The name of the provider to be searched
+ * @return The context that can be used to access the server, or null if not found.
+ */
+ @SuppressWarnings("nls")
+ private Context getContext(RequestContext rc, String selfLinkURL, String providerName) {
+ VMURL vm = VMURL.parseURL(selfLinkURL);
+ IdentityURL ident = IdentityURL.parseURL(providerName);
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+
+ if (vm == null) {
+ String msg = EELFResourceManager.format(Msg.INVALID_SELF_LINK_URL, appName, selfLinkURL);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ return null;
+ }
+
+ /*
+ * Get the cache of tenants and contexts for the named provider, if one exists
+ */
+ ProviderCache cache = providerCache.get(providerName);
+
+ /*
+ * If one doesn't exist, try and create it. If we have enough information to create it successfully, add it to
+ * the cache and continue, otherwise fail the request.
+ */
+ if (cache == null) {
+ if (ident != null) {
+ cache = createProviderCache(vm, ident);
+ }
+ if (cache != null) {
+ providerCache.put(cache.getProviderName(), cache);
+ } else {
+ String msg =
+ EELFResourceManager.format(Msg.UNKNOWN_PROVIDER, providerName, providerCache.keySet().toString());
+ logger.error(msg);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ return null;
+ }
+ }
+
+ if (providerName == null) {
+ logger
+ .debug(String.format("Using the default provider cache [%s] since no valid identity url was passed in.",
+ cache.getIdentityURL()));
+ }
+
+ // get the tenant cache for the vm
+ String identityURL = cache.getIdentityURL();
+ TenantCache tenantCache = cache.getTenant(vm.getTenantId());
+
+ if(tenantCache == null){
+ //no tenantCache matching tenant, add tenant to the provider cache
+ tenantCache = cache.addTenant(vm.getTenantId(),null,DEFAULT_USER, DEFAULT_PASS);
+
+ if(tenantCache == null){
+ //tenant not found
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, selfLinkURL);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ return null;
+ }
+ }
+
+ //reserve the context
+ String tenantName = tenantCache.getTenantName();
+ String tenantId = tenantCache.getTenantId();
+ String region = tenantCache.determineRegion(vm);
+
+ if (region != null) {
+ Pool<Context> pool = tenantCache.getPools().get(region);
+
+ while (rc.attempt()) {
+ try {
+ Context context = pool.reserve();
+
+ /*
+ * Insert logic here to test the context for connectivity because we may have gotten one from
+ * the pool that was previously created.
+ */
+ if (context.isStale()) {
+ context.relogin();
+ }
+ return context;
+ } catch (PoolExtensionException e) {
+ String msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, providerName, identityURL,
+ tenantName, tenantId, e.getMessage(), Long.toString(rc.getRetryDelay()),
+ Integer.toString(rc.getAttempts()), Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ } catch (Exception e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e,
+ e.getClass().getSimpleName(), "find", selfLinkURL, tenantCache.getTenantName());
+
+ logger.error(msg, e);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ return null;
+ }
+ }
+
+ String msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, providerName, identityURL);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.BAD_GATEWAY_502, msg);
+ return null;
+ }
+
+
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, selfLinkURL);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ return null;
+ }
+
+ /**
+ * 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.
+ * <p>
+ * 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. <pre>
+ * provider1.type=OpenStackProvider1
+ * provider1.name=OpenStackProviderName1
+ * provider1.identity=http://192.168.1.2:5000/v2.0
+ * provider1.tenant1.name=MY-TENANT-NAME
+ * provider1.tenant1.userid=userid
+ * provider1.tenant1.password=userid@123
+ * provider1.tenant2.name=MY-TENANT-NAME
+ * provider1.tenant2.userid=userid
+ * provider1.tenant2.password=userid@123
+ * provider2.type=OpenStackProvider2
+ * provider2.name=OpenStackProviderName2
+ * provider2.identity=http://192.168.1.2:5000/v2.0
+ * provider2.tenant1.name=MY-TENANT-NAME
+ * provider2.tenant1.userid=userid
+ * provider2.tenant1.password=userid@123
+ * </pre>
+ * </p>
+ */
+ providerCache = new HashMap<>();
+ Properties properties = configuration.getProperties();
+ List<Node> providers = StructuredPropertyHelper.getStructuredProperties(properties, PROPERTY_PROVIDER);
+
+ for (Node provider : providers) {
+ ProviderCache cache = new ProviderCache();
+ List<Node> 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;
+ 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;
+ }
+ }
+
+ cache.addTenant(null, tenantName, userId, password);
+ }
+ }
+
+ /*
+ * 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();
+ }
+ }
+
+ /**
+ * This method is called to rebuild the provided server.
+ * <p>
+ * If the server was booted from a volume, then the request is failed immediately and no action is taken. Rebuilding
+ * a VM from a bootable volume, where the bootable volume itself is not rebuilt, serves no purpose.
+ * </p>
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * @throws ZoneException
+ * @throws RequestFailedException
+ */
+ @SuppressWarnings("nls")
+ private void rebuildServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+
+ ServerBootSource builtFrom = server.getBootSource();
+ String msg;
+
+ // Throw exception for non image/snap boot source
+ if (ServerBootSource.VOLUME.equals(builtFrom)) {
+ msg = String.format("Rebuilding is currently not supported for servers built from bootable volumes [%s]",
+ server.getId());
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.FORBIDDEN_403, server);
+ }
+ /*
+ * Pending is a bit of a special case. If we find the server is in a pending state, then the provider is in the
+ * process of changing state of the server. So, lets try to wait a little bit and see if the state settles down
+ * to one we can deal with. If not, then we have to fail the request.
+ */
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ if (server.getStatus().equals(Status.PENDING)) {
+ waitForStateChange(rc, server, Status.READY, Status.RUNNING, Status.ERROR, Status.SUSPENDED, Status.PAUSED);
+ }
+
+ /*
+ * Get the image to use. This is determined by the presence or absence of snapshot images. If any snapshots
+ * exist, then the latest snapshot is used, otherwise the image used to construct the VM is used.
+ */
+ List<Image> snapshots = server.getSnapshots();
+ String imageToUse;
+ if (snapshots != null && !snapshots.isEmpty()) {
+ imageToUse = snapshots.get(0).getId();
+ } else {
+ imageToUse = server.getImage();
+ ImageService imageService = server.getContext().getImageService();
+ try {
+ while (rc.attempt()) {
+ try {
+ /*
+ * We are just trying to make sure that the image exists. We arent interested in the details at
+ * this point.
+ */
+ imageService.getImage(imageToUse);
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(),
+ imageService.getURL(), context.getTenant().getName(), context.getTenant().getId(),
+ e.getMessage(), Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ } catch (ZoneException e) {
+ msg = EELFResourceManager.format(Msg.IMAGE_NOT_FOUND, imageToUse, "rebuild");
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+
+ /*
+ * We determine what to do based on the current state of the server
+ */
+ switch (server.getStatus()) {
+ case DELETED:
+ // Nothing to do, the server is gone
+ msg = EELFResourceManager.format(Msg.SERVER_DELETED, server.getName(), server.getId(),
+ server.getTenantId(), "rebuilt");
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+
+ case RUNNING:
+ // Attempt to stop the server, then rebuild it
+ stopServer(rc, server);
+ rebuildServer(rc, server, imageToUse);
+ startServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case ERROR:
+ msg = EELFResourceManager.format(Msg.SERVER_ERROR_STATE, server.getName(), server.getId(),
+ server.getTenantId(), "rebuild");
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+
+ case READY:
+ // Attempt to rebuild the server
+ rebuildServer(rc, server, imageToUse);
+ startServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case PAUSED:
+ // if paused, un-pause it, stop it, and rebuild it
+ unpauseServer(rc, server);
+ stopServer(rc, server);
+ rebuildServer(rc, server, imageToUse);
+ startServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case SUSPENDED:
+ // Attempt to resume the suspended server, stop it, and rebuild it
+ resumeServer(rc, server);
+ stopServer(rc, server);
+ rebuildServer(rc, server, imageToUse);
+ startServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ default:
+ // Hmmm, unknown status, should never occur
+ msg = EELFResourceManager.format(Msg.UNKNOWN_SERVER_STATE, server.getName(), server.getId(),
+ server.getTenantId(), server.getStatus().name());
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+ }
+ }
+
+ /**
+ * This method handles the case of restarting a server once we have found the server and have obtained the abstract
+ * representation of the server via the context (i.e., the "Server" object from the CDP-Zones abstraction).
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server object representing the server we want to operate on
+ * @throws ZoneException
+ */
+ @SuppressWarnings("nls")
+ private void restartServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ /*
+ * Pending is a bit of a special case. If we find the server is in a pending state, then the provider is in the
+ * process of changing state of the server. So, lets try to wait a little bit and see if the state settles down
+ * to one we can deal with. If not, then we have to fail the request.
+ */
+ String msg;
+ if (server.getStatus().equals(Status.PENDING)) {
+ waitForStateChange(rc, server, Status.READY, Status.RUNNING, Status.ERROR, Status.SUSPENDED, Status.PAUSED);
+ }
+
+ /*
+ * We determine what to do based on the current state of the server
+ */
+ switch (server.getStatus()) {
+ case DELETED:
+ // Nothing to do, the server is gone
+ msg = EELFResourceManager.format(Msg.SERVER_DELETED, server.getName(), server.getId(),
+ server.getTenantId(), "restarted");
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ break;
+
+ case RUNNING:
+ // Attempt to stop and start the server
+ stopServer(rc, server);
+ startServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case ERROR:
+ msg = EELFResourceManager.format(Msg.SERVER_ERROR_STATE, server.getName(), server.getId(),
+ server.getTenantId(), "rebuild");
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.METHOD_NOT_ALLOWED_405, server);
+
+ case READY:
+ // Attempt to start the server
+ startServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case PAUSED:
+ // if paused, un-pause it
+ unpauseServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case SUSPENDED:
+ // Attempt to resume the suspended server
+ resumeServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ default:
+ // Hmmm, unknown status, should never occur
+ msg = EELFResourceManager.format(Msg.UNKNOWN_SERVER_STATE, server.getName(), server.getId(),
+ server.getTenantId(), server.getStatus().name());
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ break;
+ }
+
+ }
+
+ /**
+ * Resume a suspended server and wait for it to enter a running state
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server to be resumed
+ * @throws ZoneException
+ * @throws RequestFailedException
+ */
+ @SuppressWarnings("nls")
+ private void resumeServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ logger.debug(Msg.RESUME_SERVER, server.getId());
+
+ Context context = server.getContext();
+ String msg;
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ while (rc.attempt()) {
+ try {
+ server.resume();
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Resume Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ waitForStateChange(rc, server, Status.RUNNING);
+ }
+
+ /**
+ * Start the server and wait for it to enter a running state
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server to be started
+ * @throws ZoneException
+ * @throws RequestFailedException
+ */
+ @SuppressWarnings("nls")
+ private void startServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ logger.debug(Msg.START_SERVER, server.getId());
+ String msg;
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ while (rc.attempt()) {
+ try {
+ server.start();
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Start Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ waitForStateChange(rc, server, Status.RUNNING);
+ }
+
+ /**
+ * Stop the specified server and wait for it to stop
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server to be stopped
+ * @throws ZoneException
+ * @throws RequestFailedException
+ */
+ @SuppressWarnings("nls")
+ private void stopServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ logger.debug(Msg.STOP_SERVER, server.getId());
+
+ String msg;
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ while (rc.attempt()) {
+ try {
+ server.stop();
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Stop Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ waitForStateChange(rc, server, Status.READY, Status.ERROR);
+ }
+
+ /**
+ * Un-Pause a paused server and wait for it to enter a running state
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server to be un-paused
+ * @throws ZoneException
+ * @throws RequestFailedException
+ */
+ @SuppressWarnings("nls")
+ private void unpauseServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ logger.debug(Msg.UNPAUSE_SERVER, server.getId());
+
+ String msg;
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ while (rc.attempt()) {
+ try {
+ server.unpause();
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Unpause Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ waitForStateChange(rc, server, Status.RUNNING, Status.READY);
+ }
+
+ /**
+ * Enter a pool-wait loop checking the server state to see if it has entered one of the desired states or not.
+ * <p>
+ * This method checks the state of the server periodically for one of the desired states. When the server enters one
+ * of the desired states, the method returns a successful indication (true). If the server never enters one of the
+ * desired states within the allocated timeout period, then the method returns a failed response (false). No
+ * exceptions are thrown from this method.
+ * </p>
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server to wait on
+ * @param desiredStates
+ * A variable list of desired states, any one of which is allowed.
+ * @throws RequestFailedException
+ * If the request times out or fails for some reason
+ */
+ @SuppressWarnings("nls")
+ private void waitForStateChange(RequestContext rc, Server server, Server.Status... desiredStates)
+ throws RequestFailedException {
+ int pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
+ int timeout = configuration.getIntegerProperty(Constants.PROPERTY_SERVER_STATE_CHANGE_TIMEOUT);
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ String msg;
+
+ long endTime = System.currentTimeMillis() + (timeout * 1000); //
+
+ while (rc.attempt()) {
+ try {
+ try {
+ server.waitForStateChange(pollInterval, timeout, desiredStates);
+ break;
+ } catch (TimeoutException e) {
+ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
+ List<String> list = new ArrayList<>();
+ for (Server.Status desiredState : desiredStates) {
+ list.add(desiredState.name());
+ }
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ } catch (ZoneException e) {
+ List<String> list = new ArrayList<>();
+ for (Server.Status desiredState : desiredStates) {
+ list.add(desiredState.name());
+ }
+ String reason = EELFResourceManager.format(Msg.STATE_CHANGE_EXCEPTION, e.getClass().getSimpleName(),
+ "server", server.getName(), server.getId(), StringHelper.asList(list), server.getStatus().name(),
+ e.getMessage());
+ logger.error(reason);
+ logger.error(EELFResourceManager.format(e));
+
+ // Instead of failing we are going to wait and try again.
+ // Timeout is reduced by delay time
+ logger.info(String.format("Retrying in %ds", rc.getRetryDelay()));
+ rc.delay();
+ timeout = (int) (endTime - System.currentTimeMillis()) / 1000;
+ // throw new RequestFailedException(e, operation, reason,
+ // HttpStatus.BAD_GATEWAY_502, server);
+ }
+ }
+
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Waiting for State Change", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ }
+
+ /**
+ * Enter a pool-wait loop checking the server state to see if it has entered one of the desired states or not.
+ * <p>
+ * This method checks the state of the server periodically for one of the desired states. When the server enters one
+ * of the desired states, the method returns a successful indication (true). If the server never enters one of the
+ * desired states within the allocated timeout period, then the method returns a failed response (false). No
+ * exceptions are thrown from this method.
+ * </p>
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param image
+ * The server to wait on
+ * @param desiredStates
+ * A variable list of desired states, any one of which is allowed.
+ * @throws RequestFailedException
+ * If the request times out or fails for some reason
+ * @throws NotLoggedInException
+ */
+ @SuppressWarnings("nls")
+ private void waitForStateChange(RequestContext rc, Image image, Image.Status... desiredStates)
+ throws RequestFailedException, NotLoggedInException {
+ int pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
+ int timeout = configuration.getIntegerProperty(Constants.PROPERTY_SERVER_STATE_CHANGE_TIMEOUT);
+ Context context = image.getContext();
+ Provider provider = context.getProvider();
+ ImageService service = context.getImageService();
+ String msg;
+
+ long endTime = System.currentTimeMillis() + (timeout * 1000); //
+
+ while (rc.attempt()) {
+ try {
+ try {
+ image.waitForStateChange(pollInterval, timeout, desiredStates);
+ break;
+ } catch (TimeoutException e) {
+ @SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
+ List<String> list = new ArrayList<>();
+ for (Image.Status desiredState : desiredStates) {
+ list.add(desiredState.name());
+ }
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ } catch (ZoneException e) {
+ List<String> list = new ArrayList<>();
+ for (Image.Status desiredState : desiredStates) {
+ list.add(desiredState.name());
+ }
+ String reason = EELFResourceManager.format(Msg.STATE_CHANGE_EXCEPTION, e.getClass().getSimpleName(),
+ "server", image.getName(), image.getId(), StringHelper.asList(list), image.getStatus().name(),
+ e.getMessage());
+ logger.error(reason);
+ logger.error(EELFResourceManager.format(e));
+
+ // Instead of failing we are going to wait and try again.
+ // Timeout is reduced by delay time
+ logger.info(String.format("Retrying in %ds", rc.getRetryDelay()));
+ rc.delay();
+ timeout = (int) (endTime - System.currentTimeMillis()) / 1000;
+ // throw new RequestFailedException(e, operation, reason,
+ // HttpStatus.BAD_GATEWAY_502, server);
+ }
+ }
+
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Waiting for State Change", msg, HttpStatus.BAD_GATEWAY_502, new Server());
+ }
+ rc.reset();
+ }
+
+ /**
+ * Rebuild the indicated server with the indicated image. This method assumes the server has been determined to be
+ * in the correct state to do the rebuild.
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * the server to be rebuilt
+ * @param image
+ * The image to be used (or snapshot)
+ * @throws RequestFailedException
+ * if the server does not change state in the allotted time
+ */
+ @SuppressWarnings("nls")
+ private void rebuildServer(RequestContext rc, Server server, String image) throws RequestFailedException {
+ String msg;
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+
+ try {
+ while (rc.attempt()) {
+ try {
+ server.rebuild(image);
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+
+ /*
+ * We need to provide some time for OpenStack to start processing the request.
+ */
+ try {
+ Thread.sleep(10L * 1000L);
+ } catch (InterruptedException e) {
+ logger.trace("Sleep threw interrupted exception, should never occur");
+ }
+ } catch (ZoneException e) {
+ msg =
+ EELFResourceManager.format(Msg.REBUILD_SERVER_FAILED, server.getName(), server.getId(), e.getMessage());
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+
+ /*
+ * Once we have started the process, now we wait for the final state of stopped. This should be the final state
+ * (since we started the rebuild with the server stopped).
+ */
+ waitForStateChange(rc, server, Status.READY);
+
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Rebuild Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ }
+
+ /**
+ * Looks up the indicated server using the provided context and returns the server to the caller
+ *
+ * @param rc
+ * The request context
+ * @param context
+ * The provider context
+ * @param id
+ * The id of the server
+ * @return The server, or null if there is a problem
+ * @throws ZoneException
+ * If the server cannot be found
+ * @throws RequestFailedException
+ * If the server cannot be found because we cant connect to the provider
+ */
+ @SuppressWarnings("nls")
+ private Server lookupServer(RequestContext rc, Context context, String id)
+ throws ZoneException, RequestFailedException {
+ ComputeService service = context.getComputeService();
+ Server server = null;
+ String msg;
+ Provider provider = context.getProvider();
+
+ while (rc.attempt()) {
+ try {
+ server = service.getServer(id);
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ doFailure(rc, HttpStatus.BAD_GATEWAY_502, msg);
+ throw new RequestFailedException("Lookup Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ return server;
+ }
+
+ private String getConnectionExceptionMessage(RequestContext rc, Context ctx, ContextConnectionException e)
+ throws ZoneException {
+ return EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, ctx.getProvider().getName(),
+ ctx.getComputeService().getURL(), ctx.getTenant().getName(), ctx.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ }
+
+ private ProviderCache createProviderCache(VMURL vm, IdentityURL ident) {
+ if (vm != null && ident != null) {
+ ProviderCache cache = new ProviderCache();
+
+ cache.setIdentityURL(ident.toString());
+ cache.setProviderName(ident.toString());
+ // cache.setProviderType("OpenStack");
+
+ TenantCache tenant = cache.addTenant(vm.getTenantId(),null, DEFAULT_USER, DEFAULT_PASS);
+
+ // Make sure we could initialize the the cache otherwise return null
+ if (tenant != null && tenant.isInitialized()) {
+ return cache;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * This method is used to delete an existing virtual machine given the fully qualified URL of the machine.
+ * <p>
+ * The fully qualified URL contains enough information to locate the appropriate server. The URL is of the form
+ * <pre>
+ * [scheme]://[host[:port]] / [path] / [tenant_id] / servers / [vm_id]
+ * </pre> Where the various parts of the URL can be parsed and extracted and used to locate the appropriate service
+ * in the provider service catalog. This then allows us to open a context using the CDP abstraction, obtain the
+ * server by its UUID, and then perform the restart.
+ * </p>
+ *
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IllegalArgumentException
+ * if the expected argument(s) are not defined or are invalid
+ * @see org.openecomp.appc.adapter.iaas.ProviderAdapter#terminateServer(java.util.Map, org.openecomp.sdnc.sli.SvcLogicContext)
+ */
+ @SuppressWarnings("nls")
+ @Override
+ public Server terminateServer(Map<String, String> params, SvcLogicContext ctx)
+ throws UnknownProviderException, IllegalArgumentException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, TERMINATE_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:Terminate");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Inside org.openecomp.appc.adapter.iaas.impl.ProviderAdapter.terminateServer");
+ }
+
+ try {
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ debugParameters(params);
+ debugContext(ctx);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ ctx.setAttribute("TERMINATE_STATUS", "SUCCESS");
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ Context context = null;
+ try {
+ context = getContext(rc, vm_url, identStr);
+ if (context != null) {
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ logger.info(EELFResourceManager.format(Msg.TERMINATING_SERVER, server.getName()));
+ terminateServer(rc, server);
+ logger.info(EELFResourceManager.format(Msg.TERMINATE_SERVER, server.getName()));
+ context.close();
+ doSuccess(rc);
+ }else{
+ ctx.setAttribute("TERMINATE_STATUS", "SERVER_NOT_FOUND");
+ }
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ ctx.setAttribute("TERMINATE_STATUS", "SERVER_NOT_FOUND");
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ RESTART_SERVICE, vm_url, context == null ? "Unknown" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ logger.error(EELFResourceManager.format(Msg.TERMINATE_SERVER_FAILED, appName, "n/a", "n/a", e.getMessage()));
+ doFailure(rc, e.getStatus(), e.getMessage());
+ ctx.setAttribute("TERMINATE_STATUS", "ERROR");
+ }
+
+ return server;
+ }
+
+ /**
+ * This method handles the case of restarting a server once we have found the server and have obtained the abstract
+ * representation of the server via the context (i.e., the "Server" object from the CDP-Zones abstraction).
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server object representing the server we want to operate on
+ * @throws ZoneException
+ */
+ @SuppressWarnings("nls")
+ private void terminateServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ /*
+ * Pending is a bit of a special case. If we find the server is in a pending state, then the provider is in the
+ * process of changing state of the server. So, lets try to wait a little bit and see if the state settles down
+ * to one we can deal with. If not, then we have to fail the request.
+ */
+ String msg;
+ if (server.getStatus().equals(Status.PENDING)) {
+ waitForStateChange(rc, server, Status.READY, Status.RUNNING, Status.ERROR, Status.SUSPENDED, Status.PAUSED);
+ }
+
+ /*
+ * We determine what to do based on the current state of the server
+ */
+ switch (server.getStatus()) {
+ case DELETED:
+ // Nothing to do, the server is gone
+ msg = EELFResourceManager.format(Msg.SERVER_DELETED, server.getName(), server.getId(),
+ server.getTenantId(), "restarted");
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ break;
+
+ case RUNNING:
+ // Attempt to stop and start the server
+ logger.info("stopping SERVER");
+ stopServer(rc, server);
+ deleteServer(rc, server);
+ logger.info("after delete SERVER");
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ case ERROR:
+
+ case READY:
+
+ case PAUSED:
+
+ case SUSPENDED:
+ // Attempt to delete the suspended server
+ deleteServer(rc, server);
+ generateEvent(rc, true, OUTCOME_SUCCESS);
+ break;
+
+ default:
+ // Hmmm, unknown status, should never occur
+ msg = EELFResourceManager.format(Msg.UNKNOWN_SERVER_STATE, server.getName(), server.getId(),
+ server.getTenantId(), server.getStatus().name());
+ generateEvent(rc, false, msg);
+ logger.error(msg);
+ break;
+ }
+
+ }
+
+ /**
+ * Start the server and wait for it to enter a running state
+ *
+ * @param rc
+ * The request context that manages the state and recovery of the request for the life of its processing.
+ * @param server
+ * The server to be started
+ * @throws ZoneException
+ * @throws RequestFailedException
+ */
+ @SuppressWarnings("nls")
+ private void deleteServer(RequestContext rc, Server server) throws ZoneException, RequestFailedException {
+ String msg;
+ Context context = server.getContext();
+ Provider provider = context.getProvider();
+ ComputeService service = context.getComputeService();
+ while (rc.attempt()) {
+ try {
+ logger.info("deleting SERVER");
+ server.delete();
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), service.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), service.getURL());
+ logger.error(msg);
+ throw new RequestFailedException("Delete Server", msg, HttpStatus.BAD_GATEWAY_502, server);
+ }
+ rc.reset();
+ }
+
+ private boolean hasImageAccess(@SuppressWarnings("unused") RequestContext rc, Context context) {
+ logger.info("Checking permissions for image service.");
+ try {
+ ImageService service = context.getImageService();
+ service.getImageByName("CHECK_IMAGE_ACCESS");
+ logger.info("Image service is accessible.");
+ return true;
+ } catch (ZoneException e) {
+ logger.warn("Image service could not be accessed. Some operations may fail.", e);
+ return false;
+ }
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public Stack terminateStack(Map<String, String> params, SvcLogicContext ctx) throws IllegalArgumentException, APPCException {
+ Stack stack = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ ctx.setAttribute("TERMINATE_STATUS", "STACK_NOT_FOUND");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+
+ try {
+
+ logAndValidate(params, ctx, rc, TERMINATE_STACK, "Terminate Stack",
+ ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME,
+ ProviderAdapter.PROPERTY_STACK_ID);
+
+ String stackId = params.get(ProviderAdapter.PROPERTY_STACK_ID);
+ String vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+
+ Context context = resolveContext(rc, params, appName, vm_url);
+
+ try {
+ if (context != null) {
+ stack = lookupStack(rc, context, stackId);
+ logger.debug(Msg.STACK_FOUND, vm_url, context.getTenantName(), stack.getStatus().toString());
+ logger.info(EELFResourceManager.format(Msg.TERMINATING_STACK, stack.getName()));
+ deleteStack(rc, stack);
+ logger.info(EELFResourceManager.format(Msg.TERMINATE_STACK, stack.getName()));
+ context.close();
+ doSuccess(rc);
+ }else{
+ ctx.setAttribute("TERMINATE_STATUS", "SERVER_NOT_FOUND");
+ }
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.STACK_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ TERMINATE_STACK, vm_url, context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+ } catch (RequestFailedException e) {
+ logger.error(EELFResourceManager.format(Msg.TERMINATE_STACK_FAILED, appName, "n/a", "n/a"));
+ doFailure(rc, e.getStatus(), e.getMessage());
+ }
+ return stack;
+ }
+
+ @Override
+ public Stack snapshotStack(Map<String, String> params, SvcLogicContext ctx) throws IllegalArgumentException, APPCException {
+ Stack stack = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ ctx.setAttribute("SNAPSHOT_STATUS", "STACK_NOT_FOUND");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+
+ String vm_url = null;
+ Context context = null;
+ try {
+
+ logAndValidate(params, ctx, rc, SNAPSHOT_STACK, "Snapshot Stack",
+ ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME,
+ ProviderAdapter.PROPERTY_STACK_ID);
+
+ String stackId = params.get(ProviderAdapter.PROPERTY_STACK_ID);
+ vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+
+ context = resolveContext(rc, params, appName, vm_url);
+
+ if (context != null) {
+ stack = lookupStack(rc, context, stackId);
+ logger.debug(Msg.STACK_FOUND, vm_url, context.getTenantName(), stack.getStatus().toString());
+ logger.info(EELFResourceManager.format(Msg.SNAPSHOTING_STACK, stack.getName()));
+
+ Snapshot snapshot = snapshotStack(rc, stack);
+
+ ctx.setAttribute(ProviderAdapter.DG_OUTPUT_PARAM_NAMESPACE +
+ ProviderAdapter.PROPERTY_SNAPSHOT_ID, snapshot.getId());
+
+ logger.info(EELFResourceManager.format(Msg.STACK_SNAPSHOTED, stack.getName(), snapshot.getId()));
+ context.close();
+ doSuccess(rc);
+ } else {
+ ctx.setAttribute(Constants.DG_ATTRIBUTE_STATUS, "failure");
+ }
+
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.STACK_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg, e);
+ } catch (RequestFailedException e) {
+ logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "snapshotStack"));
+ doFailure(rc, e.getStatus(), e.getMessage(), e);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ "snapshotStack", vm_url, null == context ? "n/a" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, t);
+ }
+ return stack;
+ }
+
+ @Override
+ public Stack restoreStack(Map<String, String> params, SvcLogicContext ctx) throws IllegalArgumentException, APPCException {
+ Stack stack = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ ctx.setAttribute("SNAPSHOT_STATUS", "STACK_NOT_FOUND");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+
+ String vm_url = null;
+ Context context = null;
+
+ try {
+
+ logAndValidate(params, ctx, rc, SNAPSHOT_STACK, "Snapshot Stack",
+ ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME,
+ ProviderAdapter.PROPERTY_STACK_ID,
+ ProviderAdapter.PROPERTY_INPUT_SNAPSHOT_ID);
+
+ String stackId = params.get(ProviderAdapter.PROPERTY_STACK_ID);
+ vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+
+ String snapshotId = params.get(ProviderAdapter.PROPERTY_INPUT_SNAPSHOT_ID);
+
+ context = resolveContext(rc, params, appName, vm_url);
+
+ if (context != null) {
+ stack = lookupStack(rc, context, stackId);
+ logger.debug(Msg.STACK_FOUND, vm_url, context.getTenantName(), stack.getStatus().toString());
+ logger.info(EELFResourceManager.format(Msg.RESTORING_STACK, stack.getName(), snapshotId));
+ restoreStack(stack, snapshotId);
+ logger.info(EELFResourceManager.format(Msg.STACK_RESTORED, stack.getName(), snapshotId));
+ context.close();
+ doSuccess(rc);
+ } else {
+ ctx.setAttribute(Constants.DG_ATTRIBUTE_STATUS, "failure");
+ }
+
+ } catch (ResourceNotFoundException e) {
+ String msg = EELFResourceManager.format(Msg.STACK_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg, e);
+ } catch (RequestFailedException e) {
+ logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "restoreStack"));
+ doFailure(rc, e.getStatus(), e.getMessage(), e);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ "restoreStack", vm_url, null == context ? "n/a" : context.getTenantName());
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, t);
+ }
+ return stack;
+ }
+
+ private void logAndValidate(Map<String, String> params, SvcLogicContext ctx, RequestContext rc, String methodName, String serviceName, String ... attributes)
+ throws RequestFailedException {
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, SNAPSHOT_STACK);
+ MDC.put(MDC_SERVICE_NAME, String.format("App-C IaaS Adapter:%s", serviceName));
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("Inside org.openecomp.appc.adapter.iaas.impl.ProviderAdapter.%s", methodName));
+ }
+
+ validateParametersExist(rc, params, attributes);
+
+ debugParameters(params);
+ debugContext(ctx);
+ }
+
+ private Context resolveContext(RequestContext rc, Map<String, String> params, String appName, String vm_url)
+ throws RequestFailedException {
+
+ VMURL vm = VMURL.parseURL(vm_url);
+ if (vm == null) {
+ String msg = EELFResourceManager.format(Msg.INVALID_SELF_LINK_URL, appName, vm_url);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ logger.error(msg);
+ return null;
+ }
+ validateVMURL(vm);
+ IdentityURL ident = IdentityURL.parseURL(params.get(ProviderAdapter.PROPERTY_IDENTITY_URL));
+ String identStr = (ident == null) ? null : ident.toString();
+
+ return getContext(rc, vm_url, identStr);
+
+ }
+
+ private void deleteStack(RequestContext rc, Stack stack) throws ZoneException, RequestFailedException {
+ SvcLogicContext ctx = rc.getSvcLogicContext();
+ Context context = stack.getContext();
+ StackService stackService = context.getStackService();
+ logger.debug("Deleting Stack: " + "id:{ " + stack.getId() + "}");
+ stackService.deleteStack(stack);
+
+ // wait for the stack deletion
+ boolean success = waitForStackStatus(rc, stack, Stack.Status.DELETED);
+ if (success) {
+ ctx.setAttribute("TERMINATE_STATUS", "SUCCESS");
+ } else {
+ ctx.setAttribute("TERMINATE_STATUS", "ERROR");
+ throw new RequestFailedException("Delete Stack failure : " + Msg.STACK_OPERATION_EXCEPTION.toString());
+ }
+ }
+
+ private boolean waitForStackStatus(RequestContext rc, Stack stack, Stack.Status expectedStatus) throws ZoneException, RequestFailedException {
+ SvcLogicContext ctx = rc.getSvcLogicContext();
+ Context context = stack.getContext();
+ StackService stackService = context.getStackService();
+
+ int pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
+ int timeout = configuration.getIntegerProperty(Constants.PROPERTY_STACK_STATE_CHANGE_TIMEOUT);
+ long maxTimeToWait = System.currentTimeMillis() + (long) timeout * 1000;
+ Stack.Status stackStatus;
+ while (System.currentTimeMillis() < maxTimeToWait) {
+ stackStatus = stackService.getStack(stack.getName(), stack.getId()).getStatus();
+ logger.debug("Stack status : " + stackStatus.toString());
+ if (stackStatus == expectedStatus) {
+ return true;
+ } else if (stackStatus == Stack.Status.FAILED) {
+ return false;
+ } else {
+ try {
+ Thread.sleep(pollInterval * 1000);
+ } catch (InterruptedException e) {
+ logger.trace("Sleep threw interrupted exception, should never occur");
+ }
+ }
+ }
+
+ ctx.setAttribute("TERMINATE_STATUS", "ERROR");
+ throw new TimeoutException("Timeout waiting for stack status change");
+
+ }
+
+ private Snapshot snapshotStack(@SuppressWarnings("unused") RequestContext rc, Stack stack) throws ZoneException, RequestFailedException {
+ Snapshot snapshot = new Snapshot();
+ Context context = stack.getContext();
+
+ OpenStackContext osContext = (OpenStackContext)context;
+
+ final HeatConnector heatConnector = osContext.getHeatConnector();
+ ((OpenStackContext)context).refreshIfStale(heatConnector);
+
+ trackRequest(context);
+ RequestState.put("SERVICE", "Orchestration");
+ RequestState.put("SERVICE_URL", heatConnector.getEndpoint());
+
+ Heat heat = heatConnector.getClient();
+
+ SnapshotResource snapshotResource = new SnapshotResource(heat);
+
+ try {
+
+ snapshot = snapshotResource.create(stack.getName(), stack.getId(), new CreateSnapshotParams()).execute();
+
+ // wait for the stack deletion
+ StackResource stackResource = new StackResource(heat);
+ if (!waitForStack(stack, stackResource, "SNAPSHOT_COMPLETE")) {
+ throw new RequestFailedException("Stack Snapshot failed.");
+ }
+
+ } catch (OpenStackBaseException e) {
+ ExceptionMapper.mapException(e);
+ }
+
+ return snapshot;
+ }
+
+ private void restoreStack(Stack stack, String snapshotId) throws ZoneException, RequestFailedException {
+ Context context = stack.getContext();
+
+ OpenStackContext osContext = (OpenStackContext)context;
+
+ final HeatConnector heatConnector = osContext.getHeatConnector();
+ ((OpenStackContext)context).refreshIfStale(heatConnector);
+
+ trackRequest(context);
+ RequestState.put("SERVICE", "Orchestration");
+ RequestState.put("SERVICE_URL", heatConnector.getEndpoint());
+
+ Heat heat = heatConnector.getClient();
+
+ SnapshotResource snapshotResource = new SnapshotResource(heat);
+
+ try {
+
+ snapshotResource.restore(stack.getName(), stack.getId(), snapshotId).execute();
+
+ // wait for the snapshot restore
+ StackResource stackResource = new StackResource(heat);
+ if (!waitForStack(stack, stackResource, "RESTORE_COMPLETE")) {
+ throw new RequestFailedException("Snapshot restore failed.");
+ }
+
+ } catch (OpenStackBaseException e) {
+ ExceptionMapper.mapException(e);
+ }
+
+ }
+
+ private boolean waitForStack(Stack stack, StackResource stackResource, String expectedStatus)
+ throws OpenStackBaseException, TimeoutException {
+ int pollInterval = configuration.getIntegerProperty(Constants.PROPERTY_OPENSTACK_POLL_INTERVAL);
+ int timeout = configuration.getIntegerProperty(Constants.PROPERTY_STACK_STATE_CHANGE_TIMEOUT);
+ long maxTimeToWait = System.currentTimeMillis() + (long) timeout * 1000;
+
+ while (System.currentTimeMillis() < maxTimeToWait) {
+ String stackStatus = stackResource.show(stack.getName(), stack.getId()).execute().getStackStatus();
+ logger.debug("Stack status : " + stackStatus);
+ if (stackStatus.toUpperCase().contains("FAILED")) return false;
+ if(checkStatus(expectedStatus, pollInterval, stackStatus)) return true;
+ }
+ throw new TimeoutException("Timeout waiting for stack status change");
+ }
+
+ private boolean checkStatus(String expectedStatus, int pollInterval, String actualStatus) {
+ if (actualStatus.toUpperCase().equals(expectedStatus)) {
+ return true;
+ } else {
+ try {
+ Thread.sleep(pollInterval * 1000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+ return false;
+ }
+
+ private void trackRequest(Context context, AbstractService.State... states) {
+ RequestState.clear();
+
+ if (null == states) return;
+ for (AbstractService.State state : states) {
+ RequestState.put(state.getName(), state.getValue());
+ }
+
+ Thread currentThread = Thread.currentThread();
+ StackTraceElement[] stack = currentThread.getStackTrace();
+ if (stack != null && stack.length > 0) {
+ int index = 0;
+ StackTraceElement element;
+ for (; index < stack.length; index++) {
+ element = stack[index];
+ if ("trackRequest".equals(element.getMethodName())) { //$NON-NLS-1$
+ break;
+ }
+ }
+ index++;
+
+ if (index < stack.length) {
+ element = stack[index];
+ RequestState.put(RequestState.METHOD, element.getMethodName());
+ RequestState.put(RequestState.CLASS, element.getClassName());
+ RequestState.put(RequestState.LINE_NUMBER, Integer.toString(element.getLineNumber()));
+ RequestState.put(RequestState.THREAD, currentThread.getName());
+ RequestState.put(RequestState.PROVIDER, context.getProvider().getName());
+ RequestState.put(RequestState.TENANT, context.getTenantName());
+ RequestState.put(RequestState.PRINCIPAL, context.getPrincipal());
+ }
+ }
+ }
+
+ private Stack lookupStack(RequestContext rc, Context context, String id)
+ throws ZoneException, RequestFailedException {
+ StackService stackService = context.getStackService();
+ Stack stack = null;
+ String msg;
+ Provider provider = context.getProvider();
+ while (rc.attempt()) {
+ try {
+ List<Stack> stackList = stackService.getStacks();
+ for (Stack stackObj : stackList) {
+ if (stackObj.getId().equals(id)) {
+ stack = stackObj;
+ break;
+ }
+ }
+ break;
+ } catch (ContextConnectionException e) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED_RETRY, provider.getName(), stackService.getURL(),
+ context.getTenant().getName(), context.getTenant().getId(), e.getMessage(),
+ Long.toString(rc.getRetryDelay()), Integer.toString(rc.getAttempts()),
+ Integer.toString(rc.getRetryLimit()));
+ logger.error(msg, e);
+ rc.delay();
+ }
+
+ }
+ if (rc.isFailed()) {
+ msg = EELFResourceManager.format(Msg.CONNECTION_FAILED, provider.getName(), stackService.getURL());
+ logger.error(msg);
+ doFailure(rc, HttpStatus.BAD_GATEWAY_502, msg);
+ throw new RequestFailedException("Lookup Stack", msg, HttpStatus.BAD_GATEWAY_502, stack);
+ }
+
+ if (stack == null) {
+ throw new ResourceNotFoundException("Stack not found with Id : {" + id + "}");
+ }
+ return stack;
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public Server lookupServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ Server server = null;
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive(); //should we test the return and fail if false?
+ MDC.put(MDC_ADAPTER, ADAPTER_NAME);
+ MDC.put(MDC_SERVICE, LOOKUP_SERVICE);
+ MDC.put(MDC_SERVICE_NAME, "App-C IaaS Adapter:LookupServer");
+ String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME);
+
+ //for debugging merge into single method?
+ debugParameters(params);
+ debugContext(ctx);
+
+ String vm_url = null;
+ VMURL vm = null;
+ try {
+
+ //process vm_url
+ validateParametersExist(rc, params, ProviderAdapter.PROPERTY_INSTANCE_URL,
+ ProviderAdapter.PROPERTY_PROVIDER_NAME);
+ vm_url = params.get(ProviderAdapter.PROPERTY_INSTANCE_URL);
+ vm = VMURL.parseURL(vm_url);
+ if (validateVM(rc, appName, vm_url, vm)) return null;
+
+
+ //use try with resource to ensure context is closed (returned to pool)
+ try(Context context = resolveContext(rc, params, appName, vm_url)){
+ //resloveContext & getContext call doFailure and log errors before returning null
+ if (context != null){
+ server = lookupServer(rc, context, vm.getServerId());
+ logger.debug(Msg.SERVER_FOUND, vm_url, context.getTenantName(), server.getStatus().toString());
+ ctx.setAttribute("serverFound", "success");
+ doSuccess(rc);
+ }
+ } catch (ZoneException e) {
+ //server not found
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ ctx.setAttribute("serverFound", "failure");
+ } catch (IOException e) {
+ //exception closing context
+ String msg = EELFResourceManager.format(Msg.CLOSE_CONTEXT_FAILED, e, vm_url);
+ logger.error(msg);
+ } catch (Throwable t) {
+ String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(),
+ LOOKUP_SERVICE, vm_url, "Unknown" );
+ logger.error(msg, t);
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg);
+ }
+
+ } catch (RequestFailedException e) {
+ // parameters not valid, unable to connect to provider
+ String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url);
+ logger.error(msg);
+ doFailure(rc, HttpStatus.NOT_FOUND_404, msg);
+ ctx.setAttribute("serverFound", "failure");
+ }
+ return server;
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderCache.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderCache.java
new file mode 100644
index 000000000..c70875da0
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ProviderCache.java
@@ -0,0 +1,164 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.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.
+ * <p>
+ * Providers may be multi-tenant, such as OpenStack, where the available services and resources vary from one tenant to
+ * another. Therefore, the provider cache maintains a cache of tenants and the service catalogs for each, as well as the
+ * credentials used to access the tenants, and a pool of Context objects for each tenant. The context pool allows use of
+ * the CDP abstraction layer to access the services of the provider within the specific tenant.
+ * </p>
+ */
+public class ProviderCache {
+
+ /**
+ * The type of provider (e.g., OpenStackProvider) used to setup the CDP abstraction layer and load the appropriate
+ * support
+ */
+ private String providerType;
+
+ /**
+ * The URL of the provider's identity service or whatever service is used to login and authenticate to the provider
+ */
+ private String identityURL;
+
+ /**
+ * A string used to identify the provider instance
+ */
+ private String providerName;
+
+ /**
+ * The map of tenant cache objects by tenant id
+ */
+ private Map<String /* tenant id */, TenantCache> tenants = new HashMap<String, TenantCache>();
+
+ /**
+ * @return the value of providerType
+ */
+ public String getProviderType() {
+ return providerType;
+ }
+
+ /**
+ * This method is called to initialize the provider cache, set up the context pools for each of the tenants,
+ * discover all of the regions supported on the provider, and load all of the service catalogs for each provider.
+ */
+ public void initialize() {
+ for (Map.Entry<String, TenantCache> entry: tenants.entrySet()) {
+ entry.getValue().initialize();
+ }
+ }
+
+ /**
+ * @param providerType
+ * the value for providerType
+ */
+ public void setProviderType(String providerType) {
+ this.providerType = providerType;
+ }
+
+ /**
+ * @return the value of identityURL
+ */
+ public String getIdentityURL() {
+ return identityURL;
+ }
+
+ /**
+ * @param identityURL
+ * the value for identityURL
+ */
+ public void setIdentityURL(String identityURL) {
+ this.identityURL = identityURL;
+ }
+
+ /**
+ * @return the value of providerName
+ */
+ public String getProviderName() {
+ return providerName;
+ }
+
+ /**
+ * @param providerName
+ * the value for providerName
+ */
+ public void setProviderName(String providerName) {
+ this.providerName = providerName;
+ }
+
+ /**
+ * @return the value of tenants
+ */
+ public Map<String, TenantCache> getTenants() {
+ return tenants;
+ }
+
+ /**
+ * This method is a helper to return a specific TenantCache
+ *
+ * @param tenantId
+ * @return
+ */
+ public TenantCache getTenant(String tenantId){
+ return tenants.get(tenantId);
+ }
+
+ // Previously there was no way to add additional tenants to the tenant cache
+ /**
+ * This method is used to add a tenant to the provider cache
+ *
+ * @param tenantId
+ * @param UserId
+ * @param password
+ * @return the new initialized TenantCache or null if unsuccessful
+ */
+ public TenantCache addTenant(String tenantId, String tenantName, String userId, String password){
+ if(tenantId != null || tenantName != null && userId != null && password != null){
+ TenantCache tenant = new TenantCache(this);
+ if(tenantId != null){
+ tenant.setTenantId(tenantId);
+ }
+ if(tenantName != null){
+ tenant.setTenantName(tenantName);
+ }
+ tenant.setUserid(userId);
+ tenant.setPassword(password);
+
+ if(identityURL != null){
+ tenant.initialize();
+ }
+
+ if (tenant.isInitialized()) {
+ tenants.put(tenant.getTenantId(), tenant);
+ return tenant;
+ }
+ }
+ return null;
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestContext.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestContext.java
new file mode 100644
index 000000000..395d37847
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestContext.java
@@ -0,0 +1,250 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.sdnc.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.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @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-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestFailedException.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestFailedException.java
new file mode 100644
index 000000000..c7e7e93c8
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/RequestFailedException.java
@@ -0,0 +1,277 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import org.glassfish.grizzly.http.util.HttpStatus;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Stack;
+
+/**
+ * This class is used to capture the exact cause and point of failure for the processing of a request. It is then used
+ * to encode the reason for the failure, status code, and anything else that needs to be captured and reported for
+ * diagnostic purposes.
+ */
+public class RequestFailedException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The operation that was being requested or performed at the time of the failure.
+ */
+ private String operation;
+
+ /**
+ * A message that details the reason for the failure
+ */
+ private String reason;
+
+ /**
+ * The server that was being operated upon
+ */
+ private Server server;
+
+ /**
+ * The stack that was being operated upon
+ */
+ private Stack stack;
+ /**
+ * The id of the server being operated upon if the server object is not available (such as the server was not found)
+ */
+ private String serverId;
+
+ /**
+ * The id of the stack being operated upon if the stack object is not available (such as the stack was not found)
+ */
+ private String stackId;
+ /**
+ * The most appropriate Http Status code that reflects the error
+ */
+ private HttpStatus status;
+
+ /**
+ *
+ */
+ public RequestFailedException() {
+ // intentionally empty
+ }
+
+ /**
+ * @param message
+ * The error message
+ */
+ public RequestFailedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the server we were processing.
+ *
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param server
+ * The server that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
+ super(operation + ":" + reason);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.server = server;
+ if (server != null) {
+ this.serverId = server.getId();
+ }
+ }
+
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the stack we were processing.
+ *
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param stack
+ * The stack that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(String operation, String reason, HttpStatus status, Stack stack) {
+ super(operation + ":" + reason);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.stack = stack;
+ if (stack != null) {
+ this.stackId = stack.getId();
+ }
+ }
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the server we were processing.
+ *
+ * @param ex
+ * The exception that we are wrapping
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param server
+ * The server that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
+ super(operation + ":" + reason, ex);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.server = server;
+ if (server != null) {
+ this.serverId = server.getId();
+ }
+ }
+
+ /**
+ * @param message
+ * The error message
+ * @param cause
+ * A nested exception
+ */
+ public RequestFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ * The error message
+ * @param cause
+ * A nested exception
+ * @param enableSuppression
+ * whether or not suppression is enabled or disabled
+ * @param writableStackTrace
+ * whether or not the stack trace should be writable
+ */
+ public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ /**
+ * @param cause
+ * the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
+ * permitted, and indicates that the cause is nonexistent or unknown.)
+ */
+ public RequestFailedException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @return The operation being performed
+ */
+ public String getOperation() {
+ return operation;
+ }
+
+ /**
+ * @return The reason for the failure
+ */
+ public String getReason() {
+ return reason;
+ }
+
+ /**
+ * @return The server being operated upon
+ */
+ public Server getServer() {
+ return server;
+ }
+
+ /**
+ * @return The id of the server being operated upon
+ */
+ public String getServerId() {
+ return serverId;
+ }
+
+ /**
+ * @return The status code from the operation
+ */
+ public HttpStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @param operation
+ * The operation being performed
+ */
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ /**
+ * @param reason
+ * The reason for the failure
+ */
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ /**
+ * @param server
+ * The server being operated upon
+ */
+ public void setServer(Server server) {
+ this.server = server;
+ if (server != null) {
+ setServerId(server.getId());
+ }
+ }
+
+ /**
+ * @param serverId
+ * The id of the server being operated upon
+ */
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ /**
+ * @param status
+ * The status of the request
+ */
+ public void setStatus(HttpStatus status) {
+ this.status = status;
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalog.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalog.java
new file mode 100644
index 000000000..8ac81b2b9
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/ServiceCatalog.java
@@ -0,0 +1,488 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import java.net.NoRouteToHostException;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import com.att.cdp.exceptions.ContextConnectionException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.openstack.util.ExceptionMapper;
+import com.att.cdp.pal.util.Time;
+import com.att.cdp.zones.ContextFactory;
+import com.att.cdp.zones.spi.AbstractService;
+import com.att.cdp.zones.spi.RequestState;
+import com.att.cdp.zones.spi.AbstractService.State;
+
+import com.sun.jersey.api.client.ClientHandlerException;
+import com.woorea.openstack.base.client.OpenStackBaseException;
+import com.woorea.openstack.base.client.OpenStackClientConnector;
+import com.woorea.openstack.base.client.OpenStackResponseException;
+import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
+import com.woorea.openstack.keystone.Keystone;
+import com.woorea.openstack.keystone.api.TokensResource;
+import com.woorea.openstack.keystone.model.Access;
+import com.woorea.openstack.keystone.model.Access.Service;
+import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
+import com.woorea.openstack.keystone.model.Authentication;
+import com.woorea.openstack.keystone.model.Tenant;
+import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
+
+/**
+ * This class is used to capture and cache the service catalog for a specific OpenStack provider.
+ * <p>
+ * This is needed because the way the servers are represented in the ECOMP product is as their fully qualified URL's.
+ * This is very problematic, because we cant identify their region from the URL, URL's change, and we cant identify the
+ * versions of the service implementations. In otherwords, the URL does not provide us enough information.
+ * </p>
+ * <p>
+ * The zone abstraction layer is designed to detect the versions of the services dynamically, and step up or down to
+ * match those reported versions. In order to do that, we need to know before hand what region we are accessing (since
+ * the supported versions may be different by regions). We will need to authenticate to the identity service in order to
+ * do this, plus we have to duplicate the code supporting proxies and trusted hosts that exists in the abstraction
+ * layer, but that cant be helped.
+ * </p>
+ * <p>
+ * What we do to circumvent this is connect to the provider using the lowest supported identity api, and read the entire
+ * service catalog into this object. Then, we parse the vm URL to extract the host and port and match that to the
+ * compute services defined in the catalog. When we find a compute service that has the same host name and port,
+ * whatever region that service is supporting is the region for that server.
+ * </p>
+ * <p>
+ * While we really only need to do this for compute nodes, there is no telling what other situations may arise where the
+ * full service catalog may be needed. Also, there is very little additional cost (additional RAM) associated with
+ * caching the full service catalog since there is no way to list only a portion of it.
+ * </p>
+ */
+public class ServiceCatalog {
+
+ /**
+ * The service name for the compute service endpoint
+ */
+ public static final String COMPUTE_SERVICE = "compute"; //$NON-NLS-1$
+
+ /**
+ * The service name for the identity service endpoint
+ */
+ public static final String IDENTITY_SERVICE = "identity"; //$NON-NLS-1$
+
+ /**
+ * The service name for the compute service endpoint
+ */
+ public static final String IMAGE_SERVICE = "image"; //$NON-NLS-1$
+
+ /**
+ * The service name for the network service endpoint
+ */
+ public static final String NETWORK_SERVICE = "network"; //$NON-NLS-1$
+
+ /**
+ * The service name for the orchestration service endpoint
+ */
+ public static final String ORCHESTRATION_SERVICE = "orchestration"; //$NON-NLS-1$
+
+ /**
+ * The service name for the volume service endpoint
+ */
+ public static final String VOLUME_SERVICE = "volume"; //$NON-NLS-1$
+
+ /**
+ * The service name for the persistent object service endpoint
+ */
+ public static final String OBJECT_SERVICE = "object-store"; //$NON-NLS-1$
+
+ /**
+ * The service name for the metering service endpoint
+ */
+ public static final String METERING_SERVICE = "metering"; //$NON-NLS-1$
+
+ /**
+ * The Openstack Access object that manages the authenticated token and access control
+ */
+ private Access access;
+
+ /**
+ * The time (local) that the token expires and we need to re-authenticate
+ */
+ @SuppressWarnings("unused")
+ private long expiresLocal;
+
+ /**
+ * The set of all regions that have been defined
+ */
+ private Set<String> regions;
+
+ /**
+ * The read/write lock used to protect the cache contents
+ */
+ private ReadWriteLock rwLock;
+
+ /**
+ * A map of endpoints for each service organized by service type
+ */
+ private Map<String /* Service Type */, List<Service.Endpoint>> serviceEndpoints;
+
+ /**
+ * A map of service types that are published
+ */
+ private Map<String /* Service Type */, Service> serviceTypes;
+
+ /**
+ * The tenant that we are accessing
+ */
+ private Tenant tenant;
+
+ /**
+ * A "token provider" that manages the authentication token that we obtain when logging in
+ */
+ private OpenStackSimpleTokenProvider tokenProvider;
+
+ public static final String CLIENT_CONNECTOR_CLASS = "com.woorea.openstack.connector.JerseyConnector";
+
+ /**
+ * Create the ServiceCatalog cache and load it from the specified provider
+ *
+ * @param identityURL
+ * The identity service URL to connect to
+ * @param tenantIdentifier
+ * The name or id of the tenant to authenticate with. If the ID is a UUID format (32-character
+ * hexadecimal string), then the authentication is done using the tenant ID, otherwise it is done using
+ * the name.
+ * @param principal
+ * The user id to authenticate to the provider
+ * @param credential
+ * The password to authenticate to the provider
+ * @param properties
+ * Additional properties used to configure the connection, such as proxy and trusted hosts lists
+ * @throws ZoneException
+ * @throws ClassNotFoundException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ public ServiceCatalog(String identityURL, String tenantIdentifier, String principal, String credential,
+ Properties properties) throws ZoneException {
+ rwLock = new ReentrantReadWriteLock();
+ serviceTypes = new HashMap<>();
+ serviceEndpoints = new HashMap<>();
+ regions = new HashSet<>();
+
+ Class<?> connectorClass;
+ OpenStackClientConnector connector;
+ try {
+ connectorClass = Class.forName(CLIENT_CONNECTOR_CLASS);
+ connector = (OpenStackClientConnector) connectorClass.newInstance();
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
+ e.printStackTrace();
+ return;
+ }
+ Keystone keystone = new Keystone(identityURL, connector);
+
+ String proxyHost = properties.getProperty(ContextFactory.PROPERTY_PROXY_HOST);
+ String proxyPort = properties.getProperty(ContextFactory.PROPERTY_PROXY_PORT);
+ String trustedHosts = properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, ""); //$NON-NLS-1$
+ if (proxyHost != null && proxyHost.length() > 0) {
+ keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_HOST, proxyHost);
+ keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.PROXY_PORT, proxyPort);
+ }
+ if (trustedHosts != null) {
+ keystone.getProperties().setProperty(com.woorea.openstack.common.client.Constants.TRUST_HOST_LIST,
+ trustedHosts);
+ }
+
+ Authentication authentication = new UsernamePassword(principal, credential);
+ TokensResource tokens = keystone.tokens();
+ TokensResource.Authenticate authenticate = tokens.authenticate(authentication);
+ if (tenantIdentifier.length() == 32 && tenantIdentifier.matches("[0-9a-fA-F]+")) { //$NON-NLS-1$
+ authenticate = authenticate.withTenantId(tenantIdentifier);
+ } else {
+ authenticate = authenticate.withTenantName(tenantIdentifier);
+ }
+
+ /*
+ * We have to set up the TrackRequest TLS collection for the ExceptionMapper
+ */
+ trackRequest();
+ RequestState.put(RequestState.PROVIDER, "OpenStackProvider");
+ RequestState.put(RequestState.TENANT, tenantIdentifier);
+ RequestState.put(RequestState.PRINCIPAL, principal);
+
+ try {
+ access = authenticate.execute();
+ expiresLocal = getLocalExpiration(access);
+ tenant = access.getToken().getTenant();
+ tokenProvider = new OpenStackSimpleTokenProvider(access.getToken().getId());
+ keystone.setTokenProvider(tokenProvider);
+ parseServiceCatalog(access.getServiceCatalog());
+ } catch (OpenStackBaseException e) {
+ ExceptionMapper.mapException(e);
+ } catch (Exception ex) {
+ throw new ContextConnectionException(ex.getMessage());
+ }
+ }
+
+ /**
+ * Returns the list of service endpoints for the published service type
+ *
+ * @param serviceType
+ * The service type to obtain the endpoints for
+ * @return The list of endpoints for the service type, or null if none exist
+ */
+ public List<Service.Endpoint> getEndpoints(String serviceType) {
+ Lock readLock = rwLock.readLock();
+ readLock.lock();
+ try {
+ return serviceEndpoints.get(serviceType);
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ /**
+ * Computes the local time when the access token will expire, after which we will need to re-login to access the
+ * provider.
+ *
+ * @param accessKey
+ * The access key used to access the provider
+ * @return The local time the key expires
+ */
+ private static long getLocalExpiration(Access accessKey) {
+ Date now = Time.getCurrentUTCDate();
+ if (accessKey != null && accessKey.getToken() != null) {
+ Calendar issued = accessKey.getToken().getIssued_at();
+ Calendar expires = accessKey.getToken().getExpires();
+ if (issued != null && expires != null) {
+ long tokenLife = expires.getTimeInMillis() - issued.getTimeInMillis();
+ return now.getTime() + tokenLife;
+ }
+ }
+ return now.getTime();
+ }
+
+ /**
+ * @return The set of all regions that are defined
+ */
+ public Set<String> getRegions() {
+ Lock readLock = rwLock.readLock();
+ readLock.lock();
+ try {
+ return regions;
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ /**
+ * @return A list of service types that are published
+ */
+ public List<String> getServiceTypes() {
+ Lock readLock = rwLock.readLock();
+ readLock.lock();
+ try {
+ ArrayList<String> result = new ArrayList<>();
+ result.addAll(serviceTypes.keySet());
+ return result;
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ /**
+ * @return The tenant id
+ */
+ public String getTenantId() {
+ Lock readLock = rwLock.readLock();
+ readLock.lock();
+ try {
+ return tenant.getId();
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ /**
+ * @return The tenant name
+ */
+ public String getTenantName() {
+ Lock readLock = rwLock.readLock();
+ readLock.lock();
+ try {
+ return tenant.getName();
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ /**
+ * Returns an indication if the specified service type is published by this provider
+ *
+ * @param serviceType
+ * The service type to check for
+ * @return True if a service of that type is published
+ */
+ public boolean isServicePublished(String serviceType) {
+ Lock readLock = rwLock.readLock();
+ readLock.lock();
+ try {
+ return serviceTypes.containsKey(serviceType);
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ /**
+ * Parses the service catalog and caches the results
+ *
+ * @param services
+ * The list of services published by this provider
+ */
+ private void parseServiceCatalog(List<Service> services) {
+ Lock lock = rwLock.writeLock();
+ lock.lock();
+ try {
+ serviceTypes.clear();
+ serviceEndpoints.clear();
+ regions.clear();
+
+ for (Service service : services) {
+ String type = service.getType();
+ serviceTypes.put(type, service);
+
+ List<Service.Endpoint> endpoints = service.getEndpoints();
+ for (Service.Endpoint endpoint : endpoints) {
+ List<Service.Endpoint> endpointList = serviceEndpoints.get(type);
+ if (endpointList == null) {
+ endpointList = new ArrayList<>();
+ serviceEndpoints.put(type, endpointList);
+ }
+ endpointList.add(endpoint);
+
+ String region = endpoint.getRegion();
+ if (!regions.contains(region)) {
+ regions.add(region);
+ }
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * This method is used to provide a diagnostic listing of the service catalog
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+
+ StringBuilder builder = new StringBuilder();
+ Lock lock = rwLock.readLock();
+ lock.lock();
+ try {
+ builder.append(String.format("Service Catalog: tenant %s, id[%s], description[%s]\n", tenant.getName(), //$NON-NLS-1$
+ tenant.getId(), tenant.getDescription()));
+ if (regions != null && !regions.isEmpty()) {
+ builder.append(String.format("%d regions:\n", regions.size())); //$NON-NLS-1$
+ for (String region : regions) {
+ builder.append("\t" + region + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ builder.append(String.format("%d services:\n", serviceEndpoints.size())); //$NON-NLS-1$
+ for (String serviceType : serviceEndpoints.keySet()) {
+ List<Endpoint> endpoints = serviceEndpoints.get(serviceType);
+ Service service = serviceTypes.get(serviceType);
+
+ builder.append(String.format("\t%s [%s] - %d endpoints\n", service.getType(), service.getName(), //$NON-NLS-1$
+ endpoints.size()));
+ for (Endpoint endpoint : endpoints) {
+ builder.append(String.format("\t\tRegion [%s], public URL [%s]\n", endpoint.getRegion(), //$NON-NLS-1$
+ endpoint.getPublicURL()));
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Initializes the request state for the current requested service.
+ * <p>
+ * This method is used to track requests made to the various service implementations and to provide additional
+ * information for diagnostic purposes. The <code>RequestState</code> class stores the state in thread-local storage
+ * and is available to all code on that thread.
+ * </p>
+ * <p>
+ * This method first obtains the stack trace and scans the stack backward for the call to this method. It then backs
+ * up one more call and assumes that method is the request that we are "tracking".
+ * </p>
+ *
+ * @param states
+ * A variable argument list of additional state values that the caller wants to add to the request state
+ * thread-local object to track the context.
+ */
+ protected void trackRequest(State... states) {
+ RequestState.clear();
+
+ for (State state : states) {
+ RequestState.put(state.getName(), state.getValue());
+ }
+
+ Thread currentThread = Thread.currentThread();
+ StackTraceElement[] stack = currentThread.getStackTrace();
+ if (stack != null && stack.length > 0) {
+ int index = 0;
+ StackTraceElement element = null;
+ for (; index < stack.length; index++) {
+ element = stack[index];
+ if ("trackRequest".equals(element.getMethodName())) { //$NON-NLS-1$
+ break;
+ }
+ }
+ index++;
+
+ if (index < stack.length) {
+ element = stack[index];
+ RequestState.put(RequestState.METHOD, element.getMethodName());
+ RequestState.put(RequestState.CLASS, element.getClassName());
+ RequestState.put(RequestState.LINE_NUMBER, Integer.toString(element.getLineNumber()));
+ RequestState.put(RequestState.THREAD, currentThread.getName());
+ // RequestState.put(RequestState.PROVIDER, context.getProvider().getName());
+ // RequestState.put(RequestState.TENANT, context.getTenantName());
+ // RequestState.put(RequestState.PRINCIPAL, context.getPrincipal());
+ }
+ }
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/TenantCache.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/TenantCache.java
new file mode 100644
index 000000000..c0c114dc8
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/TenantCache.java
@@ -0,0 +1,378 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.pool.Allocator;
+import org.openecomp.appc.pool.Destructor;
+import org.openecomp.appc.pool.Pool;
+import org.openecomp.appc.pool.PoolSpecificationException;
+import com.att.cdp.exceptions.ContextConnectionException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ContextFactory;
+import com.att.cdp.zones.Provider;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import com.sun.jersey.api.client.ClientHandlerException;
+import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
+
+/**
+ * This class maintains a cache of tenants within a specific provider.
+ * <p>
+ * Providers may be multi-tenant, such as OpenStack, where the available services and resources vary from one tenant to
+ * another. Therefore, the provider cache maintains a cache of tenants and the service catalogs for each, as well as the
+ * credentials used to access the tenants, and a pool of Context objects for each tenant. The context pool allows use of
+ * the CDP abstraction layer to access the services of the provider within the specific tenant.
+ * </p>
+ */
+public class TenantCache implements Allocator<Context>, Destructor<Context> {
+
+ public static final String POOL_PROVIDER_NAME = "pool.provider.name";
+ public static final String POOL_TENANT_NAME = "pool.tenant.name";
+ public static final String CLIENT_CONNECTOR_CLASS = "com.woorea.openstack.connector.JerseyConnector";
+
+ /**
+ * The provider we are part of
+ */
+ private ProviderCache provider;
+
+ /**
+ * The password used to authenticate
+ */
+ private String password;
+
+ /**
+ * The context pools by region used to access this tenant
+ */
+ private Map<String /* region */, Pool<Context>> pools = new HashMap<>();
+
+ /**
+ * The tenant id
+ */
+ private String tenantId;
+
+ /**
+ * The tenant name
+ */
+ private String tenantName;
+
+ /**
+ * The user id used to authenticate
+ */
+ private String userid;
+
+ /**
+ * The configuration of this adapter
+ */
+ private Configuration configuration;
+
+ /**
+ * The service catalog for this provider
+ */
+ private ServiceCatalog catalog;
+
+ /**
+ * Set to true when the cache has been initialized
+ */
+ private boolean initialized;
+
+ /**
+ * The logger to use
+ */
+ private EELFLogger logger;
+
+ /**
+ * Construct the cache of tenants for the specified provider
+ *
+ * @param provider
+ * The provider
+ */
+ public TenantCache(ProviderCache provider) {
+ configuration = ConfigurationFactory.getConfiguration();
+ logger = EELFManager.getInstance().getLogger(getClass());
+ this.provider = provider;
+ configuration = ConfigurationFactory.getConfiguration();
+ }
+
+ /**
+ * @return True when the cache has been initialized. A tenant cache is initialized when the service catalog for the
+ * tenant on the specified provider has been loaded and processed.
+ */
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ /**
+ * Initializes the tenant cache.
+ * <p>
+ * This method authenticates to the provider and obtains the service catalog. For the service catalog we can
+ * determine all supported regions for this provider, as well as all published services and their endpoints. We will
+ * cache and maintain a copy of the service catalog for later queries.
+ * </p>
+ * <p>
+ * Once the catalog has been obtained, we create a context pool for each region defined. The context allows access
+ * to services of a single region only, so we need a separate context by region. It is possible to operate on
+ * resources that span regions, but to do so will require acquiring a context for each region of interest.
+ * </p>
+ * <p>
+ * The context pool maintains the reusable context objects and allocates them as needed. This class is registered as
+ * the allocator and destructor for the pool, so that we can create a new context when needed, and close it when no
+ * longer used.
+ * </p>
+ */
+ public void initialize() {
+ logger.debug("Initializing TenantCache");
+
+ int min = configuration.getIntegerProperty(Constants.PROPERTY_MIN_POOL_SIZE);
+ int max = configuration.getIntegerProperty(Constants.PROPERTY_MAX_POOL_SIZE);
+ int delay = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_DELAY);
+ int limit = configuration.getIntegerProperty(Constants.PROPERTY_RETRY_LIMIT);
+
+ String url = provider.getIdentityURL();
+ String tenant = tenantName == null ? tenantId : tenantName;
+ Properties properties = configuration.getProperties();
+
+ int attempt = 1;
+ while (attempt <= limit) {
+ try {
+ catalog = new ServiceCatalog(url, tenant, userid, password, properties);
+ tenantId = catalog.getTenantId();
+ tenantName = catalog.getTenantName();
+
+ for (String region : catalog.getRegions()) {
+ try {
+ Pool<Context> pool = new Pool<>(min, max);
+ pool.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, url);
+ pool.setProperty(ContextFactory.PROPERTY_TENANT, tenantName);
+ pool.setProperty(ContextFactory.PROPERTY_CLIENT_CONNECTOR_CLASS, CLIENT_CONNECTOR_CLASS);
+ pool.setProperty(ContextFactory.PROPERTY_RETRY_DELAY,
+ configuration.getProperty(Constants.PROPERTY_RETRY_DELAY));
+ pool.setProperty(ContextFactory.PROPERTY_RETRY_LIMIT,
+ configuration.getProperty(Constants.PROPERTY_RETRY_LIMIT));
+ pool.setProperty(ContextFactory.PROPERTY_REGION, region);
+ if (properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS) != null) {
+ pool.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS,
+ properties.getProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS));
+ }
+ pool.setAllocator(this);
+ pool.setDestructor(this);
+ pools.put(region, pool);
+ logger.debug(String.format("Put pool for region %s", region));
+ } catch (PoolSpecificationException e) {
+ logger.error("Error creating pool", e);
+ e.printStackTrace();
+ }
+ }
+ initialized = true;
+ break;
+ } catch (ContextConnectionException e) {
+ attempt++;
+ logger.error(Msg.CONNECTION_FAILED_RETRY, provider.getProviderName(), url, tenantName, tenantId, e.getMessage(), Integer.toString(delay), Integer.toString(attempt),
+ Integer.toString(limit));
+
+ try {
+ Thread.sleep(delay * 1000L);
+ } catch (InterruptedException ie) {
+ // ignore
+ }
+ } catch (ClientHandlerException | ZoneException e) {
+ logger.error(e.getMessage());
+ break;
+ }
+ }
+
+ if (!initialized) {
+ logger.error(Msg.CONNECTION_FAILED, provider.getProviderName(), url);
+ }
+ }
+
+ /**
+ * This method accepts a fully qualified compute node URL and uses that to determine which region of the provider
+ * hosts that compute node.
+ *
+ * @param url
+ * The parsed URL of the compute node
+ * @return The region name, or null if no region of this tenant hosts that compute node.
+ */
+ public String determineRegion(VMURL url) {
+ logger.debug(String.format("Attempting to determine VM region for %s", url));
+ String region = null;
+ Pattern urlPattern = Pattern.compile("[^:]+://([^:/]+)(?::([0-9]+)).*");
+
+ if (url != null) {
+ for (Endpoint endpoint : catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE)) {
+ String endpointUrl = endpoint.getPublicURL();
+ Matcher matcher = urlPattern.matcher(endpointUrl);
+ if (matcher.matches()) {
+ if (url.getHost().equals(matcher.group(1))) {
+ if (url.getPort() != null) {
+ if (!url.getPort().equals(matcher.group(2))) {
+ continue;
+ }
+ }
+
+ region = endpoint.getRegion();
+ break;
+ }
+ }
+ }
+ }
+ logger.debug(String.format("Region for %s is %s", url, region));
+ return region;
+ }
+
+ /**
+ * @return the value of provider
+ */
+ public ProviderCache getProvider() {
+ return provider;
+ }
+
+ /**
+ * @param provider
+ * the value for provider
+ */
+ public void setProvider(ProviderCache provider) {
+ this.provider = provider;
+ }
+
+ /**
+ * @return the value of password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password
+ * the value for password
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the value of tenantId
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @param tenantId
+ * the value for tenantId
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return the value of tenantName
+ */
+ public String getTenantName() {
+ return tenantName;
+ }
+
+ /**
+ * @param tenantName
+ * the value for tenantName
+ */
+ public void setTenantName(String tenantName) {
+ this.tenantName = tenantName;
+ }
+
+ /**
+ * @return the value of userid
+ */
+ public String getUserid() {
+ return userid;
+ }
+
+ /**
+ * @param userid
+ * the value for userid
+ */
+ public void setUserid(String userid) {
+ this.userid = userid;
+ }
+
+ /**
+ * @return the value of pools
+ */
+ public Map<String, Pool<Context>> getPools() {
+ return pools;
+ }
+
+ /**
+ * @see org.openecomp.appc.pool.Allocator#allocate(org.openecomp.appc.pool.Pool)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Context allocate(Pool<Context> pool) {
+ logger.debug("Allocationg context for pool");
+ Class<? extends Provider> providerClass;
+ try {
+ providerClass = (Class<? extends Provider>) Class.forName("com.att.cdp.openstack.OpenStackProvider");
+ // String providerType = provider.getProviderType();
+
+ // Context context = ContextFactory.getContext(providerType, pool.getProperties());
+ Context context = ContextFactory.getContext(providerClass, pool.getProperties());
+ context.login(userid, password);
+ return context;
+ } catch (IllegalStateException | IllegalArgumentException | ZoneException | ClassNotFoundException e) {
+ logger.debug("Failed to allocate context for pool", e);
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * @see org.openecomp.appc.pool.Destructor#destroy(java.lang.Object, org.openecomp.appc.pool.Pool)
+ */
+ @Override
+ public void destroy(Context context, Pool<Context> pool) {
+ try {
+ context.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @return the service catalog for this provider
+ */
+ public ServiceCatalog getServiceCatalog() {
+ return catalog;
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
new file mode 100644
index 000000000..e9709fae0
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
@@ -0,0 +1,138 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.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 VMURL {
+
+ /**
+ * 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]+))?/v2/([^/]+)/servers/([^/]+)");
+
+ /**
+ * The URL scheme or protocol, such as HTTP or HTTPS
+ */
+ private String scheme;
+
+ /**
+ * The host name or ip address
+ */
+ private String host;
+
+ /**
+ * The port number, or null if no port is defined
+ */
+ private String port;
+
+ /**
+ * The tenant UUID
+ */
+ private String tenantId;
+
+ /**
+ * The server UUID
+ */
+ private String serverId;
+
+ /**
+ * A private default constructor prevents instantiation by any method other than the factory method
+ *
+ * @see #parseURL(String)
+ */
+ private VMURL() {
+
+ }
+
+ /**
+ * 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 VMURL parseURL(String serverUrl) {
+ VMURL obj = null;
+ if (serverUrl != null) {
+ Matcher matcher = pattern.matcher(serverUrl.trim());
+ if (matcher.matches()) {
+ obj = new VMURL();
+ obj.scheme = matcher.group(1);
+ obj.host = matcher.group(2);
+ obj.port = matcher.group(3);
+ obj.tenantId = matcher.group(4);
+ obj.serverId = 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 port, or null if no port was defined
+ */
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * @return The tenant id
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @return The server ID
+ */
+ public String getServerId() {
+ return serverId;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s://%s:%s/%s/servers/%s", scheme, host, port, tenantId, serverId);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/SnapshotResource.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/SnapshotResource.java
new file mode 100644
index 000000000..47ac7ff9e
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/SnapshotResource.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat;
+
+import org.openecomp.appc.adapter.openstack.heat.model.CreateSnapshotParams;
+import org.openecomp.appc.adapter.openstack.heat.model.Snapshot;
+
+import com.woorea.openstack.base.client.Entity;
+import com.woorea.openstack.base.client.HttpMethod;
+import com.woorea.openstack.base.client.OpenStackClient;
+import com.woorea.openstack.base.client.OpenStackRequest;
+
+
+public class SnapshotResource {
+
+ private final OpenStackClient client;
+
+ public SnapshotResource(OpenStackClient client) {
+ this.client = client;
+ }
+
+ public CreateSnapshot create(String stackName, String stackID, CreateSnapshotParams params) {
+ return new CreateSnapshot(stackName, stackID, params);
+ }
+
+ public RestoreSnapshot restore(String stackName, String stackID, String snapshotID) {
+ return new RestoreSnapshot(stackName, stackID, snapshotID);
+ }
+
+ public ShowSnapshot show(String stackName, String stackID, String snapshotID) {
+ return new ShowSnapshot(stackName, stackID, snapshotID);
+ }
+
+ public class CreateSnapshot extends OpenStackRequest<Snapshot> {
+ public CreateSnapshot(String stackName, String stackID, CreateSnapshotParams params) {
+ super(client, HttpMethod.POST, "/stacks/" + stackName + "/" + stackID + "/snapshots", Entity.json(params), Snapshot.class);
+ }
+ }
+
+ public class RestoreSnapshot extends OpenStackRequest<Void> {
+ public RestoreSnapshot(String stackName, String stackID, String snapshotID) {
+ super(client, HttpMethod.POST, "/stacks/" + stackName + "/" + stackID + "/snapshots/" + snapshotID + "/restore", null, Void.class);
+ }
+ }
+
+ public class ShowSnapshot extends OpenStackRequest<Snapshot> {
+ public ShowSnapshot(String stackName, String stackID, String snapshotID) {
+ super(client, HttpMethod.GET, "/stacks/" + stackName + "/" + stackID + "/snapshots/" + snapshotID, null, Snapshot.class);
+ }
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/StackResource.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/StackResource.java
new file mode 100644
index 000000000..de4f9da56
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/StackResource.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat;
+
+import org.openecomp.appc.adapter.openstack.heat.model.CreateSnapshotParams;
+import org.openecomp.appc.adapter.openstack.heat.model.Snapshot;
+
+import com.woorea.openstack.base.client.Entity;
+import com.woorea.openstack.base.client.HttpMethod;
+import com.woorea.openstack.base.client.OpenStackClient;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.heat.model.Stack;
+
+
+public class StackResource {
+
+ private final OpenStackClient client;
+
+ public StackResource(OpenStackClient client) {
+ this.client = client;
+ }
+
+ public ShowStack show(String stackName, String stackID) {
+ return new ShowStack(stackName, stackID);
+ }
+
+ public class ShowStack extends OpenStackRequest<Stack> {
+ public ShowStack(String stackName, String stackID) {
+ super(client, HttpMethod.GET, "/stacks/" + stackName + "/" + stackID, null, Stack.class);
+ }
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/CreateSnapshotParams.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/CreateSnapshotParams.java
new file mode 100644
index 000000000..e748f716b
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/CreateSnapshotParams.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "name"
+})
+public class CreateSnapshotParams {
+
+ @JsonProperty("name")
+ private String name;
+
+ /**
+ *
+ * @return
+ * The name
+ */
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ * @param name
+ * The name
+ */
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Data.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Data.java
new file mode 100644
index 000000000..6a984a4e6
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Data.java
@@ -0,0 +1,253 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "status",
+ "name",
+ "stack_user_project_id",
+ "environment",
+ "template",
+ "action",
+ "project_id",
+ "id",
+ "resources"
+})
+public class Data {
+
+ @JsonProperty("status")
+ private String status;
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("stack_user_project_id")
+ private String stackUserProjectId;
+ @JsonProperty("environment")
+ @Valid
+ private Environment environment;
+ @JsonProperty("template")
+ @Valid
+ private Template template;
+ @JsonProperty("action")
+ private String action;
+ @JsonProperty("project_id")
+ private String projectId;
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("resources")
+ @Valid
+ private Resources__ resources;
+
+ /**
+ *
+ * @return
+ * The status
+ */
+ @JsonProperty("status")
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ *
+ * @param status
+ * The status
+ */
+ @JsonProperty("status")
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ *
+ * @return
+ * The name
+ */
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ * @param name
+ * The name
+ */
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ * @return
+ * The stackUserProjectId
+ */
+ @JsonProperty("stack_user_project_id")
+ public String getStackUserProjectId() {
+ return stackUserProjectId;
+ }
+
+ /**
+ *
+ * @param stackUserProjectId
+ * The stack_user_project_id
+ */
+ @JsonProperty("stack_user_project_id")
+ public void setStackUserProjectId(String stackUserProjectId) {
+ this.stackUserProjectId = stackUserProjectId;
+ }
+
+ /**
+ *
+ * @return
+ * The environment
+ */
+ @JsonProperty("environment")
+ public Environment getEnvironment() {
+ return environment;
+ }
+
+ /**
+ *
+ * @param environment
+ * The environment
+ */
+ @JsonProperty("environment")
+ public void setEnvironment(Environment environment) {
+ this.environment = environment;
+ }
+
+ /**
+ *
+ * @return
+ * The template
+ */
+ @JsonProperty("template")
+ public Template getTemplate() {
+ return template;
+ }
+
+ /**
+ *
+ * @param template
+ * The template
+ */
+ @JsonProperty("template")
+ public void setTemplate(Template template) {
+ this.template = template;
+ }
+
+ /**
+ *
+ * @return
+ * The action
+ */
+ @JsonProperty("action")
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ *
+ * @param action
+ * The action
+ */
+ @JsonProperty("action")
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ /**
+ *
+ * @return
+ * The projectId
+ */
+ @JsonProperty("project_id")
+ public String getProjectId() {
+ return projectId;
+ }
+
+ /**
+ *
+ * @param projectId
+ * The project_id
+ */
+ @JsonProperty("project_id")
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ /**
+ *
+ * @return
+ * The id
+ */
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ * The id
+ */
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ * The resources
+ */
+ @JsonProperty("resources")
+ public Resources__ getResources() {
+ return resources;
+ }
+
+ /**
+ *
+ * @param resources
+ * The resources
+ */
+ @JsonProperty("resources")
+ public void setResources(Resources__ resources) {
+ this.resources = resources;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Environment.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Environment.java
new file mode 100644
index 000000000..94b7a1585
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Environment.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "parameters",
+ "resource_registry"
+})
+public class Environment {
+
+ @JsonProperty("parameters")
+ @Valid
+ private Parameters parameters;
+ @JsonProperty("resource_registry")
+ @Valid
+ private ResourceRegistry resourceRegistry;
+
+ /**
+ *
+ * @return
+ * The parameters
+ */
+ @JsonProperty("parameters")
+ public Parameters getParameters() {
+ return parameters;
+ }
+
+ /**
+ *
+ * @param parameters
+ * The parameters
+ */
+ @JsonProperty("parameters")
+ public void setParameters(Parameters parameters) {
+ this.parameters = parameters;
+ }
+
+ /**
+ *
+ * @return
+ * The resourceRegistry
+ */
+ @JsonProperty("resource_registry")
+ public ResourceRegistry getResourceRegistry() {
+ return resourceRegistry;
+ }
+
+ /**
+ *
+ * @param resourceRegistry
+ * The resource_registry
+ */
+ @JsonProperty("resource_registry")
+ public void setResourceRegistry(ResourceRegistry resourceRegistry) {
+ this.resourceRegistry = resourceRegistry;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Metadata.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Metadata.java
new file mode 100644
index 000000000..6b4aa00eb
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Metadata.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+
+})
+public class Metadata {
+
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Parameters.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Parameters.java
new file mode 100644
index 000000000..c46fded70
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Parameters.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+
+})
+public class Parameters {
+
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Properties.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Properties.java
new file mode 100644
index 000000000..026daac69
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Properties.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "size"
+})
+public class Properties {
+
+ @JsonProperty("size")
+ private int size;
+
+ /**
+ *
+ * @return
+ * The size
+ */
+ @JsonProperty("size")
+ public int getSize() {
+ return size;
+ }
+
+ /**
+ *
+ * @param size
+ * The size
+ */
+ @JsonProperty("size")
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceData.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceData.java
new file mode 100644
index 000000000..8e3910b2b
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceData.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "backup_id"
+})
+public class ResourceData {
+
+ @JsonProperty("backup_id")
+ private String backupId;
+
+ /**
+ *
+ * @return
+ * The backupId
+ */
+ @JsonProperty("backup_id")
+ public String getBackupId() {
+ return backupId;
+ }
+
+ /**
+ *
+ * @param backupId
+ * The backup_id
+ */
+ @JsonProperty("backup_id")
+ public void setBackupId(String backupId) {
+ this.backupId = backupId;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceRegistry.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceRegistry.java
new file mode 100644
index 000000000..799dc65b6
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/ResourceRegistry.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "resources"
+})
+public class ResourceRegistry {
+
+ @JsonProperty("resources")
+ @Valid
+ private Resources resources;
+
+ /**
+ *
+ * @return
+ * The resources
+ */
+ @JsonProperty("resources")
+ public Resources getResources() {
+ return resources;
+ }
+
+ /**
+ *
+ * @param resources
+ * The resources
+ */
+ @JsonProperty("resources")
+ public void setResources(Resources resources) {
+ this.resources = resources;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources.java
new file mode 100644
index 000000000..f8b2aeda2
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+
+})
+public class Resources {
+
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources_.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources_.java
new file mode 100644
index 000000000..3ac378aac
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources_.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "volume"
+})
+public class Resources_ {
+
+ @JsonProperty("volume")
+ @Valid
+ private Volume volume;
+
+ /**
+ *
+ * @return
+ * The volume
+ */
+ @JsonProperty("volume")
+ public Volume getVolume() {
+ return volume;
+ }
+
+ /**
+ *
+ * @param volume
+ * The volume
+ */
+ @JsonProperty("volume")
+ public void setVolume(Volume volume) {
+ this.volume = volume;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources__.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources__.java
new file mode 100644
index 000000000..2072cf68b
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Resources__.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "volume"
+})
+public class Resources__ {
+
+ @JsonProperty("volume")
+ @Valid
+ private Volume_ volume;
+
+ /**
+ *
+ * @return
+ * The volume
+ */
+ @JsonProperty("volume")
+ public Volume_ getVolume() {
+ return volume;
+ }
+
+ /**
+ *
+ * @param volume
+ * The volume
+ */
+ @JsonProperty("volume")
+ public void setVolume(Volume_ volume) {
+ this.volume = volume;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Snapshot.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Snapshot.java
new file mode 100644
index 000000000..47549fc60
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Snapshot.java
@@ -0,0 +1,182 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "id",
+ "name",
+ "status",
+ "status_reason",
+ "creation_time",
+ "data"
+})
+public class Snapshot {
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("status")
+ private String status;
+ @JsonProperty("status_reason")
+ private String statusReason;
+ @JsonProperty("creation_time")
+ private String creationTime;
+ @JsonProperty("data")
+ @Valid
+ private Data data;
+
+ /**
+ *
+ * @return
+ * The id
+ */
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ * The id
+ */
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ * The name
+ */
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ * @param name
+ * The name
+ */
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ * @return
+ * The status
+ */
+ @JsonProperty("status")
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ *
+ * @param status
+ * The status
+ */
+ @JsonProperty("status")
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ *
+ * @return
+ * The statusReason
+ */
+ @JsonProperty("status_reason")
+ public String getStatusReason() {
+ return statusReason;
+ }
+
+ /**
+ *
+ * @param statusReason
+ * The status_reason
+ */
+ @JsonProperty("status_reason")
+ public void setStatusReason(String statusReason) {
+ this.statusReason = statusReason;
+ }
+
+ /**
+ *
+ * @return
+ * The creationTime
+ */
+ @JsonProperty("creation_time")
+ public String getCreationTime() {
+ return creationTime;
+ }
+
+ /**
+ *
+ * @param creationTime
+ * The creation_time
+ */
+ @JsonProperty("creation_time")
+ public void setCreationTime(String creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ /**
+ *
+ * @return
+ * The data
+ */
+ @JsonProperty("data")
+ public Data getData() {
+ return data;
+ }
+
+ /**
+ *
+ * @param data
+ * The data
+ */
+ @JsonProperty("data")
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotDetails.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotDetails.java
new file mode 100644
index 000000000..b88e569ef
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotDetails.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "snapshot"
+})
+public class SnapshotDetails {
+
+ @JsonProperty("snapshot")
+ @Valid
+ private Snapshot snapshot;
+
+ /**
+ *
+ * @return
+ * The snapshot
+ */
+ @JsonProperty("snapshot")
+ public Snapshot getSnapshot() {
+ return snapshot;
+ }
+
+ /**
+ *
+ * @param snapshot
+ * The snapshot
+ */
+ @JsonProperty("snapshot")
+ public void setSnapshot(Snapshot snapshot) {
+ this.snapshot = snapshot;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java
new file mode 100644
index 000000000..8fa6e5272
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/SnapshotRestoreResponse.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "code",
+ "message",
+ "title"
+})
+public class SnapshotRestoreResponse {
+
+ @JsonProperty("code")
+ private String code;
+ @JsonProperty("message")
+ private String message;
+ @JsonProperty("title")
+ private String title;
+
+ /**
+ *
+ * @return
+ * The code
+ */
+ @JsonProperty("code")
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ *
+ * @param code
+ * The code
+ */
+ @JsonProperty("code")
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ /**
+ *
+ * @return
+ * The message
+ */
+ @JsonProperty("message")
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ *
+ * @param message
+ * The message
+ */
+ @JsonProperty("message")
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ *
+ * @return
+ * The title
+ */
+ @JsonProperty("title")
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ *
+ * @param title
+ * The title
+ */
+ @JsonProperty("title")
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Template.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Template.java
new file mode 100644
index 000000000..ef3aa473c
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Template.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "heat_template_version",
+ "resources"
+})
+public class Template {
+
+ @JsonProperty("heat_template_version")
+ private String heatTemplateVersion;
+ @JsonProperty("resources")
+ @Valid
+ private Resources_ resources;
+
+ /**
+ *
+ * @return
+ * The heatTemplateVersion
+ */
+ @JsonProperty("heat_template_version")
+ public String getHeatTemplateVersion() {
+ return heatTemplateVersion;
+ }
+
+ /**
+ *
+ * @param heatTemplateVersion
+ * The heat_template_version
+ */
+ @JsonProperty("heat_template_version")
+ public void setHeatTemplateVersion(String heatTemplateVersion) {
+ this.heatTemplateVersion = heatTemplateVersion;
+ }
+
+ /**
+ *
+ * @return
+ * The resources
+ */
+ @JsonProperty("resources")
+ public Resources_ getResources() {
+ return resources;
+ }
+
+ /**
+ *
+ * @param resources
+ * The resources
+ */
+ @JsonProperty("resources")
+ public void setResources(Resources_ resources) {
+ this.resources = resources;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume.java
new file mode 100644
index 000000000..26f4cd7e9
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "type",
+ "properties"
+})
+public class Volume {
+
+ @JsonProperty("type")
+ private String type;
+ @JsonProperty("properties")
+ @Valid
+ private Properties properties;
+
+ /**
+ *
+ * @return
+ * The type
+ */
+ @JsonProperty("type")
+ public String getType() {
+ return type;
+ }
+
+ /**
+ *
+ * @param type
+ * The type
+ */
+ @JsonProperty("type")
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ *
+ * @return
+ * The properties
+ */
+ @JsonProperty("properties")
+ public Properties getProperties() {
+ return properties;
+ }
+
+ /**
+ *
+ * @param properties
+ * The properties
+ */
+ @JsonProperty("properties")
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume_.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume_.java
new file mode 100644
index 000000000..f36808a0d
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/openstack/heat/model/Volume_.java
@@ -0,0 +1,206 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.openstack.heat.model;
+
+import javax.annotation.Generated;
+import javax.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@Generated("org.jsonschema2pojo")
+@JsonPropertyOrder({
+ "status",
+ "name",
+ "resource_data",
+ "resource_id",
+ "action",
+ "type",
+ "metadata"
+})
+public class Volume_ {
+
+ @JsonProperty("status")
+ private String status;
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("resource_data")
+ @Valid
+ private ResourceData resourceData;
+ @JsonProperty("resource_id")
+ private String resourceId;
+ @JsonProperty("action")
+ private String action;
+ @JsonProperty("type")
+ private String type;
+ @JsonProperty("metadata")
+ @Valid
+ private Metadata metadata;
+
+ /**
+ *
+ * @return
+ * The status
+ */
+ @JsonProperty("status")
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ *
+ * @param status
+ * The status
+ */
+ @JsonProperty("status")
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ *
+ * @return
+ * The name
+ */
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ /**
+ *
+ * @param name
+ * The name
+ */
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ * @return
+ * The resourceData
+ */
+ @JsonProperty("resource_data")
+ public ResourceData getResourceData() {
+ return resourceData;
+ }
+
+ /**
+ *
+ * @param resourceData
+ * The resource_data
+ */
+ @JsonProperty("resource_data")
+ public void setResourceData(ResourceData resourceData) {
+ this.resourceData = resourceData;
+ }
+
+ /**
+ *
+ * @return
+ * The resourceId
+ */
+ @JsonProperty("resource_id")
+ public String getResourceId() {
+ return resourceId;
+ }
+
+ /**
+ *
+ * @param resourceId
+ * The resource_id
+ */
+ @JsonProperty("resource_id")
+ public void setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ /**
+ *
+ * @return
+ * The action
+ */
+ @JsonProperty("action")
+ public String getAction() {
+ return action;
+ }
+
+ /**
+ *
+ * @param action
+ * The action
+ */
+ @JsonProperty("action")
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ /**
+ *
+ * @return
+ * The type
+ */
+ @JsonProperty("type")
+ public String getType() {
+ return type;
+ }
+
+ /**
+ *
+ * @param type
+ * The type
+ */
+ @JsonProperty("type")
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ *
+ * @return
+ * The metadata
+ */
+ @JsonProperty("metadata")
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ /**
+ *
+ * @param metadata
+ * The metadata
+ */
+ @JsonProperty("metadata")
+ public void setMetadata(Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this);
+ }
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/com/att/cdp/default.properties b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/com/att/cdp/default.properties
new file mode 100644
index 000000000..6a11d7214
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/com/att/cdp/default.properties
@@ -0,0 +1,158 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# Default Properties - Configured for integration of CDP into APPC
+#
+#--------------------------------------------------------------------------------------------
+# The path and file used to load configuration settings, if any
+com.att.cdp.bootstrap.path=${user.home},src/main/config,/etc/aft/scld/,/opt/app/aft/scld/etc/,/opt/app/aft/cdp/etc/,C:/Program Files/aft/scld/etc/,etc,../etc,.
+com.att.cdp.bootstrap.file=cdp.properties
+# com.att.cdp.system.admins=
+#
+# AFT properties for lat/long/environment and platform
+#
+AFT_LATITUDE=12.3456
+AFT_LONGITUDE=-12.3456
+AFT_ENVIRONMENT=AFT-ENVIRONMENT
+SCLD_PLATFORM=OPEN-SOURCE
+#
+# The versions of CDP API, CDP itself, and the build number
+#
+API_VERSION=${version}
+CDP_VERSION=${version}
+CDP_BUILD=${buildNumber}
+#
+# The path to search for logging configuration document, and the name of the document
+#
+com.att.cdp.logging.path=${user.home},src/main/config,etc,../etc,.
+com.att.cdp.logging.file=logback.xml
+#
+# The resource bundle base name to be loaded for message resources. This property can be a comma delimited list of resources to be
+# loaded, allowing multiple resource bundles to be loaded simultaneously (for the same locale).
+#
+com.att.cdp.resources=com/att/cdp/StrategyServiceMessages
+#
+# Logger names used in the application
+#
+com.att.cdp.logger=org.openecomp.appc
+com.att.cdp.security.logger=org.openecomp.appc.security
+com.att.cdp.perf.logger=org.openecomp.appc.perf
+com.att.cdp.gui.logger=org.openecomp.appc.gui
+com.att.cdp.server.logger=org.openecomp.appc.server
+com.att.cdp.coordinator.logger=org.openecomp.appc.coordinator
+com.att.cdp.policy.logger=org.openecomp.appc.policy
+
+#
+# This property allows to 'simulate' SSH processes within engine.
+# By default, it is set to 'false' - So that it allows to actually execute SSH process. If 'true', it will 'simulate' SSH processes
+#
+com.att.cdp.ssh.simulate=false
+#
+# These properties are used to specify the default stack metadata path and file names written and read on each server node
+#
+com.att.cdp.metadata.path=/etc/cdp/metadata
+com.att.cdp.metadata.export.filename=stack.xml
+com.att.cdp.metadata.import.filename=stack.xml
+#
+#Below properties are to specify minimum and maximum bootstrap time in minutes.
+#These properties are ONLY supposed to be used in tandem with SSH simulation.(testing purpose)
+com.att.cdp.ssh.simulate.minBootstrapTime=6
+com.att.cdp.ssh.simulate.maxBootstrapTime=12
+#
+#
+# These properties are used to configure the AAF security interface
+#
+# com.att.cdp.aaf.connection.url = dme2 url to connect to aaf service
+# com.att.cdp.aaf.connection.timeout = connection timeout, in seconds
+# com.att.cdp.aaf.cache.flush = cache flush interval in minutes
+# com.att.cdp.aaf.cache.size = the maximum number of cache entries
+# com.att.cdp.aaf.auth.principal = The principal id we use to authenticate ourself to AAF
+# com.att.cdp.aaf.auth.credentials = The credentials (password) we use to authenticate ourself to AAF
+#
+com.att.cdp.aaf.connection.url=https://DME2SITE/service=com.att.authz.AuthorizationService/version=2.0/envContext=TEST/routeOffer=BAU_SE
+com.att.cdp.aaf.connection.timeout=10
+com.att.cdp.aaf.cache.flush=5
+com.att.cdp.aaf.cache.size=400
+com.att.cdp.aaf.auth.principal=emailaddress@example.com
+com.att.cdp.aaf.auth.credentials=MyPassw0rd
+#
+# ----------------------------------------------------------------------------------------------------
+# These properties are used to configure the operation of the StackBuilder engine
+#
+# maximum number of build manager threads in the thread pool
+com.att.cdp.engine.maxManagerPool=30
+# max number of worker threads in the pool for use by workers
+com.att.cdp.engine.MaxWorkerPool=300
+
+# max number of workers that can be created per build request (set to 1 to single-thread a build)
+com.att.cdp.engine.maxWorkers=10
+# Maximum amount of time to wait for a provider to complete any requested operation, in minutes. Such
+# as creating a server or a volume.
+com.att.cdp.engine.maxWaitTime=15
+#
+# ----------------------------------------------------------------------------------------------------
+# These properties are used to configure the managed node hostname generation/resolution process
+#
+com.att.cdp.managed.hostname.resolve.retry=3
+# ----------------------------------------------------------------------------------------------------
+#
+# Cassandra Connection Configuration Properties
+#
+cassandra.userName=cassandra
+cassandra.password=cassandra
+#cassandra.dataCenter=
+cassandra.hosts=127.0.0.1
+cassandra.port=9042
+cassandra.keyspace=cdp
+cassandra.minPoolSize=8
+cassandra.maxPoolSize=8
+cassandra.readtimeout=180000
+#
+# Cassandra data Migration toggle
+com.att.cdp.db.migration=true
+com.att.cdp.db.update=true
+
+#Default Values for Image Attributes Configuration.These SHOULD NOT be removed.
+image.default.namepattern=.*
+image.default.user=root
+image.default.sudo=false
+
+# ----------------------------------------------------------------------------------------------------
+#
+# The path OSSupport will search for OS configuration properties files
+#
+com.att.cdp.OSType.path=/etc/os/
+# ----------------------------------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------------------------------
+#
+# The properties used in ConnectivityBuilder
+internet_url=www.google.com
+ubuntu_sat_access_url=example.com
+grm_server_url=example.com
+#
+# ----------------------------------------------------------------------------------------------------
+com.att.cdp.ptr.cleanup=true
+
+# ----------------------------------------------------------------------------------------------------
+# The maximum amount of time in seconds that we should wait for input from the shell
+com.att.cdp.ssh.timeout=1800
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..259cc1ba7
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,102 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# 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.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.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.openecomp.appc.provider.min.pool=1
+org.openecomp.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.openecomp.appc.provider.retry.delay = 30
+org.openecomp.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.openecomp.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.openecomp.appc.openstack.poll.interval=20
+
+ #
+ #The amount of time, in seconds, that the application waits for a change of state of a stacj to a known valid
+ #sate before giving up and failing the request.
+ #
+org.openecomp.appc.stack.state.change.timeout=100
+
+
+
+#
+# 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-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java
new file mode 100644
index 000000000..4f797f859
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestIdentityUrl.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.IdentityURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+public class TestIdentityUrl {
+
+ private static String URL;
+
+ @BeforeClass
+ public static void before() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ URL = props.getProperty("");
+ }
+
+ /**
+ * Test that we can parse and interpret valid URLs
+ */
+ @Test
+ public void testValidURLs() {
+ URL = "http://192.168.1.1:5000/v2.0/";
+ IdentityURL idurl = IdentityURL.parseURL(URL);
+ assertNotNull(idurl);
+ System.out.println(idurl.getVersion());
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
new file mode 100644
index 000000000..d83c18b04
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImpl.java
@@ -0,0 +1,943 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+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.junit.experimental.categories.Category;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.iaas.ProviderAdapter;
+import org.openecomp.appc.adapter.iaas.impl.ProviderAdapterImpl;
+import org.openecomp.appc.adapter.iaas.impl.ProviderCache;
+import org.openecomp.appc.adapter.iaas.impl.ServiceCatalog;
+import org.openecomp.appc.adapter.iaas.impl.TenantCache;
+import org.openecomp.appc.adapter.iaas.impl.VMURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ContextFactory;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Server.Status;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
+
+/**
+ * Test the ProviderAdapter implementation.
+ */
+@Category(org.openecomp.appc.adapter.iaas.impl.TestProviderAdapterImpl.class)
+public class TestProviderAdapterImpl {
+
+ @SuppressWarnings("nls")
+ private static final String PROVIDER_NAME = "ILAB";
+
+ @SuppressWarnings("nls")
+ private static final String PROVIDER_TYPE = "OpenStackProvider";
+
+ private static String IDENTITY_URL;
+
+ private static String PRINCIPAL;
+
+ private static String CREDENTIAL;
+
+ private static String TENANT_NAME;
+
+ private static String TENANT_ID;
+
+ private static String USER_ID;
+
+ private static String REGION_NAME;
+
+ private static String SERVER_URL;
+
+ private static Class<?> providerAdapterImplClass;
+ private static Class<?> configurationFactoryClass;
+ private static Field providerCacheField;
+ private static Field configField;
+
+ private ProviderAdapterImpl adapter;
+
+ /**
+ * Use reflection to locate fields and methods so that they can be manipulated during the test to change the
+ * internal state accordingly.
+ *
+ * @throws NoSuchFieldException
+ * if the field(s) dont exist
+ * @throws SecurityException
+ * if reflective access is not allowed
+ * @throws NoSuchMethodException
+ * If the method(s) dont exist
+ */
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+ providerAdapterImplClass = ProviderAdapterImpl.class;
+ configurationFactoryClass = ConfigurationFactory.class;
+
+ providerCacheField = providerAdapterImplClass.getDeclaredField("providerCache");
+ providerCacheField.setAccessible(true);
+
+ configField = configurationFactoryClass.getDeclaredField("config");
+ configField.setAccessible(true);
+
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ IDENTITY_URL = props.getProperty("provider1.identity");
+ PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");
+ CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");
+ TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");
+ TENANT_ID = props.getProperty("provider1.tenant1.id", "abcde12345fghijk6789lmnopq123rst");
+ REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");
+ SERVER_URL = props.getProperty("test.url");
+ }
+
+ /**
+ * Setup the test environment.
+ *
+ * @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.
+ * @throws NullPointerException
+ * if the specified object is null and the field is an instance field.
+ * @throws ExceptionInInitializerError
+ * if the initialization provoked by this method fails.
+ */
+ @Before
+ public void setup() throws IllegalArgumentException, IllegalAccessException {
+ configField.set(null, null);
+ Properties properties = new Properties();
+ adapter = new ProviderAdapterImpl(properties);
+ }
+
+ /**
+ * This method inspects the provider adapter implementation to make sure that the cache of providers and tenants, as
+ * well as the service catalog, and all pools of contexts have been set up correctly.
+ *
+ * @throws IllegalAccessException
+ * if this Field object is enforcing Java language access control and the underlying field is
+ * inaccessible.
+ * @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).
+ */
+ @SuppressWarnings({
+ "unchecked"
+ })
+ @Ignore
+ @Test
+ public void validateCacheIsCreatedCorrectly() throws IllegalArgumentException, IllegalAccessException {
+ Map<String, ProviderCache> providerCaches = (Map<String, ProviderCache>) providerCacheField.get(adapter);
+
+ assertNotNull(providerCaches);
+ assertEquals(1, providerCaches.size());
+ assertTrue(providerCaches.containsKey(PROVIDER_NAME));
+
+ ProviderCache providerCache = providerCaches.get(PROVIDER_NAME);
+ assertEquals(PROVIDER_NAME, providerCache.getProviderName());
+ assertEquals(PROVIDER_TYPE, providerCache.getProviderType());
+
+ Map<String, TenantCache> tenantCaches = providerCache.getTenants();
+ assertNotNull(tenantCaches);
+ assertEquals(1, tenantCaches.size());
+ assertTrue(tenantCaches.containsKey(TENANT_NAME));
+
+ TenantCache tenantCache = tenantCaches.get(TENANT_NAME);
+
+ assertEquals(TENANT_ID, tenantCache.getTenantId());
+ assertEquals(TENANT_NAME, tenantCache.getTenantName());
+ assertEquals(USER_ID, tenantCache.getUserid());
+
+ ServiceCatalog catalog = tenantCache.getServiceCatalog();
+ assertNotNull(catalog);
+
+ System.out.println(catalog.toString());
+ List<String> serviceTypes = catalog.getServiceTypes();
+ assertNotNull(serviceTypes);
+ assertEquals(12, serviceTypes.size());
+
+ assertEquals(TENANT_NAME, catalog.getTenantName());
+ assertEquals(TENANT_ID, catalog.getTenantId());
+
+ Set<String> regionNames = catalog.getRegions();
+ assertNotNull(regionNames);
+ assertEquals(1, regionNames.size());
+ assertTrue(regionNames.contains(REGION_NAME));
+
+ List<Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.IDENTITY_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ Endpoint endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+ assertEquals(IDENTITY_URL, endpoint.getPublicURL());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.VOLUME_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.IMAGE_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ endpoints = catalog.getEndpoints(ServiceCatalog.NETWORK_SERVICE);
+ assertNotNull(endpoints);
+ assertEquals(1, endpoints.size());
+ endpoint = endpoints.get(0);
+ assertNotNull(endpoint);
+ assertEquals(REGION_NAME, endpoint.getRegion());
+
+ assertTrue(catalog.isServicePublished(ServiceCatalog.IDENTITY_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.COMPUTE_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.VOLUME_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.IMAGE_SERVICE));
+ assertTrue(catalog.isServicePublished(ServiceCatalog.NETWORK_SERVICE));
+ }
+
+ /**
+ * This test case is used to actually validate that a server has been restarted from an already running state
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ */
+ // @Ignore
+ @Test
+ public void testRestartRunningServer()
+ throws IllegalStateException, IllegalArgumentException, ZoneException, UnknownProviderException, IOException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+ properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ if (!server.getStatus().equals(Status.RUNNING)) {
+ server.start();
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.restartServer(params, svcContext);
+
+ assertEquals(Server.Status.RUNNING, server.getStatus());
+ }
+ }
+
+
+ /****************************************/
+ /**
+ * Tests that the vmStatuschecker method works and returns the correct status of the VM requested
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ */
+ // @Ignore
+ @Test
+ public void testVmStatuschecker() throws IllegalStateException, IllegalArgumentException, ZoneException,
+ UnknownProviderException, IOException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+ properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ if (!server.getStatus().equals(Status.RUNNING)) {
+ server.start();
+ assertTrue(waitForStateChange(server, Status.RUNNING));}
+ //or instead of the if-block, can ensureRunning(server) be used?
+ ensureRunning(server);
+ assertEquals(Server.Status.RUNNING, server.getStatus());
+ }
+ }
+ /****************************************/
+
+
+ /**
+ * Tests that we can restart a server that is already stopped
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ */
+ // @Ignore
+ @Test
+ public void testRestartStoppedServer()
+ throws IllegalStateException, IllegalArgumentException, ZoneException, UnknownProviderException, IOException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ if (!server.getStatus().equals(Status.READY)) {
+ server.stop();
+ assertTrue(waitForStateChange(server, Status.READY));
+ }
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.restartServer(params, svcContext);
+
+ assertEquals(Server.Status.RUNNING, server.getStatus());
+
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a running server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildRunningServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensureRunning(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a paused server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildPausedServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensurePaused(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a paused server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildSuspendedServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensureSuspended(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+ }
+
+ /**
+ * Tests that we can rebuild a paused server (not created from a bootable volume)
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid.
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws UnknownProviderException
+ * If the provider cannot be found
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ * If the server cannot be rebuilt for some reason
+ */
+ // @Ignore
+ @Test
+ public void testRebuildStoppedServer()
+ throws IOException, IllegalStateException, IllegalArgumentException, ZoneException, APPCException {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login(PRINCIPAL, CREDENTIAL);
+ VMURL vm = VMURL.parseURL(SERVER_URL);
+
+ ComputeService computeService = context.getComputeService();
+ Server server = computeService.getServer(vm.getServerId());
+ ensureStopped(server);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL);
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, PROVIDER_NAME);
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ server = adapter.rebuildServer(params, svcContext);
+ assertTrue(waitForStateChange(server, Status.RUNNING));
+ }
+ }
+
+ /**
+ * Test subsequent action on second vm in different Tenant resulting in {"itemNotFound": {"message": "Instance could not be found", "code": 404}}
+ *
+ * @throws ZoneException
+ * If the login cannot be performed because the principal and/or credentials are invalid.
+ * @throws IllegalArgumentException
+ * If the principal and/or credential are null or empty, or if the expected argument(s) are not defined
+ * or are invalid
+ * @throws IllegalStateException
+ * If the identity service is not available or cannot be created
+ * @throws IOException
+ * if an I/O error occurs
+ * @throws APPCException
+ */
+
+ @Test
+ public void testTenantVerification() throws IllegalStateException, IllegalArgumentException, ZoneException,
+ IOException, APPCException {
+
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, "http://example.com:5000");
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, "APP-C");
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ String vmUrl =
+ "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+
+ //try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ // context.login("AppC", "AppC");
+
+ // call lookupServer on vm in defined tenant "APP-C_TLV"
+ VMURL vm = VMURL.parseURL(vmUrl);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+ params.put(ProviderAdapter.PROPERTY_IDENTITY_URL, "http://example.com:5000/v2.0");
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, "http://example.com:5000/v2.0");
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ long start, end = 0;
+
+ System.out.println("\n--------------------Begin lookupServer on tenant 1--------------------");
+ start = System.currentTimeMillis();
+ Server server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+
+ System.out.println(String.format("lookupServer on tenant 1 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNotNull(server);
+
+ //repeat to show that context is reused for second request
+ System.out.println("\n-----------------Begin repeat lookupServer on tenant 1----------------");
+ start = System.currentTimeMillis();
+ server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+
+ System.out.println(String.format("Repeat lookupServer on tenant 1 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNotNull(server);
+
+ // call lookupServer on vm in second tenant "Play"
+ // This is where we would fail due to using the previous
+ // tenants context
+ vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+ vm = VMURL.parseURL(vmUrl);
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+
+ System.out.println("\n--------------------Begin lookupServer on tenant 2--------------------");
+ start = System.currentTimeMillis();
+ server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+ System.out.println(String.format("\nlookupServer on tenant 2 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNotNull(server);
+
+ // call lookupServer on vm in non-existing tenant
+ vmUrl = "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+ vm = VMURL.parseURL(vmUrl);
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+
+ System.out.println("\n--------------Begin lookupServer on non-existant tenant--------------");
+ start = System.currentTimeMillis();
+ server = adapter.lookupServer(params, svcContext);
+ end = System.currentTimeMillis();
+ System.out.println(String.format("\nlookupServer on tenant 3 took %ds", (end - start) / 1000));
+ System.out.println("----------------------------------------------------------------------\n");
+ assertNull(server);
+
+ //}
+ }
+ /****************************************/
+
+
+ @Test
+ public void testSnapshotServer() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, "http://example.com:5000");
+ // properties.setProperty(ContextFactory.PROPERTY_REGION, "");
+ properties.setProperty(ContextFactory.PROPERTY_TENANT, "Play");
+ properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+
+ String vmUrl =
+ "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+
+ try (Context context = ContextFactory.getContext(PROVIDER_TYPE, properties)) {
+ context.login("AppC", "AppC");
+ VMURL vm = VMURL.parseURL(vmUrl);
+
+ Map<String, String> params = new HashMap<>();
+ params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, vmUrl);
+ params.put(ProviderAdapter.PROPERTY_IDENTITY_URL, "http://example.com:5000/v2.0");
+ params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME, "http://example.com:5000/v2.0");
+ SvcLogicContext svcContext = new SvcLogicContext();
+
+ long start, end = 0;
+
+ start = System.currentTimeMillis();
+ Image image = adapter.createSnapshot(params, svcContext);
+ end = System.currentTimeMillis();
+
+ System.out.println(String.format("Image ID: %s", image.getId()));
+ System.out.println(String.format("Snapshot took %ds", (end - start) / 1000));
+
+ start = System.currentTimeMillis();
+ adapter.rebuildServer(params, svcContext);
+ end = System.currentTimeMillis();
+ System.out.println(String.format("Rebuild took %ds", (end - start) / 1000));
+ }
+
+ }
+
+ /**
+ * Ensures that the server is in stopped (shutdown) state prior to test
+ *
+ * @param server
+ * The server to ensure is stopped
+ * @throws ZoneException
+ * If the server can't be operated upon for some reason
+ */
+ @SuppressWarnings("nls")
+ private static void ensureStopped(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case READY:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensureSuspended(server);
+ break;
+
+ case PAUSED:
+ server.unpause();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.stop();
+ waitForStateChange(server, Server.Status.READY);
+ break;
+
+ case SUSPENDED:
+ server.resume();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.stop();
+ waitForStateChange(server, Server.Status.READY);
+ break;
+
+ case RUNNING:
+ server.stop();
+ waitForStateChange(server, Server.Status.READY);
+ break;
+
+ case DELETED:
+ case ERROR:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * Ensures that the server is in suspended state prior to test
+ *
+ * @param server
+ * The server to ensure is suspended
+ * @throws ZoneException
+ * If the server can't be operated upon for some reason
+ */
+ @SuppressWarnings("nls")
+ private static void ensureSuspended(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case SUSPENDED:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensureSuspended(server);
+ break;
+
+ case PAUSED:
+ server.unpause();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.suspend();
+ waitForStateChange(server, Server.Status.SUSPENDED);
+ break;
+
+ case READY:
+ server.start();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.suspend();
+ waitForStateChange(server, Server.Status.SUSPENDED);
+ break;
+
+ case RUNNING:
+ server.suspend();
+ waitForStateChange(server, Server.Status.SUSPENDED);
+ break;
+
+ case DELETED:
+ case ERROR:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * This method makes sure that the indicated server is running before performing a test
+ *
+ * @param server
+ * The server to ensure is running
+ * @throws ZoneException
+ * If the server can't be operated upon
+ */
+ @SuppressWarnings("nls")
+ private static void ensureRunning(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case RUNNING:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensureRunning(server);
+ break;
+
+ case PAUSED:
+ server.unpause();
+ waitForStateChange(server, Server.Status.RUNNING);
+ break;
+
+ case SUSPENDED:
+ server.resume();
+ waitForStateChange(server, Server.Status.RUNNING);
+ break;
+
+ case READY:
+ server.start();
+ waitForStateChange(server, Server.Status.RUNNING);
+ break;
+
+ case DELETED:
+ case ERROR:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * This method will make sure that the server we are testing is paused
+ *
+ * @param server
+ * The server to make sure is paused for the test
+ * @throws ZoneException
+ * If anything fails
+ */
+ @SuppressWarnings("nls")
+ private static void ensurePaused(Server server) throws ZoneException {
+ switch (server.getStatus()) {
+ case PAUSED:
+ break;
+
+ case PENDING:
+ waitForStateChange(server, Server.Status.READY, Server.Status.RUNNING, Server.Status.PAUSED,
+ Server.Status.SUSPENDED, Server.Status.ERROR);
+ ensurePaused(server);
+ break;
+
+ case READY:
+ server.start();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.pause();
+ waitForStateChange(server, Server.Status.PAUSED);
+ break;
+
+ case RUNNING:
+ server.pause();
+ waitForStateChange(server, Server.Status.PAUSED);
+ break;
+
+ case SUSPENDED:
+ server.resume();
+ waitForStateChange(server, Server.Status.RUNNING);
+ server.pause();
+ waitForStateChange(server, Server.Status.PAUSED);
+ break;
+
+ case ERROR:
+ case DELETED:
+ default:
+ fail("Server state is not valid for test - " + server.getStatus().name());
+ }
+ }
+
+ /**
+ * Enter a pool-wait loop checking the server state to see if it has entered one of the desired states or not.
+ * <p>
+ * This method checks the state of the server periodically for one of the desired states. When the server enters one
+ * of the desired states, the method returns a successful indication (true). If the server never enters one of the
+ * desired states within the alloted timeout period, then the method returns a failed response (false). No
+ * exceptions are thrown from this method.
+ * </p>
+ *
+ * @param server
+ * The server to wait on
+ * @param desiredStates
+ * A variable list of desired states, any one of which is allowed.
+ * @return True if the server entered one of the desired states, and false if not and the wait loop timed out.
+ */
+ private static boolean waitForStateChange(Server server, Server.Status... desiredStates) {
+ int timeout =
+ ConfigurationFactory.getConfiguration().getIntegerProperty(Constants.PROPERTY_SERVER_STATE_CHANGE_TIMEOUT);
+ long limit = System.currentTimeMillis() + (timeout * 1000);
+ Server vm = server;
+
+ try {
+ while (limit > System.currentTimeMillis()) {
+ vm.refresh();
+ for (Server.Status desiredState : desiredStates) {
+ if (server.getStatus().equals(desiredState)) {
+ return true;
+ }
+ }
+
+ try {
+ Thread.sleep(10000L);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ } catch (ZoneException e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+
+ /*
+ * @Test public void testTerminateStack() throws IllegalStateException, IllegalArgumentException, ZoneException,
+ * UnknownProviderException, IOException { Properties properties = new Properties();
+ * properties.setProperty(ContextFactory.PROPERTY_IDENTITY_URL, IDENTITY_URL);
+ * properties.setProperty(ContextFactory.PROPERTY_REGION, REGION_NAME);
+ * properties.setProperty(ContextFactory.PROPERTY_TENANT, TENANT_NAME);
+ * properties.setProperty(ContextFactory.PROPERTY_TRUSTED_HOSTS, "*");
+ * properties.setProperty(ContextFactory.PROPERTY_DISABLE_PROXY, "true"); try (Context context =
+ * ContextFactory.getContext(PROVIDER_TYPE, properties)) { context.login(PRINCIPAL, CREDENTIAL); VMURL vm =
+ * VMURL.parseURL(SERVER_URL); ComputeService computeService = context.getComputeService(); Server server =
+ * computeService.getServer(vm.getServerId()); if (!server.getStatus().equals(Status.RUNNING)) { server.start();
+ * assertTrue(waitForStateChange(server, Status.RUNNING)); } Map<String, String> params = new HashMap<>();
+ * params.put(ProviderAdapter.PROPERTY_INSTANCE_URL, SERVER_URL); params.put(ProviderAdapter.PROPERTY_PROVIDER_NAME,
+ * PROVIDER_NAME); SvcLogicContext svcContext = new SvcLogicContext(); Stack stack = adapter.terminateStack(params,
+ * svcContext); assertNotNull(stack); } }
+ */
+
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java
new file mode 100644
index 000000000..d4683aa80
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestProviderAdapterImplNoConnection.java
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import java.lang.reflect.Field;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.ProviderAdapterImpl;
+import org.openecomp.appc.adapter.iaas.impl.RequestContext;
+import org.openecomp.appc.adapter.iaas.impl.RequestFailedException;
+import org.openecomp.appc.adapter.iaas.impl.VMURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.slf4j.MDC;
+
+/**
+ * This class is used to test methods and functions of the adapter implementation that do not require and do not set up
+ * connections to any providers.
+ */
+
+public class TestProviderAdapterImplNoConnection {
+
+ private static Class<?> providerAdapterImplClass;
+ private static Class<?> configurationFactoryClass;
+ private static Field providerCacheField;
+ private static Field configField;
+
+ private ProviderAdapterImpl adapter;
+
+ /**
+ * Use reflection to locate fields and methods so that they can be manipulated during the test to change the
+ * internal state accordingly.
+ *
+ * @throws NoSuchFieldException
+ * if the field(s) dont exist
+ * @throws SecurityException
+ * if reflective access is not allowed
+ * @throws NoSuchMethodException
+ * If the method(s) dont exist
+ */
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+ providerAdapterImplClass = ProviderAdapterImpl.class;
+ configurationFactoryClass = ConfigurationFactory.class;
+
+ providerCacheField = providerAdapterImplClass.getDeclaredField("providerCache");
+ providerCacheField.setAccessible(true);
+
+ configField = configurationFactoryClass.getDeclaredField("config");
+ configField.setAccessible(true);
+ }
+
+ /**
+ * initialize the test cases
+ */
+ @Before
+ public void setup() {
+ adapter = new ProviderAdapterImpl(false);
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is a null URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailNullValue() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = null;
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is an empty URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailEmptyValue() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = "";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is a blank URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailBlankValue() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = " ";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects a failure because the value to be validated is a bad URL
+ *
+ * @throws RequestFailedException
+ * Expected
+ */
+ @SuppressWarnings("nls")
+ @Test(expected = RequestFailedException.class)
+ public void testValidateParameterPatternExpectFailBadURL() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link = "http://some.host:1234/01d82c08594a4b23a0f9260c94be0c4d/";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+
+ /**
+ * This test expects to pass
+ *
+ * @throws RequestFailedException
+ * Un-Expected
+ */
+ @SuppressWarnings("nls")
+ @Test
+ public void testValidateParameterPatternValidURL() throws RequestFailedException {
+ MDC.put(ProviderAdapterImpl.MDC_SERVICE, "junit");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ RequestContext rc = new RequestContext(svcContext);
+ String link =
+ "http://some.host:1234/v2/01d82c08594a4b23a0f9260c94be0c4d/servers/f888f89f-096b-421e-ba36-34f714071551";
+
+ adapter.validateVMURL(VMURL.parseURL(link));
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java
new file mode 100644
index 000000000..a7cc5dc3c
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestRequestContext.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.iaas.impl.RequestContext;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+/**
+ * Test the RequestContext object
+ * <p>
+ * The request context is used to track retries, recovery attempts, and time to live of the processing of a request.
+ * </p>
+ */
+
+public class TestRequestContext {
+
+ private RequestContext rc;
+ private Configuration config = ConfigurationFactory.getConfiguration();
+
+ /**
+ * Set up the test environment by forcing the retry delay and limit to small values for the test and setting up the
+ * request context object.
+ */
+ @Before
+ public void setup() {
+ config.setProperty(Constants.PROPERTY_RETRY_DELAY, "1");
+ config.setProperty(Constants.PROPERTY_RETRY_LIMIT, "3");
+ rc = new RequestContext(null);
+ rc.setTimeToLiveSeconds(2);
+ }
+
+ /**
+ * Ensure that we set up the property correctly
+ */
+ @Test
+ public void testRetryDelayProperty() {
+ assertEquals(1, rc.getRetryDelay());
+ }
+
+ /**
+ * Ensure that we set up the property correctly
+ */
+ @Test
+ public void testRetryLimitProperty() {
+ assertEquals(3, rc.getRetryLimit());
+ }
+
+ /**
+ * This test ensures that the retry attempt counter is zero on a new context
+ */
+ @Test
+ public void testRetryCountNoRetries() {
+ assertEquals(0, rc.getAttempts());
+ }
+
+ /**
+ * Test that the delay is accurate
+ */
+ @Test
+ public void testDelay() {
+ long future = System.currentTimeMillis() + (rc.getRetryDelay() * 1000L);
+
+ rc.delay();
+
+ assertTrue(System.currentTimeMillis() >= future);
+ }
+
+ /**
+ * The RequestContext tracks the number of retry attempts against the limit. This test verifies that tracking logic
+ * works correctly.
+ */
+ @Test
+ public void testCanRetry() {
+ assertEquals(0, rc.getAttempts());
+ assertTrue(rc.attempt());
+ assertEquals(1, rc.getAttempts());
+ assertTrue(rc.attempt());
+ assertEquals(2, rc.getAttempts());
+ assertTrue(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ assertFalse(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ assertFalse(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ assertFalse(rc.attempt());
+ assertEquals(3, rc.getAttempts());
+ }
+
+ /**
+ * The same RequestContext is used throughout the processing, and retries need to be reset once successfully
+ * connected so that any earlier (successful) recoveries are not considered when performing any new future
+ * recoveries. This test ensures that a reset clears the retry counter and that we can attempt retries again up to
+ * the limit.
+ */
+ @Test
+ public void testResetAndCanRetry() {
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ rc.reset();
+
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ assertTrue(rc.attempt());
+ assertFalse(rc.attempt());
+ assertFalse(rc.attempt());
+ assertFalse(rc.attempt());
+ }
+
+ /**
+ * This test is used to test tracking of time to live for the request context. Because time is inexact, the
+ * assertions can only be ranges of values, such as at least some value or greater. The total duration tracking in
+ * the request context is only updated on each call to {@link RequestContext#isAlive()}. Also, durations are NOT
+ * affected by calls to reset.
+ */
+ @Test
+ public void testTimeToLive() {
+ assertTrue(rc.getTotalDuration() == 0L);
+ assertTrue(rc.isAlive());
+ rc.reset();
+ rc.delay();
+ assertTrue(rc.isAlive());
+ assertTrue(rc.getTotalDuration() >= 1000L);
+ rc.reset();
+ rc.delay();
+ rc.isAlive();
+ assertTrue(rc.getTotalDuration() >= 2000L);
+ rc.reset();
+ rc.delay();
+ assertFalse(rc.isAlive());
+ assertTrue(rc.getTotalDuration() >= 3000L);
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java
new file mode 100644
index 000000000..ac8cde31a
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.iaas.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.List;
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.ServiceCatalog;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import com.att.cdp.exceptions.ZoneException;
+
+import com.woorea.openstack.keystone.model.Access.Service;
+
+/**
+ * This class tests the service catalog against a known provider.
+ */
+@Ignore
+public class TestServiceCatalog {
+
+ // Number
+ private static int EXPECTED_REGIONS = 1;
+ private static int EXPECTED_ENDPOINTS = 1;
+
+ private static String PRINCIPAL;
+ private static String CREDENTIAL;
+ private static String TENANT_NAME;
+ private static String TENANT_ID;
+ private static String IDENTITY_URL;
+ private static String REGION_NAME;
+
+ private ServiceCatalog catalog;
+
+ private Properties properties;
+
+ @BeforeClass
+ public static void before() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ IDENTITY_URL = props.getProperty("provider1.identity");
+ PRINCIPAL = props.getProperty("provider1.tenant1.userid", "appc");
+ CREDENTIAL = props.getProperty("provider1.tenant1.password", "appc");
+ TENANT_NAME = props.getProperty("provider1.tenant1.name", "appc");
+ TENANT_ID =
+ props.getProperty("provider1.tenant1.id",
+ props.getProperty("test.tenantid", "abcde12345fghijk6789lmnopq123rst"));
+ REGION_NAME = props.getProperty("provider1.tenant1.region", "RegionOne");
+
+ EXPECTED_REGIONS = Integer.valueOf(props.getProperty("test.expected-regions", "0"));
+ EXPECTED_ENDPOINTS = Integer.valueOf(props.getProperty("test.expected-endpoints", "0"));
+ }
+
+ /**
+ * Setup the test environment by loading a new service catalog for each test
+ *
+ * @throws ZoneException
+ */
+ @Before
+ public void setup() throws ZoneException {
+ properties = new Properties();
+ catalog = new ServiceCatalog(IDENTITY_URL, TENANT_NAME, PRINCIPAL, CREDENTIAL, properties);
+ }
+
+ /**
+ * Test that the tenant name and ID are returned correctly
+ */
+ @Test
+ public void testKnownTenant() {
+ assertEquals(TENANT_NAME, catalog.getTenantName());
+ assertEquals(TENANT_ID, catalog.getTenantId());
+ }
+
+ /**
+ * Test that we find all of the expected region(s)
+ */
+ @Test
+ public void testKnownRegions() {
+ assertEquals(EXPECTED_REGIONS, catalog.getRegions().size());
+ // assertEquals(REGION_NAME, catalog.getRegions().toArray()[0]);
+ }
+
+ /**
+ * Test that we can check for published services correctly
+ */
+ @Test
+ public void testServiceTypesPublished() {
+ assertTrue(catalog.isServicePublished("compute"));
+ assertFalse(catalog.isServicePublished("bogus"));
+ }
+
+ /**
+ * Check that we can get the list of published services
+ */
+ @Test
+ public void testPublishedServicesList() {
+ List<String> services = catalog.getServiceTypes();
+
+ assertTrue(services.contains(ServiceCatalog.COMPUTE_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.IDENTITY_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.IMAGE_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.NETWORK_SERVICE));
+ assertTrue(services.contains(ServiceCatalog.VOLUME_SERVICE));
+ }
+
+ /**
+ * Test that we can get the endpoint(s) for a service
+ */
+ @Test
+ public void testEndpointList() {
+ List<Service.Endpoint> endpoints = catalog.getEndpoints(ServiceCatalog.COMPUTE_SERVICE);
+
+ assertNotNull(endpoints);
+ assertFalse(endpoints.isEmpty());
+ assertEquals(EXPECTED_ENDPOINTS, endpoints.size());
+
+ Service.Endpoint endpoint = endpoints.get(0);
+ // assertEquals(REGION_NAME, endpoint.getRegion());
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
new file mode 100644
index 000000000..852bb4137
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
@@ -0,0 +1,107 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.iaas.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.Properties;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openecomp.appc.adapter.iaas.impl.VMURL;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+public class TestVMURL {
+
+ private static String IP;
+ private static String PORT;
+ private static String TENANTID;
+ private static String VMID;
+ private static String URL;
+
+ @BeforeClass
+ public static void before() {
+ Properties props = ConfigurationFactory.getConfiguration().getProperties();
+ IP = props.getProperty("test.ip");
+ PORT = props.getProperty("test.port");
+ TENANTID = props.getProperty("test.tenantid");
+ VMID = props.getProperty("test.vmid");
+ URL = String.format("http://%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID);
+ }
+
+ /**
+ * Test that we can parse and interpret valid URLs
+ */
+ @Test
+ public void testValidURLs() {
+ VMURL url = VMURL.parseURL(URL);
+
+ assertEquals("http", url.getScheme());
+ assertEquals(IP, url.getHost());
+ assertEquals(PORT, url.getPort());
+ assertEquals(TENANTID, url.getTenantId());
+ assertEquals(VMID, url.getServerId());
+
+ url = VMURL.parseURL(String.format("http://%s/v2/%s/servers/%s", IP, TENANTID, VMID));
+ assertEquals("http", url.getScheme());
+ assertEquals(IP, url.getHost());
+ assertNull(url.getPort());
+ assertEquals(TENANTID, url.getTenantId());
+ assertEquals(VMID, url.getServerId());
+ }
+
+ /**
+ * Test that we ignore and return null for invalid URLs
+ */
+ @Test
+ public void testInvalidURLs() {
+ VMURL url = VMURL.parseURL(null);
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("http:/%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("http:///%s:%s/v2/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("http://v2/%s/servers/%s", TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/%s/servers/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/servers/%s", IP, PORT, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/%s/%s", IP, PORT, TENANTID, VMID));
+ assertNull(url);
+
+ url = VMURL.parseURL(String.format("%s:%s/v2/%s/servers", IP, PORT, TENANTID));
+ assertNull(url);
+ }
+}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
new file mode 100644
index 000000000..d552edccf
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.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.openecomp.appc.test.InterceptLogger;
+
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.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<String, Method> 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:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>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</li>
+ * </ul>
+ * @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:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>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</li>
+ * </ul>
+ * @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<String> getExecMethodNames() {
+ List<String> 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-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
new file mode 100644
index 000000000..394352136
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
@@ -0,0 +1,451 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.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<LogRecord> events;
+
+ /**
+ * Create the intercept logger
+ */
+ public InterceptLogger() {
+ events = new ArrayList<LogRecord>(1000);
+ }
+
+ /**
+ * @return Returns all intercepted log events
+ */
+ public List<LogRecord> 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-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..2daa085ad
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,109 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# 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.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.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.openecomp.appc.provider.min.pool=1
+org.openecomp.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.openecomp.appc.provider.retry.delay = 30
+org.openecomp.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.openecomp.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.openecomp.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-iaas-adapter/appc-iaas-adapter-features/.gitignore b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/.gitignore
new file mode 100644
index 000000000..615a76bbc
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/bin/
+/classes/
+/.settings/
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/pom.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/pom.xml
new file mode 100644
index 000000000..48588a6fb
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-iaas-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-iaas-adapter-features</artifactId>
+ <name>IaaS Adaptor - Features</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-iaas-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <type>zip</type>
+ </dependency>
+
+<!-- <dependency> -->
+<!-- Required for launching the feature tests -->
+<!-- <groupId>org.opendaylight.yangtools</groupId> -->
+<!-- <artifactId>features-test</artifactId> -->
+<!-- <scope>test</scope> -->
+<!-- </dependency> -->
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- launches the feature test, which validates that your karaf feature
+ can be installed inside of a karaf container. It doesn't validate that your
+ functionality works correctly, just that you have all of the dependent bundles
+ defined correctly. -->
+ <!-- <plugin> -->
+ <!-- <groupId>org.apache.maven.plugins</groupId> -->
+ <!-- <artifactId>maven-surefire-plugin</artifactId> -->
+ <!-- <version>2.16</version> -->
+ <!-- <configuration> -->
+ <!-- <systemPropertyVariables> -->
+ <!-- <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId> -->
+ <!-- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId> -->
+ <!-- <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version> -->
+ <!-- </systemPropertyVariables> -->
+ <!-- <dependenciesToScan> -->
+ <!-- <dependency>org.opendaylight.yangtools:features-test</dependency> -->
+ <!-- </dependenciesToScan> -->
+ <!-- </configuration> -->
+ <!-- </plugin> -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/src/main/resources/features.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/src/main/resources/features.xml
new file mode 100644
index 000000000..f68027e90
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-iaas-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+<!-- <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features</repository> -->
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${features-mdsal.version}/xml/features</repository>
+
+
+ <feature name='appc-iaas-adapter' description="appc-iaas-adapter" version='${project.version}'>
+ <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
+<!-- <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature> -->
+ <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature>
+ <feature>sdnc-sli</feature>
+ <bundle>mvn:org.openecomp.appc/appc-iaas-adapter-bundle/${project.version}</bundle>
+ </feature>
+
+</features>
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/.gitignore b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/.gitignore
new file mode 100644
index 000000000..731eb433c
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/.gitignore
@@ -0,0 +1,2 @@
+/target/
+/.settings/
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/pom.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/pom.xml
new file mode 100644
index 000000000..376196e42
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-iaas-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-iaas-adapter-installer</artifactId>
+ <name>IaaS Adapter - Karaf Installer</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>appc-iaas-adapter</application.name>
+ <features.boot>appc-iaas-adapter</features.boot>
+ <features.repositories>mvn:org.openecomp.appc/appc-iaas-adapter-features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-iaas-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-iaas-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>mvn-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <excludeGroupIds>org.opendaylight</excludeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_installer_zip.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 000000000..9fbaad8c5
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 000000000..1ac5a82bc
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/main/resources/scripts/install-feature.sh b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 000000000..1d769fada
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/appc-adapters/appc-iaas-adapter/pom.xml b/appc-adapters/appc-iaas-adapter/pom.xml
new file mode 100644
index 000000000..27ae766fc
--- /dev/null
+++ b/appc-adapters/appc-iaas-adapter/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-adapters</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-iaas-adapter</artifactId>
+ <name>IaaS Adaptor</name>
+ <description>Abstraction to connect to and utilize the services of cloud providers such as OpenStack or VMWare.</description>
+ <packaging>pom</packaging>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.3</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc-no-fork</report>
+ <report>test-javadoc-no-fork</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>dual-report</id>
+ <configuration>
+ <type>range</type>
+ <range>30</range>
+ </configuration>
+ <reports>
+ <report>changelog</report>
+ <report>file-activity</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-iaas-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-iaas-adapter-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+ </dependencyManagement>
+
+ <modules>
+ <module>appc-iaas-adapter-bundle</module>
+ <module>appc-iaas-adapter-features</module>
+ <module>appc-iaas-adapter-installer</module>
+ </modules>
+</project>
diff --git a/appc-adapters/appc-netconf-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-netconf-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml
new file mode 100644
index 000000000..861529836
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/pom.xml
@@ -0,0 +1,189 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-netconf-adapter-bundle</artifactId>
+ <packaging>bundle</packaging>
+ <name>NETCONF Adapter - bundle</name>
+ <properties>
+ <exam.version>4.9.1</exam.version>
+ <url.version>1.6.0</url.version>
+ <sal-netconf-connector.version>1.3.1-Beryllium-SR1</sal-netconf-connector.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dmaap-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-openstack</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ </dependency>
+
+ <!-- Jersey support needed for OpenStack connector and API version logic -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <!-- Needed to run test cases -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.12</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vmware</groupId>
+ <artifactId>vijava</artifactId>
+ <version>5.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${apache.httpcomponents.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-netconf-adapter</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.adapter.netconf.AppcNetconfAdapterActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.adapter.netconf,org.openecomp.appc.adapter.netconf.dao,org.openecomp.appc.adapter.netconf.util,org.openecomp.appc.adapter.netconf.exception</Export-Package>
+ <Import-Package>
+ org.w3c.dom.*,com.sun.org.apache.xerces.*,javax.sql.*,javax.sql.rowset.*,javax.xml.*,org.openecomp.appc.adapter.dmaap.*,javax.crypto.*,org.openecomp.appc.common.exception.*,com.mysql.*,org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.vmware.*,org.apache.xerces.*,javax.net.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.bind.*,javax.naming.*
+ </Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|dblib-provider|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis|appc-dmaap-adapter-bundle</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java
new file mode 100644
index 000000000..aac49c288
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/AppcNetconfAdapterActivator.java
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.adapter.netconf.internal.NetconfDataAccessServiceImpl;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class AppcNetconfAdapterActivator implements BundleActivator {
+
+ /**
+ * The bundle registration
+ */
+ private ServiceRegistration registration = null;
+ private ServiceRegistration reporterRegistration = null;
+ private ServiceRegistration factoryRegistration = null;
+ private ServiceRegistration dbRegistration = null;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private NetconfClientFactory clientFactory;
+ private NetconfDataAccessService DAService;
+
+ /**
+ * The logger to be used
+ */
+ //private static final EELFLogger logger = EELFManager.getInstance().getLogger(AppcNetconfAdapterActivator.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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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 {
+
+ if (registration == null) {
+ clientFactory = new NetconfClientFactory();
+ factoryRegistration = context.registerService(NetconfClientFactory.class, clientFactory, null);
+
+ DAService = new NetconfDataAccessServiceImpl();
+ //set dblib service
+ DbLibService dblibSvc = null;
+ ServiceReference sref = context.getServiceReference(DbLibService.class.getName());
+ dblibSvc = (DbLibService)context.getService(sref);
+ DAService.setDbLibService(dblibSvc);
+ ///////////////////////////////////
+ factoryRegistration = context.registerService(NetconfDataAccessService.class, DAService, null);
+ }
+
+ //logger.info(Msg.COMPONENT_INITIALIZED, "NETCONF 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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 {
+ if (registration != null) {
+ registration.unregister();
+ registration = null;
+ }
+ if (reporterRegistration != null) {
+ reporterRegistration.unregister();
+ reporterRegistration = null;
+ }
+
+ if (null != factoryRegistration) {
+ factoryRegistration.unregister();
+ factoryRegistration = null;
+ }
+
+ if (dbRegistration != null) {
+ dbRegistration.unregister();
+ dbRegistration = null;
+ }
+ }
+
+ public String getName() {
+ return "APPC NETCONF adapter";
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java
new file mode 100644
index 000000000..71fe16f6b
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/ConnectionDetails.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+
+public class ConnectionDetails {
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java
new file mode 100644
index 000000000..95eae28af
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/MockOperationalStateValidatorImpl.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+public class MockOperationalStateValidatorImpl implements OperationalStateValidator {
+ @Override
+ public VnfType getVnfType() {
+ return VnfType.MOCK;
+ }
+
+ @Override
+ public String getConfigurationFileName() {
+ String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX);
+ return configFileName;
+ }
+
+ @Override
+ public void validateResponse(String response) throws APPCException {
+ if(response != null && response.toUpperCase().contains("INVALID")){
+ throw new APPCException("INVALID");
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java
new file mode 100644
index 000000000..904155273
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClient.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+
+public interface NetconfClient {
+
+ /**
+ * Open connection to netconf device.
+ *
+ * @param connectionDetails object providing details required for netconf connection
+ */
+ void connect(NetconfConnectionDetails connectionDetails) throws APPCException;
+
+ /**
+ * Send Netconf message to device and receive response.
+ *
+ * @param message input netconf xml message
+ * @return output netconf xml message
+ */
+ String exchangeMessage(String message) throws APPCException;
+
+ /**
+ * send configuration to Netconf server
+ *
+ * @param configuration - xml configuration payload
+ */
+ void configure(String configuration) throws APPCException;
+
+ /**
+ * returns running configuration of Netconf server
+ */
+ String getConfiguration() throws APPCException;
+
+ /**
+ * Disconnect from netconf device.
+ */
+ void disconnect() throws APPCException;
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java
new file mode 100644
index 000000000..20fec5c49
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientFactory.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.adapter.netconf.odlconnector.NetconfClientRestconfImpl;
+
+
+public class NetconfClientFactory {
+
+ public NetconfClient GetNetconfClient(NetconfClientType type){
+
+ if(type==NetconfClientType.RESTCONF) {
+ return new NetconfClientRestconfImpl();
+ }else if(type == NetconfClientType.SSH){
+ return new NetconfClientJsch();
+ }
+
+ return null;
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java
new file mode 100644
index 000000000..04368615a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientRestconf.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+
+public interface NetconfClientRestconf {
+
+ /*
+ mount device to controller
+ @param deviceMountPointName - the name of the mounting point in controller
+ @param payload - json data describing device info
+ */
+ void connect(String deviceMountPointName, String payload) throws APPCException;
+
+ /*
+ check connection to device
+ @param deviceMountPointName - the name of the mounting point in controller
+ */
+ boolean checkConnection(String deviceMountPointName) throws APPCException;
+
+ /*
+ send configuration to Netconf server
+ @param configuration - xml configuration payload
+ @param deviceMountPointName - the name of the mounting point in controller
+ @param moduleName - name of the yang model
+ @param nodeName - name of the node created in server
+ */
+ void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException;
+
+ /*
+ backup device configuration
+ @param deviceMountPointName - the name of the mounting point in controlle
+ */
+ //void backupConfiguration(String deviceMountPointName);
+ /*
+ returns configuration of Netconf server
+ @param deviceMountPointName - the name of the mounting point in controller
+ @param moduleName - name of the yang model
+ @param nodeName - name of the node created in server
+ */
+ String getConfiguration(String deviceName, String moduleName, String nodeName) throws APPCException;
+
+ /*
+ unmount device
+ @param deviceMountPointName - the name of the mounting point in controller
+ */
+ void disconnect(String deviceMountPointName) throws APPCException;
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java
new file mode 100644
index 000000000..9757ae9ec
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfClientType.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+
+public enum NetconfClientType {
+ RESTCONF,
+ SSH
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java
new file mode 100644
index 000000000..fdbda2916
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfConnectionDetails.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Provides details required for connecting to netconf device.
+ */
+public class NetconfConnectionDetails {
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+
+ public static int DEFAULT_PORT = 830;
+ private List<String> capabilities;
+ private Properties additionalProperties;
+
+ public NetconfConnectionDetails() {
+ super();
+ setPort(DEFAULT_PORT);
+ }
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public List<String> getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(List<String> capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ public Properties getAdditionalProperties() {
+ return additionalProperties;
+ }
+
+ public void setAdditionalProperties(Properties additionalProperties) {
+ this.additionalProperties = additionalProperties;
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java
new file mode 100644
index 000000000..3536cf3b9
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/NetconfDataAccessService.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+
+@SuppressWarnings("JavaDoc")
+public interface NetconfDataAccessService {
+
+ /**
+ *
+ * @param schema
+ */
+ void setSchema(String schema);
+
+ /**
+ *
+ * @param dbLibService
+ */
+ void setDbLibService(DbLibService dbLibService);
+
+ /**
+ *
+ * @param xmlID
+ * @return
+ * @throws DataAccessException
+ */
+ String retrieveConfigFileName(String xmlID) throws DataAccessException;
+
+ /**
+ *
+ * @param vnfType
+ * @param connectionDetails
+ * @return
+ * @throws DataAccessException
+ */
+ boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws DataAccessException;
+
+ /**
+ *
+ * @param vnfType
+ * @param connectionDetails
+ * @return
+ * @throws DataAccessException
+ */
+ boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws
+ DataAccessException;
+
+ /**
+ *
+ * @param instanceId
+ * @param requestId
+ * @param creationDate
+ * @param logText
+ * @return
+ * @throws DataAccessException
+ */
+ boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws
+ DataAccessException;
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java
new file mode 100644
index 000000000..fb9aba002
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidator.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.openecomp.appc.exceptions.APPCException;
+
+
+public interface OperationalStateValidator {
+ public VnfType getVnfType();
+ public String getConfigurationFileName();
+ public void validateResponse(String response) throws APPCException;
+ final public static String CONFIG_FILE_PROPERTY_SUFFIX = "-CONFIG_FILE";
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java
new file mode 100644
index 000000000..94b87f497
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/OperationalStateValidatorFactory.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+
+public class OperationalStateValidatorFactory {
+ protected static final Configuration configuration = ConfigurationFactory.getConfiguration();
+
+ public static OperationalStateValidator getOperationalStateValidator(String vnfType) {
+ VnfType vnfTypeEnum = null;
+ try {
+ vnfTypeEnum = VnfType.getVnfType(vnfType);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Illegal value in vnfType. vnfType="+vnfType,e);
+ }
+ return getOperationalStateValidator(vnfTypeEnum);
+ }
+
+ public static OperationalStateValidator getOperationalStateValidator(VnfType vnfType) {
+ switch (vnfType) {
+ case VNF:
+ case VNF_MOCK:
+ return new VNFOperationalStateValidatorImpl();
+ case MOCK:
+ return new MockOperationalStateValidatorImpl();
+ default:
+ throw new NotImplementedException("missing implementaion for the given vnfType:" + vnfType.name());
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java
new file mode 100644
index 000000000..fa84ea1a1
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VNFOperationalStateValidatorImpl.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.*;
+
+public class VNFOperationalStateValidatorImpl implements OperationalStateValidator {
+ private static final String OPERATIONAL_STATE_ELEMENT_NAME = "operationalState";
+ @Override
+ public VnfType getVnfType() {
+ return VnfType.VNF;
+ }
+
+ @Override
+ public String getConfigurationFileName() {
+ String configFileName = OperationalStateValidatorFactory.configuration.getProperty(this.getClass().getCanonicalName() + CONFIG_FILE_PROPERTY_SUFFIX);
+ configFileName = configFileName == null? "VnfGetOperationalStates" : configFileName;
+ return configFileName;
+ }
+
+ @Override
+ public void validateResponse(String response) throws APPCException {
+ if(StringUtils.isEmpty(response)) {
+ throw new APPCException("empty response");
+ }
+
+ boolean isValid = false;
+ String errorMsg = "unexpected response";
+ try {
+ List<Map.Entry> operationalStateList = getOperationalStateList(response);
+ if(operationalStateList != null && !operationalStateList.isEmpty()) {
+ for (Map.Entry stateEntry : operationalStateList) {
+ if(!((String)stateEntry.getValue()).equalsIgnoreCase("ENABLED")){
+ errorMsg = "at least one "+OPERATIONAL_STATE_ELEMENT_NAME+" is not in valid satae. "+operationalStateList.toString();
+ isValid = false;
+ break;
+ }else{
+ isValid =true;
+ }
+ }
+ }else {
+ errorMsg = "response without any "+OPERATIONAL_STATE_ELEMENT_NAME+" element";
+ }
+ } catch (Exception e ) {
+ isValid = false;
+ errorMsg = e.toString();
+ }
+ if(!isValid) throw new APPCException(errorMsg);
+ }
+
+ private static List<Map.Entry> getOperationalStateList(String xmlText) throws IOException, ParserConfigurationException, SAXException {
+ List<Map.Entry> entryList = null;
+ if(StringUtils.isNotEmpty(xmlText)) {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ Document document = builder.parse(new ByteArrayInputStream(xmlText.getBytes("UTF-8")));
+ if(document != null) {
+ Element rootElement = document.getDocumentElement();
+ NodeList nodeList = rootElement.getElementsByTagName(OPERATIONAL_STATE_ELEMENT_NAME);
+ if (nodeList != null && nodeList.getLength() > 0) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ String text = node.getTextContent();
+ String id = getElementID(node);
+ entryList = (entryList == null) ? new ArrayList<Map.Entry>() : entryList;
+ Map.Entry entry = new AbstractMap.SimpleEntry<String, String>(id, text);
+ entryList.add(entry);
+ }
+ }
+ }
+ }
+ return entryList;
+ }
+
+ private static String getElementID(Node node) {
+ String id = null;
+ Node parentNode = node.getParentNode();
+ if (parentNode != null) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ NodeList nodeList = ((Element) parentNode).getElementsByTagName("id");
+ if (nodeList != null && nodeList.getLength() > 0) {
+ Node idNode = nodeList.item(0);
+ id = idNode != null ? idNode.getTextContent() : null;
+ }
+ }else {
+ id = parentNode.getNodeValue()+"|"+parentNode.getTextContent();
+ }
+ }
+
+ id = StringUtils.isEmpty(id) ? null : StringUtils.normalizeSpace(id);
+ id = StringUtils.isBlank(id) ? null : id;
+ id = id != null ? id : "unknown-id";
+ return id;
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java
new file mode 100644
index 000000000..18f334fa1
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/VnfType.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf;
+
+public enum VnfType {
+ VNF("VNF"),
+ MOCK("MOCK"),
+ VNF_MOCK("MOCK"),
+ ;
+
+ String familyType;
+ String upperCaseName;
+ VnfType(String familyType) {
+ this.familyType = familyType;
+ this.upperCaseName = name().toUpperCase();
+ }
+
+ public VnfType getFamilyType() {
+ return VnfType.valueOf(familyType);
+ }
+
+ public String getUpperCaseName() {
+ return upperCaseName;
+ }
+
+ public static VnfType getVnfType(String inSensitiveCaseName){
+ String localUpperCaseName = inSensitiveCaseName.toUpperCase();
+ for(VnfType vnfType : VnfType.values()){
+ if(vnfType.getUpperCaseName().equals(localUpperCaseName)){
+ return vnfType;
+ }
+ }
+ throw new IllegalArgumentException(
+ "No enum with upperCaseName for this input value:" + inSensitiveCaseName );
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java
new file mode 100644
index 000000000..1f3b9d830
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/DataAccessException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.exception;
+
+
+public class DataAccessException extends RuntimeException {
+
+ private static final long serialVersionUID = -155423437162622414L;
+
+ public DataAccessException(){
+ }
+
+ public DataAccessException(String message){
+ super(message);
+ }
+
+ public DataAccessException(Throwable cause){
+ super(cause);
+ }
+
+ public DataAccessException(String message , Throwable cause){
+ super(message , cause);
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java
new file mode 100644
index 000000000..c8c692c2a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/exception/NetconfDAOException.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.exception;
+
+public class NetconfDAOException extends RuntimeException {
+
+ private static final long serialVersionUID = -155423437162622414L;
+
+ public NetconfDAOException(){
+ }
+
+ public NetconfDAOException(String message){
+ super(message);
+ }
+
+ public NetconfDAOException(Throwable cause){
+ super(cause);
+ }
+
+ public NetconfDAOException(String message , Throwable cause){
+ super(message , cause);
+ }
+
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java
new file mode 100644
index 000000000..7740728f4
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter.java
@@ -0,0 +1,129 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.internal;
+
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.*;
+
+/**
+ * Provides basic methods for exchanging netconf messages.
+ */
+public class NetconfAdapter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter.class);
+ private static final long MAX_WAITING_TIME = 1800000;
+ private static ExecutorService executor = Executors.newFixedThreadPool(5);
+
+ // device input stream
+ private InputStream in;
+ // device output stream
+ private OutputStream out;
+ private long maxWaitingTime = ConfigurationFactory.getConfiguration().getLongProperty("org.openecomp.appc.netconf.recv.timeout", MAX_WAITING_TIME);
+
+ /**
+ * Constructor.
+ *
+ * @param in InputStream this instance will read netconf messages from
+ * @param out OutputStream this instance will write netconf messages to
+ * @throws IOException
+ */
+ public NetconfAdapter(InputStream in, OutputStream out) throws IOException {
+ this.in = in;
+ this.out = out;
+ }
+
+ /**
+ * Receives netconf message from InputStream and return it's text (without netconf frame characters).
+ *
+ * @return text of message received from netconf device
+ * @throws IOException
+ */
+ public String receiveMessage() throws IOException {
+
+ final NetconfMessage message = new NetconfMessage();
+ final byte[] buf = new byte[1024];
+
+ //int readByte = 1;
+ // Read data with timeout
+ Callable<Boolean> readTask = new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ int c;
+ while ((c = in.read(buf)) > 0) {
+ if (c > 0) {
+ message.append(buf, 0, c);
+ if (message.isCompleted()) {
+ break;
+ }
+ }
+ }
+
+ if (c < 0) {
+ return false;
+ }
+ return true;
+ }
+ };
+
+ Future<Boolean> future = executor.submit(readTask);
+ Boolean status;
+ try {
+ status = future.get(maxWaitingTime, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
+
+ if (status == false) {
+ throw new IOException("Failed to read netconf message");
+ }
+
+
+ String text = message.getText();
+ if (text != null) {
+ text = text.trim();
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Received message from netconf device:\n" + text);
+ }
+ return text;
+ }
+
+ /**
+ * Sends netconf message with provided text (adds netconf frame characters and sends the message).
+ *
+ * @param text text of message to be sent to netconf device
+ * @throws IOException
+ */
+ public void sendMessage(final String text) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Sending message to netconf device:\n" + text);
+ }
+ out.write(new NetconfMessage(text).getFrame());
+ out.flush();
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java
new file mode 100644
index 000000000..e0f166483
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfAdapter2.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.internal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+
+/**
+ * Provides basic methods for exchanging netconf messages.
+ */
+public class NetconfAdapter2 {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfAdapter2.class);
+
+ // device input pipe
+ private final PipedOutputStream pipedOutIn = new PipedOutputStream();
+ private PipedInputStream in;
+ // device output pipe
+ private final PipedInputStream pipedInOut = new PipedInputStream();
+ private PipedOutputStream out;
+
+ /**
+ * Constructor.
+ *
+ * @throws IOException
+ */
+ public NetconfAdapter2() throws IOException {
+ in = new PipedInputStream(pipedOutIn);
+ out = new PipedOutputStream(pipedInOut);
+ }
+
+ /**
+ * @return InputStream this instance will read netconf messages from.
+ */
+ public InputStream getIn() {
+ return in;
+ }
+
+ /**
+ * @return OutputStream this instance will write netconf messages to.
+ */
+ public OutputStream getOut() {
+ return out;
+ }
+
+ /**
+ * Receives netconf message from InputStream and return it's text (without netconf frame characters).
+ *
+ * @return text of message received from netconf device
+ * @throws IOException
+ */
+ public String receiveMessage() throws IOException {
+ NetconfMessage message = new NetconfMessage();
+ byte[] buf = new byte[1024];
+ int c;
+ while((c = pipedInOut.read(buf)) > 0) {
+ message.append(buf, 0, c);
+ if (message.isCompleted()) {
+ break;
+ }
+ }
+ String text = message.getText();
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Received message from netconf device:\n" + text);
+ }
+ return text;
+ }
+
+ /**
+ * Sends netconf message with provided text (adds netconf frame characters and sends the message).
+ *
+ * @param text text of message to be sent to netconf device
+ * @throws IOException
+ */
+ public void sendMessage(final String text) throws IOException {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Sending message to netconf device:\n" + text);
+ }
+ pipedOutIn.write(new NetconfMessage(text).getFrame());
+// pipedOutIn.flush();
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java
new file mode 100644
index 000000000..d68900802
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfConstMessages.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.internal;
+
+public class NetconfConstMessages {
+
+ public static final String CAPABILITIES_START =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <capabilities>\n";
+
+ public static final String CAPABILITIES_BASE =
+ " <capability>urn:ietf:params:netconf:base:1.0</capability>\n";
+
+ public static final String CAPABILITIES_END =
+ " </capabilities>\n" +
+ "</hello>";
+
+ public static final String GET_RUNNING_CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <get-config>\n" +
+ " <source>\n" +
+ " <running/>\n" +
+ " </source>\n" +
+ " </get-config>\n" +
+ "</rpc>";
+
+ public static final String CLOSE_SESSION =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"terminateConnection\" xmlns:netconf=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <close-session/>\n" +
+ "</rpc>";
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
new file mode 100644
index 000000000..53eb5b520
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
@@ -0,0 +1,154 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.internal;
+
+import javax.sql.rowset.CachedRowSet;
+
+import org.openecomp.appc.adapter.netconf.ConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.NetconfDataAccessService;
+import org.openecomp.appc.adapter.netconf.exception.DataAccessException;
+import org.openecomp.appc.adapter.netconf.util.Constants;
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+
+public class NetconfDataAccessServiceImpl implements NetconfDataAccessService {
+
+ private static EELFLogger logger = EELFManager.getInstance().getLogger(NetconfDataAccessServiceImpl.class);
+
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ private String schema;
+
+ public void setDbLibService(DbLibService service) {dbLibService = service;}
+
+ private DbLibService dbLibService;
+
+ @Override
+ public String retrieveConfigFileName(String xmlID) throws DataAccessException {
+ String fileContent = "";
+
+ String queryString = "select " + Constants.FILE_CONTENT_TABLE_FIELD_NAME + " " +
+ "from " + Constants.CONFIGFILES_TABLE_NAME + " " +
+ "where " + Constants.FILE_NAME_TABLE_FIELD_NAME + " = ?";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(xmlID);
+
+ try {
+
+ final CachedRowSet data = dbLibService.getData(queryString, argList, schema);
+ if (data.first()) {
+ fileContent = data.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME);
+ }
+
+ } catch (Throwable e) {
+ logger.error("Error Accessing Database " + e);
+ throw new DataAccessException(e);
+ }
+
+ return fileContent;
+ }
+
+ @Override
+ public boolean retrieveConnectionDetails(String vnfType, ConnectionDetails connectionDetails) throws
+ DataAccessException {
+ boolean recordFound = false;
+
+ String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " +
+ "from " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME + " " +
+ "where " + Constants.VNF_TYPE_TABLE_FIELD_NAME + " = ?";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(vnfType);
+
+ try {
+
+ final CachedRowSet data = dbLibService.getData(queryString, argList, schema);
+ if (data.first()) {
+ connectionDetails.setUsername(data.getString(Constants.USER_NAME_TABLE_FIELD_NAME));
+ connectionDetails.setPassword(data.getString(Constants.PASSWORD_TABLE_FIELD_NAME));
+ connectionDetails.setPort(data.getInt(Constants.PORT_NUMBER_TABLE_FIELD_NAME));
+ recordFound = true;
+ }
+
+ } catch (SQLException e) {
+ logger.error("Error Accessing Database " + e);
+ throw new DataAccessException(e);
+ }
+
+ return recordFound;
+ }
+
+ @Override
+ public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws
+ DataAccessException
+ {
+ ConnectionDetails connDetails = new ConnectionDetails();
+ if(this.retrieveConnectionDetails(vnfType, connDetails))
+ {
+ connectionDetails.setHost(connDetails.getHost());
+ connectionDetails.setPort(connDetails.getPort());
+ connectionDetails.setUsername(connDetails.getUsername());
+ connectionDetails.setPassword(connDetails.getPassword());
+ }
+ return true;
+ }
+
+ @Override
+ public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws
+ DataAccessException {
+
+ String queryString = "INSERT INTO "+ Constants.DEVICE_INTERFACE_LOG_TABLE_NAME+"("+
+ Constants.SERVICE_INSTANCE_ID_FIELD_NAME+","+
+ Constants.REQUEST_ID_FIELD_NAME+","+
+ Constants.CREATION_DATE_FIELD_NAME+","+
+ Constants.LOG_FIELD_NAME+") ";
+ queryString += "values(?,?,?,?)";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(instanceId);
+ argList.add(requestId);
+ argList.add(creationDate);
+ argList.add(logText);
+
+ try {
+
+ dbLibService.writeData(queryString, argList, schema);
+
+ } catch (SQLException e) {
+ logger.error("Logging Device interaction failed - "+ queryString);
+ throw new DataAccessException(e);
+ }
+
+ return true;
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java
new file mode 100644
index 000000000..200145b0a
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfMessage.java
@@ -0,0 +1,94 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.internal;
+
+import java.io.ByteArrayOutputStream;
+
+class NetconfMessage {
+
+ private static final String EOM = "]]>]]>";
+
+ private String text;
+ private MessageBuffer buffer = new MessageBuffer();
+ private int eomNotch;
+
+ NetconfMessage() {
+ }
+
+ NetconfMessage(String text) {
+ if(text == null) {
+ throw new NullPointerException("Netconf message payload is null");
+ }
+ append(text.getBytes(), 0, text.length());
+ if(this.text == null) {
+ this.text = text;
+ }
+ }
+
+ void append(byte[] bytes, int start, int end) {
+ boolean eomFound = false;
+ for(int i = start; i < end; i++) {
+ if(bytes[i] == EOM.charAt(eomNotch)) {
+ // advance notch
+ eomNotch++;
+ } else {
+ // reset notch
+ eomNotch = 0;
+ }
+ if(eomNotch == EOM.length()) {
+ // end of message found
+ eomFound = true;
+ end = i + 1;
+ break;
+ }
+ }
+ buffer.write(bytes, start, end);
+ if(eomFound) {
+ text = new String(buffer.getBytes(), 0, buffer.size() - EOM.length());
+ buffer.reset();
+ }
+ }
+
+ String getText() {
+ return text;
+ }
+
+ boolean isCompleted() {
+ return (text != null);
+ }
+
+ byte[] getFrame() {
+ StringBuilder sb = new StringBuilder();
+ if(text != null) {
+ sb.append(text).append("\n");
+ }
+ sb.append(EOM);
+ return sb.toString().getBytes();
+ }
+
+ private class MessageBuffer extends ByteArrayOutputStream {
+
+ byte[] getBytes() {
+ return buf;
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java
new file mode 100644
index 000000000..e6b47db38
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/JSchLogger.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * JSch logger implementation delegating to logback.
+ */
+public class JSchLogger implements com.jcraft.jsch.Logger {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JSchLogger.class);
+
+ @Override
+ public boolean isEnabled(int level) {
+ return true;
+ }
+
+ @Override
+ public void log(int level, String message) {
+ switch(level) {
+ case com.jcraft.jsch.Logger.DEBUG:
+ LOG.debug(message);
+ break;
+
+ case com.jcraft.jsch.Logger.INFO:
+ LOG.info(message);
+ break;
+
+ case com.jcraft.jsch.Logger.WARN:
+ LOG.warn(message);
+ break;
+
+ case com.jcraft.jsch.Logger.ERROR:
+ case com.jcraft.jsch.Logger.FATAL:
+ LOG.error(message);
+ break;
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java
new file mode 100644
index 000000000..c743b2dd8
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/jsch/NetconfClientJsch.java
@@ -0,0 +1,171 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import com.jcraft.jsch.Channel;
+import com.jcraft.jsch.ChannelSubsystem;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.Session;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Properties;
+
+import org.openecomp.appc.adapter.netconf.NetconfClient;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.internal.NetconfAdapter;
+import org.openecomp.appc.adapter.netconf.internal.NetconfConstMessages;
+import org.openecomp.appc.encryption.EncryptionTool;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.i18n.Msg;
+import com.att.eelf.i18n.EELFResourceManager;
+
+/**
+ * Implementation of NetconfClient interface based on JCraft jsch library.
+ */
+public class NetconfClientJsch implements NetconfClient {
+
+ private static final int SESSION_CONNECT_TIMEOUT = 30000;
+ private static final int CHANNEL_CONNECT_TIMEOUT = 10000;
+
+ private Session session;
+ private Channel channel;
+ private NetconfAdapter netconfAdapter;
+// private NetconfAdapter2 netconfAdapter;
+
+
+ @Override
+ public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
+ String host = connectionDetails.getHost();
+ int port = connectionDetails.getPort();
+ String username = connectionDetails.getUsername();
+ String password = connectionDetails.getPassword();
+ try {
+ JSch.setLogger(new JSchLogger());
+ JSch jsch = new JSch();
+ session = jsch.getSession(EncryptionTool.getInstance().decrypt(username), host, port);
+ session.setPassword(EncryptionTool.getInstance().decrypt(password));
+ session.setConfig("StrictHostKeyChecking", "no");
+
+ Properties additionalProps = connectionDetails.getAdditionalProperties();
+ if((additionalProps != null) && !additionalProps.isEmpty()) {
+ session.setConfig(additionalProps);
+ }
+
+ session.connect(SESSION_CONNECT_TIMEOUT);
+ session.setTimeout(10000);
+ try {
+// session.setServerAliveCountMax(0); // If this is not set to '0', then socket timeout on all reads will not work!!!!
+ channel = session.openChannel("subsystem");
+ ((ChannelSubsystem)channel).setSubsystem("netconf");
+ netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream());
+// netconfAdapter = new NetconfAdapter2();
+// channel.setInputStream(netconfAdapter.getIn());
+// channel.setOutputStream(netconfAdapter.getOut());
+ channel.connect(CHANNEL_CONNECT_TIMEOUT);
+ hello(connectionDetails.getCapabilities());
+ } catch(Exception e) {
+ disconnect();
+ throw e;
+ }
+ } catch(Exception e) {
+ String message = EELFResourceManager.format(Msg.CANNOT_ESTABLISH_CONNECTION, host, String.valueOf(port), username);
+ throw new APPCException(message, e);
+ }
+ }
+
+ @Override
+ public String exchangeMessage(String message) throws APPCException {
+ try {
+ netconfAdapter.sendMessage(message);
+ return netconfAdapter.receiveMessage();
+ } catch(IOException e) {
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public void configure(String configuration) throws APPCException {
+ try {
+ isOk(exchangeMessage(configuration));
+ } catch(IOException e) {
+ throw new APPCException(e);
+ }
+ }
+
+ @Override
+ public String getConfiguration() throws APPCException {
+ return exchangeMessage(NetconfConstMessages.GET_RUNNING_CONFIG);
+ }
+
+ @Override
+ public void disconnect() {
+ try {
+ if((channel != null) && !channel.isClosed()) {
+ netconfAdapter.sendMessage(NetconfConstMessages.CLOSE_SESSION);
+ isOk(netconfAdapter.receiveMessage());
+ }
+ } catch(IOException e) {
+ throw new RuntimeException("Error closing netconf device", e);
+ } finally {
+ netconfAdapter = null;
+ if(channel != null) {
+ channel.disconnect();
+ channel = null;
+ }
+ if(session != null) {
+ session.disconnect();
+ session = null;
+ }
+ }
+ }
+
+ private void hello(List<String> capabilities) throws IOException {
+ String helloIn = netconfAdapter.receiveMessage();
+ if(helloIn == null) {
+ throw new IOException("Expected hello message, but nothing received error from netconf device");
+ }
+ if(helloIn.contains("<rpc-error>")) {
+ throw new IOException("Expected hello message, but received error from netconf device:\n" + helloIn);
+ }
+ StringBuilder sb = new StringBuilder();
+ sb.append(NetconfConstMessages.CAPABILITIES_START);
+ sb.append(NetconfConstMessages.CAPABILITIES_BASE);
+ if(capabilities != null) {
+ for(String capability: capabilities) {
+ sb.append(" ").append(capability).append("\n");
+ }
+ }
+ sb.append(NetconfConstMessages.CAPABILITIES_END);
+ String helloOut = sb.toString();
+ netconfAdapter.sendMessage(helloOut);
+ }
+
+ private void isOk(String response) throws IOException {
+ if(response == null) {
+ throw new IOException("No response from netconf device");
+ }
+ if(!response.contains("<ok/>")) {
+ throw new IOException("Error response from netconf device: \n" + response);
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
new file mode 100644
index 000000000..2c10cdedd
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/odlconnector/NetconfClientRestconfImpl.java
@@ -0,0 +1,233 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.odlconnector;
+
+import org.apache.http.HttpStatus;
+import org.openecomp.appc.adapter.netconf.NetconfClient;
+import org.openecomp.appc.adapter.netconf.NetconfClientRestconf;
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.util.Constants;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.util.httpClient;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.util.Properties;
+
+public class NetconfClientRestconfImpl implements NetconfClient, NetconfClientRestconf {
+
+ private EELFLogger logger = EELFManager.getInstance().getLogger(NetconfClientRestconfImpl.class);
+
+ private NetconfConnectionDetails connectionDetails;
+
+ //constructor
+ public NetconfClientRestconfImpl(){
+ }
+
+ //restconf client impl
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void configure(String configuration, String deviceMountPointName, String moduleName, String nodeName) throws APPCException {
+
+ logger.info("Configuring device "+deviceMountPointName+" with configuration "+configuration);
+
+ int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/json");
+
+ if (httpCode != HttpStatus.SC_OK) {
+ logger.error("Configuration request failed. throwing Exception !");
+ throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ }
+ }
+
+ @Override
+ public void connect(String deviceMountPointName, String payload) throws APPCException{
+
+ logger.info("Connecting device "+deviceMountPointName);
+
+ int httpCode = httpClient.postMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getConnectPath(),payload,"application/json");
+
+ if(httpCode != HttpStatus.SC_NO_CONTENT){
+ logger.error("Connect request failed with code "+httpCode+". throwing Exception !");
+ throw new APPCException("Error connecting device :" + deviceMountPointName);
+ }
+ }
+
+ @Override
+ public boolean checkConnection(String deviceMountPointName) throws APPCException {
+ logger.info("Checking device "+deviceMountPointName+" connectivity");
+
+ String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getCheckConnectivityPath(deviceMountPointName),"application/json");
+
+ return result != null;
+ }
+
+ @Override
+ public void disconnect(String deviceMountPointName) throws APPCException {
+ logger.info("Disconnecting "+deviceMountPointName);
+
+ int httpCode = httpClient.deleteMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getDisconnectPath(deviceMountPointName),"application/json");
+
+ if(httpCode != HttpStatus.SC_OK){
+ logger.error("Disconnection of device "+deviceMountPointName+" failed!");
+ throw new APPCException("Disconnection of device "+deviceMountPointName+" failed!");
+ }
+ }
+
+ @Override
+ public String getConfiguration(String deviceMountPointName, String moduleName, String nodeName) throws APPCException{
+ logger.info("Getting configuration of device "+deviceMountPointName);
+
+ String result = httpClient.getMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),"application/json");
+
+ if (result == null) {
+ logger.error("Configuration request failed. throwing Exception !");
+ throw new APPCException("Error getting configuration of node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ }
+
+ return result;
+ }
+
+ //netconf client impl
+
+ @Override
+ public void connect(NetconfConnectionDetails connectionDetails) throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+ this.connectionDetails = connectionDetails;
+ this.connect(connectionDetails.getHost(),getPayload());
+ }
+
+ @Override
+ public String exchangeMessage(String message) throws APPCException {
+ // TODO implement
+ return null;
+ }
+
+ @Override
+ public void configure(String configuration) throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+
+ Properties props = connectionDetails.getAdditionalProperties();
+ if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){
+ throw new APPCException("Invalid properties!");
+ }
+
+ String moduleName = props.getProperty("module.name");
+ String nodeName = props.getProperty("node.name");
+ String deviceMountPointName = connectionDetails.getHost();
+
+ int httpCode = httpClient.putMethod(Constants.PROTOCOL,Constants.CONTROLLER_IP,Constants.CONTROLLER_PORT,getModuleConfigurePath(deviceMountPointName, moduleName, nodeName),configuration,"application/xml");
+
+ if (httpCode != HttpStatus.SC_OK) {
+ logger.error("Configuration request failed. throwing Exception !");
+ throw new APPCException("Error configuring node :"+nodeName + ", of Module :" + moduleName + ", in device :" + deviceMountPointName);
+ }
+ }
+
+ @Override
+ public String getConfiguration() throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+
+ Properties props = connectionDetails.getAdditionalProperties();
+ if(props == null || !props.containsKey("module.name") || !props.containsKey("node.name")){
+ throw new APPCException("Invalid properties!");
+ }
+
+ return this.getConfiguration(connectionDetails.getHost(),props.getProperty("module.name"),props.getProperty("node.name"));
+ }
+
+ @Override
+ public void disconnect() throws APPCException {
+ if(connectionDetails == null){
+ throw new APPCException("Invalid connection details - null value");
+ }
+ this.disconnect(connectionDetails.getHost());
+ }
+
+ //private methods
+ private String getModuleConfigurePath(String deviceMountPointName, String moduleName, String nodeName){
+
+
+ String deviceSpecificPath = deviceMountPointName + "/yang-ext:mount/" + moduleName + ":" + nodeName;
+
+ return Constants.CONFIGURE_PATH + deviceSpecificPath;
+ }
+
+ private String getConnectPath(){
+
+ return Constants.CONNECT_PATH;
+ }
+
+ private String getCheckConnectivityPath(String deviceMountPointName) {
+ return Constants.CHECK_CONNECTION_PATH + deviceMountPointName;
+ }
+
+ private String getDisconnectPath(String deviceMountPointName) {
+ return Constants.DISCONNECT_PATH + deviceMountPointName;
+ }
+
+ private String getPayload() {
+ return "{\n" +
+ " \"config:module\":\n" +
+ " {\n" +
+ " \"type\":\"odl-sal-netconf-connector-cfg:sal-netconf-connector\",\n" +
+ " \"netconf-northbound-ssh\\odl-sal-netconf-connector-cfg:name\":"+connectionDetails.getHost()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:address\":"+connectionDetails.getHost()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:port\":"+connectionDetails.getPort()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:username\":"+connectionDetails.getUsername()+",\n" +
+ " \"odl-sal-netconf-connector-cfg:password\":"+connectionDetails.getPassword()+",\n" +
+ " \"tcp-only\":\"false\",\n" +
+ " \"odl-sal-netconf-connector-cfg:event-executor\":\n" +
+ " {\n" +
+ " \"type\":\"netty:netty-event-executor\",\n" +
+ " \"name\":\"global-event-executor\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:binding-registry\":\n" +
+ " {\n" +
+ " \"type\":\"opendaylight-md-sal-binding:binding-broker-osgi-registry\",\n" +
+ " \"name\":\"binding-osgi-broker\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:dom-registry\":\n" +
+ " {\n" +
+ " \"type\":\"opendaylight-md-sal-dom:dom-broker-osgi-registry\",\n" +
+ " \"name\":\"dom-broker\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:client-dispatcher\":\n" +
+ " {\n" +
+ " \"type\":\"odl-netconf-cfg:netconf-client-dispatcher\",\n" +
+ " \"name\":\"global-netconf-dispatcher\"\n" +
+ " },\n" +
+ " \"odl-sal-netconf-connector-cfg:processing-executor\":\n" +
+ " {\n" +
+ " \"type\":\"threadpool:threadpool\",\n" +
+ " \"name\":\"global-netconf-processing-executor\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java
new file mode 100644
index 000000000..92141e1b7
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/util/Constants.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.util;
+
+public class Constants {
+
+ public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/";
+ public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules";
+ public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/";
+ public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/";
+
+ public static final String CONTROLLER_IP = "127.0.0.1";
+ public static final int CONTROLLER_PORT = 8181;
+ public static final String PROTOCOL = "http";
+
+ // tables and fields
+ public static final String NETCONF_SCHEMA = "sdnctl";
+ public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION";
+ public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES";
+ public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG";
+ public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT";
+ public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME";
+ public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME";
+ public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD";
+ public static final String VM_HOST_TABLE_FIELD_NAME = "VM_HOST";
+ public static final String VM_NAME_TABLE_FIELD_NAME = "VM_NAME";
+ public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER";
+ public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE";
+ public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID";
+ public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID";
+ public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE";
+ public static final String LOG_FIELD_NAME = "LOG";
+
+ // input fields names
+ public static final String VNF_TYPE_FIELD_NAME = "org.openecomp.appc.vftype";
+ public static final String TARGET_VNF_TYPE = "target-vnf-type";
+ public static final String FILE_CONTENT_FIELD_NAME = "file-content";
+ public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details";
+ public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name";
+ public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address";
+ public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
+ public static final String RESOURCEKEY = "resourceKey";
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..fc741daf5
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,41 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+org.openecomp.appc.netconf.db.jdbc.driver=netconfctl
+org.openecomp.appc.netconf.db.url.netconfctl=jdbc:mysql://127.0.0.1:3306/test
+org.openecomp.appc.netconf.db.user.netconfctl=test
+org.openecomp.appc.netconf.db.pass.netconfctl=123456
+org.openecomp.appc.netconf.recv.timeout=1800000
+
+### ###
+### Properties commented out below provided in appc.properties ###
+### ###
+#event.pool.members=<DMAAP_IP>:3904
+event.topic.write=APPC-TEST1
+event.client.key=VIlbtVl6YLhNUrtU
+event.client.secret=64AG2hF4pYeG2pq7CT6XwUOT
+#restconf.user=<RESTCONF_USER>
+#restconf.pass=<RESTCONF_PASSWORD>
+
+org.openecomp.appc.adapter.netconf.VNFOperationalStateValidatorImpl-CONFIG_FILE=VnfGetOperationalStates
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java
new file mode 100644
index 000000000..d6d5ae278
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.junit.Test;
+import org.openecomp.appc.adapter.netconf.OperationalStateValidator;
+import org.openecomp.appc.adapter.netconf.OperationalStateValidatorFactory;
+import org.openecomp.appc.adapter.netconf.VnfType;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+public class OperationalStateValidatorTest {
+
+ @Test
+ public void testVNFValidResponse() {
+ String validResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ " <data>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <id>1</id>\n" +
+ " <ProcessorManagement>\n" +
+ " <id>1</id>\n" +
+ " <MatedPair>\n" +
+ " <id>1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_5</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_7</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <id>SC-1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " <SystemController>\n" +
+ " <id>SC-2</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </data>\n" +
+ "</rpc-reply>";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.VNF);
+ assertValidResponse(validResponse, operationalStateValidator);
+ }
+
+ void assertInvalidResponse(String response, OperationalStateValidator operationalStateValidator) {
+ try {
+ operationalStateValidator.validateResponse(response);
+ fail("invalid resposne passed without exception!!!");
+ } catch (APPCException e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testVNFInvalidResponses() {
+
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.VNF);
+ assertInvalidResponse(null, operationalStateValidator);
+
+ assertInvalidResponse("", operationalStateValidator);
+
+ String response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ assertInvalidResponse(response, operationalStateValidator);
+
+ response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ "</rpc-reply>";
+ assertInvalidResponse(response, operationalStateValidator);
+
+ response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ " <data>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <id>1</id>\n" +
+ " <ProcessorManagement>\n" +
+ " <id>1</id>\n" +
+ " <MatedPair>\n" +
+ " <id>1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_5</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_7</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <id>SC-1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " <SystemController>\n" +
+ " <id>SC-2</id>\n" +
+ " <operationalState></operationalState>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </data>\n" +
+ "</rpc-reply>";
+ assertInvalidResponse(response, operationalStateValidator);
+ }
+
+ void assertValidResponse(String response, OperationalStateValidator operationalStateValidator) {
+ try {
+ operationalStateValidator.validateResponse(response);
+ } catch (APPCException e) {
+ fail("Got unexpected exception. Validation failed. " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testMockValidResponse() {
+ String response = "valid";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator("mock");
+ assertValidResponse(response, operationalStateValidator);
+
+ response = "";
+ assertValidResponse(response, operationalStateValidator);
+
+ response = null;
+ assertValidResponse(response, operationalStateValidator);
+ }
+
+ @Test
+ public void testMockInValidResponse() {
+ String response = "anything InValid anything.. ";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.MOCK);
+ assertInvalidResponse(response, operationalStateValidator);
+ }
+
+ @Test
+ public void testGetOperationalStateValidatorForInValidVnfType() {
+ try{
+ OperationalStateValidatorFactory.getOperationalStateValidator("wrongVnfType");
+ fail("invalid vnfType without exception!!!");
+ } catch (Exception e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetOperationalStateValidatorForValidVnfType() {
+ String vnfType = VnfType.VNF.name().toLowerCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.VNF.name().toUpperCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.MOCK.name().toLowerCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.MOCK.name().toUpperCase();
+ assertGettingValidatorForValidVnf(vnfType);
+ }
+
+ void assertGettingValidatorForValidVnf(String vnfType) {
+ try{
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(vnfType);
+ assertNotNull(operationalStateValidator);
+ } catch (Exception e) {
+ fail("valid vnfType throw exception!!!");
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java
new file mode 100644
index 000000000..5e63d5010
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.internal;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.adapter.netconf.internal.NetconfAdapter;
+
+import java.io.IOException;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+
+public class TestNetconfAdapter {
+
+ private static final String EOM = "]]>]]>";
+
+ @Test
+ public void testReceiveMessage() throws IOException {
+ PipedOutputStream pos = new PipedOutputStream();
+ PipedInputStream is = new PipedInputStream(pos);
+
+ PipedInputStream pis = new PipedInputStream();
+ PipedOutputStream os = new PipedOutputStream(pis);
+
+ NetconfAdapter netconfAdapter = new NetconfAdapter(is, os);
+
+ String request = "Hello, netconf!";
+ pos.write(request.getBytes());
+ pos.write(EOM.getBytes());
+ String response = netconfAdapter.receiveMessage();
+ Assert.assertNotNull(response);
+ Assert.assertEquals(request, response.trim());
+ }
+
+ @Test
+ public void testSendMessage() throws IOException {
+ PipedOutputStream pos = new PipedOutputStream();
+ PipedInputStream is = new PipedInputStream(pos);
+
+ PipedInputStream pis = new PipedInputStream();
+ PipedOutputStream os = new PipedOutputStream(pis);
+
+ NetconfAdapter netconfAdapter = new NetconfAdapter(is, os);
+
+ String request = "Hello, netconf!";
+ netconfAdapter.sendMessage(request);
+ byte[] bytes = new byte[request.length()+EOM.length()+2];
+ int count = pis.read(bytes);
+ String response = new String(bytes, 0, count);
+ Assert.assertNotNull(response);
+ Assert.assertTrue(response.endsWith(EOM));
+ response = response.substring(0, response.length() - EOM.length()).trim();
+ Assert.assertEquals(request, response);
+ }
+
+ @Test
+ public void testSendReceive() throws IOException {
+ PipedOutputStream os = new PipedOutputStream();
+ PipedInputStream is = new PipedInputStream(os);
+
+ NetconfAdapter netconfAdapter = new NetconfAdapter(is, os);
+
+ String request = "Hello, netconf!";
+ netconfAdapter.sendMessage(request);
+ String response = netconfAdapter.receiveMessage();
+ Assert.assertNotNull(response);
+ Assert.assertEquals(request, response.trim());
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java
new file mode 100644
index 000000000..a26c6e9e9
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestGetRunningConfig {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java
new file mode 100644
index 000000000..e4baecc89
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestModifyConfig {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <running />\n" +
+ " </target>\n" +
+ " <default-operation>merge</default-operation>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <ManagedElement xmlns=\"urn:org.openecomp.appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:VnfFunction\">\n" +
+ " <id>1</id>\n" +
+ " <Interfaces>\n" +
+ " <id>1</id>\n" +
+ " <DiaRealmRf>\n" +
+ " <realm>example.com</realm>\n" +
+ " <reconnectTimer>60</reconnectTimer>\n" +
+ " </DiaRealmRf>\n" +
+ " </Interfaces>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Reconfiguring device...");
+ String outMessage = netconfClientJsch.exchangeMessage(CONFIG);
+ System.out.println("=> Reconfiguration response:\n" + outMessage);
+
+ System.out.println("=> Running get configuration...");
+ configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java
new file mode 100644
index 000000000..1fe2e1093
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestModifyConfigMock {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <running />\n" +
+ " </target>\n" +
+ " <default-operation>merge</default-operation>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <ManagedElement xmlns=\"urn:org.openecomp.appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:VnfFunction\">\n" +
+ " <id>1</id>\n" +
+ " <Interfaces>\n" +
+ " <id>1</id>\n" +
+ " <DiaRealmRf>\n" +
+ " <realm>example.com</realm>\n" +
+ " <reconnectTimer>60</reconnectTimer>\n" +
+ " </DiaRealmRf>\n" +
+ " </Interfaces>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Reconfiguring device...");
+ String outMessage = netconfClientJsch.exchangeMessage(CONFIG);
+ System.out.println("=> Reconfiguration response:\n" + outMessage);
+
+ System.out.println("=> Running get configuration...");
+ configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
new file mode 100644
index 000000000..256e8e8f5
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestModifyConfigRouterMock {
+
+ private static final String HOST = "10.147.27.50"; // yuma netconf simulator
+ private static final int PORT = 830;
+ private static final String USER = "admin";
+ private static final String PSWD = "admin";
+ private static final List<String> CAPABILITIES = Collections.emptyList();
+ private static final String CONFIG =
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <candidate/>\n" +
+ " </target>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <router xmlns=\"urn:sdnhub:odl:tutorial:router\">\n" +
+ " <ospf>\n" +
+ " <process-id>1</process-id>\n" +
+ " <networks>\n" +
+ " <subnet-ip>100.100.100.0/24</subnet-ip>\n" +
+ " <area-id>10</area-id>\n" +
+ " </networks>\n" +
+ " </ospf>\n" +
+ " <bgp>\n" +
+ " <as-number>1000</as-number>\n" +
+ " <router-id>10.10.1.1</router-id>\n" +
+ " <neighbors>\n" +
+ " <as-number>2000</as-number>\n" +
+ " <peer-ip>10.10.1.2</peer-ip>\n" +
+ " </neighbors>\n" +
+ " </bgp>\n" +
+ " </router>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>\n";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Reconfiguring device...");
+ String outMessage = netconfClientJsch.exchangeMessage(CONFIG);
+ System.out.println("=> Reconfiguration response:\n" + outMessage);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java
new file mode 100644
index 000000000..39c1a871c
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.appc.exceptions.APPCException;
+
+public class TestOperationalStates {
+
+ private static final String HOST = "192.168.1.2";
+ private static final String USER = "test";
+ private static final String PSWD = "test123";
+ private static final int PORT = 830;
+ private static final List<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String GET_OPERATIONAL_STATES =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <get>\n" +
+ " <filter>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <ProcessorManagement>\n" +
+ " <MatedPair>\n" +
+ " <operationalState/>\n" +
+ " <PayloadProcessor>\n" +
+ " <operationalState/>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <operationalState/>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </filter>\n" +
+ " </get>\n" +
+ "</rpc>";
+
+ public static void main(String[] args) throws APPCException {
+ try {
+ NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails();
+ connectionDetails.setHost(HOST);
+ connectionDetails.setPort(PORT);
+ connectionDetails.setUsername(USER);
+ connectionDetails.setPassword(PSWD);
+ connectionDetails.setCapabilities(CAPABILITIES);
+ NetconfClientJsch netconfClientJsch = new NetconfClientJsch();
+ netconfClientJsch.connect(connectionDetails);
+ try {
+ System.out.println("=> Running get configuration...");
+ String configuration = netconfClientJsch.getConfiguration();
+ System.out.println("=> Configuration:\n" + configuration);
+
+ System.out.println("=> Running get operational states...");
+ String outMessage = netconfClientJsch.exchangeMessage(GET_OPERATIONAL_STATES);
+ System.out.println("=> Operational states:\n" + outMessage);
+ } finally {
+ netconfClientJsch.disconnect();
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/pom.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/pom.xml
new file mode 100644
index 000000000..e94bdba56
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>appc-netconf-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>appc-netconf-adapter-features</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <type>zip</type>
+ </dependency>
+
+ <!-- <dependency>-->
+ <!-- Required for launching the feature tests -->
+ <!-- <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-test</artifactId>
+ <scope>test</scope>
+ </dependency>-->
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- launches the feature test, which validates that your karaf feature
+ can be installed inside of a karaf container. It doesn't validate that your
+ functionality works correctly, just that you have all of the dependent bundles
+ defined correctly. -->
+ <!-- <plugin> -->
+ <!-- <groupId>org.apache.maven.plugins</groupId> -->
+ <!-- <artifactId>maven-surefire-plugin</artifactId> -->
+ <!-- <version>2.16</version> -->
+ <!-- <configuration> -->
+ <!-- <systemPropertyVariables> -->
+ <!-- <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId> -->
+ <!-- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId> -->
+ <!-- <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version> -->
+ <!-- </systemPropertyVariables> -->
+ <!-- <dependenciesToScan> -->
+ <!-- <dependency>org.opendaylight.yangtools:features-test</dependency> -->
+ <!-- </dependenciesToScan> -->
+ <!-- </configuration> -->
+ <!-- </plugin> -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/src/main/resources/features.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/src/main/resources/features.xml
new file mode 100644
index 000000000..bfb4b8090
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-netconf-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${features-mdsal.version}/xml/features</repository>
+
+ <feature name='appc-netconf-adapter' description="appc-netconf-adapter" version='${project.version}'>
+ <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
+ <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature>
+ <bundle>mvn:org.openecomp.appc/appc-dmaap-adapter-bundle/${project.version}</bundle>
+ <bundle start-level="83" start="true">mvn:org.openecomp.appc/appc-netconf-adapter-bundle/${project.version}</bundle>
+ </feature>
+
+</features>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-installer/pom.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/pom.xml
new file mode 100644
index 000000000..141a1e254
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/pom.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-netconf-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-netconf-adapter-installer</artifactId>
+ <name>NETCONF Adapter - Karaf Installer</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>appc-netconf-adapter</application.name>
+ <features.boot>appc-netconf-adapter</features.boot>
+ <features.repositories>mvn:org.openecomp.appc/appc-netconf-adapter-features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <excludeGroupIds>org.opendaylight</excludeGroupIds>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_installer_zip.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 000000000..9fbaad8c5
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 000000000..1ac5a82bc
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/main/resources/scripts/install-feature.sh b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 000000000..1d769fada
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/appc-adapters/appc-netconf-adapter/pom.xml b/appc-adapters/appc-netconf-adapter/pom.xml
new file mode 100644
index 000000000..5ef2cd3e3
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/pom.xml
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>appc-adapters</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>appc-netconf-adapter</artifactId>
+ <name>NETCONF adapter</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <feature.netconf.connector.version>1.0.1-Beryllium-SR1</feature.netconf.connector.version>
+ </properties>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.3</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc-no-fork</report>
+ <report>test-javadoc-no-fork</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>dual-report</id>
+ <configuration>
+ <type>range</type>
+ <range>30</range>
+ </configuration>
+ <reports>
+ <report>changelog</report>
+ <report>file-activity</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-netconf-adapter-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <modules>
+ <module>appc-netconf-adapter-bundle</module>
+ <module>appc-netconf-adapter-features</module>
+ <module>appc-netconf-installer</module>
+ </modules>
+
+
+</project> \ No newline at end of file
diff --git a/appc-adapters/appc-rest-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-rest-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/.gitignore b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/.gitignore
new file mode 100644
index 000000000..755cdc373
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/.gitignore
@@ -0,0 +1,3 @@
+/bin/
+/target/
+/.settings/
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml
new file mode 100644
index 000000000..662fd00a2
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/pom.xml
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-rest-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-rest-adapter-bundle</artifactId>
+ <packaging>bundle</packaging>
+ <name>rest Adapter - bundle</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <!-- http://mvnrepository.com/artifact/commons-logging/commons-logging -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <!-- http://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.4.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ <classifier>jar-with-dependencies</classifier>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>7.0</version>
+ </dependency>
+<!-- <dependency> -->
+<!-- <groupId>jce</groupId> -->
+<!-- <artifactId>jce</artifactId> -->
+<!-- <version>1_2-do</version> -->
+<!-- <scope>compile</scope> -->
+<!-- </dependency> -->
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.att.cdp</groupId>
+ <artifactId>cdp-pal-openstack</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ </dependency>
+
+ <!-- Jersey support needed for OpenStack connector and API version logic -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.xml</groupId>
+ <artifactId>jaxp-api</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+
+ <!-- Needed to run test cases -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-jaxrs</artifactId>
+ <version>1.9.12</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ <!-- Added exclusion to prevent missing dependency issue on dblib -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.31</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vmware</groupId>
+ <artifactId>vijava</artifactId>
+ <version>5.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ <version>2.4.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>appc-rest-adapter</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.appc.adapter.rest.RestActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.appc.adapter.rest</Export-Package>
+ <Import-Package>org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.vmware.*,org.apache.xerces.*,javax.net.*,javax.net.ssl.*,org.xml.sax.*,javax.xml.bind.*,javax.naming.*</Import-Package>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestActivator.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestActivator.java
new file mode 100644
index 000000000..d1515c418
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestActivator.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.rest;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.rest.impl.RestAdapterImpl;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.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.
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * 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.
+ * </p>
+ * <p>
+ * When the bundle is deactivated, the cache is torn down with all contexts being closed.
+ * </p>
+ */
+public class RestActivator implements BundleActivator {
+
+ /**
+ * The bundle registration
+ */
+ private ServiceRegistration registration = null;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private RestAdapter adapter;
+
+ /**
+ * The logger to be used
+ */
+ // private static final Logger LOG = LoggerFactory.getLogger(RestActivator.class);
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(RestActivator.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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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, "rest adapter");
+ adapter = new RestAdapterImpl(configuration.getProperties());
+ if (registration == null) {
+ logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),
+ RestAdapter.class.getSimpleName());
+ registration = context.registerService(RestAdapter.class, adapter, null);
+ }
+
+ logger.info(Msg.COMPONENT_INITIALIZED, appName, "REST 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.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @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, "REST adapter");
+ logger.info(Msg.UNREGISTERING_SERVICE, appName, adapter.getAdapterName());
+ registration.unregister();
+ registration = null;
+ logger.info(Msg.COMPONENT_TERMINATED, appName, "REST adapter");
+ }
+ }
+
+ public String getName() {
+ return "APPC IaaS adapter";
+ }
+
+}
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestAdapter.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestAdapter.java
new file mode 100644
index 000000000..0d4a19709
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/RestAdapter.java
@@ -0,0 +1,205 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.rest;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import com.att.cdp.zones.model.Server;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+/**
+ * This interface defines the operations that the provider adapter exposes.
+ * <p>
+ * 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.
+ * </p>
+ */
+public interface RestAdapter 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.openecomp.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.openecomp.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.openecomp.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.openecomp.appc.identity.url";
+
+ /**
+ * This method is used to restart an existing virtual machine given the fully qualified URL of the machine.
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to stop the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to start the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * This method is used to rebuild the indicated server
+ * <p>
+ * This method is invoked from a directed graph as an <code>Executor</code> 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:
+ * <dl>
+ * <dt>org.openecomp.appc.provider.type</dt>
+ * <dd>The appropriate provider type, such as <code>OpenStackProvider</code>. 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.</dd>
+ * <dt>org.openecomp.appc.instance.url</dt>
+ * <dd>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)</dd>
+ * </dl>
+ * </p>
+ *
+ * @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 <code>Server</code> 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<String, String> properties, SvcLogicContext context) throws APPCException;
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ */
+ String getAdapterName();
+
+ // Server evacuateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ //Server migrateServer(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void commonGet(Map<String, String> params, SvcLogicContext ctx) ;
+
+ void commonPost(Map<String, String> params, SvcLogicContext ctx) ;
+
+ void commonPut(Map<String, String> params, SvcLogicContext ctx) ;
+
+ void commonDelete(Map<String, String> params, SvcLogicContext ctx) ;
+
+}
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestContext.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestContext.java
new file mode 100644
index 000000000..c4b852317
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestContext.java
@@ -0,0 +1,251 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.rest.impl;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.sdnc.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.
+ * <p>
+ * 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.
+ * </p>
+ *
+ * @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-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestFailedException.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestFailedException.java
new file mode 100644
index 000000000..eff1597c1
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RequestFailedException.java
@@ -0,0 +1,244 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.adapter.rest.impl;
+
+import org.glassfish.grizzly.http.util.HttpStatus;
+import com.att.cdp.zones.model.Server;
+
+/**
+ * This class is used to capture the exact cause and point of failure for the processing of a request. It is then used
+ * to encode the reason for the failure, status code, and anything else that needs to be captured and reported for
+ * diagnostic purposes.
+ */
+public class RequestFailedException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The operation that was being requested or performed at the time of the failure.
+ */
+ private String operation;
+
+ /**
+ * A message that details the reason for the failure
+ */
+ private String reason;
+
+ /**
+ * The server that was being operated upon
+ */
+ private Server server;
+
+ /**
+ * The id of the server being operated upon if the server object is not available (such as the server was not found)
+ */
+ private String serverId;
+
+ /**
+ * The most appropriate Http Status code that reflects the error
+ */
+ private HttpStatus status;
+
+ /**
+ *
+ */
+ public RequestFailedException() {
+ // intentionally empty
+ }
+
+ /**
+ * @param message
+ * The error message
+ */
+ public RequestFailedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the server we were processing.
+ *
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param server
+ * The server that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(String operation, String reason, HttpStatus status, Server server) {
+ super(operation + ":" + reason);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.server = server;
+ if (server != null) {
+ this.serverId = server.getId();
+ }
+ }
+
+ /**
+ * Construct the request failed exception with the operation being performed, reason for the failure, http status
+ * code that is most appropriate, and the server we were processing.
+ *
+ * @param ex
+ * The exception that we are wrapping
+ * @param operation
+ * The operation being performed
+ * @param reason
+ * The reason that the operation was failed
+ * @param status
+ * The http status code that is most appropriate
+ * @param server
+ * The server that we were processing
+ */
+ @SuppressWarnings("nls")
+ public RequestFailedException(Throwable ex, String operation, String reason, HttpStatus status, Server server) {
+ super(operation + ":" + reason, ex);
+ this.operation = operation;
+ this.reason = reason;
+ this.status = status;
+ this.server = server;
+ if (server != null) {
+ this.serverId = server.getId();
+ }
+ }
+
+ /**
+ * @param message
+ * The error message
+ * @param cause
+ * A nested exception
+ */
+ public RequestFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ * The error message
+ * @param cause
+ * A nested exception
+ * @param enableSuppression
+ * whether or not suppression is enabled or disabled
+ * @param writableStackTrace
+ * whether or not the stack trace should be writable
+ */
+ public RequestFailedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
+ /**
+ * @param cause
+ * the cause (which is saved for later retrieval by the {@link #getCause()} method). (A null value is
+ * permitted, and indicates that the cause is nonexistent or unknown.)
+ */
+ public RequestFailedException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * @return The operation being performed
+ */
+ public String getOperation() {
+ return operation;
+ }
+
+ /**
+ * @return The reason for the failure
+ */
+ public String getReason() {
+ return reason;
+ }
+
+ /**
+ * @return The server being operated upon
+ */
+ public Server getServer() {
+ return server;
+ }
+
+ /**
+ * @return The id of the server being operated upon
+ */
+ public String getServerId() {
+ return serverId;
+ }
+
+ /**
+ * @return The status code from the operation
+ */
+ public HttpStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @param operation
+ * The operation being performed
+ */
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ /**
+ * @param reason
+ * The reason for the failure
+ */
+ public void setReason(String reason) {
+ this.reason = reason;
+ }
+
+ /**
+ * @param server
+ * The server being operated upon
+ */
+ public void setServer(Server server) {
+ this.server = server;
+ if (server != null) {
+ setServerId(server.getId());
+ }
+ }
+
+ /**
+ * @param serverId
+ * The id of the server being operated upon
+ */
+ public void setServerId(String serverId) {
+ this.serverId = serverId;
+ }
+
+ /**
+ * @param status
+ * The status of the request
+ */
+ public void setStatus(HttpStatus status) {
+ this.status = status;
+ }
+
+}
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RestAdapterImpl.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RestAdapterImpl.java
new file mode 100644
index 000000000..82aad7d6f
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/openecomp/appc/adapter/rest/impl/RestAdapterImpl.java
@@ -0,0 +1,491 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.rest.impl;
+
+import java.net.URI;
+import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.rest.RestAdapter;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.pool.Pool;
+import org.openecomp.appc.pool.PoolExtensionException;
+import org.openecomp.appc.util.StructuredPropertyHelper;
+import org.openecomp.appc.util.StructuredPropertyHelper.Node;
+import com.att.cdp.exceptions.ContextConnectionException;
+import com.att.cdp.exceptions.ResourceNotFoundException;
+import com.att.cdp.exceptions.TimeoutException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.pal.util.StringHelper;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ImageService;
+import com.att.cdp.zones.Provider;
+import com.att.cdp.zones.model.Image;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Server.Status;
+import com.att.cdp.zones.model.ServerBootSource;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.slf4j.MDC;
+
+import java.net.InetAddress;
+import java.util.Locale;
+import java.util.UUID;
+import static com.att.eelf.configuration.Configuration.*;
+
+import org.apache.http.*;
+import org.apache.http.client.*;
+import org.apache.http.client.methods.*;
+import org.apache.http.impl.client.*;
+import org.apache.http.util.EntityUtils;
+import java.io.IOException;
+import org.apache.http.entity.StringEntity;
+
+import java.net.InetAddress;
+import org.json.*;
+
+/**
+ * This class implements the {@link RestAdapter} interface. This interface
+ * defines the behaviors that our service provides.
+ */
+public class RestAdapterImpl implements RestAdapter {
+
+ /**
+ * The constant used to define the adapter name in the mapped diagnostic
+ * context
+ */
+
+
+ @SuppressWarnings("nls")
+ public static final String MDC_ADAPTER = "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";
+
+ /**
+ * A constant for the property token "provider" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER = "provider";
+
+ /**
+ * A constant for the property token "identity" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_IDENTITY = "identity";
+
+ /**
+ * A constant for the property token "name" used in the structured property
+ * specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_NAME = "name";
+
+ /**
+ * A constant for the property token "tenant" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT = "tenant";
+
+ /**
+ * A constant for the property token "tenant name" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT_NAME = "name";
+
+ /**
+ * A constant for the property token "password" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT_PASSWORD = "password"; // NOSONAR
+
+ /**
+ * A constant for the property token "userid" used in the structured
+ * property specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TENANT_USERID = "userid";
+
+ /**
+ * A constant for the property token "type" used in the structured property
+ * specifications
+ */
+ @SuppressWarnings("nls")
+ public static final String PROPERTY_PROVIDER_TYPE = "type";
+
+ /**
+ * The name of the service to restart a server
+ */
+ @SuppressWarnings("nls")
+ public static final String PING_SERVICE = "pingServer";
+
+ /**
+ * The logger to be used
+ */
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(RestAdapterImpl.class);
+
+ /**
+ * The constant for a left parenthesis
+ */
+ private static final char LPAREN = '(';
+
+ /**
+ * The constant for a new line control code
+ */
+ private static final char NL = '\n';
+
+ /**
+ * The constant for a single quote
+ */
+ private static final char QUOTE = '\'';
+
+ /**
+ * The constant for a right parenthesis
+ */
+ private static final char RPAREN = ')';
+
+ /**
+ * The constant for a space
+ */
+ private static final char SPACE = ' ';
+
+ /**
+ * A reference to the adapter configuration object.
+ */
+ private Configuration configuration;
+
+ /**
+ * A cache of providers that are predefined.
+ */
+ // private Map<String /* provider name */, ProviderCache> providerCache;
+
+ /**
+ * This default constructor is used as a work around because the activator
+ * wasnt getting called
+ */
+ /**
+ * A cache of providers that are predefined.
+ */
+ // private Map<String /* provider name */, ProviderCache> providerCache;
+
+ /**
+ * This default constructor is used as a work around because the activator
+ * wasnt getting called
+ */
+ public RestAdapterImpl() {
+ 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 RestAdapterImpl(boolean initialize) {
+ configuration = ConfigurationFactory.getConfiguration();
+ if (initialize) {
+ initialize();
+
+ }
+ }
+
+ /**
+ * @param props
+ * not used
+ */
+ public RestAdapterImpl(Properties props) {
+ initialize();
+
+ }
+
+ /**
+ * Returns the symbolic name of the adapter
+ *
+ * @return The adapter name
+ * @see org.openecomp.appc.adapter.rest.RestAdapter#getAdapterName()
+ */
+ @Override
+ public String getAdapterName() {
+ return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
+ }
+
+ public HttpRequestBase addHeaders(HttpRequestBase method,String headers){
+ if(headers.length()==0)
+ {
+ return method;
+ }else{
+ JSONObject JsonHeaders= new JSONObject(headers);
+ Iterator keys = JsonHeaders.keys();
+ while(keys.hasNext()) {
+ String String1 = (String)keys.next();
+ String String2 = JsonHeaders.getString(String1);
+ method.addHeader(String1,String2);
+ }
+ return method;
+ }
+ }
+
+
+ public void commonGet(Map<String, String> params, SvcLogicContext ctx) {
+ logger.info("Run get method");
+ String haveHeader="false";
+ String tUrl=params.get("org.openecomp.appc.instance.URI");
+ haveHeader=params.get("org.openecomp.appc.instance.haveHeader");
+ String headers=params.get("org.openecomp.appc.instance.headers");
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ try {
+ HttpGet httpGet = new HttpGet(tUrl);
+
+ if(haveHeader.equals("true"))
+ {
+ JSONObject JsonHeaders= new JSONObject(headers);
+ Iterator keys = JsonHeaders.keys();
+ while(keys.hasNext()) {
+ String String1 = (String)keys.next();
+ String String2 = JsonHeaders.getString(String1);
+ httpGet.addHeader(String1,String2);
+ }
+
+ }
+
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpResponse response = null;
+ response = httpClient.execute(httpGet);
+ int responseCode=response.getStatusLine().getStatusCode();
+ HttpEntity entity = response.getEntity();
+ String responseOutput=EntityUtils.toString(entity);
+ doSuccess(rc,responseCode,responseOutput);
+ } catch (Exception ex) {
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.toString());
+ }
+ }
+
+
+ public void commonDelete(Map<String, String> params, SvcLogicContext ctx) {
+ logger.info("Run Delete method");
+ String haveHeader="false";
+ String tUrl=params.get("org.openecomp.appc.instance.URI");
+ haveHeader=params.get("org.openecomp.appc.instance.haveHeader");
+ String headers=params.get("org.openecomp.appc.instance.headers");
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ try {
+ HttpDelete httpDelete = new HttpDelete(tUrl);
+ if(haveHeader.equals("true"))
+ {
+ JSONObject JsonHeaders= new JSONObject(headers);
+ Iterator keys = JsonHeaders.keys();
+ while(keys.hasNext()) {
+ String String1 = (String)keys.next();
+ String String2 = JsonHeaders.getString(String1);
+ httpDelete.addHeader(String1,String2);
+ }
+
+ }
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpResponse response = null;
+ response = httpClient.execute(httpDelete);
+ int responseCode=response.getStatusLine().getStatusCode();
+ HttpEntity entity = response.getEntity();
+ String responseOutput=EntityUtils.toString(entity);
+ doSuccess(rc,responseCode,responseOutput);
+ } catch (Exception ex) {
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.toString());
+ }
+ }
+
+
+
+ public void commonPost(Map<String, String> params, SvcLogicContext ctx) {
+ logger.info("Run post method");
+ String haveHeader="false";
+ String tUrl=params.get("org.openecomp.appc.instance.URI");
+ String body=params.get("org.openecomp.appc.instance.requestBody");
+ haveHeader=params.get("org.openecomp.appc.instance.haveHeader");
+ String headers=params.get("org.openecomp.appc.instance.headers");
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ try {
+ HttpPost httpPost = new HttpPost(tUrl);
+ if(haveHeader.equals("true"))
+ {
+ JSONObject JsonHeaders= new JSONObject(headers);
+ Iterator keys = JsonHeaders.keys();
+ while(keys.hasNext()) {
+ String String1 = (String)keys.next();
+ String String2 = JsonHeaders.getString(String1);
+ httpPost.addHeader(String1,String2);
+ }
+
+ }
+ StringEntity bodyParams =new StringEntity (body,"UTF-8");
+ httpPost.setEntity(bodyParams);
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpResponse response = null;
+ response = httpClient.execute(httpPost);
+ int responseCode=response.getStatusLine().getStatusCode();
+ HttpEntity entity = response.getEntity();
+ String responseOutput=EntityUtils.toString(entity);
+ doSuccess(rc,responseCode,responseOutput);
+ } catch (Exception ex) {
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.toString());
+ }
+ }
+
+ public void commonPut(Map<String, String> params, SvcLogicContext ctx) {
+ logger.info("Run put method");
+ String haveHeader="false";
+ String tUrl=params.get("org.openecomp.appc.instance.URI");
+ String body=params.get("org.openecomp.appc.instance.requestBody");
+ haveHeader=params.get("org.openecomp.appc.instance.haveHeader");
+ String headers=params.get("org.openecomp.appc.instance.headers");
+ RequestContext rc = new RequestContext(ctx);
+ rc.isAlive();
+
+ try {
+ HttpPut httpPut = new HttpPut(tUrl);
+ if(haveHeader.equals("true"))
+ {
+ JSONObject JsonHeaders= new JSONObject(headers);
+ Iterator keys = JsonHeaders.keys();
+ while(keys.hasNext()) {
+ String String1 = (String)keys.next();
+ String String2 = JsonHeaders.getString(String1);
+ httpPut.addHeader(String1,String2);
+ }
+
+ }
+ StringEntity bodyParams =new StringEntity (body,"UTF-8");
+ httpPut.setEntity(bodyParams);
+ HttpClient httpClient = HttpClients.createDefault();
+ HttpResponse response = null;
+ response = httpClient.execute(httpPut);
+ int responseCode=response.getStatusLine().getStatusCode();
+ HttpEntity entity = response.getEntity();
+ String responseOutput=EntityUtils.toString(entity);
+ if(responseCode == 200){
+ doSuccess(rc,responseCode,responseOutput);
+ } else {
+ doFailure(rc, HttpStatus.getHttpStatus(responseCode), response.getStatusLine().getReasonPhrase());
+ }
+ }
+ catch (Exception ex) {
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.toString());
+ }
+/* } catch (Exception ex) {
+ doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.getMessage());
+ }*/
+ }
+
+ @SuppressWarnings("static-method")
+ private void doFailure(RequestContext rc, HttpStatus code, String message) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ String msg = (message == null) ? code.getReasonPhrase() : message;
+ if (msg.contains("\n")) {
+ msg = msg.substring(msg.indexOf("\n"));
+ }
+
+ String status;
+ try {
+ status = Integer.toString(code.getStatusCode());
+ } catch (Exception e) {
+ status = "500";
+ }
+ svcLogic.setStatus(OUTCOME_FAILURE);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_CODE, status);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ svcLogic.setAttribute("org.openecomp.rest.result.code", status);
+ svcLogic.setAttribute("org.openecomp.rest.result.message", msg);
+ }
+
+
+ /**
+ * @param rc
+ * The request context that manages the state and recovery of the
+ * request for the life of its processing.
+ */
+ @SuppressWarnings("static-method")
+ private void doSuccess(RequestContext rc, int code, String message) {
+ SvcLogicContext svcLogic = rc.getSvcLogicContext();
+ svcLogic.setStatus(OUTCOME_SUCCESS);
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_CODE, Integer.toString(HttpStatus.OK_200.getStatusCode()));
+ svcLogic.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, message);
+ svcLogic.setAttribute("org.openecomp.rest.agent.result.code",Integer.toString(code));
+ svcLogic.setAttribute("org.openecomp.rest.agent.result.message",message);
+ svcLogic.setAttribute("org.openecomp.rest.result.code",Integer.toString(HttpStatus.OK_200.getStatusCode()));
+ }
+
+
+ /**
+ * initialize the provider adapter by building the context cache
+ */
+ private void initialize() {
+ configuration = ConfigurationFactory.getConfiguration();
+
+ logger.info("init rest adapter!!!!!");
+ }
+
+}
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..3d4f9b373
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,93 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# 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.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.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.openecomp.appc.provider.min.pool=1
+org.openecomp.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.openecomp.appc.provider.retry.delay = 30
+org.openecomp.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.openecomp.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.openecomp.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-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/adapter/rest/impl/TestRestAdapterImpl.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/adapter/rest/impl/TestRestAdapterImpl.java
new file mode 100644
index 000000000..daa379413
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/adapter/rest/impl/TestRestAdapterImpl.java
@@ -0,0 +1,161 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.rest.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.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.slf4j.MDC;
+
+import org.openecomp.appc.Constants;
+import org.openecomp.appc.adapter.rest.RestAdapter;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.exceptions.UnknownProviderException;
+import com.att.cdp.exceptions.ZoneException;
+import com.att.cdp.zones.ComputeService;
+import com.att.cdp.zones.Context;
+import com.att.cdp.zones.ContextFactory;
+import com.att.cdp.zones.model.Server;
+import com.att.cdp.zones.model.Server.Status;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+/**
+ * Test the ProviderAdapter implementation.
+ */
+
+@Ignore
+public class TestRestAdapterImpl {
+
+ @SuppressWarnings("nls")
+ private static final String PROVIDER_NAME = "APPC";
+
+ @SuppressWarnings("nls")
+ private static final String PROVIDER_TYPE = "OpenStackProvider";
+
+ private static String IDENTITY_URL;
+
+ private static String PRINCIPAL;
+
+ private static String CREDENTIAL;
+
+ private static String TENANT_NAME;
+
+ private static String TENANT_ID;
+
+ private static String USER_ID;
+
+ private static String REGION_NAME;
+
+ private static String SERVER_URL;
+
+ private static Class<?> providerAdapterImplClass;
+ private static Class<?> configurationFactoryClass;
+ private static Field providerCacheField;
+ private static Field configField;
+
+ private RestAdapterImpl adapter;
+
+
+ @SuppressWarnings("nls")
+ @BeforeClass
+ public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
+
+ }
+
+ @Before
+ public void setup() throws IllegalArgumentException, IllegalAccessException {
+
+ adapter = new RestAdapterImpl();
+ }
+
+ @Test
+ public void testCommonGet() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.URI", "http://example.com:8080/about/health");
+ params.put("org.openecomp.appc.instance.haveHeader","false");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.commonGet(params, svcContext);
+ String statusCode=svcContext.getAttribute("org.openecomp.rest.agent.result.code");
+ assertEquals("200",statusCode);
+ }
+
+ @Test
+ public void testCommonPost() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.URI", "http://example.com:8081/posttest");
+ params.put("org.openecomp.appc.instance.haveHeader","false");
+ params.put("org.openecomp.appc.instance.requestBody", "{\"name\":\"MyNode\", \"width\":200, \"height\":100}");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.commonPost(params, svcContext);
+ String statusCode=svcContext.getAttribute("org.openecomp.rest.agent.result.code");
+ assertEquals("200",statusCode);
+ }
+
+ @Test
+ public void testCommonPut() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.URI", "http://example.com:8081/puttest");
+ params.put("org.openecomp.appc.instance.haveHeader","false");
+ params.put("org.openecomp.appc.instance.requestBody", "{\"name\":\"MyNode2\", \"width\":300, \"height\":300}");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.commonPut(params, svcContext);
+ String statusCode=svcContext.getAttribute("org.openecomp.rest.agent.result.code");
+ assertEquals("200",statusCode);
+ }
+
+ @Test
+ public void testCommonDelete() throws IOException, IllegalStateException, IllegalArgumentException,
+ ZoneException, APPCException {
+
+ Map<String, String> params = new HashMap<>();
+ params.put("org.openecomp.appc.instance.URI", "http://example.com:8081/deletetest");
+ params.put("org.openecomp.appc.instance.haveHeader","false");
+ SvcLogicContext svcContext = new SvcLogicContext();
+ adapter.commonDelete(params, svcContext);
+ String statusCode=svcContext.getAttribute("org.openecomp.rest.agent.result.code");
+ assertEquals("200",statusCode);
+ }
+
+
+}
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
new file mode 100644
index 000000000..c21435d2e
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/ExecutorHarness.java
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.openecomp.appc.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.openecomp.appc.test.InterceptLogger;
+
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.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<String, Method> 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:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>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</li>
+ * </ul>
+ * @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:
+ * <ul>
+ * <li>invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared field</li>
+ * <li>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</li>
+ * </ul>
+ * @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<String> getExecMethodNames() {
+ List<String> 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-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
new file mode 100644
index 000000000..acb122914
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/java/org/openecomp/appc/test/InterceptLogger.java
@@ -0,0 +1,452 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+
+package org.openecomp.appc.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<LogRecord> events;
+
+ /**
+ * Create the intercept logger
+ */
+ public InterceptLogger() {
+ events = new ArrayList<LogRecord>(1000);
+ }
+
+ /**
+ * @return Returns all intercepted log events
+ */
+ public List<LogRecord> 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-rest-adapter/appc-rest-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
new file mode 100644
index 000000000..996730239
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/test/resources/org/openecomp/appc/default.properties
@@ -0,0 +1,113 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#
+# 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.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+appc.application.name=APPC
+
+#
+# Define the message resource bundle name to be loaded
+org.openecomp.appc.resources=org/openecomp/appc/i18n/MessageResources
+#
+# The name of the adapter.
+org.openecomp.appc.provider.adaptor.name=org.openecomp.appc.appc_provider_adapter
+#
+# Set up the logging environment
+#
+org.openecomp.appc.logging.file=org/openecomp/appc/logback.xml
+org.openecomp.appc.logging.path=${user.home};etc;../etc
+org.openecomp.appc.logger=org.openecomp.appc
+org.openecomp.appc.security.logger=org.openecomp.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.openecomp.appc.provider.min.pool=1
+org.openecomp.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.openecomp.appc.provider.retry.delay = 30
+org.openecomp.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.openecomp.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.openecomp.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.
+#
+
+
+### ###
+### Properties commented out below provided in appc.properties ###
+### ###
+
+# 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-rest-adapter/appc-rest-adapter-features/.gitignore b/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/.gitignore
new file mode 100644
index 000000000..615a76bbc
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/.gitignore
@@ -0,0 +1,4 @@
+/target/
+/bin/
+/classes/
+/.settings/
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/pom.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/pom.xml
new file mode 100644
index 000000000..05352e56b
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/pom.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-rest-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-rest-adapter-features</artifactId>
+ <name>Rest Adaptor - Features</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-rest-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <type>zip</type>
+ </dependency>
+
+<!-- <dependency> -->
+<!-- Required for launching the feature tests -->
+<!-- <groupId>org.opendaylight.yangtools</groupId> -->
+<!-- <artifactId>features-test</artifactId> -->
+<!-- <scope>test</scope> -->
+<!-- </dependency> -->
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- launches the feature test, which validates that your karaf feature
+ can be installed inside of a karaf container. It doesn't validate that your
+ functionality works correctly, just that you have all of the dependent bundles
+ defined correctly. -->
+ <!-- <plugin> -->
+ <!-- <groupId>org.apache.maven.plugins</groupId> -->
+ <!-- <artifactId>maven-surefire-plugin</artifactId> -->
+ <!-- <version>2.16</version> -->
+ <!-- <configuration> -->
+ <!-- <systemPropertyVariables> -->
+ <!-- <karaf.distro.groupId>org.opendaylight.controller</karaf.distro.groupId> -->
+ <!-- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId> -->
+ <!-- <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version> -->
+ <!-- </systemPropertyVariables> -->
+ <!-- <dependenciesToScan> -->
+ <!-- <dependency>org.opendaylight.yangtools:features-test</dependency> -->
+ <!-- </dependenciesToScan> -->
+ <!-- </configuration> -->
+ <!-- </plugin> -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/src/main/resources/features.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/src/main/resources/features.xml
new file mode 100644
index 000000000..e3fab488d
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-rest-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${features-mdsal.version}/xml/features</repository>
+
+ <feature name='appc-rest-adapter' description="appc-rest-adapter" version='${project.version}'>
+ <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
+ <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature>
+ <feature>sdnc-sli</feature>
+ <bundle>mvn:org.openecomp.appc/appc-rest-adapter-bundle/${project.version}</bundle>
+ </feature>
+
+</features>
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/.gitignore b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/.gitignore
new file mode 100644
index 000000000..731eb433c
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/.gitignore
@@ -0,0 +1,2 @@
+/target/
+/.settings/
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/pom.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/pom.xml
new file mode 100644
index 000000000..26970bfc0
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>appc-rest-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-rest-adapter-installer</artifactId>
+ <name>rest Adapter - Karaf Installer</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>appc-rest-adapter</application.name>
+ <features.boot>appc-rest-adapter</features.boot>
+ <features.repositories>mvn:org.openecomp.appc/appc-rest-adapter-features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-rest-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-rest-adapter-bundle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <excludeGroupIds>org.opendaylight</excludeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_installer_zip.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_installer_zip.xml
new file mode 100644
index 000000000..9fbaad8c5
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_installer_zip.xml
@@ -0,0 +1,59 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
new file mode 100644
index 000000000..1ac5a82bc
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/assembly/assemble_mvnrepo_zip.xml
@@ -0,0 +1,47 @@
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>adapter</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/main/resources/scripts/install-feature.sh b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/main/resources/scripts/install-feature.sh
new file mode 100644
index 000000000..1d769fada
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/appc-rest-adapter-installer/src/main/resources/scripts/install-feature.sh
@@ -0,0 +1,40 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot}
diff --git a/appc-adapters/appc-rest-adapter/pom.xml b/appc-adapters/appc-rest-adapter/pom.xml
new file mode 100644
index 000000000..c98c6ccd9
--- /dev/null
+++ b/appc-adapters/appc-rest-adapter/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-adapters</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-rest-adapter</artifactId>
+ <name>rest Adaptor</name>
+ <description>Abstraction to connect to and utilize the services of cloud providers such as OpenStack or VMWare.</description>
+ <packaging>pom</packaging>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <additionalDependencies>
+ <additionalDependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4</artifactId>
+ <version>${antlr.version}</version>
+ </additionalDependency>
+ <additionalDependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-runtime</artifactId>
+ <version>4.3</version>
+ </additionalDependency>
+ </additionalDependencies>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>javadoc-no-fork</report>
+ <report>test-javadoc-no-fork</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>aggregate</id>
+ <reports>
+ <report>aggregate</report>
+ <report>test-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changelog-plugin</artifactId>
+ <version>2.3</version>
+ <reportSets>
+ <reportSet>
+ <id>dual-report</id>
+ <configuration>
+ <type>range</type>
+ <range>30</range>
+ </configuration>
+ <reports>
+ <report>changelog</report>
+ <report>file-activity</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-rest-adapter-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-rest-adapter-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+
+ </dependencyManagement>
+
+ <modules>
+ <module>appc-rest-adapter-bundle</module>
+ <module>appc-rest-adapter-features</module>
+ <module>appc-rest-adapter-installer</module>
+ </modules>
+</project>
diff --git a/appc-adapters/appc-ssh-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-ssh-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/pom.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/pom.xml
new file mode 100644
index 000000000..0a402669b
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-ssh-adapter-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.openecomp.appc.adapter.ssh</Export-Package>
+ <Embed-Dependency>!dblib-provider</Embed-Dependency>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/Constants.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/Constants.java
new file mode 100644
index 000000000..9a160dbff
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/Constants.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+public class Constants {
+
+ private Constants(){}
+
+// public static final String CONFIGURE_PATH = "/restconf/config/opendaylight-inventory:nodes/node/";
+// public static final String CONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules";
+// public static final String CHECK_CONNECTION_PATH = "/restconf/operational/opendaylight-inventory:nodes/node/";
+// public static final String DISCONNECT_PATH = "/restconf/config/opendaylight-inventory:nodes/node/controller-config/yang-ext:mount/config:modules/module/odl-sal-netconf-connector-cfg:sal-netconf-connector/";
+//
+// public static final String CONTROLLER_IP = "127.0.0.1";
+// public static final int CONTROLLER_PORT = 8181;
+// public static final String PROTOCOL = "http";
+//
+// public static final String VF_LICENSE = "VF_LICENSE";
+
+ // tables and fields
+ public static final String NETCONF_SCHEMA = "sdnctl";
+ public static final String SDNCTL_SCHEMA = "sdnctl";
+ public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION";
+ public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES";
+ public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG";
+ public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT";
+ public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME";
+ public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME";
+ public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD";
+ public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER";
+ public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE";
+ public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID";
+ public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID";
+ public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE";
+ public static final String LOG_FIELD_NAME = "LOG";
+ public static final String ASDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS";
+
+ // input fields names
+ public static final String PAYLOAD = "payload";
+
+
+ public static final String PARAM_IN_connection_details = "connection-details";
+ public static final String SKIP_EXECUTION_INSTALLER_BIN_FILE = "Skip-execution-installer-bin-file";
+ public static final String SKIP_DEPLOY = "Skip-deploy";
+ public static final String UPGRADE_VERSION = "upgrade-version";
+
+ //command to get number of UP hosts
+ public static final String STATE_COMMAND = "/opt/jnetx/skyfall-scp/asp-state.sh | grep -o UP | wc -l";
+ public static final int STATE_COMMAND_RESULT = 18;
+ //commands to check FE hosts
+ public static final String FE_STATE_TRUE_TEST_COMMAND = "ssh -t -q fe1 /opt/omni/bin/swmml -e display-platform-status | grep -o TRUE | wc -l";
+ public static final int FE_STATE_TRUE_TEST_RESULT = 22;
+ public static final String FE_STATE_FALSE_TEST_COMMAND = "ssh -t -q fe1 /opt/omni/bin/swmml -e display-platform-status | grep -o FALSE | wc -l";
+ public static final int FE_STATE_FALSE_TEST_RESULT = 2;
+ public static final String FE_OPERATIONAL_TEST_COMMAND = "ssh -t -q fe1 /opt/omni/bin/swmml -e display-platform-status | grep -o 'NOT FULLY OPERATIONAL' | wc -l";
+ public static final int FE_OPERATIONAL_TEST_RESULT = 2;
+ //rsync command
+ public static final String RSYNC_COMMAND = "yes n | /opt/jnetx/skyfall-scp/asp-rsync.sh --check | grep -o 'is active' | wc -l";
+ public static final int RSYNC_COMMAND_RESULT = 9;
+
+ public static final String PARAM_IN_TIMEOUT = "timeout";
+ public static final String PARAM_IN_FILE_URL = "source-file-url";
+ public static final String DOWNLOAD_COMMAND = "wget -N %s";
+
+ // pre-define jnetx VM names
+ public static final String[] VM_NAMES = {"fe1", "fe2", "be1", "be2", "be3", "be4", "be5", "smp1", "smp2"};
+
+ public static final String DEFAULT_DISK_SPACE = "10240000";
+ public static final String DF_COMMAND_TEMPLATE = "ssh %s df | grep vda1 | grep -v grep | tr -s ' '|cut -d ' ' -f4";
+
+ public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+
+
+ // constants fo DG
+// public static final String VNF_TYPE_FIELD_NAME = "org.openecomp.appc.vftype";
+// public static final String VNF_VERSION_FIELD_NAME = "org.openecomp.appc.vfversion";
+// public static final String VNF_RESOURCE_VERSION_FIELD_NAME = "org.openecomp.appc.resource-version";
+// public static final String TARGET_VNF_TYPE = "target-vnf-type";
+// public static final String FILE_CONTENT_FIELD_NAME = "file-content";
+ public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details";
+// public static final String CONFIGURATION_FILE_FIELD_NAME = "configuration-file-name";
+ public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address";
+// public static final String UPGRADE_VERSION = "upgrade-version";
+ public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
+// public static final String RESOURCEKEY = "resourceKey";
+// public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
+// public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
+// public static final String MODEL_ENTITLMENT_POOL_UUID_NAME = "model.entitlement.pool.uuid";
+// public static final String MODEL_LICENSE_KEY_UUID_NAME = "model.license.key.uuid";
+// public static final String ENTITLMENT_POOL_UUID_NAME = "entitlement.pool.uuid";
+// public static final String LICENSE_KEY_UUID_NAME = "license.key.uuid";
+// public static final String IS_ACQUIRE_LICENSE_REQUIRE ="is.acquire-license.require";
+// public static final String IS_RELEASE_LICENSE_REQUIRE ="is.release-license.require";
+//
+// public static final String AAI_ENTITLMENT_POOL_UUID_NAME = "aai.input.data.entitlement-assignment-group-uuid";
+// public static final String AAI_LICENSE_KEY_UUID_NAME = "aai.input.data.license-assignment-group-uuid";
+// public static final String AAI_LICENSE_KEY_VALUE = "aai.input.data.license-key";
+// public static final String IS_AAI_ENTITLEMENT_UPDATE_REQUIRE = "is.aai-entitlement-update.require";
+// public static final String IS_AAI_LICENSE_UPDATE_REQUIRE = "is.aai-license-update.require";
+// public static final String IS_ACQUIRE_ENTITLEMENT_REQUIRE ="is.acquire-entitlement.require";
+// public static final String IS_RELEASE_ENTITLEMENT_REQUIRE ="is.release-entitlement.require";
+//
+// public enum ASDC_ARTIFACTS_FIELDS {
+// SERVICE_UUID,
+// DISTRIBUTION_ID,
+// SERVICE_NAME,
+// SERVICE_DESCRIPTION,
+// RESOURCE_UUID,
+// RESOURCE_INSTANCE_NAME,
+// RESOURCE_NAME,
+// RESOURCE_VERSION,
+// RESOURCE_TYPE,
+// ARTIFACT_UUID,
+// ARTIFACT_TYPE,
+// ARTIFACT_VERSION,
+// ARTIFACT_DESCRIPTION,
+// INTERNAL_VERSION,
+// CREATION_DATE,
+// ARTIFACT_NAME,
+// ARTIFACT_CONTENT
+// }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapter.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapter.java
new file mode 100644
index 000000000..3d305877b
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapter.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+/**
+ * Factory class for creating SshConnection instances.
+ */
+public interface SshAdapter {
+
+ /**
+ * Creates instance of SshConnection.
+ *
+ * @param host remote host to open SSH connection to
+ * @param port remote SSH port
+ * @param username SSH connection user name
+ * @param password SSH connection password
+ * @return instance of SshConnection
+ */
+ SshConnection getConnection(String host, int port, String username, String password);
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnection.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnection.java
new file mode 100644
index 000000000..0b3275f5d
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnection.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+import java.io.OutputStream;
+
+/**
+ * Provides utility method(s) to call commands on remote host via SSH.
+ */
+public interface SshConnection {
+
+ /**
+ * Connect to SSH server.
+ */
+ void connect();
+
+ /**
+ * Disconnect from SSH server.
+ */
+ void disconnect();
+
+ /**
+ * Exec remote command over SSH. Return command execution status.
+ * Command output is written to out or err stream.
+ *
+ * @param cmd command to execute
+ * @param out content of sysout will go to this stream
+ * @param err content of syserr will go to this stream
+ * @return command execution status
+ */
+ int execCommand(String cmd, OutputStream out, OutputStream err);
+
+ /**
+ * Exec remote command over SSH with pseudo-tty. Return command execution status.
+ * Command output is written to out stream only as pseudo-tty writes to one stream only.
+ *
+ * @param cmd command to execute
+ * @param out content of sysout will go to this stream
+ * @return command execution status
+ */
+ int execCommandWithPty(String cmd, OutputStream out);
+
+ /**
+ * Set the command execution timeout
+ * @param timeout time in milliseconds
+ */
+ void setExecTimeout(long timeout);
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionDetails.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionDetails.java
new file mode 100644
index 000000000..a1fa97422
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionDetails.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+/**
+ * Provides details required for connecting to device.
+ */
+public class SshConnectionDetails {
+
+ private static int DEFAULT_PORT = 22;
+
+ private String host;
+ private int port = DEFAULT_PORT;
+ private String username;
+ private String password;
+
+ public SshConnectionDetails() {
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessException.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessException.java
new file mode 100644
index 000000000..2d7f8333d
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessException.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+
+
+public class SshDataAccessException extends RuntimeException {
+
+ private static final long serialVersionUID = -155423437162622414L;
+
+ public SshDataAccessException(){
+ }
+
+ public SshDataAccessException(String message){
+ super(message);
+ }
+
+ public SshDataAccessException(Throwable cause){
+ super(cause);
+ }
+
+ public SshDataAccessException(String message , Throwable cause){
+ super(message , cause);
+ }
+
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessService.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessService.java
new file mode 100644
index 000000000..2d8119899
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshDataAccessService.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+
+@SuppressWarnings("JavaDoc")
+public interface SshDataAccessService {
+
+ /**
+ *
+ * @param schema
+ */
+ void setSchema(String schema);
+
+ /**
+ *@param dbLibService
+ */
+ void setDbLibService(DbLibService dbLibService);
+
+ /**
+ *
+ * @param xmlID
+ * @return
+ * @throws SshDataAccessException
+ */
+ String retrieveConfigFileName(String xmlID) throws SshDataAccessException;
+
+ /**
+ *
+ * @param vnfType
+ * @param connectionDetails
+ * @return
+ * @throws SshException
+ */
+ boolean retrieveConnectionDetails(String vnfType, SshConnectionDetails connectionDetails) throws SshDataAccessException;
+
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshException.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshException.java
new file mode 100644
index 000000000..7a0c1fb99
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/openecomp/appc/adapter/ssh/SshException.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+public class SshException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor with message.
+ *
+ * @param message exception message
+ */
+ public SshException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with message and cause exception.
+ *
+ * @param message exception message
+ * @param cause exception cause
+ */
+ public SshException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/pom.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/pom.xml
new file mode 100644
index 000000000..39ac425d9
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>appc-ssh-adapter</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>appc-ssh-adapter-features</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-sshd</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/src/main/resources/features.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/src/main/resources/features.xml
new file mode 100644
index 000000000..6f565dc09
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-features/src/main/resources/features.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-ssh-adapter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+ <feature name='appc-ssh-adapter' description="appc-ssh-adapter" version='${project.version}'>
+ <bundle>mvn:org.openecomp.appc/appc-ssh-adapter-api/${project.version}</bundle>
+ <bundle>mvn:org.openecomp.appc/appc-ssh-adapter-sshd/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/pom.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/pom.xml
new file mode 100644
index 000000000..54b7ea428
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>appc-ssh-adapter-sshd</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>dblib-provider</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Service>org.openecomp.appc.adapter.ssh.SshAdapter</Export-Service>
+ <Private-Package>org.openecomp.appc.adapter.ssh.impl.*</Private-Package>
+ <Import-Package>!org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*</Import-Package>
+ <Embed-Dependency>!dblib-provider,appc-common,jasypt,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSshd.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSshd.java
new file mode 100644
index 000000000..44a6fb4ce
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSshd.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh.sshd;
+
+import org.openecomp.appc.adapter.ssh.SshAdapter;
+import org.openecomp.appc.adapter.ssh.SshConnection;
+
+public class SshAdapterSshd implements SshAdapter {
+
+ @Override
+ public SshConnection getConnection(String host, int port, String username, String password) {
+ return new SshConnectionSshd(host, port, username, password);
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshConnectionSshd.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshConnectionSshd.java
new file mode 100644
index 000000000..4d8b83b6f
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshConnectionSshd.java
@@ -0,0 +1,172 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh.sshd;
+
+import org.apache.sshd.ClientChannel;
+import org.apache.sshd.ClientSession;
+import org.apache.sshd.SshClient;
+import org.apache.sshd.client.channel.ChannelExec;
+import org.apache.sshd.client.future.AuthFuture;
+import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.common.KeyPairProvider;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+import org.openecomp.appc.adapter.ssh.SshConnection;
+import org.openecomp.appc.adapter.ssh.SshException;
+import org.openecomp.appc.encryption.EncryptionTool;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.io.OutputStream;
+import java.security.KeyPair;
+
+/**
+ * Implementation of SshConnection interface based on Apache MINA SSHD library.
+ */
+class SshConnectionSshd implements SshConnection {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+
+ private static final long AUTH_TIMEOUT = 60000;
+ private static final long EXEC_TIMEOUT = 120000;
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+ private long timeout = EXEC_TIMEOUT;
+ private String keyFile;
+ private SshClient sshClient;
+ private ClientSession clientSession;
+
+ public SshConnectionSshd(String host, int port, String username, String password, String keyFile) {
+ this.host = host;
+ this.port = port;
+ this.username = username;
+ this.password = password;
+ this.keyFile = keyFile;
+ }
+
+ public SshConnectionSshd(String host, int port, String username, String password) {
+ this(host, port, username, password, null);
+ }
+
+ public SshConnectionSshd(String host, int port, String keyFile) {
+ this(host, port, null, null, keyFile);
+ }
+
+ @Override
+ public void connect() {
+ sshClient = SshClient.setUpDefaultClient();
+ sshClient.start();
+ try {
+ clientSession = sshClient.connect(EncryptionTool.getInstance().decrypt(username), host, port).await().getSession();
+ if(password != null) {
+ clientSession.addPasswordIdentity(EncryptionTool.getInstance().decrypt(password));
+ }
+ if(keyFile != null) {
+ KeyPairProvider keyPairProvider = new FileKeyPairProvider(new String[]{keyFile});
+ KeyPair keyPair = keyPairProvider.loadKeys().iterator().next();
+ clientSession.addPublicKeyIdentity(keyPair);
+ }
+ AuthFuture authFuture = clientSession.auth();
+ authFuture.await(AUTH_TIMEOUT);
+ if(!authFuture.isSuccess()) {
+ throw new SshException("Error establishing ssh connection to [" + username + "@" + host + ":" + port + "]. Authentication failed.");
+ }
+ } catch(RuntimeException e) {
+ throw e;
+ } catch(Exception e) {
+ throw new SshException("Error establishing ssh connection to [" + username + "@" + host + ":" + port + "].", e);
+ }
+ if(logger.isDebugEnabled()) {
+ logger.debug("SSH: connected to [" + toString() + "]");
+ }
+ }
+
+ @Override
+ public void disconnect() {
+ try {
+ if(logger.isDebugEnabled()) {
+ logger.debug("SSH: disconnecting from [" + toString() + "]");
+ }
+ clientSession.close(false);
+ } finally {
+ if(sshClient != null) {
+ sshClient.stop();
+ }
+ }
+ }
+
+ @Override
+ public void setExecTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ @Override
+ public int execCommand(String cmd, OutputStream out, OutputStream err) {
+ return execCommand(cmd, out, err, false);
+ }
+
+ @Override
+ public int execCommandWithPty(String cmd, OutputStream out) {
+ return execCommand(cmd, out, out, true);
+ }
+
+ private int execCommand(String cmd, OutputStream out, OutputStream err, boolean usePty) {
+ try {
+ if(logger.isDebugEnabled()) {
+ logger.debug("SSH: executing command");
+ }
+ ChannelExec client = clientSession.createExecChannel(cmd);
+ client.setUsePty(usePty); // use pseudo-tty?
+ client.setOut(out);
+ client.setErr(err);
+ OpenFuture openFuture = client.open();
+ int exitStatus = 0;
+ try {
+ client.waitFor(ClientChannel.CLOSED, timeout);
+ openFuture.verify();
+ Integer exitStatusI = client.getExitStatus();
+ if(exitStatusI == null) {
+ throw new SshException("Error executing command [" + cmd + "] over SSH [" + username + "@" + host + ":" + port + "]. Operation timed out.");
+ }
+ exitStatus = exitStatusI;
+ } finally {
+ client.close(false);
+ }
+ return exitStatus;
+ } catch(RuntimeException e) {
+ throw e;
+ } catch(Exception t) {
+ throw new SshException("Error executing command [" + cmd + "] over SSH [" + username + "@" + host + ":" + port + "]", t);
+ }
+ }
+
+ @Override
+ public String toString() {
+ String address = host;
+ if(username != null) {
+ address = username + '@' +address;
+ }
+ return address;
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshdDataAccessService.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshdDataAccessService.java
new file mode 100644
index 000000000..a12e2be93
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/openecomp/appc/adapter/ssh/sshd/SshdDataAccessService.java
@@ -0,0 +1,106 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh.sshd;
+
+import javax.sql.rowset.CachedRowSet;
+
+import org.openecomp.appc.adapter.ssh.Constants;
+import org.openecomp.appc.adapter.ssh.SshConnectionDetails;
+import org.openecomp.appc.adapter.ssh.SshDataAccessException;
+import org.openecomp.appc.adapter.ssh.SshDataAccessService;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+
+
+public class SshdDataAccessService implements SshDataAccessService {
+
+ private String schema = Constants.NETCONF_SCHEMA;
+ private DbLibService dbLibService;
+
+ @Override
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public void setDbLibService(DbLibService dbLibService) {
+ this.dbLibService = dbLibService;
+ }
+
+ @Override
+ public boolean retrieveConnectionDetails(String vnfType, SshConnectionDetails connectionDetails) throws SshDataAccessException {
+
+ boolean recordFound = false;
+
+ String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " +
+ "from " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME + " " +
+ "where " + Constants.VNF_TYPE_TABLE_FIELD_NAME + " = ?";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(vnfType);
+
+ try {
+
+ final CachedRowSet data = dbLibService.getData(queryString, argList, schema);
+ if (data.first()) {
+ recordFound = true;
+ connectionDetails.setUsername(data.getString(Constants.USER_NAME_TABLE_FIELD_NAME));
+ connectionDetails.setPassword(data.getString(Constants.PASSWORD_TABLE_FIELD_NAME));
+ connectionDetails.setPort(data.getInt(Constants.PORT_NUMBER_TABLE_FIELD_NAME));
+ }
+
+ } catch (SQLException e) {
+ throw new SshDataAccessException(e);
+ }
+
+ return recordFound;
+ }
+
+ @Override
+ public String retrieveConfigFileName(String xmlID) throws SshDataAccessException {
+ String fileContent;
+
+ String queryString = "select " + Constants.FILE_CONTENT_TABLE_FIELD_NAME + " " +
+ "from " + Constants.CONFIGFILES_TABLE_NAME + " " +
+ "where " + Constants.FILE_NAME_TABLE_FIELD_NAME + " = ?";
+
+ ArrayList<String> argList = new ArrayList<>();
+ argList.add(xmlID);
+
+ try {
+
+ final CachedRowSet data = dbLibService.getData(queryString, argList, schema);
+ fileContent = data.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME);
+
+ } catch (SQLException e) {
+ throw new SshDataAccessException(e);
+ }
+
+ return fileContent;
+ }
+
+
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..f9d10868a
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <bean id="sshdBean" class="org.openecomp.appc.adapter.ssh.sshd.SshAdapterSshd" scope="singleton"/>
+ <service id="sshAdapter" interface="org.openecomp.appc.adapter.ssh.SshAdapter" ref="sshdBean"/>
+
+ <reference id="dbLibServiceRef" availability="mandatory" activation="eager" interface="org.openecomp.sdnc.sli.resource.dblib.DbLibService" />
+ <bean id="sshdDAServiceBean" class="org.openecomp.appc.adapter.ssh.sshd.SshdDataAccessService" scope="singleton">
+ <property name="dbLibService" ref="dbLibServiceRef" />
+ </bean>
+
+ <service id="sshDAService" interface="org.openecomp.appc.adapter.ssh.SshDataAccessService" ref="sshdDAServiceBean"/>
+
+</blueprint>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSample.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSample.java
new file mode 100644
index 000000000..197915de8
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterSample.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh.sshd;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import org.openecomp.appc.adapter.ssh.SshAdapter;
+import org.openecomp.appc.adapter.ssh.SshConnection;
+import org.openecomp.appc.adapter.ssh.sshd.SshAdapterSshd;
+
+public class SshAdapterSample {
+
+ public static void main(String[] args) {
+ String host = "hostname";
+ int port = 22;
+ String username = "user";
+ String password = "secret";
+ String command = "ls";
+
+ SshAdapter sshAdapter = new SshAdapterSshd();
+ SshConnection sshConnection = sshAdapter.getConnection(host, port, username, password);
+ sshConnection.connect();
+ try {
+ OutputStream stdout = new ByteArrayOutputStream();
+ OutputStream stderr = new ByteArrayOutputStream();
+ int status = sshConnection.execCommand(command, stdout, stderr);
+ if(status == 0) {
+ System.out.println("Command executed successfully. Output:\n" + stdout.toString());
+ } else {
+ System.err.println("Command returned status " + status + ". Error:\n" + stderr.toString());
+ }
+ } finally {
+ sshConnection.disconnect();
+ }
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterTest.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterTest.java
new file mode 100644
index 000000000..1d7d06df2
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/openecomp/appc/adapter/ssh/sshd/SshAdapterTest.java
@@ -0,0 +1,247 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh.sshd;
+
+import org.apache.sshd.SshServer;
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.util.OsUtils;
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.CommandFactory;
+import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.command.ScpCommandFactory;
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
+import org.apache.sshd.server.session.ServerSession;
+import org.apache.sshd.server.sftp.SftpSubsystem;
+import org.apache.sshd.server.shell.ProcessShellFactory;
+import org.hamcrest.CoreMatchers;
+import org.junit.*;
+import org.junit.rules.ExpectedException;
+import org.openecomp.appc.adapter.ssh.SshAdapter;
+import org.openecomp.appc.adapter.ssh.SshConnection;
+import org.openecomp.appc.adapter.ssh.SshException;
+import org.openecomp.appc.adapter.ssh.sshd.SshAdapterSshd;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.BindException;
+import java.security.PublicKey;
+import java.util.Collections;
+import java.util.EnumSet;
+
+public class SshAdapterTest {
+
+ private static final boolean START_SERVER = true;
+ private static final String SSH_HOST = "localhost";
+ private static final int SSH_PORT = 2222;
+ private static final String SSH_USERNAME = "test";
+ private static final String SSH_PASSWORD = "test";
+ private static final String F_TEST_CMD = "ping -%c 4 %s";
+
+ private int sshPort = SSH_PORT;
+ private SshServer sshd;
+ private SshAdapter sshAdapter = new SshAdapterSshd();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testExecute() {
+ String cmd = String.format(F_TEST_CMD, OsUtils.isUNIX() ? 'c' : 'n', "localhost");
+ SshConnection sshConnection = connect(SSH_USERNAME, SSH_PASSWORD);
+ try {
+ System.out.println("SSH client connected. Server port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ int status = execCmd(sshConnection, cmd, stdout, stderr, false);
+ Assert.assertEquals(stdout.toString() + ". " + stderr.toString(), 0, status);
+ } finally {
+ disconnect(sshConnection);
+ }
+ }
+
+ @Test
+ public void testExecuteWithPty() {
+ String cmd = String.format(F_TEST_CMD, OsUtils.isUNIX() ? 'c' : 'n', "localhost");
+ SshConnection sshConnection = connect(SSH_USERNAME, SSH_PASSWORD);
+ try {
+ System.out.println("SSH client connected. Server port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ int status = execCmd(sshConnection, cmd, stdout, null, true);
+ Assert.assertEquals(stdout.toString() + ". " + stdout.toString(), 0, status);
+ } finally {
+ disconnect(sshConnection);
+ }
+ }
+
+ @Test
+ public void testExecuteInvalidCommand() {
+ String cmd = String.format(F_TEST_CMD, OsUtils.isUNIX() ? 'c' : 'n', "nosuchhost");
+ SshConnection sshConnection = connect(SSH_USERNAME, SSH_PASSWORD);
+ try {
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+ ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+ int status = execCmd(sshConnection, cmd, stdout, stderr, false);
+ Assert.assertNotEquals(stdout.toString() + ". " + stderr.toString(), 0, status);
+ } finally {
+ disconnect(sshConnection);
+ }
+ }
+
+ @Test
+ public void testWrongUsername() {
+ thrown.expect(SshException.class);
+ thrown.expectMessage(CoreMatchers.containsString("Authentication failed"));
+ disconnect(connect("WrongUsername", SSH_PASSWORD));
+ }
+
+ @Test
+ public void testWrongPassword() {
+ thrown.expect(SshException.class);
+ thrown.expectMessage(CoreMatchers.containsString("Authentication failed"));
+ disconnect(connect(SSH_USERNAME, "WrongPassword"));
+ }
+
+ @Before
+ public void beforeTest() throws IOException {
+ if (START_SERVER) {
+ startServer();
+ }
+ }
+
+ @After
+ public void afterTest() throws InterruptedException {
+ stopServer();
+ }
+
+ private SshConnection connect(String username, String password) {
+ SshConnection sshConnection = sshAdapter.getConnection(SSH_HOST, sshPort, username, password);
+ sshConnection.connect();
+ System.out.println("SSH client connected. Server port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ return sshConnection;
+ }
+
+ private void disconnect(SshConnection sshConnection) {
+ sshConnection.disconnect();
+ System.out.println("SSH client disconnected. Server port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ }
+
+ private int execCmd(SshConnection sshConnection, String cmd, OutputStream stdout, OutputStream stderr, boolean usePty) {
+ System.out.println("=> Running command [" + cmd + "] over SSH");
+ int status;
+ if (usePty) {
+ status = sshConnection.execCommandWithPty(cmd, stdout);
+ } else {
+ status = sshConnection.execCommand(cmd, stdout, stderr);
+ }
+ System.out.println("=> Command [" + cmd + "] status is [" + status + "], stdout is [" + String.valueOf(stdout) + "], stderr is [" + String.valueOf(stderr) + "]");
+ return status;
+ }
+
+ private void startServer() throws IOException {
+ sshd = SshServer.setUpDefaultServer();
+ sshd.setSubsystemFactories(Collections.<NamedFactory<Command>>singletonList(new SftpSubsystem.Factory()));
+ sshd.setCommandFactory(new ScpCommandFactory(new CommandFactory() {
+
+ public Command createCommand(String command) {
+ EnumSet<ProcessShellFactory.TtyOptions> ttyOptions;
+ if (OsUtils.isUNIX()) {
+ ttyOptions = EnumSet.of(ProcessShellFactory.TtyOptions.ONlCr);
+ } else {
+ ttyOptions = EnumSet.of(ProcessShellFactory.TtyOptions.Echo, ProcessShellFactory.TtyOptions.ICrNl, ProcessShellFactory.TtyOptions.ONlCr);
+ }
+ return new ProcessShellFactory(command.split(" "), ttyOptions).create();
+ }
+ }));
+ if (OsUtils.isUNIX()) {
+ sshd.setShellFactory(new ProcessShellFactory(new String[]{"/bin/sh", "-i", "-l"},
+ EnumSet.of(ProcessShellFactory.TtyOptions.ONlCr)));
+ } else {
+ sshd.setShellFactory(new ProcessShellFactory(new String[]{"cmd.exe "},
+ EnumSet.of(ProcessShellFactory.TtyOptions.Echo, ProcessShellFactory.TtyOptions.ICrNl, ProcessShellFactory.TtyOptions.ONlCr)));
+ }
+// if(SecurityUtils.isBouncyCastleRegistered()) {
+// sshd.setKeyPairProvider(new PEMGeneratorHostKeyProvider(System.getProperty("java.io.tmpdir") + "/key.pem"));
+// } else {
+ sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(System.getProperty("java.io.tmpdir") + "/key.ser"));
+// }
+ sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
+
+ @Override
+ public boolean authenticate(String username, String password, ServerSession session) {
+ return (SSH_USERNAME.equals(username) && SSH_PASSWORD.equals(password));
+ }
+ });
+ sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
+
+ public boolean authenticate(String username, PublicKey key, ServerSession session) {
+ return true;
+ }
+ });
+ sshd.getProperties().put(SshServer.WELCOME_BANNER, "Welcome to SSHD\n");
+ startServer0();
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ private void startServer0() throws IOException {
+ boolean serverStarted = false;
+ IOException exception = null;
+ while (!serverStarted && (sshPort < Integer.MAX_VALUE)) {
+ try {
+ System.out.println("Starting SSH server on port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ sshd.setPort(sshPort);
+ sshd.start();
+ serverStarted = true;
+ } catch (BindException e) {
+ System.err.println("Cannot start SSH server on port [" + sshPort + "]. " + e.getMessage());
+ if (exception == null) {
+ // store first thrown exception - will be thrown if cannot start the server
+ exception = e;
+ }
+ sshPort++;
+ }
+ }
+ if (!serverStarted) {
+ throw exception;
+ }
+ System.out.println("SSH server started on port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ }
+
+ private void stopServer() {
+ try {
+ if (sshd != null) {
+ sshd.stop(true);
+ System.out.println("SSH server stopped on port [" + sshPort + "]. [" + getClass().getName() + "#" + System.identityHashCode(this) + "]");
+ }
+ } catch (InterruptedException e) {
+ System.err.println("=> Error stopping SSH server.");
+ e.printStackTrace();
+ } finally {
+ sshd = null;
+ }
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/.settings/org.eclipse.wst.common.project.facet.core.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 000000000..f4ef8aa0a
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="java" version="1.8"/>
+</faceted-project>
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml
new file mode 100644
index 000000000..0c66afd21
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-ssh-adapter-tests</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-ssh-adapter-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapterMock.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapterMock.java
new file mode 100644
index 000000000..c0ccdfaee
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshAdapterMock.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openecomp.appc.adapter.ssh.SshAdapter;
+import org.openecomp.appc.adapter.ssh.SshConnection;
+
+public class SshAdapterMock implements SshAdapter {
+
+ private List<SshConnectionMock> connectionMocks = new ArrayList<>();
+
+ private int returnStatus;
+ private String returnStdout;
+ private String returnStderr;
+
+ @Override
+ public SshConnection getConnection(String host, int port, String username, String password) {
+ SshConnectionMock sshConnectionMock = new SshConnectionMock(host, port, username, password);
+ sshConnectionMock.setReturnStatus(returnStatus);
+ sshConnectionMock.setReturnStdout(returnStdout);
+ sshConnectionMock.setReturnStderr(returnStderr);
+ connectionMocks.add(sshConnectionMock);
+ return sshConnectionMock;
+ }
+
+ public List<SshConnectionMock> getConnectionMocks() {
+ return connectionMocks;
+ }
+
+ public int getReturnStatus() {
+ return returnStatus;
+ }
+
+ public void setReturnStatus(int returnStatus) {
+ this.returnStatus = returnStatus;
+ }
+
+ public String getReturnStdout() {
+ return returnStdout;
+ }
+
+ public void setReturnStdout(String returnStdout) {
+ this.returnStdout = returnStdout;
+ }
+
+ public String getReturnStderr() {
+ return returnStderr;
+ }
+
+ public void setReturnStderr(String returnStderr) {
+ this.returnStderr = returnStderr;
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionMock.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionMock.java
new file mode 100644
index 000000000..3194edcfb
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/main/java/org/openecomp/appc/adapter/ssh/SshConnectionMock.java
@@ -0,0 +1,155 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.adapter.ssh;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openecomp.appc.adapter.ssh.SshConnection;
+
+public class SshConnectionMock implements SshConnection {
+
+ private static final int DEF_SUCCESS_STATUS = 0;
+
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+ private long timeout;
+
+ private int returnStatus = DEF_SUCCESS_STATUS;
+ private String returnStdout;
+ private String returnStderr;
+
+ private int connectCallCount = 0;
+ private int disconnectCallCount = 0;
+ private List<String> executedCommands = new ArrayList<>();
+
+ public SshConnectionMock(String host, int port, String username, String password) {
+ this.host = host;
+ this.port = port;
+ this.username = username;
+ this.password = password;
+ }
+
+ @Override
+ public void connect() {
+ connectCallCount++;
+ }
+
+ @Override
+ public void disconnect() {
+ disconnectCallCount++;
+ }
+
+ @Override
+ public int execCommand(String cmd, OutputStream out, OutputStream err) {
+ return execCommand(cmd, out, err, false);
+ }
+
+ @Override
+ public int execCommandWithPty(String cmd, OutputStream out) {
+ return execCommand(cmd, out, out, true);
+ }
+
+ private int execCommand(String cmd, OutputStream out, OutputStream err, boolean usePty) {
+ executedCommands.add(cmd);
+ try {
+ if((out != null) && (returnStdout != null)) {
+ out.write(returnStdout.getBytes());
+ }
+ } catch(IOException e) {
+ throw new RuntimeException("Error writing to stdout output stream", e);
+ }
+ try {
+ if((err != null) && (returnStderr != null)) {
+ err.write(returnStderr.getBytes());
+ }
+ } catch(IOException e) {
+ throw new RuntimeException("Error writing to stderr output stream", e);
+ }
+ return returnStatus;
+ }
+
+ @Override
+ public void setExecTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public long getExecTimeout() {
+ return timeout;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public int getConnectCallCount() {
+ return connectCallCount;
+ }
+
+ public int getDisconnectCallCount() {
+ return disconnectCallCount;
+ }
+
+ public List<String> getExecutedCommands() {
+ return executedCommands;
+ }
+
+ public int getReturnStatus() {
+ return returnStatus;
+ }
+
+ public void setReturnStatus(int returnStatus) {
+ this.returnStatus = returnStatus;
+ }
+
+ public String getReturnStdout() {
+ return returnStdout;
+ }
+
+ public void setReturnStdout(String returnStdout) {
+ this.returnStdout = returnStdout;
+ }
+
+ public String getReturnStderr() {
+ return returnStderr;
+ }
+
+ public void setReturnStderr(String returnStderr) {
+ this.returnStderr = returnStderr;
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/pom.xml b/appc-adapters/appc-ssh-adapter/pom.xml
new file mode 100644
index 000000000..af3d503fc
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/pom.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>appc-adapters</artifactId>
+ <groupId>org.openecomp.appc</groupId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>appc-ssh-adapter</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>appc-ssh-adapter-api</module>
+ <module>appc-ssh-adapter-tests</module>
+ <module>appc-ssh-adapter-sshd</module>
+ <module>appc-ssh-adapter-features</module>
+ </modules>
+</project> \ No newline at end of file
diff --git a/appc-adapters/pom.xml b/appc-adapters/pom.xml
new file mode 100644
index 000000000..67ee81bfc
--- /dev/null
+++ b/appc-adapters/pom.xml
@@ -0,0 +1,21 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <artifactId>appc-adapters</artifactId>
+ <name>APPC Adapters</name>
+ <description>Adapter bundles for app-c</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>appc-chef-adapter</module>
+ <module>appc-rest-adapter</module>
+ <module>appc-iaas-adapter</module>
+ <module>appc-dmaap-adapter</module>
+ <module>appc-netconf-adapter</module>
+ <module>appc-ssh-adapter</module>
+ </modules>
+</project>