From 55dcf3197958c76b1622a0c26489e68fe77e0314 Mon Sep 17 00:00:00 2001 From: Ravi Mantena Date: Wed, 21 Oct 2020 15:47:38 -0400 Subject: Blueprint Generator Refactored Code Issue-ID: DCAEGEN2-2472 Change-Id: I2ade7fb3b4196554eb4ecadd918fd45cb6ba8a52 Signed-off-by: Ravi Mantena --- mod/bpgenerator/README.md | 13 +- .../blueprint_withTlsFalseAndExternalTlsFalse.yaml | 136 ------- .../blueprint_withTlsTrueAndExternalTlsTrue.yaml | 136 ------- .../blueprint_withTlsTrueAndNoExternalTls.yaml | 101 ----- .../TlsInfo/blueprint_withoutTlsInfo.yaml | 93 ----- ...ponentSpec_withTlsFalseAndExternalTlsFalse.json | 43 --- ...omponentSpec_withTlsTrueAndExternalTlsTrue.json | 43 --- ...tComponentSpec_withTlsTrueAndNoExternalTls.json | 42 -- .../TlsInfo/testComponentSpec_withoutTlsInfo.json | 38 -- mod/bpgenerator/TestCases/datafile.json | 426 --------------------- .../TestCases/expects/createAppConfigResult.txt | 1 - mod/bpgenerator/TestCases/hello.json | 129 ------- .../blueprint/helloworld_changed_with_dmaap.yaml | 376 ------------------ .../helloworld_changed_without_dmaap_yaml.yaml | 330 ---------------- .../helloworld/compspec/hello-changed.json | 154 -------- mod/bpgenerator/TestCases/imports/imports.yaml | 2 - .../TestCases/imports/importsWithBlanks.yaml | 3 - mod/bpgenerator/TestCases/j.json | 96 ----- mod/bpgenerator/TestCases/jack.json | 93 ----- mod/bpgenerator/TestCases/policyInput.json | 28 -- mod/bpgenerator/TestCases/testComponentSpec.json | 116 ------ mod/bpgenerator/TestCases/testImport.yaml | 4 - mod/bpgenerator/TestCases/testImports.yaml | 3 - mod/bpgenerator/TestCases/ves.json | 384 ------------------- .../TestCases/ves/blueprints/vesK8sWithDmaap.yaml | 319 --------------- .../ves/blueprints/vesK8sWithoutDmaap.yaml | 185 --------- .../TestCases/ves/componentSpecs/ves.json | 276 ------------- .../TestCases/ves/inputFiles/ves_nodmaap.json | 11 - mod/bpgenerator/common/pom.xml | 44 +++ .../config/ObjectMapperConfig.java | 57 +++ .../blueprintgenerator/constants/Constants.java | 100 +++++ .../exception/BlueprintException.java | 43 +++ .../exception/ComponentSpecException.java | 43 +++ .../exception/DatabasesNotFoundException.java | 38 ++ .../exception/FixesException.java | 43 +++ .../blueprintgenerator/model/base/Blueprint.java | 55 +++ .../onap/blueprintgenerator/model/base/Node.java | 46 +++ .../blueprintgenerator/model/common/Appconfig.java | 64 ++++ .../blueprintgenerator/model/common/Concat.java | 48 +++ .../model/common/DataRouter.java | 47 +++ .../blueprintgenerator/model/common/Dmaap.java | 53 +++ .../blueprintgenerator/model/common/GetInput.java | 54 +++ .../model/common/GetProperty.java | 47 +++ .../blueprintgenerator/model/common/Imports.java | 45 +++ .../blueprintgenerator/model/common/Input.java | 72 ++++ .../model/common/MessageRouter.java | 50 +++ .../model/componentspec/base/Auxilary.java | 74 ++++ .../model/componentspec/base/ComponentSpec.java | 55 +++ .../model/componentspec/common/Artifacts.java | 49 +++ .../model/componentspec/common/Calls.java | 50 +++ .../model/componentspec/common/Constraints.java | 60 +++ .../model/componentspec/common/Container.java | 46 +++ .../model/componentspec/common/EntrySchema.java | 56 +++ .../model/componentspec/common/HealthCheck.java | 58 +++ .../model/componentspec/common/Host.java | 47 +++ .../model/componentspec/common/Parameters.java | 69 ++++ .../model/componentspec/common/Policy.java | 47 +++ .../model/componentspec/common/PolicySchema.java | 57 +++ .../model/componentspec/common/Provides.java | 52 +++ .../model/componentspec/common/Publishes.java | 56 +++ .../model/componentspec/common/Reconfigs.java | 54 +++ .../componentspec/common/RequestResponse.java | 48 +++ .../model/componentspec/common/Self.java | 53 +++ .../model/componentspec/common/Streams.java | 50 +++ .../model/componentspec/common/Subscribes.java | 56 +++ .../model/componentspec/common/Volumes.java | 54 +++ .../blueprintgenerator/model/policy/Policies.java | 52 +++ .../model/policy/PoliciesNode.java | 44 +++ .../model/policy/PoliciesProperties.java | 43 +++ .../blueprintgenerator/model/policy/Policy.java | 44 +++ .../model/policy/PolicyFilter.java | 52 +++ .../model/policy/PolicyInput.java | 45 +++ .../model/policy/PolicyNode.java | 44 +++ .../model/policy/PolicyProperties.java | 44 +++ .../model/translate/GetProperty.java | 45 +++ .../service/base/BlueprintHelperService.java | 118 ++++++ .../service/base/BlueprintService.java | 157 ++++++++ .../service/base/FixesService.java | 170 ++++++++ .../exception/PolicyCreateException.java | 43 +++ .../org/onap/policycreate/model/PolicyModel.java | 49 +++ .../onap/policycreate/model/PolicyModelNode.java | 47 +++ .../onap/policycreate/model/PolicyProperties.java | 45 +++ mod/bpgenerator/onap/pom.xml | 71 ++++ .../BlueprintGeneratorMainApplication.java | 110 ++++++ .../common/ExternalCertificateParameters.java | 47 +++ .../model/common/ExternalTlsInfo.java | 60 +++ .../model/common/GetAttribute.java | 44 +++ .../onap/blueprintgenerator/model/common/Info.java | 54 +++ .../model/common/Interfaces.java | 42 ++ .../onap/blueprintgenerator/model/common/Node.java | 51 +++ .../model/common/OnapBlueprint.java | 48 +++ .../blueprintgenerator/model/common/PgaasNode.java | 46 +++ .../model/common/PgaasNodeProperties.java | 49 +++ .../model/common/PolicyModel.java | 48 +++ .../model/common/PolicyModelNode.java | 47 +++ .../model/common/PolicyNode.java | 46 +++ .../model/common/PolicyNodeProperties.java | 48 +++ .../model/common/PolicyProperties.java | 45 +++ .../model/common/Properties.java | 89 +++++ .../model/common/ResourceConfig.java | 45 +++ .../blueprintgenerator/model/common/Services.java | 50 +++ .../blueprintgenerator/model/common/Start.java | 49 +++ .../model/common/StartInputs.java | 49 +++ .../model/componentspec/OnapAuxilary.java | 60 +++ .../model/componentspec/OnapComponentSpec.java | 52 +++ .../model/componentspec/PolicyInfo.java | 45 +++ .../model/componentspec/Services.java | 51 +++ .../model/componentspec/TypePolicy.java | 43 +++ .../blueprintgenerator/model/dmaap/Streams.java | 66 ++++ .../blueprintgenerator/model/dmaap/TlsInfo.java | 49 +++ .../blueprintgenerator/service/InfoService.java | 116 ++++++ .../service/OnapBlueprintService.java | 111 ++++++ .../service/common/AppConfigService.java | 166 ++++++++ .../service/common/CommonUtils.java | 152 ++++++++ .../service/common/ComponentSpecService.java | 66 ++++ .../service/common/DmaapService.java | 103 +++++ .../ExternalCertificateDataFactoryService.java | 50 +++ ...xternalCertificateParametersFactoryService.java | 71 ++++ .../common/ExternalTlsInfoFactoryService.java | 87 +++++ .../service/common/ImportsService.java | 98 +++++ .../service/common/InterfacesService.java | 67 ++++ .../service/common/NodeService.java | 222 +++++++++++ .../service/common/PgaasNodeService.java | 138 +++++++ .../service/common/PolicyNodeService.java | 99 +++++ .../service/common/PropertiesService.java | 259 +++++++++++++ .../service/common/QuotationService.java | 59 +++ .../service/common/ResourceConfigService.java | 98 +++++ .../service/common/StartInputsService.java | 97 +++++ .../service/common/StartService.java | 65 ++++ .../service/dmaap/DmaapBlueprintService.java | 144 +++++++ .../service/dmaap/StreamsService.java | 104 +++++ .../service/PolicyModelNodeService.java | 150 ++++++++ .../policycreate/service/PolicyModelService.java | 105 +++++ .../onap/src/main/resources/application.properties | 36 ++ .../test/BlueprintGeneratorTestSuite.java | 40 ++ .../test/BlueprintGeneratorTests.java | 109 ++++++ .../test/BlueprintJarComparatorTest.java | 115 ++++++ ...nalCertificateParametersFactoryServiceTest.java | 61 +++ .../test/OnapBlueprintServiceTest.java | 257 +++++++++++++ .../test/OnapComponentSpecTest.java | 58 +++ .../blueprintgenerator/test/OnapTestUtils.java | 207 ++++++++++ .../onap/blueprintgenerator/test/TlsInfoTest.java | 168 ++++++++ ...ponentSpec_withTlsFalseAndExternalTlsFalse.json | 43 +++ ...omponentSpec_withTlsTrueAndExternalTlsTrue.json | 43 +++ ...tComponentSpec_withTlsTrueAndNoExternalTls.json | 42 ++ .../testComponentSpec_withoutTlsInfo.json | 38 ++ .../test/resources/componentspecs/testImports.yaml | 4 + .../src/test/resources/componentspecs/ves.json | 337 ++++++++++++++++ .../src/test/resources/policyjson/policyInput.json | 28 ++ mod/bpgenerator/onap/version.properties | 29 ++ mod/bpgenerator/pom.xml | 312 ++++++++------- mod/bpgenerator/src/assembly/dep.xml | 52 --- .../common/blueprint/BlueprintHelper.java | 76 ---- .../java/org/onap/blueprintgenerator/core/App.java | 40 -- .../blueprintgenerator/core/BlueprintCommand.java | 60 --- .../org/onap/blueprintgenerator/core/Fixes.java | 104 ----- .../blueprintgenerator/core/PgaasNodeBuilder.java | 129 ------- .../blueprintgenerator/core/PolicyCommand.java | 42 -- .../blueprintgenerator/core/PolicyNodeBuilder.java | 92 ----- .../blueprintgenerator/core/TestComponentSpec.java | 270 ------------- .../exception/DatabasesNotFoundException.java | 24 -- .../blueprintgenerator/models/GetAttribute.java | 34 -- .../models/blueprint/Appconfig.java | 152 -------- .../models/blueprint/Blueprint.java | 151 -------- .../models/blueprint/BpConstants.java | 43 --- .../models/blueprint/ConcatObj.java | 57 --- .../models/blueprint/GetInput.java | 38 -- .../models/blueprint/GetProperty.java | 55 --- .../models/blueprint/Imports.java | 67 ---- .../models/blueprint/Interfaces.java | 40 -- .../blueprintgenerator/models/blueprint/Node.java | 35 -- .../models/blueprint/Properties.java | 290 -------------- .../models/blueprint/ResourceConfig.java | 115 ------ .../blueprintgenerator/models/blueprint/Start.java | 47 --- .../models/blueprint/StartInputs.java | 118 ------ .../models/blueprint/TemplateNode.java | 69 ---- .../models/blueprint/dmaap/DmaapInfo.java | 105 ----- .../models/blueprint/dmaap/DmaapObj.java | 83 ---- .../models/blueprint/pgaas/PgaasNode.java | 35 -- .../blueprint/pgaas/PgaasNodeProperties.java | 40 -- .../models/blueprint/policy/PolicyNode.java | 34 -- .../blueprint/policy/PolicyNodeProperties.java | 37 -- .../tls/ExternalCertificateParametersFactory.java | 74 ---- .../blueprint/tls/ExternalTlsInfoFactory.java | 102 ----- .../models/blueprint/tls/TlsConstants.java | 38 -- .../models/blueprint/tls/TlsInfo.java | 39 -- .../tls/api/ExternalCertificateDataFactory.java | 37 -- .../tls/impl/ExternalCertificateParameters.java | 43 --- .../models/blueprint/tls/impl/ExternalTlsInfo.java | 54 --- .../models/componentspec/Artifacts.java | 63 --- .../models/componentspec/Auxilary.java | 127 ------ .../models/componentspec/CallsObj.java | 45 --- .../models/componentspec/ComponentSpec.java | 166 -------- .../models/componentspec/ConstraintsObj.java | 62 --- .../models/componentspec/Container.java | 60 --- .../models/componentspec/EntrySchemaObj.java | 82 ---- .../models/componentspec/HealthCheck.java | 72 ---- .../models/componentspec/Host.java | 56 --- .../models/componentspec/Parameters.java | 106 ----- .../models/componentspec/Policy.java | 62 --- .../models/componentspec/PolicySchemaObj.java | 86 ----- .../models/componentspec/ProvidesObj.java | 63 --- .../models/componentspec/Publishes.java | 73 ---- .../models/componentspec/ReconfigsObj.java | 60 --- .../models/componentspec/RequestResponseObj.java | 43 --- .../models/componentspec/Self.java | 70 ---- .../models/componentspec/Services.java | 61 --- .../models/componentspec/Streams.java | 63 --- .../models/componentspec/Subscribes.java | 77 ---- .../models/componentspec/Volumes.java | 61 --- .../componentspec/policy_info/PolicyInfo.java | 35 -- .../componentspec/policy_info/TypePolicy.java | 36 -- .../models/dmaapbp/DmaapBlueprint.java | 126 ------ .../models/dmaapbp/DmaapNode.java | 185 --------- .../models/dmaapbp/DmaapStreams.java | 123 ------ .../models/onapbp/LogDirectory.java | 28 -- .../models/onapbp/OnapBlueprint.java | 95 ----- .../blueprintgenerator/models/onapbp/OnapNode.java | 94 ----- .../models/policymodel/PolicyModel.java | 136 ------- .../models/policymodel/PolicyModelNode.java | 147 ------- .../models/policymodel/PolicyProperties.java | 41 -- .../core/BlueprintGeneratorTest.java | 286 -------------- .../onap/blueprintgenerator/core/TlsInfoTest.java | 163 -------- .../models/blueprint/AppconfigTest.java | 62 --- .../models/blueprint/ImportsTest.java | 52 --- .../models/blueprint/ResourceConfigTest.java | 38 -- .../ExternalCertificateParametersFactoryTest.java | 62 --- .../models/dmaapbp/DmaapBlueprintTest.java | 245 ------------ .../models/dmaapbp/DmaapNodeTest.java | 224 ----------- mod/bpgenerator/version.properties | 6 - 230 files changed, 9011 insertions(+), 10373 deletions(-) delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsFalseAndExternalTlsFalse.yaml delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndExternalTlsTrue.yaml delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndNoExternalTls.yaml delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/blueprint_withoutTlsInfo.yaml delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json delete mode 100644 mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json delete mode 100644 mod/bpgenerator/TestCases/datafile.json delete mode 100644 mod/bpgenerator/TestCases/expects/createAppConfigResult.txt delete mode 100644 mod/bpgenerator/TestCases/hello.json delete mode 100644 mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml delete mode 100644 mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml delete mode 100644 mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json delete mode 100644 mod/bpgenerator/TestCases/imports/imports.yaml delete mode 100644 mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml delete mode 100644 mod/bpgenerator/TestCases/j.json delete mode 100644 mod/bpgenerator/TestCases/jack.json delete mode 100644 mod/bpgenerator/TestCases/policyInput.json delete mode 100644 mod/bpgenerator/TestCases/testComponentSpec.json delete mode 100644 mod/bpgenerator/TestCases/testImport.yaml delete mode 100644 mod/bpgenerator/TestCases/testImports.yaml delete mode 100644 mod/bpgenerator/TestCases/ves.json delete mode 100644 mod/bpgenerator/TestCases/ves/blueprints/vesK8sWithDmaap.yaml delete mode 100644 mod/bpgenerator/TestCases/ves/blueprints/vesK8sWithoutDmaap.yaml delete mode 100644 mod/bpgenerator/TestCases/ves/componentSpecs/ves.json delete mode 100644 mod/bpgenerator/TestCases/ves/inputFiles/ves_nodmaap.json create mode 100644 mod/bpgenerator/common/pom.xml create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/config/ObjectMapperConfig.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/BlueprintException.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/ComponentSpecException.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/FixesException.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Blueprint.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Node.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Appconfig.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Concat.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/DataRouter.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Dmaap.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetInput.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetProperty.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Imports.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Input.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/MessageRouter.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/Auxilary.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/ComponentSpec.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Artifacts.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Calls.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Constraints.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Container.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/EntrySchema.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/HealthCheck.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Host.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Parameters.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Policy.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/PolicySchema.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Provides.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Publishes.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Reconfigs.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/RequestResponse.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Self.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Streams.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Subscribes.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policies.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesNode.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesProperties.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policy.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyFilter.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyInput.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyNode.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyProperties.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/translate/GetProperty.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintService.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/policycreate/exception/PolicyCreateException.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModel.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModelNode.java create mode 100644 mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyProperties.java create mode 100644 mod/bpgenerator/onap/pom.xml create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalCertificateParameters.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalTlsInfo.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/GetAttribute.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Info.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Interfaces.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Node.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/OnapBlueprint.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNode.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNodeProperties.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModel.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModelNode.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNode.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNodeProperties.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyProperties.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ResourceConfig.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Services.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Start.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/StartInputs.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapAuxilary.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapComponentSpec.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/PolicyInfo.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/Services.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/TypePolicy.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/Streams.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/TlsInfo.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ComponentSpecService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/DmaapService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelNodeService.java create mode 100644 mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelService.java create mode 100644 mod/bpgenerator/onap/src/main/resources/application.properties create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTestSuite.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTests.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintJarComparatorTest.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/ExternalCertificateParametersFactoryServiceTest.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapBlueprintServiceTest.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapComponentSpecTest.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java create mode 100644 mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java create mode 100644 mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsFalseAndExternalTlsFalse.json create mode 100644 mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndExternalTlsTrue.json create mode 100644 mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndNoExternalTls.json create mode 100644 mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withoutTlsInfo.json create mode 100644 mod/bpgenerator/onap/src/test/resources/componentspecs/testImports.yaml create mode 100644 mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json create mode 100644 mod/bpgenerator/onap/src/test/resources/policyjson/policyInput.json create mode 100644 mod/bpgenerator/onap/version.properties delete mode 100644 mod/bpgenerator/src/assembly/dep.xml delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java delete mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java delete mode 100644 mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java delete mode 100644 mod/bpgenerator/version.properties (limited to 'mod') diff --git a/mod/bpgenerator/README.md b/mod/bpgenerator/README.md index d6b6f7d..eb35aff 100644 --- a/mod/bpgenerator/README.md +++ b/mod/bpgenerator/README.md @@ -27,14 +27,17 @@ OPTIONS: - -d: Onvoke the dmaap plugin (optional) - -o: The service component name override (optional) - it will look like this: ```bash -java -jar target/blueprint-generator-1.4.0-SNAPSHOT-executable.jar blueprint -p Blueprints -i ComponentSpecs/TestComponentSpec.json -n HelloWorld -d + java -jar target/.jar app ONAP -i componentspec -p OutputBlueprintPath -n Blueprintname -d ``` -This command will create a blueprint from the component spec TestComponentSpec. The blueprint file name will be called HelloWorld.yaml and it will be in the directory Blueprints. The blueprint will also contain the DMaaP plugin. +This command will create a blueprint from the component spec. The blueprint file name will be called Blueprintname.yaml and it will be in the directory OutputBlueprintPath. The blueprint will also contain the DMaaP plugin. + + + + ## Extra information: - The component spec must be of the same format as stated in the onap [readthedocs](https://onap.readthedocs.io/en/latest/submodules/dcaegen2.git/docs/sections/components/component-specification/common-specification.html#working-with-component-specs) page @@ -53,9 +56,9 @@ OPTIONS: - -p: The output path for all of the models (required) it will look like this: - + ```bash -java -jar target/blueprint-generator-1.4.0-SNAPSHOT-executable.jar policy -p models -i ComponentSpecs/TestComponentSpec.json + java -jar target/.jar app ONAP -type policycreate -i componentspec -p OutputPolicyPath ``` This command will create a directory called models and put the policy models created from the component spec given in that directory. (A component spec may generate multiple policy models) \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsFalseAndExternalTlsFalse.yaml b/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsFalseAndExternalTlsFalse.yaml deleted file mode 100644 index 94a3f1e..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsFalseAndExternalTlsFalse.yaml +++ /dev/null @@ -1,136 +0,0 @@ - -#description: Test component spec -#blueprint_version: 1.0.1 ---- -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml -inputs: - always_pull_image: - type: boolean - description: Set to true if the image should always be pulled - default: true - envs: - default: {} - external_cert_ca_name: - type: string - description: Name of Certificate Authority configured on CertService side. - default: "RA" - external_cert_cert_type: - type: string - description: Format of provided certificates - default: "P12" - external_cert_common_name: - type: string - description: Common name which should be present in certificate. - default: "sample.onap.org" - external_cert_sans: - type: string - description: "List of Subject Alternative Names (SANs) which should be present - in certificate. Delimiter - : Should contain common_name value and other FQDNs - under which given component is accessible." - default: "sample.onap.org:component.sample.onap.org" - external_cert_use_external_tls: - type: boolean - description: Flag to indicate external tls enable/disable. - default: false - external_port_0: - type: string - default: "80" - external_port_1: - type: string - default: "99" - image: - type: string - default: "test.tester" - location_id: - type: string - default: "" - replicas: - type: integer - description: number of instances - default: 1 - service_component_name_override: - type: string - default: "" - test.component.spec_cpu_limit: - type: string - default: "250m" - test.component.spec_cpu_request: - type: string - default: "250m" - test.component.spec_memory_limit: - type: string - default: "128Mi" - test.component.spec_memory_request: - type: string - default: "128Mi" - use_tls: - type: boolean - description: flag to indicate tls enable/disable - default: false -node_templates: - test.component.spec: - type: dcae.nodes.ContainerizedServiceComponent - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: - - concat: ["80:", {get_input: external_port_0}] - - concat: ["99:", {get_input: external_port_1}] - envs: - get_input: envs - properties: - application_config: - service_calls: [] - streams_publishes: {} - streams_subscribes: {} - service_component_name_override: - get_input: service_component_name_override - docker_config: - healthcheck: - interval: 300s - timeout: 120s - script: /etc/init.d/nagios status - type: docker - image: - get_input: image - location_id: - get_input: location_id - service_component_type: test-component-spec - replicas: - get_input: replicas - tls_info: - cert_directory: /opt/app/dcae-certificate/ - use_tls: - get_input: use_tls - external_cert: - external_cert_directory: /opt/app/dcae-certificate/ - use_external_tls: - get_input: external_cert_use_external_tls - ca_name: - get_input: external_cert_ca_name - cert_type: - get_input: external_cert_cert_type - external_certificate_parameters: - common_name: - get_input: external_cert_common_name - sans: - get_input: external_cert_sans - resource_config: - limits: - cpu: - get_input: test.component.spec_cpu_limit - memory: - get_input: test.component.spec_memory_limit - requests: - cpu: - get_input: test.component.spec_cpu_request - memory: - get_input: test.component.spec_memory_request - always_pull_image: - get_input: always_pull_image - relationships: [] \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndExternalTlsTrue.yaml b/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndExternalTlsTrue.yaml deleted file mode 100644 index 4313d6b..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndExternalTlsTrue.yaml +++ /dev/null @@ -1,136 +0,0 @@ - -#description: Test component spec -#blueprint_version: 1.0.1 ---- -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml -inputs: - always_pull_image: - type: boolean - description: Set to true if the image should always be pulled - default: true - envs: - default: {} - external_cert_ca_name: - type: string - description: Name of Certificate Authority configured on CertService side. - default: "RA" - external_cert_cert_type: - type: string - description: Format of provided certificates - default: "P12" - external_cert_common_name: - type: string - description: Common name which should be present in certificate. - default: "sample.onap.org" - external_cert_sans: - type: string - description: "List of Subject Alternative Names (SANs) which should be present - in certificate. Delimiter - : Should contain common_name value and other FQDNs - under which given component is accessible." - default: "sample.onap.org:component.sample.onap.org" - external_cert_use_external_tls: - type: boolean - description: Flag to indicate external tls enable/disable. - default: true - external_port_0: - type: string - default: "80" - external_port_1: - type: string - default: "99" - image: - type: string - default: "test.tester" - location_id: - type: string - default: "" - replicas: - type: integer - description: number of instances - default: 1 - service_component_name_override: - type: string - default: "" - test.component.spec_cpu_limit: - type: string - default: "250m" - test.component.spec_cpu_request: - type: string - default: "250m" - test.component.spec_memory_limit: - type: string - default: "128Mi" - test.component.spec_memory_request: - type: string - default: "128Mi" - use_tls: - type: boolean - description: flag to indicate tls enable/disable - default: true -node_templates: - test.component.spec: - type: dcae.nodes.ContainerizedServiceComponent - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: - - concat: ["80:", {get_input: external_port_0}] - - concat: ["99:", {get_input: external_port_1}] - envs: - get_input: envs - properties: - application_config: - service_calls: [] - streams_publishes: {} - streams_subscribes: {} - service_component_name_override: - get_input: service_component_name_override - docker_config: - healthcheck: - interval: 300s - timeout: 120s - script: /etc/init.d/nagios status - type: docker - image: - get_input: image - location_id: - get_input: location_id - service_component_type: test-component-spec - replicas: - get_input: replicas - tls_info: - cert_directory: /opt/app/dcae-certificate/ - use_tls: - get_input: use_tls - external_cert: - external_cert_directory: /opt/app/dcae-certificate/ - use_external_tls: - get_input: external_cert_use_external_tls - ca_name: - get_input: external_cert_ca_name - cert_type: - get_input: external_cert_cert_type - external_certificate_parameters: - common_name: - get_input: external_cert_common_name - sans: - get_input: external_cert_sans - resource_config: - limits: - cpu: - get_input: test.component.spec_cpu_limit - memory: - get_input: test.component.spec_memory_limit - requests: - cpu: - get_input: test.component.spec_cpu_request - memory: - get_input: test.component.spec_memory_request - always_pull_image: - get_input: always_pull_image - relationships: [] \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndNoExternalTls.yaml b/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndNoExternalTls.yaml deleted file mode 100644 index c4515e3..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withTlsTrueAndNoExternalTls.yaml +++ /dev/null @@ -1,101 +0,0 @@ - -#description: Test component spec -#blueprint_version: 1.0.1 ---- -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml -inputs: - always_pull_image: - type: boolean - description: Set to true if the image should always be pulled - default: true - envs: - default: {} - external_port_0: - type: string - default: "80" - external_port_1: - type: string - default: "99" - image: - type: string - default: "test.tester" - location_id: - type: string - default: "" - replicas: - type: integer - description: number of instances - default: 1 - service_component_name_override: - type: string - default: "" - test.component.spec_cpu_limit: - type: string - default: "250m" - test.component.spec_cpu_request: - type: string - default: "250m" - test.component.spec_memory_limit: - type: string - default: "128Mi" - test.component.spec_memory_request: - type: string - default: "128Mi" - use_tls: - type: boolean - description: flag to indicate tls enable/disable - default: true -node_templates: - test.component.spec: - type: dcae.nodes.ContainerizedServiceComponent - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: - - concat: ["80:", {get_input: external_port_0}] - - concat: ["99:", {get_input: external_port_1}] - envs: - get_input: envs - properties: - application_config: - service_calls: [] - streams_publishes: {} - streams_subscribes: {} - service_component_name_override: - get_input: service_component_name_override - docker_config: - healthcheck: - interval: 300s - timeout: 120s - script: /etc/init.d/nagios status - type: docker - image: - get_input: image - location_id: - get_input: location_id - service_component_type: test-component-spec - replicas: - get_input: replicas - tls_info: - cert_directory: /opt/app/dcae-certificate/ - use_tls: - get_input: use_tls - resource_config: - limits: - cpu: - get_input: test.component.spec_cpu_limit - memory: - get_input: test.component.spec_memory_limit - requests: - cpu: - get_input: test.component.spec_cpu_request - memory: - get_input: test.component.spec_memory_request - always_pull_image: - get_input: always_pull_image - relationships: [] \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withoutTlsInfo.yaml b/mod/bpgenerator/TestCases/TlsInfo/blueprint_withoutTlsInfo.yaml deleted file mode 100644 index e1f942f..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/blueprint_withoutTlsInfo.yaml +++ /dev/null @@ -1,93 +0,0 @@ - -#description: Test component spec -#blueprint_version: 1.0.1 ---- -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml -inputs: - always_pull_image: - type: boolean - description: Set to true if the image should always be pulled - default: true - envs: - default: {} - external_port_0: - type: string - default: "80" - external_port_1: - type: string - default: "99" - image: - type: string - default: "test.tester" - location_id: - type: string - default: "" - replicas: - type: integer - description: number of instances - default: 1 - service_component_name_override: - type: string - default: "" - test.component.spec_cpu_limit: - type: string - default: "250m" - test.component.spec_cpu_request: - type: string - default: "250m" - test.component.spec_memory_limit: - type: string - default: "128Mi" - test.component.spec_memory_request: - type: string - default: "128Mi" -node_templates: - test.component.spec: - type: dcae.nodes.ContainerizedServiceComponent - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: - - concat: ["80:", {get_input: external_port_0}] - - concat: ["99:", {get_input: external_port_1}] - envs: - get_input: envs - properties: - application_config: - service_calls: [] - streams_publishes: {} - streams_subscribes: {} - service_component_name_override: - get_input: service_component_name_override - docker_config: - healthcheck: - interval: 300s - timeout: 120s - script: /etc/init.d/nagios status - type: docker - image: - get_input: image - location_id: - get_input: location_id - service_component_type: test-component-spec - replicas: - get_input: replicas - resource_config: - limits: - cpu: - get_input: test.component.spec_cpu_limit - memory: - get_input: test.component.spec_memory_limit - requests: - cpu: - get_input: test.component.spec_cpu_request - memory: - get_input: test.component.spec_memory_request - always_pull_image: - get_input: always_pull_image - relationships: [] \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json b/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json deleted file mode 100644 index da75ab8..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Test component spec", - "name": "test.component.spec", - "version": "1.0.1" - }, - - "services": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [], - "subscribes": [] - }, - - "parameters": [], - - "auxilary": { - "healthcheck": { - "type": "docker", - "interval": "300s", - "timeout": "120s", - "script": "/etc/init.d/nagios status" - }, - "ports": [ - "80:80", - "99:99" - ], - "tls_info": { - "cert_directory": "/opt/app/dcae-certificate/", - "use_tls": false, - "use_external_tls": false - } - }, - "artifacts": [{ - "type": "docker image", - "uri": "test.tester" - }] - -} diff --git a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json b/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json deleted file mode 100644 index f13e3fd..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Test component spec", - "name": "test.component.spec", - "version": "1.0.1" - }, - - "services": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [], - "subscribes": [] - }, - - "parameters": [], - - "auxilary": { - "healthcheck": { - "type": "docker", - "interval": "300s", - "timeout": "120s", - "script": "/etc/init.d/nagios status" - }, - "ports": [ - "80:80", - "99:99" - ], - "tls_info": { - "cert_directory": "/opt/app/dcae-certificate/", - "use_tls": true, - "use_external_tls": true - } - }, - "artifacts": [{ - "type": "docker image", - "uri": "test.tester" - }] - -} diff --git a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json b/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json deleted file mode 100644 index 517c461..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Test component spec", - "name": "test.component.spec", - "version": "1.0.1" - }, - - "services": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [], - "subscribes": [] - }, - - "parameters": [], - - "auxilary": { - "healthcheck": { - "type": "docker", - "interval": "300s", - "timeout": "120s", - "script": "/etc/init.d/nagios status" - }, - "ports": [ - "80:80", - "99:99" - ], - "tls_info": { - "cert_directory": "/opt/app/dcae-certificate/", - "use_tls": true - } - }, - "artifacts": [{ - "type": "docker image", - "uri": "test.tester" - }] - -} diff --git a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json b/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json deleted file mode 100644 index a94c987..0000000 --- a/mod/bpgenerator/TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Test component spec", - "name": "test.component.spec", - "version": "1.0.1" - }, - - "services": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [], - "subscribes": [] - }, - - "parameters": [], - - "auxilary": { - "healthcheck": { - "type": "docker", - "interval": "300s", - "timeout": "120s", - "script": "/etc/init.d/nagios status" - }, - "ports": [ - "80:80", - "99:99" - ] - }, - "artifacts": [{ - "type": "docker image", - "uri": "test.tester" - }] - -} diff --git a/mod/bpgenerator/TestCases/datafile.json b/mod/bpgenerator/TestCases/datafile.json deleted file mode 100644 index d93bdb6..0000000 --- a/mod/bpgenerator/TestCases/datafile.json +++ /dev/null @@ -1,426 +0,0 @@ -{ - "self": { - "name": "dcaegen2.collectors.datafile.datafile-app-server", - "version": "1.0.0", - "description": "Docker application to collect log file from PNF", - "component_type": "docker" - }, - "streams": { - "subscribes": [ - { - "type": "message_router", - "config_key": "datafile_subscribe_mr", - "format": "VES_specification", - "version": "7.30.1" - } - ], - "publishes": [ - { - "type": "data_router", - "config_key": "datafile_publish_dr", - "format": "3GPP_XML", - "version": "1.0.0" - } - ] - }, - "services": { - "calls": [], - "provides": [] - }, - "auxilary": { - "healthcheck": { - "type": "http", - "interval": "15s", - "timeout": "1s", - "endpoint": "/heartbeat" - } - }, - "artifacts": [ - { - "uri": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.datafile.datafile-app-server:latest", - "type": "docker image" - } - ], - "parameters": [ - { - "name": "service_name", - "value": "datafile", - "description": "Name of the service", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "buscontroller_feed_publishing_endpoint", - "value": "http://dmaap-bc.onap.svc.cluster.local:8080/webapi/feeds", - "description": "DMAAP Bus Controller feed endpoint", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": true, - "type": "string", - "required": true - }, - { - "name": "dmaap_dr_feed_id", - "value": "bulk_pm_feed", - "description": "ID of the data router feed that the datafile collector will publish", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "streams_consumer.datafile_consume_mr.message_router_topic", - "value": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT", - "description": "datafile collector consume VES event to message router topic ", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.dmaapHostName", - "value": "localhost", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.dmaapPortNumber", - "value": "2222", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.dmaapTopicName", - "value": "/events/unauthenticated.VES_NOTIFICATION_OUTPUT", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.dmaapProtocol", - "value": "http", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.dmaapContentType", - "value": "application/json", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.consumerId", - "value": "C12", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.consumerGroup", - "value": "OpenDcae-c12", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.timeoutMs", - "value": "-1", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapConsumerConfiguration.messageLimit", - "value": "1", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapHostName", - "value": "localhost", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapPortNumber", - "value": "3907", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapTopicName", - "value": "publish", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapProtocol", - "value": "https", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapUserName", - "value": "dradmin", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapUserPassword", - "value": "dradmin", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapProducerConfiguration.dmaapContentType", - "value": "application/octet-stream", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "ftp.ftpesConfiguration.keyCert", - "value": "config/dfc.jks", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "ftp.ftpesConfiguration.keyPassword", - "value": "secret", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "ftp.ftpesConfiguration.trustedCA", - "value": "config/ftp.jks", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "ftp.ftpesConfiguration.trustedCAPassword", - "value": "secret", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "security.trustStorePath", - "value": "/opt/app/datafile/etc/cert/trust.jks", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "security.trustStorePasswordPath", - "value": "/opt/app/datafile/etc/cert/trust.pass", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "security.keyStorePath", - "value": "/opt/app/datafile/etc/cert/key.p12", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "security.keyStorePasswordPath", - "value": "/opt/app/datafile/etc/cert/key.pass", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "security.enableDmaapCertAuth", - "value": false, - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapHostName", - "value": "localhost", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapPortNumber", - "value": "6666", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapTopicName", - "value": "webapis/feeds", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapDrFeedName", - "value": "bulk_pm_feed", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapProtocol", - "value": "https", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapUserName", - "value": "dbcadmin", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapUserPassword", - "value": "dbcadmin", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "dmaap.dmaapBusControllerConfiguration.dmaapContentType", - "value": "application/json", - "description": "", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false, - "type": "string", - "required": true - }, - { - "name": "datafile.policy", - "value": "", - "description": "datafile Policy JSON as string", - "designer_editable": false, - "sourced_at_deployment": false, - "policy_editable": true, - "type": "string", - "required": true - } - ] -} diff --git a/mod/bpgenerator/TestCases/expects/createAppConfigResult.txt b/mod/bpgenerator/TestCases/expects/createAppConfigResult.txt deleted file mode 100644 index 11ce552..0000000 --- a/mod/bpgenerator/TestCases/expects/createAppConfigResult.txt +++ /dev/null @@ -1 +0,0 @@ -{TEST-PUB-DR_delivery_url={type=string}, TEST-PUB-DR_location={type=string}, TEST-PUB-DR_password={type=string}, TEST-PUB-DR_subscriber_id={type=string}, TEST-PUB-DR_username={type=string}, TEST-SUB-DR_delivery_url={type=string}, TEST-SUB-DR_location={type=string}, TEST-SUB-DR_password={type=string}, TEST-SUB-DR_subscriber_id={type=string}, TEST-SUB-DR_username={type=string}, TEST_PUB_MR_publish_url={type=string}, TEST_SUB_MR_subscribe_url={type=string}, service_component_name_override={type=string, default=}, testParam1={type=string, default=test-param-1}} diff --git a/mod/bpgenerator/TestCases/hello.json b/mod/bpgenerator/TestCases/hello.json deleted file mode 100644 index ec7d26a..0000000 --- a/mod/bpgenerator/TestCases/hello.json +++ /dev/null @@ -1,129 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR", - "name": "dcae.collectors.vcc.helloworld.pm", - "version": "1.0.1" - }, - "services": { - "calls": [], - "provides": [] - }, - "streams": { - "publishes": [{ - "config_key": "DCAE-HELLO-WORLD-PUB-DR", - "format": "dataformat_Hello_World_PM", - "type": "data_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-PUB-MR", - "format": "dataformat_Hello_World_PM", - "type": "message_router", - "version": "1.0.0" - } - ], - "subscribes": [{ - "config_key": "DCAE-HELLO-WORLD-SUB-MR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE_HELLO_WORLD_SUB_MR", - "type": "message_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-SUB-DR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE-HELLO-WORLD-SUB-DR", - "type": "data_router", - "version": "1.0.0" - } - ] - }, - "parameters": - [ - { - "name": "vcc_hello_name", - "value": "fsdfa", - "description": "the name entered for specific person", - "sourced_at_deployment": true, - "designer_editable": true, - "policy_editable": false, - "type": "string" - }, - - { - "name": "useDtiConfig", - "value": false, - "description": "component depends on configuration from dti.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true - }, - - { - "name": "isSelfServeComponent", - "value": false, - "description": "Is this used as self serve component.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true, - "type": "string" - } - ], - "auxilary": { - "healthcheck": { - "interval": "60s", - "timeout": "20s", - "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh", - "type": "docker" - }, - "volumes": [ - { - "container": { - "bind": "/opt/app/dcae-certificate" - }, - "host": { - "path": "/opt/app/dcae-certificate" - } - }, - { - "container": { - "bind": "/opt/logs/DCAE/dmd/AGENT" - }, - "host": { - "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT" - } - }, - { - "container": { - "bind": "/opt/logs/DCAE/dmd/WATCHER" - }, - "host": { - "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER" - } - }, - { - "container": { - "bind": "/opt/app/vcc/logs/DCAE" - }, - "host": { - "path": "/opt/logs/DCAE/helloworldpm/vcc-logs" - } - }, - { - "container": { - "bind": "/opt/app/vcc/archive/data" - }, - "host": { - "path": "/opt/data/DCAE/helloworldpm/vcc-archive" - } - } - ] - }, - "artifacts": [{ - "type": "docker image", - "uri": "dockercentral.it.att.com:5100/com.att.dcae.controller/dcae-controller-vcc-helloworld-pm:18.02-001" - }] -} \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml b/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml deleted file mode 100644 index 95961ee..0000000 --- a/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml +++ /dev/null @@ -1,376 +0,0 @@ -# ============LICENSE_START======================================================= -# org.onap.dcae -# ================================================================================ -# Copyright (c) 2019-2020 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========================================================= -# -#description: Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR -#blueprint_version: 1.0.1 ---- -tosca_definitions_version: cloudify_dsl_1_3 -description: Hello World mS for subscribing the data from local DMaaP, DR or MR, processing - them and publishing them as PM files to local DMaaP DR -imports: -- https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.1/k8splugin_types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml -inputs: - DCAE-HELLO-WORLD-PUB-DR_DCAE-HELLO-WORLD-PUB-DR_feed_location: - type: string - DCAE-HELLO-WORLD-PUB-DR_feed_name: - type: string - DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_password: - type: string - DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_username: - type: string - DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_client_role: - type: string - DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_location: - type: string - DCAE-HELLO-WORLD-PUB-MR_topic_name: - type: string - DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_decompress: - type: string - DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_location: - type: string - DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_password: - type: string - DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_priviliged: - type: string - DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_username: - type: string - DCAE-HELLO-WORLD-SUB-DR_feed_name: - type: string - DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_password: - type: string - DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_username: - type: string - DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_client_role: - type: string - DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_location: - type: string - DCAE-HELLO-WORLD-SUB-MR_topic_name: - type: string - dcae.collectors.vcc.helloworld.pm_cpu_limit: - type: string - default: "250m" - dcae.collectors.vcc.helloworld.pm_cpu_request: - type: string - default: "250m" - dcae.collectors.vcc.helloworld.pm_memory_limit: - type: string - default: "128Mi" - dcae.collectors.vcc.helloworld.pm_memory_request: - type: string - default: "128Mi" - dcaes_database_name: - type: string - description: db name - default: "" - dcaes_database_writerfqdn: - type: string - description: db writerfqdn - default: "" - dti_database_name: - type: string - description: db name - default: "" - dti_database_writerfqdn: - type: string - description: db writerfqdn - default: "" - envs: - default: &envs {} - replicas: - type: integer - description: number of instances - default: 1 - repo_database_name: - type: string - description: db name - default: "" - repo_database_writerfqdn: - type: string - description: db writerfqdn - default: "" - service_component_name_override: - type: string - default: "" - tag_version: - type: string - default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" - tca_policy_00_policy_id: - type: string - description: policy_id - default: "" - tca_policy_11_policy_id: - type: string - description: policy_id - default: "tca_policy_id_11" - use_tls: - type: boolean - description: flag to indicate tls enable/disable - default: true - vcc_hello_name: - type: string - default: "fsdfa" -node_templates: - DCAE-HELLO-WORLD-PUB-DR_feed: - type: ccsdk.nodes.Feed - properties: - feed_name: - get_input: DCAE-HELLO-WORLD-PUB-DR_feed_name - DCAE-HELLO-WORLD-PUB-MR_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: DCAE-HELLO-WORLD-PUB-MR_topic_name - DCAE-HELLO-WORLD-SUB-DR_feed: - type: ccsdk.nodes.Feed - properties: - feed_name: - get_input: DCAE-HELLO-WORLD-SUB-DR_feed_name - DCAE-HELLO-WORLD-SUB-MR_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: DCAE-HELLO-WORLD-SUB-MR_topic_name - dcae.collectors.vcc.helloworld.pm: - type: dcae.nodes.ContainerizedServiceComponentUsingDmaap - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: [] - envs: - <<: *envs - DCAES_DB_NAME: - get_input: dcaes_database_name - DCAES_DB_ADMIN_HOST: - get_attribute: - - dcaes_pgaasdb - - admin - - host - DCAES_DB_ADMIN_USER: - get_attribute: - - dcaes_pgaasdb - - admin - - user - DCAES_DB_ADMIN_PASS: - get_attribute: - - dcaes_pgaasdb - - admin - - password - DTI_DB_NAME: - get_input: dti_database_name - DTI_DB_ADMIN_HOST: - get_attribute: - - dti_pgaasdb - - admin - - host - DTI_DB_ADMIN_USER: - get_attribute: - - dti_pgaasdb - - admin - - user - DTI_DB_ADMIN_PASS: - get_attribute: - - dti_pgaasdb - - admin - - password - REPO_DB_NAME: - get_input: repo_database_name - REPO_DB_ADMIN_HOST: - get_attribute: - - repo_pgaasdb - - admin - - host - REPO_DB_ADMIN_USER: - get_attribute: - - repo_pgaasdb - - admin - - user - REPO_DB_ADMIN_PASS: - get_attribute: - - repo_pgaasdb - - admin - - password - properties: - application_config: - service_calls: [] - streams_publishes: - DCAE-HELLO-WORLD-PUB-DR: - dmaap_info: <> - type: data_router - DCAE-HELLO-WORLD-PUB-MR: - dmaap_info: <> - type: message_router - pass: - get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_password - user: - get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_username - streams_subscribes: - DCAE-HELLO-WORLD-SUB-DR: - dmaap_info: <> - type: data_router - DCAE-HELLO-WORLD-SUB-MR: - dmaap_info: <> - type: message_router - pass: - get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_password - user: - get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_username - isSelfServeComponent: false - service_component_name_override: - get_input: service_component_name_override - useDtiConfig: false - vcc_hello_name: - get_input: vcc_hello_name - docker_config: - healthcheck: - interval: 60s - timeout: 20s - script: /opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh - type: docker - volumes: - - container: - bind: /opt/app/dcae-certificate - host: - path: /opt/app/dcae-certificate - - container: - bind: /opt/logs/DCAE/dmd/AGENT - host: - path: /opt/logs/DCAE/helloworldpm/dmd/AGENT - - container: - bind: /opt/logs/DCAE/dmd/WATCHER - host: - path: /opt/logs/DCAE/helloworldpm/dmd/WATCHER - - container: - bind: /opt/app/vcc/logs/DCAE - host: - path: /opt/logs/DCAE/helloworldpm/vcc-logs - - container: - bind: /opt/app/vcc/archive/data - host: - path: /opt/data/DCAE/helloworldpm/vcc-archive - image: - get_input: tag_version - service_component_type: dcae-collectors-vcc-helloworld-pm - log_info: - log_directory: /opt/app/VESCollector/logs/ecomp - replicas: - get_input: replicas - streams_publishes: - - name: DCAE-HELLO-WORLD-PUB-DR_feed - location: - get_input: DCAE-HELLO-WORLD-PUB-DR_DCAE-HELLO-WORLD-PUB-DR_feed_location - type: data_router - - name: DCAE-HELLO-WORLD-PUB-MR_topic - location: - get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_location - client_role: - get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_client_role - type: message_router - streams_subscribes: - - name: DCAE-HELLO-WORLD-SUB-MR_topic - location: - get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_location - client_role: - get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_client_role - type: message_router - - name: DCAE-HELLO-WORLD-SUB-DR_feed - location: - get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_location - type: data_router - username: - get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_username - password: - get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_password - privileged: - get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_priviliged - decompress: - get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_decompress - route: /DCAE-HELLO-WORLD-SUB-DR - scheme: https - tls_info: - cert_directory: /opt/app/dh/etc/cert - use_tls: - get_input: use_tls - resource_config: - limits: - cpu: - get_input: dcae.collectors.vcc.helloworld.pm_cpu_limit - memory: - get_input: dcae.collectors.vcc.helloworld.pm_memory_limit - requests: - cpu: - get_input: dcae.collectors.vcc.helloworld.pm_cpu_request - memory: - get_input: dcae.collectors.vcc.helloworld.pm_memory_request - relationships: - - type: ccsdk.relationships.publish_files - target: DCAE-HELLO-WORLD-PUB-DR_feed - - type: ccsdk.relationships.publish_events - target: DCAE-HELLO-WORLD-PUB-MR_topic - - type: ccsdk.relationships.subscribe_to_events - target: DCAE-HELLO-WORLD-SUB-MR_topic - - type: ccsdk.relationships.subscribe_to_files - target: DCAE-HELLO-WORLD-SUB-DR_feed - - type: cloudify.relationships.depends_on - target: tca_policy_00 - - type: cloudify.relationships.depends_on - target: tca_policy_11 - - type: cloudify.relationships.depends_on - target: dcaes_pgaasdb - - type: cloudify.relationships.depends_on - target: dti_pgaasdb - - type: cloudify.relationships.depends_on - target: repo_pgaasdb - dcaes_pgaasdb: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: dcaes_database_writerfqdn - name: - get_input: dcaes_database_name - use_existing: true - dti_pgaasdb: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: dti_database_writerfqdn - name: - get_input: dti_database_name - use_existing: true - repo_pgaasdb: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: repo_database_writerfqdn - name: - get_input: repo_database_name - use_existing: true - tca_policy_00: - type: clamp.nodes.policy - properties: - policy_id: - get_input: tca_policy_00_policy_id - policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app - tca_policy_11: - type: clamp.nodes.policy - properties: - policy_id: - get_input: tca_policy_11_policy_id - policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml b/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml deleted file mode 100644 index 4e1f5b5..0000000 --- a/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml +++ /dev/null @@ -1,330 +0,0 @@ -# ============LICENSE_START======================================================= -# org.onap.dcae -# ================================================================================ -# Copyright (c) 2019-2020 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========================================================= -# -#description: Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR -#blueprint_version: 1.0.1 ---- -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.1/k8splugin_types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml -inputs: - DCAE-HELLO-WORLD-PUB-DR_delivery_url: - type: string - DCAE-HELLO-WORLD-PUB-DR_location: - type: string - DCAE-HELLO-WORLD-PUB-DR_password: - type: string - DCAE-HELLO-WORLD-PUB-DR_subscriber_id: - type: string - DCAE-HELLO-WORLD-PUB-DR_username: - type: string - DCAE-HELLO-WORLD-SUB-DR_delivery_url: - type: string - DCAE-HELLO-WORLD-SUB-DR_location: - type: string - DCAE-HELLO-WORLD-SUB-DR_password: - type: string - DCAE-HELLO-WORLD-SUB-DR_subscriber_id: - type: string - DCAE-HELLO-WORLD-SUB-DR_username: - type: string - DCAE_HELLO_WORLD_PUB_MR_publish_url: - type: string - DCAE_HELLO_WORLD_SUB_MR_subscribe_url: - type: string - always_pull_image: - type: boolean - description: Set to true if the image should always be pulled - default: true - dcae.collectors.vcc.helloworld.pm_cpu_limit: - type: string - default: "250m" - dcae.collectors.vcc.helloworld.pm_cpu_request: - type: string - default: "250m" - dcae.collectors.vcc.helloworld.pm_memory_limit: - type: string - default: "128Mi" - dcae.collectors.vcc.helloworld.pm_memory_request: - type: string - default: "128Mi" - dcaes_database_name: - type: string - description: db name - default: "" - dcaes_database_writerfqdn: - type: string - description: db writerfqdn - default: "" - dti_database_name: - type: string - description: db name - default: "" - dti_database_writerfqdn: - type: string - description: db writerfqdn - default: "" - envs: - default: &envs {} - image: - type: string - default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" - location_id: - type: string - default: "" - replicas: - type: integer - description: number of instances - default: 1 - repo_database_name: - type: string - description: db name - default: "" - repo_database_writerfqdn: - type: string - description: db writerfqdn - default: "" - service_component_name_override: - type: string - default: "" - tca_policy_00_policy_id: - type: string - description: policy_id - default: "" - tca_policy_11_policy_id: - type: string - description: policy_id - default: "tca_policy_id_11" - use_tls: - type: boolean - description: flag to indicate tls enable/disable - default: true - vcc_hello_name: - type: string - default: "fsdfa" -node_templates: - dcae.collectors.vcc.helloworld.pm: - type: dcae.nodes.ContainerizedPlatformComponent - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: [] - envs: - <<: *envs - DCAES_DB_NAME: - get_input: dcaes_database_name - DCAES_DB_ADMIN_HOST: - get_attribute: - - dcaes_pgaasdb - - admin - - host - DCAES_DB_ADMIN_USER: - get_attribute: - - dcaes_pgaasdb - - admin - - user - DCAES_DB_ADMIN_PASS: - get_attribute: - - dcaes_pgaasdb - - admin - - password - DTI_DB_NAME: - get_input: dti_database_name - DTI_DB_ADMIN_HOST: - get_attribute: - - dti_pgaasdb - - admin - - host - DTI_DB_ADMIN_USER: - get_attribute: - - dti_pgaasdb - - admin - - user - DTI_DB_ADMIN_PASS: - get_attribute: - - dti_pgaasdb - - admin - - password - REPO_DB_NAME: - get_input: repo_database_name - REPO_DB_ADMIN_HOST: - get_attribute: - - repo_pgaasdb - - admin - - host - REPO_DB_ADMIN_USER: - get_attribute: - - repo_pgaasdb - - admin - - user - REPO_DB_ADMIN_PASS: - get_attribute: - - repo_pgaasdb - - admin - - password - properties: - application_config: - service_calls: [] - streams_publishes: - DCAE-HELLO-WORLD-PUB-DR: - dmaap_info: - username: - get_input: DCAE-HELLO-WORLD-PUB-DR_username - password: - get_input: DCAE-HELLO-WORLD-PUB-DR_password - location: - get_input: DCAE-HELLO-WORLD-PUB-DR_location - delivery_url: - get_input: DCAE-HELLO-WORLD-PUB-DR_delivery_url - subscriber_id: - get_input: DCAE-HELLO-WORLD-PUB-DR_subscriber_id - type: data_router - DCAE-HELLO-WORLD-PUB-MR: - dmaap_info: - topic_url: - get_input: DCAE_HELLO_WORLD_PUB_MR_publish_url - type: message_router - streams_subscribes: - DCAE-HELLO-WORLD-SUB-DR: - dmaap_info: - username: - get_input: DCAE-HELLO-WORLD-SUB-DR_username - password: - get_input: DCAE-HELLO-WORLD-SUB-DR_password - location: - get_input: DCAE-HELLO-WORLD-SUB-DR_location - delivery_url: - get_input: DCAE-HELLO-WORLD-SUB-DR_delivery_url - subscriber_id: - get_input: DCAE-HELLO-WORLD-SUB-DR_subscriber_id - type: data_router - DCAE-HELLO-WORLD-SUB-MR: - dmaap_info: - topic_url: - get_input: DCAE_HELLO_WORLD_SUB_MR_subscribe_url - type: message_router - isSelfServeComponent: false - service_component_name_override: - get_input: service_component_name_override - useDtiConfig: false - vcc_hello_name: - get_input: vcc_hello_name - docker_config: - healthcheck: - interval: 60s - timeout: 20s - script: /opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh - type: docker - volumes: - - container: - bind: /opt/app/dcae-certificate - host: - path: /opt/app/dcae-certificate - - container: - bind: /opt/logs/DCAE/dmd/AGENT - host: - path: /opt/logs/DCAE/helloworldpm/dmd/AGENT - - container: - bind: /opt/logs/DCAE/dmd/WATCHER - host: - path: /opt/logs/DCAE/helloworldpm/dmd/WATCHER - - container: - bind: /opt/app/vcc/logs/DCAE - host: - path: /opt/logs/DCAE/helloworldpm/vcc-logs - - container: - bind: /opt/app/vcc/archive/data - host: - path: /opt/data/DCAE/helloworldpm/vcc-archive - image: - get_input: image - location_id: - get_input: location_id - log_info: - log_directory: /opt/app/VESCollector/logs/ecomp - dns_name: dcae.collectors.vcc.helloworld.pm - replicas: - get_input: replicas - name: dcae.collectors.vcc.helloworld.pm - tls_info: - cert_directory: /opt/app/dh/etc/cert - use_tls: - get_input: use_tls - resource_config: - limits: - cpu: - get_input: dcae.collectors.vcc.helloworld.pm_cpu_limit - memory: - get_input: dcae.collectors.vcc.helloworld.pm_memory_limit - requests: - cpu: - get_input: dcae.collectors.vcc.helloworld.pm_cpu_request - memory: - get_input: dcae.collectors.vcc.helloworld.pm_memory_request - always_pull_image: - get_input: always_pull_image - relationships: - - type: cloudify.relationships.depends_on - target: tca_policy_00 - - type: cloudify.relationships.depends_on - target: tca_policy_11 - - type: cloudify.relationships.depends_on - target: dcaes_pgaasdb - - type: cloudify.relationships.depends_on - target: dti_pgaasdb - - type: cloudify.relationships.depends_on - target: repo_pgaasdb - dcaes_pgaasdb: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: dcaes_database_writerfqdn - name: - get_input: dcaes_database_name - use_existing: true - dti_pgaasdb: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: dti_database_writerfqdn - name: - get_input: dti_database_name - use_existing: true - repo_pgaasdb: - type: dcae.nodes.pgaas.database - properties: - writerfqdn: - get_input: repo_database_writerfqdn - name: - get_input: repo_database_name - use_existing: true - tca_policy_00: - type: clamp.nodes.policy - properties: - policy_id: - get_input: tca_policy_00_policy_id - policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app - tca_policy_11: - type: clamp.nodes.policy - properties: - policy_id: - get_input: tca_policy_11_policy_id - policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json b/mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json deleted file mode 100644 index 24d8491..0000000 --- a/mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json +++ /dev/null @@ -1,154 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR", - "name": "dcae.collectors.vcc.helloworld.pm", - "version": "1.0.1" - }, - "services": { - "calls": [], - "provides": [] - }, - "streams": { - "publishes": [{ - "config_key": "DCAE-HELLO-WORLD-PUB-DR", - "format": "dataformat_Hello_World_PM", - "type": "data_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-PUB-MR", - "format": "dataformat_Hello_World_PM", - "type": "message_router", - "version": "1.0.0" - } - ], - "subscribes": [{ - "config_key": "DCAE-HELLO-WORLD-SUB-MR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE_HELLO_WORLD_SUB_MR", - "type": "message_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-SUB-DR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE-HELLO-WORLD-SUB-DR", - "type": "data_router", - "version": "1.0.0" - } - ] - }, - "parameters": - [ - { - "name": "vcc_hello_name", - "value": "fsdfa", - "description": "the name entered for specific person", - "sourced_at_deployment": true, - "designer_editable": true, - "policy_editable": false, - "type": "string" - }, - - { - "name": "useDtiConfig", - "value": false, - "description": "component depends on configuration from dti.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true - }, - - { - "name": "isSelfServeComponent", - "value": false, - "description": "Is this used as self serve component.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true, - "type": "string" - } - ], - "auxilary": { - "healthcheck": { - "interval": "60s", - "timeout": "20s", - "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh", - "type": "docker" - }, - "log_info": { - "log_directory": "/opt/app/VESCollector/logs/ecomp" - }, - "tls_info":{ - "cert_directory":"/opt/app/dh/etc/cert", - "use_tls":true - }, - "databases": { - "dcaes": "PgaaS", - "repo": "PgaaS", - "dti": "pgaas" - }, - "volumes": [ - { - "container": { - "bind": "/opt/app/dcae-certificate" - }, - "host": { - "path": "/opt/app/dcae-certificate" - } - }, - { - "container": { - "bind": "/opt/logs/DCAE/dmd/AGENT" - }, - "host": { - "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT" - } - }, - { - "container": { - "bind": "/opt/logs/DCAE/dmd/WATCHER" - }, - "host": { - "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER" - } - }, - { - "container": { - "bind": "/opt/app/vcc/logs/DCAE" - }, - "host": { - "path": "/opt/logs/DCAE/helloworldpm/vcc-logs" - } - }, - { - "container": { - "bind": "/opt/app/vcc/archive/data" - }, - "host": { - "path": "/opt/data/DCAE/helloworldpm/vcc-archive" - } - } - ] - }, - "policy_info":{ - "policy":[ - { - "node_label":"tca_policy_00", - "policy_model_id":"onap.policies.monitoring.cdap.tca.hi.lo.app" - }, - { - "node_label":"tca_policy_11", - "policy_id":"tca_policy_id_11", - "policy_model_id":"onap.policies.monitoring.cdap.tca.hi.lo.app" - } - ] - }, - "artifacts": [{ - "type": "docker image", - "uri": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" - }] -} \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/imports/imports.yaml b/mod/bpgenerator/TestCases/imports/imports.yaml deleted file mode 100644 index 4b52b8a..0000000 --- a/mod/bpgenerator/TestCases/imports/imports.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: ['https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml', 'plugin:k8splugin?version=3.4.1', - 'plugin:pgaas?version=1.3.0', 'plugin:clamppolicyplugin?version=1.1.0', 'plugin:dmaap?version=1.5.0'] diff --git a/mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml b/mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml deleted file mode 100644 index 242c2a9..0000000 --- a/mod/bpgenerator/TestCases/imports/importsWithBlanks.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: ['https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml', 'plugin:k8splugin?version=3.4.1', - '', ' ', ' ', 'plugin:pgaas?version=1.3.0', 'plugin:clamppolicyplugin?version=1.1.0', - 'plugin:dmaap?version=1.5.0'] diff --git a/mod/bpgenerator/TestCases/j.json b/mod/bpgenerator/TestCases/j.json deleted file mode 100644 index 848b102..0000000 --- a/mod/bpgenerator/TestCases/j.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR", - "name": "dcae.test.ms", - "version": "1.0.0" - }, - - "services": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [{ - "config_key": "DCAE-HELLO-WORLD-PUB-DR", - "format": "dataformat_Hello_World_PM", - "type": "data_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-PUB-MR", - "format": "dataformat_Hello_World_PM", - "type": "message_router", - "version": "1.0.0" - } - ], - - "subscribes": [{ - "config_key": "DCAE-HELLO-WORLD-SUB-MR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE_HELLO_WORLD_SUB_MR", - "type": "message_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-SUB-DR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE-HELLO-WORLD-SUB-DR", - "type": "data_router", - "version": "1.0.0" - } - ] - }, - - "parameters": - [ - { - "name": "vcc_hello_name", - "value": "fsdfa", - "description": "the name entered for specific person", - "sourced_at_deployment": true, - "designer_editable": true, - "policy_editable": false, - "type": "string" - }, - - { - "name": "useDtiConfig", - "value": false, - "description": "component depends on configuration from dti.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true - }, - - { - "name": "isSelfServeComponent", - "value": false, - "description": "Is this used as self serve component.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true, - "type": "string" - } - ], - - "auxilary": { - "healthcheck": { - "interval": "60s", - "timeout": "20s", - "endpoint": "/", - "type": "http" - }, - "ports" : [ - "80:0" - ] - }, - - "artifacts": [{ - "type": "docker image", - "uri": "nginx" - }] -} \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/jack.json b/mod/bpgenerator/TestCases/jack.json deleted file mode 100644 index 219b1b5..0000000 --- a/mod/bpgenerator/TestCases/jack.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR", - "name": "dcae.test.ms", - "version": "1.0.0" - }, - - "services": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [{ - "config_key": "DCAE-HELLO-WORLD-PUB-DR", - "format": "dataformat_Hello_World_PM", - "type": "data_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-PUB-MR", - "format": "dataformat_Hello_World_PM", - "type": "message_router", - "version": "1.0.0" - } - ], - - "subscribes": [{ - "config_key": "DCAE-HELLO-WORLD-SUB-MR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE_HELLO_WORLD_SUB_MR", - "type": "message_router", - "version": "1.0.0" - }, - { - "config_key": "DCAE-HELLO-WORLD-SUB-DR", - "format": "dataformat_Hello_World_PM", - "route": "/DCAE-HELLO-WORLD-SUB-DR", - "type": "data_router", - "version": "1.0.0" - } - ] - }, - - "parameters": - [ - { - "name": "vcc_hello_name", - "value": "fsdfa", - "description": "the name entered for specific person", - "sourced_at_deployment": true, - "designer_editable": true, - "policy_editable": false, - "type": "string" - }, - - { - "name": "useDtiConfig", - "value": false, - "description": "component depends on configuration from dti.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true - }, - - { - "name": "isSelfServeComponent", - "value": false, - "description": "Is this used as self serve component.", - "sourced_at_deployment": false, - "designer_editable": false, - "policy_editable": false, - "required" : true, - "type": "string" - } - ], - - "auxilary": { - "healthcheck": { - "interval": "60s", - "timeout": "20s", - "endpoint": "/", - "type": "http" - } - }, - - "artifacts": [{ - "type": "docker image", - "uri": "nginx" - }] -} \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/policyInput.json b/mod/bpgenerator/TestCases/policyInput.json deleted file mode 100644 index fb89e1a..0000000 --- a/mod/bpgenerator/TestCases/policyInput.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "policies": [ - { - "configAttributes": "", - "configName": "", - "onapName": "DCAE", - "policyName": "DCAE.Config_*", - "unique": false - }, - { - "onapName": "DCAE", - "policyName": "DCAE.Config_*", - "unique": true - }, - { - "configAttributes": "", - "configName": "", - "onapName": "DCAE", - "policyName": "DCAE.Config_*", - "unique": false - } - ], - "policy": [ - { - "policy_id" : "id_0" - } - ] -} \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/testComponentSpec.json b/mod/bpgenerator/TestCases/testComponentSpec.json deleted file mode 100644 index d6b617b..0000000 --- a/mod/bpgenerator/TestCases/testComponentSpec.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "self": { - "component_type": "docker", - "description": "Test component spec", - "name": "test.component.spec", - "version": "1.0.1" - }, - - "service": { - "calls": [], - "provides": [] - }, - - "streams": { - "publishes": [{ - "config_key": "TEST-PUB-DR", - "format": "dataformat_Hello_World_PM", - "type": "data_router", - "version": "1.0.0" - }, - { - "config_key": "TEST-PUB-MR", - "format": "dataformat_Hello_World_PM", - "type": "message_router", - "version": "1.0.0" - } - ], - - "subscribes": [{ - "config_key": "TEST-SUB-MR", - "format": "dataformat_Hello_World_PM", - "route": "/TEST_HELLO_WORLD_SUB_MR", - "type": "message_router", - "version": "1.0.0" - }, - { - "config_key": "TEST-SUB-DR", - "format": "dataformat_Hello_World_PM", - "route": "/TEST-HELLO-WORLD-SUB-DR", - "type": "data_router", - "version": "1.0.0" - } - ] - }, - - "parameters": - [ - { - "name": "testParam1", - "description": "test parameter 1", - "value": "test-param-1", - "type": "string", - "sourced_at_deployment": true, - "designer_editable": true, - "policy_editable": true, - "policy_group": "Test_Parameters", - "required": true, - "policy_schema": [ - { - "name": "PolicySchemaTest", - "description": "List of objects for vnf type monitorng", - "type": "String", - "entry_schema": [ - { - "name": "TestEntrySchema", - "description": "entry", - "type": "string", - "value": "None" - } - ] - } - ] - } - ], - - "auxilary": { - "healthcheck": { - "type": "docker", - "interval": "300s", - "timeout": "120s", - "script": "/etc/init.d/nagios status" - }, - - "databases" : { - "TestDB1": "PGaaS", - "TestDB2": "PGaaS" - }, - - "policy": { - "trigger_type": "docker", - "script_path": "/opt/app/manager/bin/reconfigure.sh" - }, - "volumes": [ - { - "container": { - "bind": "/opt/app/manager/config/hostname" - }, - "host": { - "path": "/etc/hostname", - "mode": "ro" - } - } - - ], - "ports": [ - "80:80", - "99:99" - ] - }, - - "artifacts": [{ - "type": "docker image", - "uri": "test.tester" - }] - -} \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/testImport.yaml b/mod/bpgenerator/TestCases/testImport.yaml deleted file mode 100644 index a299baf..0000000 --- a/mod/bpgenerator/TestCases/testImport.yaml +++ /dev/null @@ -1,4 +0,0 @@ -imports: -- test import 1 -- test import 2 -- test import 3 \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/testImports.yaml b/mod/bpgenerator/TestCases/testImports.yaml deleted file mode 100644 index 95bd200..0000000 --- a/mod/bpgenerator/TestCases/testImports.yaml +++ /dev/null @@ -1,3 +0,0 @@ -imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves.json b/mod/bpgenerator/TestCases/ves.json deleted file mode 100644 index eb54723..0000000 --- a/mod/bpgenerator/TestCases/ves.json +++ /dev/null @@ -1,384 +0,0 @@ -{ - "self": { - "version": "1.5.0", - "name": "dcae-ves-collector", - "description": "Collector for receiving VES events through restful interface", - "component_type": "docker" - }, - "streams": { - "subscribes": [], - "publishes": [ - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-fault" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-measurement" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-syslog" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-heartbeat" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-other" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-mobileflow" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-statechange" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-thresholdCrossingAlert" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-voicequality" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-sipsignaling" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-fault-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-measurement-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-syslog-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-heartbeat-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-other-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-mobileflow-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-statechange-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-thresholdCrossingAlert-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-voicequality-secondary" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-sipsignaling-secondary" - }, - { - "format": "VES_specification", - "version": "7.30.0", - "type": "message router", - "config_key": "ves-pnfRegistration" - }, - { - "format": "VES_specification", - "version": "7.30.0", - "type": "message router", - "config_key": "ves-pnfRegistration-secondary" - }, - { - "format": "VES_specification", - "version": "7.30.0", - "type": "message router", - "config_key": "ves-notification" - }, - { - "format": "VES_specification", - "version": "7.30.0", - "type": "message router", - "config_key": "ves-notification-secondary" - } - ] - }, - "services": { - "calls": [], - "provides": [ - { - "route": "/eventListener/v1", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v2", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v3", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v4", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v5", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "5.28.4" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v7", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "7.30.0" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - } - ] - }, - "parameters": [ - { - "name": "collector.service.port", - "value": 8080, - "description": "standard http port collector will open for listening;", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.service.secure.port", - "value": 8443, - "description": "secure http port collector will open for listening ", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": true - }, - { - "name": "collector.keystore.file.location", - "value": "/opt/app/dcae-certificate/keystore.jks", - "description": "fs location of keystore file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.keystore.passwordfile", - "value": "/opt/app/dcae-certificate/.password", - "description": "location of keystore password file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.truststore.file.location", - "value": "/opt/app/dcae-certificate/truststore.jks", - "description": "fs location of truststore file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.truststore.passwordfile", - "value": "/opt/app/dcae-certificate/.trustpassword", - "description": "location of truststore password file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.dmaap.streamid", - "value": "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary", - "description": "domain-to-streamid mapping used by VESCollector to distributes events based on domain. Both primary and secondary config_key are included for resilency (multiple streamid can be included commma separated). The streamids MUST match to topic config_keys. For single site without resiliency deployment - configkeys with -secondary suffix can be removed", - "sourced_at_deployment": true, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "auth.method", - "value": "noAuth", - "description": "Property to manage application mode, possible configurations: noAuth - default option - no security (http) , certOnly - auth by certificate (https), basicAuth - auth by basic auth username and password (https),certBasicAuth - auth by certificate and basic auth username / password (https),", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "header.authlist", - "value": "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy", - "description": "List of id and base 64 encoded password.For each onboarding VNF - unique userid and password should be assigned and communicated to VNF owner. Password value should be base64 encoded in config here", - "policy_editable": false, - "sourced_at_deployment": true, - "designer_editable": true - }, - { - "name": "collector.schema.checkflag", - "value": 1, - "description": "Schema check validation flag. When enabled, collector will validate input VES events against VES Schema defined on collector.schema.file ", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.schema.file", - "value": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\",\"v7\":\"./etc/CommonEventFormat_30.json\"}", - "description": "VES schema file name per version used for validation", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false - }, - { - "name": "event.transform.flag", - "value": 1, - "description": "flag to enable tranformation rules defined under eventTransform.json; this is applicable when event tranformation rules preset should be activated for transforming > - type: message router - pass: - get_input: ves-fault_ves-fault_topic_aaf_password - user: - get_input: ves-fault_ves-fault_topic_aaf_username - ves-heartbeat-secondary: - dmaap_info: <> - type: message router - pass: - get_input: ves-heartbeat-secondary_ves-heartbeat-secondary_topic_aaf_password - user: - get_input: ves-heartbeat-secondary_ves-heartbeat-secondary_topic_aaf_username - ves-measurement: - dmaap_info: <> - type: message router - pass: - get_input: ves-measurement_ves-measurement_topic_aaf_password - user: - get_input: ves-measurement_ves-measurement_topic_aaf_username - ves-notification: - dmaap_info: <> - type: message router - pass: - get_input: ves-notification_ves-notification_topic_aaf_password - user: - get_input: ves-notification_ves-notification_topic_aaf_username - ves-other: - dmaap_info: <> - type: message router - pass: - get_input: ves-other_ves-other_topic_aaf_password - user: - get_input: ves-other_ves-other_topic_aaf_username - ves-pnfRegistration: - dmaap_info: <> - type: message router - pass: - get_input: ves-pnfRegistration_ves-pnfRegistration_topic_aaf_password - user: - get_input: ves-pnfRegistration_ves-pnfRegistration_topic_aaf_username - streams_subscribes: {} - auth.method: noAuth - collector.dmaap.streamid: - get_input: collector.dmaap.streamid - collector.keystore.file.location: /opt/app/dcae-certificate/keystore.jks - collector.keystore.passwordfile: /opt/app/dcae-certificate/.password - collector.schema.checkflag: 1 - collector.schema.file: {"v1":"./etc/CommonEventFormat_27.2.json","v2":"./etc/CommonEventFormat_27.2.json","v3":"./etc/CommonEventFormat_27.2.json","v4":"./etc/CommonEventFormat_27.2.json","v5":"./etc/CommonEventFormat_28.4.1.json","v7":"./etc/CommonEventFormat_30.json"} - collector.service.port: 8080 - collector.service.secure.port: 8443 - collector.truststore.file.location: /opt/app/dcae-certificate/truststore.jks - collector.truststore.passwordfile: /opt/app/dcae-certificate/.trustpassword - event.transform.flag: 1 - header.authlist: - get_input: header.authlist - service_component_name_override: - get_input: service_component_name_override - tomcat.maxthreads: 200 - docker_config: - healthcheck: - interval: 15s - timeout: 1s - type: http - endpoint: /healthcheck - volumes: - - container: - bind: /opt/app/dcae-certificate - host: - path: /opt/app/dcae-certificate - - container: - bind: /opt/app/VESCollector/logs - host: - path: /opt/logs/DCAE/VESCollector/logs - - container: - bind: /opt/app/VESCollector/etc - host: - path: /opt/logs/DCAE/VESCollector/etc - image: - get_input: tag_version - location_id: - get_input: location_id - service_component_type: dcae-ves-collector - replicas: - get_input: replicas - streams_publishes: - - name: ves-fault_topic - location: - get_input: ves-fault_ves-fault_topic_location - client_role: - get_input: ves-fault_ves-fault_topic_client_role - type: message router - - name: ves-measurement_topic - location: - get_input: ves-measurement_ves-measurement_topic_location - client_role: - get_input: ves-measurement_ves-measurement_topic_client_role - type: message router - - name: ves-other_topic - location: - get_input: ves-other_ves-other_topic_location - client_role: - get_input: ves-other_ves-other_topic_client_role - type: message router - - name: ves-heartbeat-secondary_topic - location: - get_input: ves-heartbeat-secondary_ves-heartbeat-secondary_topic_location - client_role: - get_input: ves-heartbeat-secondary_ves-heartbeat-secondary_topic_client_role - type: message router - - name: ves-pnfRegistration_topic - location: - get_input: ves-pnfRegistration_ves-pnfRegistration_topic_location - client_role: - get_input: ves-pnfRegistration_ves-pnfRegistration_topic_client_role - type: message router - - name: ves-notification_topic - location: - get_input: ves-notification_ves-notification_topic_location - client_role: - get_input: ves-notification_ves-notification_topic_client_role - type: message router - resource_config: - limits: - cpu: - get_input: dcae-ves-collector_cpu_limit - memory: - get_input: dcae-ves-collector_memory_limit - requests: - cpu: - get_input: dcae-ves-collector_cpu_request - memory: - get_input: dcae-ves-collector_memory_request - relationships: - - type: ccsdk.relationships.publish_events - target: ves-fault_topic - - type: ccsdk.relationships.publish_events - target: ves-measurement_topic - - type: ccsdk.relationships.publish_events - target: ves-other_topic - - type: ccsdk.relationships.publish_events - target: ves-heartbeat-secondary_topic - - type: ccsdk.relationships.publish_events - target: ves-pnfRegistration_topic - - type: ccsdk.relationships.publish_events - target: ves-notification_topic - ves-fault_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: ves-fault_topic_name - ves-heartbeat-secondary_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: ves-heartbeat-secondary_topic_name - ves-measurement_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: ves-measurement_topic_name - ves-notification_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: ves-notification_topic_name - ves-other_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: ves-other_topic_name - ves-pnfRegistration_topic: - type: ccsdk.nodes.Topic - properties: - topic_name: - get_input: ves-pnfRegistration_topic_name \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves/blueprints/vesK8sWithoutDmaap.yaml b/mod/bpgenerator/TestCases/ves/blueprints/vesK8sWithoutDmaap.yaml deleted file mode 100644 index 9786fff..0000000 --- a/mod/bpgenerator/TestCases/ves/blueprints/vesK8sWithoutDmaap.yaml +++ /dev/null @@ -1,185 +0,0 @@ -# ============LICENSE_START======================================================= -# org.onap.dcae -# ================================================================================ -# Copyright (c) 2019-2020 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========================================================= -# -#description: Collector for receiving VES events through restful interface -#blueprint_version: 1.5.0 ---- -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml -- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml -inputs: - always_pull_image: - type: boolean - description: Set to true if the image should always be pulled - default: true - collector.dmaap.streamid: - type: string - default: "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary" - dcae-ves-collector_cpu_limit: - type: string - default: "250m" - dcae-ves-collector_cpu_request: - type: string - default: "250m" - dcae-ves-collector_memory_limit: - type: string - default: "128Mi" - dcae-ves-collector_memory_request: - type: string - default: "128Mi" - envs: - default: {} - external_port_0: - type: string - default: "8080" - external_port_1: - type: string - default: "8443" - header.authlist: - type: string - default: "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy" - image: - type: string - default: "nexus.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" - location_id: - type: string - default: "" - replicas: - type: integer - description: number of instances - default: 1 - service_component_name_override: - type: string - default: "" - ves_fault_publish_url: - type: string - ves_heartbeat_secondary_publish_url: - type: string - ves_measurement_publish_url: - type: string - ves_notification_publish_url: - type: string - ves_other_publish_url: - type: string - ves_pnfRegistration_publish_url: - type: string -node_templates: - dcae-ves-collector: - type: dcae.nodes.ContainerizedServiceComponent - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - ports: - - concat: ["8080:", {get_input: external_port_0}] - - concat: ["8443:", {get_input: external_port_1}] - envs: - get_input: envs - properties: - application_config: - service_calls: [] - streams_publishes: - ves-fault: - dmaap_info: - topic_url: - get_input: ves_fault_publish_url - type: message router - ves-heartbeat-secondary: - dmaap_info: - topic_url: - get_input: ves_heartbeat_secondary_publish_url - type: message router - ves-measurement: - dmaap_info: - topic_url: - get_input: ves_measurement_publish_url - type: message router - ves-notification: - dmaap_info: - topic_url: - get_input: ves_notification_publish_url - type: message router - ves-other: - dmaap_info: - topic_url: - get_input: ves_other_publish_url - type: message router - ves-pnfRegistration: - dmaap_info: - topic_url: - get_input: ves_pnfRegistration_publish_url - type: message router - streams_subscribes: {} - auth.method: noAuth - collector.dmaap.streamid: - get_input: collector.dmaap.streamid - collector.keystore.file.location: /opt/app/dcae-certificate/keystore.jks - collector.keystore.passwordfile: /opt/app/dcae-certificate/.password - collector.schema.checkflag: 1 - collector.schema.file: {"v1":"./etc/CommonEventFormat_27.2.json","v2":"./etc/CommonEventFormat_27.2.json","v3":"./etc/CommonEventFormat_27.2.json","v4":"./etc/CommonEventFormat_27.2.json","v5":"./etc/CommonEventFormat_28.4.1.json","v7":"./etc/CommonEventFormat_30.json"} - collector.service.port: 8080 - collector.service.secure.port: 8443 - collector.truststore.file.location: /opt/app/dcae-certificate/truststore.jks - collector.truststore.passwordfile: /opt/app/dcae-certificate/.trustpassword - event.transform.flag: 1 - header.authlist: - get_input: header.authlist - service_component_name_override: - get_input: service_component_name_override - tomcat.maxthreads: 200 - docker_config: - healthcheck: - interval: 15s - timeout: 1s - type: http - endpoint: /healthcheck - volumes: - - container: - bind: /opt/app/dcae-certificate - host: - path: /opt/app/dcae-certificate - - container: - bind: /opt/app/VESCollector/logs - host: - path: /opt/logs/DCAE/VESCollector/logs - - container: - bind: /opt/app/VESCollector/etc - host: - path: /opt/logs/DCAE/VESCollector/etc - image: - get_input: image - location_id: - get_input: location_id - service_component_type: dcae-ves-collector - replicas: - get_input: replicas - resource_config: - limits: - cpu: - get_input: dcae-ves-collector_cpu_limit - memory: - get_input: dcae-ves-collector_memory_limit - requests: - cpu: - get_input: dcae-ves-collector_cpu_request - memory: - get_input: dcae-ves-collector_memory_request - always_pull_image: - get_input: always_pull_image - relationships: [] \ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves/componentSpecs/ves.json b/mod/bpgenerator/TestCases/ves/componentSpecs/ves.json deleted file mode 100644 index 6812347..0000000 --- a/mod/bpgenerator/TestCases/ves/componentSpecs/ves.json +++ /dev/null @@ -1,276 +0,0 @@ -{ - "self": { - "version": "1.5.0", - "name": "dcae-ves-collector", - "description": "Collector for receiving VES events through restful interface", - "component_type": "docker" - }, - "streams": { - "subscribes": [], - "publishes": [ - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-fault" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-measurement" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-other" - }, - { - "format": "VES_specification", - "version": "5.28.4", - "type": "message router", - "config_key": "ves-heartbeat-secondary" - }, - { - "format": "VES_specification", - "version": "7.30.0", - "type": "message router", - "config_key": "ves-pnfRegistration" - }, - { - "format": "VES_specification", - "version": "7.30.0", - "type": "message router", - "config_key": "ves-notification" - } - ] - }, - "services": { - "calls": [], - "provides": [ - { - "route": "/eventListener/v1", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v2", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v3", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v4", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "4.27.2" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v5", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "5.28.4" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - }, - { - "route": "/eventListener/v7", - "verb": "POST", - "request": { - "format": "VES_specification", - "version": "7.30.0" - }, - "response": { - "format": "ves.coll.response", - "version": "1.0.0" - } - } - ] - }, - "parameters": [ - { - "name": "collector.service.port", - "value": 8080, - "description": "standard http port collector will open for listening;", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.service.secure.port", - "value": 8443, - "description": "secure http port collector will open for listening ", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": true - }, - { - "name": "collector.keystore.file.location", - "value": "/opt/app/dcae-certificate/keystore.jks", - "description": "fs location of keystore file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.keystore.passwordfile", - "value": "/opt/app/dcae-certificate/.password", - "description": "location of keystore password file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.truststore.file.location", - "value": "/opt/app/dcae-certificate/truststore.jks", - "description": "fs location of truststore file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.truststore.passwordfile", - "value": "/opt/app/dcae-certificate/.trustpassword", - "description": "location of truststore password file in vm", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.dmaap.streamid", - "value": "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary", - "description": "domain-to-streamid mapping used by VESCollector to distributes events based on domain. Both primary and secondary config_key are included for resilency (multiple streamid can be included commma separated). The streamids MUST match to topic config_keys. For single site without resiliency deployment - configkeys with -secondary suffix can be removed", - "sourced_at_deployment": true, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "auth.method", - "value": "noAuth", - "description": "Property to manage application mode, possible configurations: noAuth - default option - no security (http) , certOnly - auth by certificate (https), basicAuth - auth by basic auth username and password (https),certBasicAuth - auth by certificate and basic auth username / password (https),", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "header.authlist", - "value": "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy", - "description": "List of id and base 64 encoded password.For each onboarding VNF - unique userid and password should be assigned and communicated to VNF owner. Password value should be base64 encoded in config here", - "policy_editable": false, - "sourced_at_deployment": true, - "designer_editable": true - }, - { - "name": "collector.schema.checkflag", - "value": 1, - "description": "Schema check validation flag. When enabled, collector will validate input VES events against VES Schema defined on collector.schema.file ", - "sourced_at_deployment": false, - "policy_editable": false, - "designer_editable": false - }, - { - "name": "collector.schema.file", - "value": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\",\"v7\":\"./etc/CommonEventFormat_30.json\"}", - "description": "VES schema file name per version used for validation", - "designer_editable": true, - "sourced_at_deployment": false, - "policy_editable": false - }, - { - "name": "event.transform.flag", - "value": 1, - "description": "flag to enable tranformation rules defined under eventTransform.json; this is applicable when event tranformation rules preset should be activated for transforming + + + + 4.0.0 + + org.onap.dcaegen2.platform + blueprint-generator-common + 2.0.0 + jar + + Common + This module is used by DCAE and ONAP Applications to generate Blueprints + + + org.onap.dcaegen2.platform + blueprint-generator + 1.7.0-SNAPSHOT + + + \ No newline at end of file diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/config/ObjectMapperConfig.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/config/ObjectMapperConfig.java new file mode 100644 index 0000000..fc546af --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/config/ObjectMapperConfig.java @@ -0,0 +1,57 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.config; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Scope; + +/* + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Config: Object Mapper + */ + +@Configuration +public class ObjectMapperConfig { + + @Bean(name="objectMapper") + @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) + public ObjectMapper objectMapper(){ + return new ObjectMapper(); + } + + @Bean(name="yamlObjectMapper") + @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) + public ObjectMapper yamlObjectMapper(){ + return new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); + } + +} \ No newline at end of file diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java new file mode 100644 index 0000000..69a71e5 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java @@ -0,0 +1,100 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.constants; + +/* + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Constants: Used in ONAP and DCAE Blueprints + */ + +public class Constants { + + public static final String _TOPIC = "_topic"; + public static final String _FEED = "_feed"; + public static final String DATAROUTER_VALUE = "data router"; + public static final String DATA_ROUTER = "data_router"; + public static final String MESSAGEROUTER_VALUE = "message router"; + public static final String MESSAGE_ROUTER = "message_router"; + public static final String TOSCA_DEF_VERSION = "cloudify_dsl_1_3"; + public static final String SERVICE_COMPONENT_NAME_OVERRIDE = "service_component_name_override"; + public static final String EMPTY = "''"; + public static final String INTEGER_TYPE = "integer"; + public static final String BOOLEAN_TYPE = "boolean"; + public static final String STRING_TYPE = "string"; + public static final String EMPTY_VALUE = ""; + public static final String DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT_USING_DMAAP = "dcae.nodes.ContainerizedServiceComponentUsingDmaap"; + public static final String MEMORY_LIMIT_128Mi = "128Mi"; + public static final String CPU_LIMIT_250m = "250m"; + public static final String CPU_LIMIT = "cpu_limit"; + public static final String MEMORY_LIMIT = "memory_limit"; + public static final String CPU_REQUEST = "cpu_request"; + public static final String MEMORY_REQUEST = "memory_request"; + + public static final String CLOUDIFY_INTERFACES_LEFECYCLE = "cloudify.interfaces.lifecycle"; + public static final String DCAE = "dcae"; + public static final String DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT = "dcae.nodes.ContainerizedServiceComponent"; + public static final String ONAP_NAME_DCAE = "DCAE"; + public static final String POLICIES_POLICYNAME_DCAECONFIG = "DCAE.Config_"; + + public static final String DB_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on"; + public static final String NAME_POSTFIX = "_database_name"; + public static final String PGAAS_NODE_NAME_POSTFIX = "_pgaasdb"; + public static final String PGAAS_NODE_TYPE = "dcae.nodes.pgaas.database"; + public static final String POLICY_NODE_TYPE = "clamp.nodes.policy"; + public static final String POLICY_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on"; + public static final String WRITER_FQDN_POSTFIX = "_database_writerfqdn"; + public static final boolean USE_EXISTING = true; + public static final String ONAP_INPUT_CPU_LIMIT = "dcae-ves-collector_cpu_limit"; + public static final String ONAP_NODETEMPLATES = "dcae-ves-collector"; + public static final String ONAP_NODETEMPLATES_TYPE = "dcae.nodes.ContainerizedServiceComponent"; + public static final String ONAP_DEFAULT250m = "\"250m\""; + public static final String ONAP_SERVICE_COMPONENTNAME_OVERRIDE_DEFAULT = "\"\""; + public static final String DMAAP_NODETEMPLATES_TYPE = "dcae.nodes.ContainerizedServiceComponentUsingDmaap"; + public static final String USE_EXTERNAL_TLS_FIELD = "use_external_tls"; + public static final String DEFAULT_CA = "RA"; + public static final Object DEFAULT_CERT_TYPE = "P12"; + public static final String INPUT_PREFIX = "external_cert_"; + public static final String EXTERNAL_CERT_DIRECTORY_FIELD = "external_cert_directory"; + public static final String CA_NAME_FIELD = "ca_name"; + public static final String CERT_TYPE_FIELD = "cert_type"; + public static final String EXTERNAL_CERTIFICATE_PARAMETERS_FIELD = "external_certificate_parameters"; + public static final String CERT_DIRECTORY_FIELD = "cert_directory"; + public static final String COMMON_NAME_FIELD = "common_name"; + public static final String SANS_FIELD = "sans"; + public static final String DEFAULT_COMMON_NAME = "sample.onap.org"; + public static final String DEFAULT_SANS = "sample.onap.org:component.sample.onap.org"; + public static final String FEED = "dcaegen2.nodes.Feed"; + public static final String TOPIC = "dcaegen2.nodes.Topic"; + public static final String PUBLISH_EVENTS = "dcaegen2.relationships.publish_events"; + public static final String PUBLISH_FILES = "dcaegen2.relationships.publish_files"; + public static final String SUBSCRIBE_TO_EVENTS = "dcaegen2.relationships.subscribe_to_events"; + public static final String SUBSCRIBE_TO_FILES = "dcaegen2.relationships.subscribe_to_files"; + public static final String TOSCA_DATATYPES_ROOT = "tosca.datatypes.Root"; + public static final String TOSCA_NODES_ROOT = "tosca.nodes.Root"; + public static final String TOSCA_SIMPLE_YAML = "tosca_simple_yaml_1_0_0"; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/BlueprintException.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/BlueprintException.java new file mode 100644 index 0000000..f6ed5c7 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/BlueprintException.java @@ -0,0 +1,43 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.exception; + +/* + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Exception: For Blueprint + */ + +public class BlueprintException extends RuntimeException{ + + public BlueprintException(String errorMessage) { + super(errorMessage); + } + + public BlueprintException(String errorMessage, Throwable err) { + super(errorMessage, err); + } +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/ComponentSpecException.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/ComponentSpecException.java new file mode 100644 index 0000000..ff0270e --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/ComponentSpecException.java @@ -0,0 +1,43 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.exception; + +/* + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Exception: For ComponentSpec + */ + +public class ComponentSpecException extends RuntimeException{ + + public ComponentSpecException(String errorMessage) { + super(errorMessage); + } + + public ComponentSpecException(String errorMessage, Throwable err) { + super(errorMessage, err); + } +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java new file mode 100644 index 0000000..423da79 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java @@ -0,0 +1,38 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.exception; + +/* + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Exception: For Databases Not Found + */ + +public class DatabasesNotFoundException extends RuntimeException { + + public DatabasesNotFoundException(String message) { super(message);} + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/FixesException.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/FixesException.java new file mode 100644 index 0000000..aa81ede --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/exception/FixesException.java @@ -0,0 +1,43 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.exception; + +/* + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Exception: For Fixes + */ + +public class FixesException extends RuntimeException{ + + public FixesException(String errorMessage) { + super(errorMessage); + } + + public FixesException(String errorMessage, Throwable err) { + super(errorMessage, err); + } +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Blueprint.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Blueprint.java new file mode 100644 index 0000000..a72a00d --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Blueprint.java @@ -0,0 +1,55 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.base; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Base Model: For Blueprint + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Blueprint { + + private String tosca_definitions_version; + + private String description; + + private List imports; + + private Map> inputs; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Node.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Node.java new file mode 100644 index 0000000..c3df820 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/base/Node.java @@ -0,0 +1,46 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.base; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Base Model: For Node + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Node { + + private String type; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Appconfig.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Appconfig.java new file mode 100644 index 0000000..3a18b70 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Appconfig.java @@ -0,0 +1,64 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.model.componentspec.common.Calls; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For App Config + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Appconfig { + + private Calls[] services_calls; + + private Map streams_publishes; + + private Map streams_subscribes; + + private Map params; + + @JsonAnyGetter //The Map is persisted as flattened properties of the target POJO. + public Map getParams() { + return params; + } + + //Used in ONAP + private Calls[] service_calls; + +} + diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Concat.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Concat.java new file mode 100644 index 0000000..d3b3c01 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Concat.java @@ -0,0 +1,48 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Concat + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Concat { + + private List concat; + +} + diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/DataRouter.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/DataRouter.java new file mode 100644 index 0000000..49e029f --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/DataRouter.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + + +import org.onap.blueprintgenerator.constants.Constants; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Data Router + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class DataRouter extends Dmaap { + + private String type = Constants.DATA_ROUTER; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Dmaap.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Dmaap.java new file mode 100644 index 0000000..de3b31e --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Dmaap.java @@ -0,0 +1,53 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Dmaap + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Dmaap { + + private Object dmaap_info; + + //Below properties are used in ONAP + private String type; + + private GetInput pass; + + private GetInput user; + +} \ No newline at end of file diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetInput.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetInput.java new file mode 100644 index 0000000..cc87014 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetInput.java @@ -0,0 +1,54 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Get Input + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@AllArgsConstructor +@NoArgsConstructor +public class GetInput { + + //private Object get_input; + + @JsonProperty("get_input") + private Object bpInputName; + +} \ No newline at end of file diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetProperty.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetProperty.java new file mode 100644 index 0000000..0514d20 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/GetProperty.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Get Property + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class GetProperty { + + private List get_property; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Imports.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Imports.java new file mode 100644 index 0000000..eacf20e --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Imports.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Imports + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class Imports { + + private List imports; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Input.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Input.java new file mode 100644 index 0000000..781ce2e --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/Input.java @@ -0,0 +1,72 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Input + */ + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Input { + + private String componentSpecPath; + + private String bluePrintName; + + private String outputPath; + + private String policyPath; + + private String bpType; + + private int numPolicies; + + private int numPolicy; + + private String comment; + + private boolean useExisting; + + private List imports; + + private boolean useDti; + + //Used in ONAP + private String serviceNameOverride; + + private String importPath; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/MessageRouter.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/MessageRouter.java new file mode 100644 index 0000000..7d96785 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/common/MessageRouter.java @@ -0,0 +1,50 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.constants.Constants; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Common Model: For Message Router + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class MessageRouter extends Dmaap { + + private String type = Constants.MESSAGE_ROUTER; + + private Object aaf_password; + + private Object aaf_username; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/Auxilary.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/Auxilary.java new file mode 100644 index 0000000..9c37163 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/Auxilary.java @@ -0,0 +1,74 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.base; + + +import org.onap.blueprintgenerator.model.componentspec.common.HealthCheck; +import org.onap.blueprintgenerator.model.componentspec.common.Policy; +import org.onap.blueprintgenerator.model.componentspec.common.Reconfigs; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Auxilary + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Auxilary { + + private HealthCheck healthcheck; + + private HealthCheck livehealthcheck; + + private Policy policy; + + private Reconfigs reconfigs; + + private List> env; + + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Map databases; + +/* @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Affinity affinity;*/ + + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Object hpa_config; + + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/ComponentSpec.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/ComponentSpec.java new file mode 100644 index 0000000..e3583e7 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/base/ComponentSpec.java @@ -0,0 +1,55 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.base; + +import org.onap.blueprintgenerator.model.componentspec.common.Artifacts; +import org.onap.blueprintgenerator.model.componentspec.common.Parameters; +import org.onap.blueprintgenerator.model.componentspec.common.Self; +import org.onap.blueprintgenerator.model.componentspec.common.Streams; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For ComponentSpec + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ComponentSpec { + + private Self self; + + private Streams streams; + + private Parameters[] parameters; + + private Artifacts[] artifacts; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Artifacts.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Artifacts.java new file mode 100644 index 0000000..0ae1c1a --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Artifacts.java @@ -0,0 +1,49 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Artifacts + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Artifacts { + + private String type; + + private String uri; +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Calls.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Calls.java new file mode 100644 index 0000000..752040d --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Calls.java @@ -0,0 +1,50 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Calls + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Calls { + + private String config_key; + + private RequestResponse request; + + private RequestResponse response; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Constraints.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Constraints.java new file mode 100644 index 0000000..cb248b9 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Constraints.java @@ -0,0 +1,60 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Constraints + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Constraints { + + private Object equal; + + private int greater_than; + + private int greater_or_equal; + + private int less_than; + + private int less_or_equal; + + private Object[] valid_values; + + private int length; + + private int min_length; + + private int max_length; +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Container.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Container.java new file mode 100644 index 0000000..3157338 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Container.java @@ -0,0 +1,46 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Container + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@EqualsAndHashCode +public class Container { + + private String bind; + + private String mode; +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/EntrySchema.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/EntrySchema.java new file mode 100644 index 0000000..d0355ea --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/EntrySchema.java @@ -0,0 +1,56 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Entry Schema + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class EntrySchema { + + private String name; + + private String description; + + private String type; + + private String value; + + private EntrySchema[] entry_schema; + + private boolean required; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/HealthCheck.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/HealthCheck.java new file mode 100644 index 0000000..01c1497 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/HealthCheck.java @@ -0,0 +1,58 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For HealthCheck + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class HealthCheck { + + private String interval; + + private String timeout; + + private String script; + + private String type; + + private String endpoint; + + private String initialDelaySeconds; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Host.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Host.java new file mode 100644 index 0000000..6a9d812 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Host.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Host + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@EqualsAndHashCode +public class Host { + + private String path; + + private String mode; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Parameters.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Parameters.java new file mode 100644 index 0000000..9c1931c --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Parameters.java @@ -0,0 +1,69 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Parameters + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Parameters { + + private String name; + + private Object value; + + private String description; + + private boolean sourced_at_deployment; + + private boolean designer_editable; + + private boolean policy_editable; + + private boolean required; + + private String type; + + private String policy_group; + + private PolicySchema[] policy_schema; + + private EntrySchema[] entry_schema; + + private Constraints[] constraints; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Policy.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Policy.java new file mode 100644 index 0000000..ea419f3 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Policy.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Policy + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@EqualsAndHashCode +public class Policy { + + private String trigger_type; + + private String script_path; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/PolicySchema.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/PolicySchema.java new file mode 100644 index 0000000..2d17086 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/PolicySchema.java @@ -0,0 +1,57 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Policy Schema + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class PolicySchema { + + private String name; + + private String description; + + private String type; + + private String value; + + private EntrySchema[] entry_schema; + + private boolean required; + + private Constraints[] constraints; + + } diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Provides.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Provides.java new file mode 100644 index 0000000..5301cbe --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Provides.java @@ -0,0 +1,52 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Provides + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Provides { + + private String route; + + private RequestResponse request; + + private RequestResponse response; + + //Used in ONAP + private String verb; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Publishes.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Publishes.java new file mode 100644 index 0000000..cd8230e --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Publishes.java @@ -0,0 +1,56 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Publishes + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Publishes { + + private String config_key; + + private String format; + + private String type; + + private String version; + + //Used in ONAP + private String route; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Reconfigs.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Reconfigs.java new file mode 100644 index 0000000..96b0fb3 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Reconfigs.java @@ -0,0 +1,54 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Reconfigs + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Reconfigs { + + private String dti; + + private String app_reconfig; + + private String policy; + + private String streams; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/RequestResponse.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/RequestResponse.java new file mode 100644 index 0000000..0376de1 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/RequestResponse.java @@ -0,0 +1,48 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Request Response + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class RequestResponse { + + private String format; + + private String version; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Self.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Self.java new file mode 100644 index 0000000..b657b16 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Self.java @@ -0,0 +1,53 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Self + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Self { + + private String component_type; + + private String description; + + private String name; + + private String version; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Streams.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Streams.java new file mode 100644 index 0000000..3791e32 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Streams.java @@ -0,0 +1,50 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Streams + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Streams { + + private Publishes[] publishes; + + private Subscribes[] subscribes; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Subscribes.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Subscribes.java new file mode 100644 index 0000000..668a517 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Subscribes.java @@ -0,0 +1,56 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Subscribes + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Subscribes { + + private String config_key; + + private String format; + + private String route; + + private String type; + + private String version; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java new file mode 100644 index 0000000..6f12b47 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java @@ -0,0 +1,54 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec.common; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAP and DCAE Blueprint Applications + * Component Spec Model: For Volumes + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +public class Volumes { + + private Container container; + + private Host host; + + private String type; + + private String name; + +} \ No newline at end of file diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policies.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policies.java new file mode 100644 index 0000000..35d210c --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policies.java @@ -0,0 +1,52 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import org.onap.blueprintgenerator.constants.Constants; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policies + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class Policies { + + private String configAttributes; + + private String configName; + + private String onapName = Constants.ONAP_NAME_DCAE; + + private String policyName = Constants.POLICIES_POLICYNAME_DCAECONFIG; + + private boolean unique = false; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesNode.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesNode.java new file mode 100644 index 0000000..7b951cc --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesNode.java @@ -0,0 +1,44 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import org.onap.blueprintgenerator.model.base.Node; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policies Node + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class PoliciesNode extends Node { + + private PoliciesProperties properties; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesProperties.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesProperties.java new file mode 100644 index 0000000..11844bf --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PoliciesProperties.java @@ -0,0 +1,43 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policies Properties + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class PoliciesProperties { + + private PolicyFilter policy_filter; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policy.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policy.java new file mode 100644 index 0000000..b5f098c --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/Policy.java @@ -0,0 +1,44 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policy + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class Policy { + + private String policy_id; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyFilter.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyFilter.java new file mode 100644 index 0000000..e49e6c3 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyFilter.java @@ -0,0 +1,52 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import org.onap.blueprintgenerator.constants.Constants; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policy Filters + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class PolicyFilter { + + private String configAttributes = Constants.EMPTY; + + private String configName = Constants.EMPTY; + + private String onapName = Constants.ONAP_NAME_DCAE; + + private Object policyName; + + private boolean unique = false; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyInput.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyInput.java new file mode 100644 index 0000000..ca13cd7 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyInput.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policy Input + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class PolicyInput { + + private Policies[] policies; + + private Policy[] policy; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyNode.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyNode.java new file mode 100644 index 0000000..f5ebf05 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyNode.java @@ -0,0 +1,44 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import org.onap.blueprintgenerator.model.base.Node; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policy Node + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class PolicyNode extends Node { + + private PolicyProperties properties; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyProperties.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyProperties.java new file mode 100644 index 0000000..8ec4a32 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/policy/PolicyProperties.java @@ -0,0 +1,44 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.policy; + +import org.onap.blueprintgenerator.model.common.GetInput; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Model: To Get Policy Properties + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class PolicyProperties { + + private GetInput policy_id; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/translate/GetProperty.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/translate/GetProperty.java new file mode 100644 index 0000000..47994c3 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/translate/GetProperty.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.translate; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Translate Model: To Get Property + */ + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +public class GetProperty { + + private List get_property; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java new file mode 100644 index 0000000..1f6b4f8 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java @@ -0,0 +1,118 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.base; + + +import org.onap.blueprintgenerator.constants.Constants; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Service: For Common Functions used across + */ + +@Service +public class BlueprintHelperService { + + + public LinkedHashMap createInputValue(String type, String description, Object defaultValue) { + LinkedHashMap inputMap = new LinkedHashMap<>(); + inputMap.put("type", type); + inputMap.put("description", description); + inputMap.put("default", defaultValue); + return inputMap; + } + + public LinkedHashMap createInputValue(String type, String description) { + LinkedHashMap inputMap = new LinkedHashMap<>(); + inputMap.put("type", type); + inputMap.put("description", description); + return inputMap; + } + + public LinkedHashMap createInputValue(String type, Object defaultValue) { + LinkedHashMap inputMap = new LinkedHashMap<>(); + inputMap.put("type", type); + inputMap.put("default", defaultValue); + return inputMap; + } + + public LinkedHashMap createIntegerInput(String description, Object defaultValue){ + return createInputValue(Constants.INTEGER_TYPE, description, defaultValue); + } + + public LinkedHashMap createIntegerInput(String description){ + return createInputValue(Constants.INTEGER_TYPE, description); + } + + public LinkedHashMap createIntegerInput(Object defaultValue){ + return createInputValue(Constants.INTEGER_TYPE, defaultValue); + } + + public LinkedHashMap createBooleanInput(String description, Object defaultValue){ + return createInputValue(Constants.BOOLEAN_TYPE, description, defaultValue); + } + + public LinkedHashMap createBooleanInput(String description){ + return createInputValue(Constants.BOOLEAN_TYPE, description); + } + + public LinkedHashMap createBooleanInput(Object defaultValue){ + return createInputValue(Constants.BOOLEAN_TYPE, defaultValue); + } + + public LinkedHashMap createStringInput(String description, Object defaultValue){ + return createInputValue(Constants.STRING_TYPE, description, defaultValue); + } + +/* public LinkedHashMap createStringInput(String description){ + return createInputValue(Constants.STRING_TYPE, description); + }*/ + + public LinkedHashMap createStringInput(Object defaultValue){ + return createInputValue(Constants.STRING_TYPE, defaultValue); + } + + public String joinUnderscore(String firstValue, String secondValue){ + return firstValue + "_" + secondValue; + } + + public boolean isDataRouterType(String type) { + return type.equals(Constants.DATA_ROUTER) || type.equals(Constants.DATAROUTER_VALUE); + } + + public boolean isMessageRouterType(String type) { + return type.equals(Constants.MESSAGE_ROUTER) || type.equals(Constants.MESSAGEROUTER_VALUE); + } + + public String getNamePrefix(String name) { + return name.isEmpty() ? "" : name + "_"; + } + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintService.java new file mode 100644 index 0000000..83c43cf --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintService.java @@ -0,0 +1,157 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.base; + +import org.onap.blueprintgenerator.model.base.Blueprint; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + + +import java.io.File; +import java.io.IOException; +import java.io.FileWriter; +import java.io.BufferedWriter; +import java.io.PrintWriter; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.regex.Pattern; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Service: For Adding Quotes and Converting Blueprint to Yaml/String + */ + +@Service +public abstract class BlueprintService { + + @Autowired + protected FixesService fixesService; + + @Qualifier("objectMapper") + @Autowired + protected ObjectMapper objectMapper; + + @Qualifier("yamlObjectMapper") + @Autowired + protected ObjectMapper yamlObjectMapper; + + public void blueprintToYaml(ComponentSpec cs, Blueprint blueprint, Input input) { + String bluePrintName = input.getBluePrintName(); + String outputPath = input.getOutputPath(); + String comment = "# " + input.getComment() + '\n'; + + try { + File outputFile; + String name = StringUtils.isEmpty(bluePrintName) ? cs.getSelf().getName() : bluePrintName; + if(name.contains(".")) { + name = name.replaceAll(Pattern.quote("."), "_"); + } + if(name.contains(" ")) { + name = name.replaceAll(" ", ""); + } + String file = name + ".yaml"; + outputFile = new File(outputPath, file); + outputFile.getParentFile().mkdirs(); + try { + outputFile.createNewFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + String version = "#blueprint_version: " + cs.getSelf().getVersion() + '\n'; + String description = "#description: " + cs.getSelf().getDescription() + '\n'; + + BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, false)); + writer.write(description); + writer.write(version); + + if(input.getBpType().equals("dti") || input.getBpType().equals("m") || input.getBpType().equals("k")) + writer.write(comment); + + writer.close(); + + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true))); + yamlObjectMapper.writeValue(out, blueprint); + out.close(); + + if(input.getBpType().equals("dti") || input.getBpType().equals("m") || input.getBpType().equals("k")) + fixesService.fixDcaeSingleQuotes(outputFile); + else + fixesService.fixOnapSingleQuotes(outputFile); + + //new Yaml().load(new FileInputStream(outputFile)); + + System.out.println("Blueprint is created with valid YAML Format"); + } catch (Exception ex) { + throw new RuntimeException("Unable to generate YAML file from Blueprint or the generated YAML is not valid", ex); + } + } + + // Used for DCAE + public Map> addQuotes(Map> inputs) { + + inputs.forEach((key,value) -> { + if(value.get("type") != null){ + if (value.get("type").equals("string") && value.get("default") != null && !key.contains("policies")){ + value.replace("default", "'" + value.get("default").toString() + "'"); + } else if (value.get("type").equals("map") || value.get("type").equals("list")) { + // Commented the Code as we need to read the object as is for Map and List. If the List object is to be converted to string uncomment the below code. + /* if(inputs.get(s).get("type").equals("list")) { + String temp = inputs.get(s).get("default").toString(); + inputs.get(s).replace("default", temp); + }*/ + inputs.get(key).remove("type"); + } + } + }); + + return inputs; + } + + public String blueprintToString(ComponentSpec componentSpec, Blueprint blueprint, Input input) { + String ret = ""; + try { + ret = yamlObjectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(blueprint); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + if(input.getBpType().equals("dti") || input.getBpType().equals("m") || input.getBpType().equals("k")){ + ret = "# " + componentSpec.getSelf().getDescription() + "\n" + "# " + componentSpec.getSelf().getVersion() + "\n" + "# " + input.getComment() + "\n" + ret; + ret = fixesService.fixStringQuotes(ret); + }else + ret = fixesService.applyFixes(ret); + return ret; + } + + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java new file mode 100644 index 0000000..d848cac --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/FixesService.java @@ -0,0 +1,170 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.base; + +import org.onap.blueprintgenerator.exception.FixesException; +import org.springframework.stereotype.Service; + + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.io.FileReader; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Service: For Blueprint Quotes Fixes + */ + +@Service +public class FixesService { + + public void fixDcaeSingleQuotes(File file) { + List lines = new ArrayList<>(); + try { + FileReader fr = new FileReader(file); + BufferedReader br = new BufferedReader(fr); + for (String line = br.readLine(); line != null; line = br.readLine()){ + if(line.contains("'")) { + line = line.replaceAll("'\\{", "{"); + line = line.replaceAll("}'", "}"); + line = line.replaceAll("'\\[", "["); + line = line.replaceAll("]'", "]"); + line = line.replaceAll("'''''", "'"); + line = line.replaceAll("'''", "'"); + line = line.replaceAll("'''", ""); + line = line.replaceAll("''\\{", "'{"); + line = line.replaceAll("}''", "}'"); + line = line.replaceAll("''\\[", "'["); + line = line.replaceAll("]''", "]'"); + line = line.replaceAll("\"''", "'"); + line = line.replaceAll("''\"", "'"); + } + if(line.contains("get_input") || line.contains("get_secret") || line.contains("envs")) + line = line.replaceAll("'", ""); + + lines.add(line); + } + + fr.close(); + br.close(); + + FileWriter fw = new FileWriter(file); + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true))); + for(String s: lines) { + out.println(); + out.write(s); + out.flush(); + } + out.close(); + fw.close(); + } catch (Exception e) { + throw new FixesException("Unable to Fix Single Quotes in Final DCAE Blueprint", e); + } + } + + public String fixStringQuotes(String string) { + String sLines[] = string.split("\n"); + String ret = ""; + for(String line: sLines) { + if(line.contains("get_input") || line.contains("get_secret") || ((line.contains("concat") || line.contains("default: ") || line.contains("description") || line.contains("dmaap") || line.contains(".\"'")) && line.contains("'"))) + line = line.replaceAll("'", ""); + + if(line.contains("'")) { + line = line.replaceAll("'\\{", "{"); + line = line.replaceAll("}'", "}"); + line = line.replaceAll("'\\[", "["); + line = line.replaceAll("]'", "]"); + line = line.replaceAll("'''''", "'"); + line = line.replaceAll("'''", "'"); + line = line.replaceAll("'''", ""); + line = line.replaceAll("''\\{", "'{"); + line = line.replaceAll("}''", "}'"); + line = line.replaceAll("''\\[", "'["); + line = line.replaceAll("]''", "]'"); + line = line.replaceAll("\"''", "'"); + line = line.replaceAll("''\"", "'"); + } + ret = ret + "\n" + line; + } + return ret; + } + + public void fixOnapSingleQuotes(File file) { + List lines = new ArrayList<>(); + try { + FileReader fr = new FileReader(file); + BufferedReader br = new BufferedReader(fr); + for (String line = br.readLine(); line != null; line = br.readLine()){ + if(line.contains("'")) { + line = line.replace("'", ""); + } + if(line.contains("\"\"") && (line.contains("m") || line.contains("M"))) { + line = line.replaceAll("\"\"", "\""); + } + lines.add(line); + + } + fr.close(); + br.close(); + FileWriter fw = new FileWriter(file); + PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file, true))); + for(String s: lines) { + out.println(); + out.write(s); + out.flush(); + } + + out.close(); + fw.close(); + + } catch (Exception e) { + throw new FixesException("Unable to Fix Single Quotes in final ONAP Blueprint", e); + } + } + + private String ensureNoSingleQuotes(String line) { + if ((line.contains("concat") || line.contains("default: ") || line.contains("description") || line.contains("dmaap") || line.contains(".\"'")) && line.contains("'")) + return line.replace("'", ""); + else + return line; + } + + public String applyFixes(String bp) { + List lines = new ArrayList<>(); + String[] linesPre = bp.split("\n"); + for (String line : linesPre) { + lines.add(ensureNoSingleQuotes(line)); + } + return String.join("\n", lines); + } + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/policycreate/exception/PolicyCreateException.java b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/exception/PolicyCreateException.java new file mode 100644 index 0000000..e848437 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/exception/PolicyCreateException.java @@ -0,0 +1,43 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.policycreate.exception; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Exception: For Policy Create + */ + +public class PolicyCreateException extends RuntimeException{ + + public PolicyCreateException(String errorMessage) { + super(errorMessage); + } + + public PolicyCreateException(String errorMessage, Throwable err) { + super(errorMessage, err); + } +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModel.java b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModel.java new file mode 100644 index 0000000..3d8c1a7 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModel.java @@ -0,0 +1,49 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.policycreate.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Create Model: For Policy Model + */ + +@Data +@JsonInclude(value=Include.NON_NULL) +public class PolicyModel { + + private String tosca_definition_version; + private Map node_types; + private Map data_types; + +} + diff --git a/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModelNode.java b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModelNode.java new file mode 100644 index 0000000..eac29b6 --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyModelNode.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.policycreate.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Create Model: For Policy Model Node + */ + +@Data +@JsonInclude(value=Include.NON_NULL) +public class PolicyModelNode { + + private String derived_from; + private Map properties; + +} diff --git a/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyProperties.java b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyProperties.java new file mode 100644 index 0000000..f12e76d --- /dev/null +++ b/mod/bpgenerator/common/src/main/java/org/onap/policycreate/model/PolicyProperties.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.policycreate.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by both ONAp and DCAE Blueprint Applications + * Policy Create Model: For Policy Properties + */ + +@Data +@JsonInclude(value=Include.NON_NULL) +public class PolicyProperties { + + private String type; + private Object entry_schema; + +} \ No newline at end of file diff --git a/mod/bpgenerator/onap/pom.xml b/mod/bpgenerator/onap/pom.xml new file mode 100644 index 0000000..799a683 --- /dev/null +++ b/mod/bpgenerator/onap/pom.xml @@ -0,0 +1,71 @@ + + + + + 4.0.0 + + org.onap.dcaegen2.platform + blueprint-generator-onap + 1.7.0 + jar + + Onap + This Application is used to generate ONAP Blueprint YAML Files for given Component Specs + + + org.onap.dcaegen2.platform + blueprint-generator + 1.7.0-SNAPSHOT + + + + + org.onap.dcaegen2.platform + blueprint-generator-common + 2.0.0 + compile + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.2.5.RELEASE + + + + repackage + + + + + + onap-blueprint-generator-${project.version} + + + \ No newline at end of file diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java new file mode 100644 index 0000000..3b9dd49 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/BlueprintGeneratorMainApplication.java @@ -0,0 +1,110 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator; + + +import org.onap.blueprintgenerator.model.base.Blueprint; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec; +import org.onap.blueprintgenerator.service.OnapBlueprintService; +import org.onap.blueprintgenerator.service.common.CommonUtils; +import org.onap.blueprintgenerator.service.common.ComponentSpecService; +import org.onap.blueprintgenerator.service.dmaap.DmaapBlueprintService; +import org.onap.policycreate.service.PolicyModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +import static java.lang.System.exit; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP - Blueprint Generator Main Application to create Policy Models or Blueprints + */ + +@ComponentScan({"org.onap.blueprintgenerator","org.onap.policycreate"}) +@SpringBootApplication +public class BlueprintGeneratorMainApplication implements CommandLineRunner { + + @Autowired + private ComponentSpecService componentSpecService; + + @Autowired + private PolicyModelService policyModelService; + + @Autowired + private CommonUtils commonUtils; + + @Autowired + private PolicyModelService onapPolicyModelNodeService; + + @Autowired + private ComponentSpecService onapComponentSpecService; + + @Autowired + private CommonUtils onapCommonUtils; + + @Autowired + private OnapBlueprintService onapBlueprintService; + + @Autowired + private DmaapBlueprintService dmaapBlueprintService; + + public static void main(String[] args) { + SpringApplication.run(BlueprintGeneratorMainApplication.class, args); + } + + @Override + public void run(String... args) { + if (args.length >=2 && args[0].equals("app") && args[1].equals("ONAP")) { + onapCommonUtils.printInstructions(); + if(args.length >=4 && args[2].equals("-type") && args[3].equals("policycreate")){ + Input input = onapCommonUtils.parseInputs(args); + ComponentSpec componentSpec = componentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + onapPolicyModelNodeService.createPolicyModels(componentSpec.getParameters(), input.getOutputPath()); + } + else { + Input input = onapCommonUtils.parseInputs(args); + OnapComponentSpec onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + if (input.getBpType().equals("o")) { + Blueprint blueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input); + onapBlueprintService.blueprintToYaml(onapComponentSpec, blueprint, input); + System.out.println(onapBlueprintService.blueprintToString(onapComponentSpec, blueprint, input)); + } else if (input.getBpType().equals("d")) { + Blueprint blueprint = dmaapBlueprintService.createBlueprint(onapComponentSpec, input); + dmaapBlueprintService.blueprintToYaml(onapComponentSpec, blueprint, input); + System.out.println(dmaapBlueprintService.blueprintToString(onapComponentSpec, blueprint, input)); + } + } + } + + exit(0); + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalCertificateParameters.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalCertificateParameters.java new file mode 100644 index 0000000..d7c76a9 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalCertificateParameters.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.constants.Constants; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: External Certificate Parameters + */ + + +@Data +public class ExternalCertificateParameters { + + @JsonProperty(Constants.COMMON_NAME_FIELD) + private GetInput commonName; + + @JsonProperty(Constants.SANS_FIELD) + private GetInput sans; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalTlsInfo.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalTlsInfo.java new file mode 100644 index 0000000..197104d --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ExternalTlsInfo.java @@ -0,0 +1,60 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.constants.Constants; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: External TLS Info + */ + + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class ExternalTlsInfo { + + @JsonProperty(Constants.EXTERNAL_CERT_DIRECTORY_FIELD) + private String externalCertDirectory; + + @JsonProperty(Constants.USE_EXTERNAL_TLS_FIELD) + private GetInput useExternalTls; + + @JsonProperty(Constants.CA_NAME_FIELD) + private GetInput caName; + + @JsonProperty(Constants.CERT_TYPE_FIELD) + private GetInput certType; + + @JsonProperty(Constants.EXTERNAL_CERTIFICATE_PARAMETERS_FIELD) + private ExternalCertificateParameters externalCertificateParameters; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/GetAttribute.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/GetAttribute.java new file mode 100644 index 0000000..2d5bca7 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/GetAttribute.java @@ -0,0 +1,44 @@ + +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Get Attribute + */ + + +@Data +public class GetAttribute { + + @JsonProperty("get_attribute") + private Object attribute; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Info.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Info.java new file mode 100644 index 0000000..3721d55 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Info.java @@ -0,0 +1,54 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Info + */ + + +@Data +@JsonInclude(value= Include.NON_NULL) +public class Info { + + private GetInput topic_url; + + private GetInput username; + + private GetInput password; + + private GetInput location; + + private GetInput delivery_url; + + private GetInput subscriber_id; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Interfaces.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Interfaces.java new file mode 100644 index 0000000..04ef7e7 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Interfaces.java @@ -0,0 +1,42 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + + +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Interfaces + */ + + +@Data +public class Interfaces { + + private Start start; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Node.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Node.java new file mode 100644 index 0000000..ea28d62 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Node.java @@ -0,0 +1,51 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Node derived from Common Module Node Model used by both DCAE and ONAP + */ + + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Node extends org.onap.blueprintgenerator.model.base.Node { + + private Map interfaces; + + private Properties properties; + + private List> relationships; +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/OnapBlueprint.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/OnapBlueprint.java new file mode 100644 index 0000000..4dd7b0f --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/OnapBlueprint.java @@ -0,0 +1,48 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.model.base.Blueprint; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Blueprint derived from Common Module Blueprint Model used by both DCAE and ONAP + */ + + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class OnapBlueprint extends Blueprint { + + private Map node_templates; + +} \ No newline at end of file diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNode.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNode.java new file mode 100644 index 0000000..af6fb54 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNode.java @@ -0,0 +1,46 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Pgaas Node + */ + + +@Data +@NoArgsConstructor +public class PgaasNode extends Node { + + @JsonProperty("properties") + private PgaasNodeProperties pgaasNodeProperties; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNodeProperties.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNodeProperties.java new file mode 100644 index 0000000..37ddb73 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PgaasNodeProperties.java @@ -0,0 +1,49 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Pgaas Node Properties + */ + + + +@Data +public class PgaasNodeProperties { + + @JsonProperty("writerfqdn") + private GetInput writerfqdn; + + @JsonProperty("name") + private GetInput name; + + @JsonProperty("use_existing") + private boolean useExisting; +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModel.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModel.java new file mode 100644 index 0000000..08b9096 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModel.java @@ -0,0 +1,48 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Policy Model + */ + + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PolicyModel { + + private String tosca_definition_version; + private Map node_types; + private Map data_types; + + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModelNode.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModelNode.java new file mode 100644 index 0000000..c418b8e --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyModelNode.java @@ -0,0 +1,47 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Policy Model Node + */ + + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PolicyModelNode { + + private String derived_from; + + private Map properties; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNode.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNode.java new file mode 100644 index 0000000..cc08814 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNode.java @@ -0,0 +1,46 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Policy Node derived from Common Module Node Model used by both DCAE and ONAP + */ + + +@Data +@NoArgsConstructor +public class PolicyNode extends Node { + + @JsonProperty("properties") + private PolicyNodeProperties policyNodeProperties; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNodeProperties.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNodeProperties.java new file mode 100644 index 0000000..3f472c8 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyNodeProperties.java @@ -0,0 +1,48 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Policy Node Properties + */ + + +@Data +@NoArgsConstructor +public class PolicyNodeProperties { + + @JsonProperty("policy_id") + private GetInput policyId; + + @JsonProperty("policy_model_id") + private String policyModelId; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyProperties.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyProperties.java new file mode 100644 index 0000000..5a63b00 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/PolicyProperties.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Policy Properties + */ + + +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PolicyProperties { + + private String type; + + private Object entry_schema; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java new file mode 100644 index 0000000..11fc06e --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Properties.java @@ -0,0 +1,89 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary; +import org.onap.blueprintgenerator.model.dmaap.Streams; +import org.onap.blueprintgenerator.model.dmaap.TlsInfo; +import org.onap.blueprintgenerator.service.common.ExternalTlsInfoFactoryService; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Properties + */ + + +@Data +@JsonInclude(value = Include.NON_NULL) +public class Properties { + + private Appconfig application_config; + + private OnapAuxilary docker_config; + + private Object image; + + private GetInput location_id; + + private String service_component_type; + + private Map log_info; + + private String dns_name; + + private Object replicas; + + private String name; + + private GetInput topic_name; + + private GetInput feed_name; + + private List streams_publishes; + + private List streams_subscribes; + + private TlsInfo tls_info; + + private ResourceConfig resource_config; + + private GetInput always_pull_image; + + private Boolean useExisting; + + @JsonIgnore + private ExternalTlsInfoFactoryService externalCertFactory; + + private ExternalTlsInfo external_cert; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ResourceConfig.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ResourceConfig.java new file mode 100644 index 0000000..8b41fd2 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/ResourceConfig.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Resource Config + */ + + +@Data +public class ResourceConfig { + + private Map limits; + + private Map requests; + +} \ No newline at end of file diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Services.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Services.java new file mode 100644 index 0000000..7aa1566 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Services.java @@ -0,0 +1,50 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import org.onap.blueprintgenerator.model.componentspec.common.Calls; +import org.onap.blueprintgenerator.model.componentspec.common.Provides; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Services + */ + + +@Data +@JsonInclude(value=Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Services { + + private Calls[] calls; + + private Provides[] provides; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Start.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Start.java new file mode 100644 index 0000000..3740668 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/Start.java @@ -0,0 +1,49 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Start + */ + + +@Data +@JsonInclude(value= JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Start { + + private StartInputs inputs; + + private Map envs; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/StartInputs.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/StartInputs.java new file mode 100644 index 0000000..458852e --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/common/StartInputs.java @@ -0,0 +1,49 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.common; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Common Model used by both ONAP and DMAAP: Start Inputs under Start + */ + + +@Data +@JsonInclude(value= JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class StartInputs { + + private Object envs; + + private List ports; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapAuxilary.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapAuxilary.java new file mode 100644 index 0000000..0923195 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapAuxilary.java @@ -0,0 +1,60 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec; + +import org.onap.blueprintgenerator.model.componentspec.base.Auxilary; +import org.onap.blueprintgenerator.model.componentspec.common.Volumes; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Component Spec Model for ONAP Auxillary derived from Common Module Auxillary used by both DCAE and ONAP + */ + + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class OnapAuxilary extends Auxilary { + + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private List ports; + + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Map log_info; + + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Map tls_info; + + private Volumes[] volumes; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapComponentSpec.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapComponentSpec.java new file mode 100644 index 0000000..5a64366 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/OnapComponentSpec.java @@ -0,0 +1,52 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec; + +import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Component Spec Model for ONAP Component Spec derived from Common Module Component Spec used by both DCAE and ONAP + */ + + +@Data +@JsonInclude(value = JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class OnapComponentSpec extends ComponentSpec { + + private Services services; + + private OnapAuxilary auxilary; + + @JsonProperty("policy_info") + private PolicyInfo policyInfo; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/PolicyInfo.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/PolicyInfo.java new file mode 100644 index 0000000..3ec5fe3 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/PolicyInfo.java @@ -0,0 +1,45 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Component Spec Model for Policy Info + */ + + +@Data +public class PolicyInfo { + + @JsonProperty("policy") + private List typePolicyList; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/Services.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/Services.java new file mode 100644 index 0000000..b7d32a4 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/Services.java @@ -0,0 +1,51 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec; + + +import org.onap.blueprintgenerator.model.componentspec.common.Calls; +import org.onap.blueprintgenerator.model.componentspec.common.Provides; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Component Spec Model for Services + */ + + +@Data +@JsonInclude(value= Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class Services { + + private Calls[] calls; + + private Provides[] provides; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/TypePolicy.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/TypePolicy.java new file mode 100644 index 0000000..6ba7daf --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/componentspec/TypePolicy.java @@ -0,0 +1,43 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.componentspec; + +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Component Spec Model for Type Policy + */ + + +@Data +public class TypePolicy { + + private String node_label; + private String policy_id; + private String policy_model_id; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/Streams.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/Streams.java new file mode 100644 index 0000000..14d0c51 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/Streams.java @@ -0,0 +1,66 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.dmaap; + +import org.onap.blueprintgenerator.model.common.GetInput; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import lombok.Data; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * DMAAP Model for Streams + */ + + +@Data +@JsonInclude(value= Include.NON_NULL) +public class Streams { + + private String name; + + private GetInput location; + + private GetInput client_role; + + private String type; + + private GetInput username; + + private GetInput password; + + //private GetInput delivery_url; + + private GetInput privileged; + + private GetInput decompress; + + private String route; + + private String scheme; + + +} \ No newline at end of file diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/TlsInfo.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/TlsInfo.java new file mode 100644 index 0000000..9290bf9 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/model/dmaap/TlsInfo.java @@ -0,0 +1,49 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.model.dmaap; + +import org.onap.blueprintgenerator.model.common.GetInput; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * DMAAP Model for TLS Info + */ + + +@Data +@NoArgsConstructor +public class TlsInfo { + + @JsonProperty("cert_directory") + private String certDirectory; + + @JsonProperty("use_tls") + private GetInput useTls; + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java new file mode 100644 index 0000000..fed3707 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/InfoService.java @@ -0,0 +1,116 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service; + +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.Info; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Service to create Message Router and Data Router Information + */ + +@Service +public class InfoService { + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // Method to create info for Message Router + public Map createMessageRouterInfo(Map> inputs, String config, char type) { + + Map response = new HashMap<>(); + Info info = new Info(); + + LinkedHashMap stringType = new LinkedHashMap<>(); + stringType.put("type", "string"); + + config = config.replaceAll("-", "_"); + if(type == 'p') { + config = config + "_publish_url"; + } + else if(type == 's') { + config = config+ "_subscribe_url"; + } + + GetInput topic = new GetInput(); + topic.setBpInputName(config); + info.setTopic_url(topic); + + inputs.put(config, stringType); + + response.put("info", info); + response.put("inputs", inputs); + return response; + } + + // Method to create info for Data Router + public Map createDataRouterInfo(Map> inputs, String config) { + + Map response = new HashMap<>(); + Info info = new Info(); + + LinkedHashMap stringType = new LinkedHashMap<>(); + stringType.put("type", "string"); + + String userNameInputName = blueprintHelperService.joinUnderscore(config, "username"); + GetInput username = new GetInput(userNameInputName); + info.setUsername(username); + inputs.put(userNameInputName, stringType); + + String userpasswordInputName = blueprintHelperService.joinUnderscore(config, "password"); + GetInput password = new GetInput(userpasswordInputName); + info.setPassword(password); + inputs.put(userpasswordInputName, stringType); + + String userlocationInputName = blueprintHelperService.joinUnderscore(config, "location"); + GetInput location = new GetInput(userlocationInputName); + info.setLocation(location); + inputs.put(userlocationInputName, stringType); + + String userdeliveryUrlInputName = blueprintHelperService.joinUnderscore(config, "delivery_url"); + GetInput deliveryUrl = new GetInput(userdeliveryUrlInputName); + info.setDelivery_url(deliveryUrl); + inputs.put(userdeliveryUrlInputName, stringType); + + String usersubscriberIDInputName = blueprintHelperService.joinUnderscore(config, "subscriber_id"); + GetInput subscriberID = new GetInput(usersubscriberIDInputName); + info.setSubscriber_id(subscriberID); + inputs.put(usersubscriberIDInputName, stringType); + + response.put("info", info); + response.put("inputs", inputs); + return response; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java new file mode 100644 index 0000000..f25c18c --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/OnapBlueprintService.java @@ -0,0 +1,111 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service; + + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.exception.BlueprintException; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.OnapBlueprint; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.service.base.BlueprintService; +import org.onap.blueprintgenerator.service.common.ImportsService; +import org.onap.blueprintgenerator.service.common.NodeService; +import org.onap.blueprintgenerator.service.common.PgaasNodeService; +import org.onap.blueprintgenerator.service.common.PolicyNodeService; +import org.onap.blueprintgenerator.service.common.QuotationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Service to create ONAP Blueprint + */ + +@Service +public class OnapBlueprintService extends BlueprintService { + + @Autowired + private NodeService nodeService; + + @Autowired + private PolicyNodeService policyNodeService; + + @Autowired + private PgaasNodeService pgaasNodeService; + + @Autowired + private QuotationService quotationService; + + @Autowired + protected ImportsService importsService; + + // Method to generate Onap Blueprint + public OnapBlueprint createBlueprint(OnapComponentSpec onapComponentSpec, Input input) { + try { + OnapBlueprint blueprint = new OnapBlueprint(); + blueprint.setTosca_definitions_version(Constants.TOSCA_DEF_VERSION); + + //if (!"".equals(input.getImportPath())) + if (!StringUtils.isEmpty(input.getImportPath())) + blueprint.setImports(importsService.createImportsFromFile(input.getImportPath())); + else + blueprint.setImports(importsService.createImports(input.getBpType())); + + Map nodeTemplate = new TreeMap<>(); + String nodeName = onapComponentSpec.getSelf().getName(); + Map> inputs = new TreeMap<>(); + + Map onapNodeResponse = nodeService.createOnapNode(inputs, onapComponentSpec, input.getServiceNameOverride()); + inputs = (Map>) onapNodeResponse.get("inputs"); + nodeTemplate.put(nodeName, (Node) onapNodeResponse.get("onapNode")); + blueprint.setNode_templates(nodeTemplate); + + if (onapComponentSpec.getPolicyInfo() != null) + policyNodeService.addPolicyNodesAndInputs(onapComponentSpec, nodeTemplate, inputs); + + if (onapComponentSpec.getAuxilary() != null && onapComponentSpec.getAuxilary().getDatabases() != null) + pgaasNodeService.addPgaasNodesAndInputs(onapComponentSpec, nodeTemplate, inputs); + + blueprint.setInputs(inputs); + + return quotationService.setQuotations(blueprint); + } catch (Exception ex) { + throw new BlueprintException("Unable to create ONAP Blueprint Object from given input parameters", ex); + } + } + + +} + + + diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java new file mode 100644 index 0000000..c6d744c --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/AppConfigService.java @@ -0,0 +1,166 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.Appconfig; +import org.onap.blueprintgenerator.model.common.Dmaap; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.common.Calls; +import org.onap.blueprintgenerator.model.componentspec.common.Parameters; +import org.onap.blueprintgenerator.model.componentspec.common.Publishes; +import org.onap.blueprintgenerator.model.componentspec.common.Subscribes; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to create App Config + */ + + +@Service("onapAppConfigService") +public class AppConfigService { + + @Autowired + private DmaapService dmaapService; + + @Autowired + private BlueprintHelperService blueprintHelperService; + + public Map createAppconfig(Map> inputs, OnapComponentSpec onapComponentSpec, String override, boolean isDmaap) { + + Map response = new HashMap<>(); + Appconfig appconfig = new Appconfig(); + + Calls[] call = new Calls[0]; + appconfig.setService_calls(call); + + Map streamPublishes = new TreeMap<>(); + if(onapComponentSpec.getStreams() != null) { + if (onapComponentSpec.getStreams().getPublishes() != null) { + for (Publishes publishes : onapComponentSpec.getStreams().getPublishes()) { + if (blueprintHelperService.isDataRouterType(publishes.getType())) { + String config = publishes.getConfig_key(); + String name = config + Constants._FEED; + Map dmaapDataRouterResponse = dmaapService.createDmaapDataRouter(inputs, config, name, isDmaap); + inputs = (Map>) dmaapDataRouterResponse.get("inputs"); + Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap"); + dmaap.setType(publishes.getType()); + streamPublishes.put(config, dmaap); + } else if (blueprintHelperService.isMessageRouterType(publishes.getType())) { + String config = publishes.getConfig_key(); + String name = config + Constants._TOPIC; + Map dmaapDataRouterResponse = dmaapService.createDmaapMessageRouter(inputs, config, 'p', name, name, isDmaap); + inputs = (Map>) dmaapDataRouterResponse.get("inputs"); + Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap"); + dmaap.setType(publishes.getType()); + streamPublishes.put(config, dmaap); + } + } + } + } + + Map streamSubscribes = new TreeMap<>(); + + if(onapComponentSpec.getStreams() != null) { + if (onapComponentSpec.getStreams().getSubscribes() != null) { + for (Subscribes subscribes : onapComponentSpec.getStreams().getSubscribes()) { + if (blueprintHelperService.isDataRouterType(subscribes.getType())) { + String config = subscribes.getConfig_key(); + String name = config + Constants._FEED; + Map dmaapDataRouterResponse = dmaapService.createDmaapDataRouter(inputs, config, name, isDmaap); + inputs = (Map>) dmaapDataRouterResponse.get("inputs"); + Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap"); + dmaap.setType(subscribes.getType()); + streamSubscribes.put(config, dmaap); + } else if (blueprintHelperService.isMessageRouterType(subscribes.getType())) { + String config = subscribes.getConfig_key(); + String name = config + Constants._TOPIC; + Map dmaapDataRouterResponse = dmaapService.createDmaapMessageRouter(inputs, config, 's', name, name, isDmaap); + inputs = (Map>) dmaapDataRouterResponse.get("inputs"); + Dmaap dmaap = (Dmaap) dmaapDataRouterResponse.get("dmaap"); + dmaap.setType(subscribes.getType()); + streamSubscribes.put(config, dmaap); + } + } + } + } + + appconfig.setStreams_publishes(streamPublishes); + appconfig.setStreams_subscribes(streamSubscribes); + + Map parameters = new TreeMap<>(); + for(Parameters p: onapComponentSpec.getParameters()) { + String pName = p.getName(); + if(p.isSourced_at_deployment()) { + GetInput paramInput = new GetInput(); + paramInput.setBpInputName(pName); + parameters.put(pName, paramInput); + if(!"".equals(p.getValue())) { + LinkedHashMap pInputs = blueprintHelperService.createStringInput( p.getValue()); + inputs.put(pName, pInputs); + } else { + LinkedHashMap pInputs = new LinkedHashMap<>(); + pInputs.put("type", "string"); + inputs.put(pName, pInputs); + } + } else { + if("string".equals(p.getType())) { + String val =(String) p.getValue(); + val = '"' + val + '"'; + parameters.put(pName, val); + } + else { + parameters.put(pName, p.getValue()); + // Updated code to resolve the issue of missing \ for collector.schema.file + //parameters.put(pName, pName.equals("collector.schema.file") ? ((String)p.getValue()).replace("\"", "\\\"") : p.getValue()); + } + } + } + if(override != null) { + GetInput ov = new GetInput(); + ov.setBpInputName(Constants.SERVICE_COMPONENT_NAME_OVERRIDE); + parameters.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, ov); + LinkedHashMap over = blueprintHelperService.createStringInput( override); + inputs.put(Constants.SERVICE_COMPONENT_NAME_OVERRIDE, over); + } + appconfig.setParams(parameters); + + response.put("appconfig", appconfig); + response.put("inputs", inputs); + return response; + + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java new file mode 100644 index 0000000..97ed47f --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/CommonUtils.java @@ -0,0 +1,152 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + + + +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.DefaultParser; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.CommandLine; +import org.onap.blueprintgenerator.model.common.Input; + +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import static java.lang.System.exit; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to Print Instructions and Parse Inputs + */ + + +@Service("onapCommonUtilsService") +public class CommonUtils { + + public void printInstructions() { + System.out.println("OPTIONS:"); + System.out.println("-i OR --component-spec: The path of the ONAP Blueprint INPUT JSON SPEC FILE (Required)"); + System.out.println("-p OR --blueprint-path: The path of the ONAP Blueprint OUTPUT where it will be saved (Required)"); + System.out.println("-n OR --blueprint-name: The NAME of the ONAP Blueprint OUTPUT that will be created (Optional)"); + System.out.println("-t OR --imports: The path of the ONAP Blueprint IMPORT FILE (Optional)"); + System.out.println("-o OR --service-name-override: The Value used to OVERRIDE the SERVICE NAME of the ONAP Blueprint (Optional)"); + System.out.println("-d OR --dmaap-plugin: The option to create a ONAP Blueprint with DMAAP Plugin (Optional)"); + System.out.println("Syntax to run from command line: \n For Blueprint : java -jar target/.jar app ONAP -i componentspec -p OutputBlueprintPath -n Blueprintname -d \n For PolicyCreate: java -jar target/.jar app ONAP -type policycreate -i componentspec -p OutputPolicyPath"); + } + + public Input parseInputs(String[] args) { + String[] modArgs = new String[args.length]; + for(int i=0; i createDmaapMessageRouter(Map> inputs,String config, char type, String counter, String num, boolean isDmaap) { + + Map response = new HashMap<>(); + Dmaap dmaap = new Dmaap(); + + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + + if(!isDmaap){ + Map infoResponse = infoService.createMessageRouterInfo(inputs, config, type); + inputs = (Map>) infoResponse.get("inputs"); + dmaap.setDmaap_info(infoResponse.get("info")); + } + else{ + String infoType = "<<" + counter + ">>"; + dmaap.setDmaap_info(infoType); + + GetInput u = new GetInput(); + u.setBpInputName(config + "_" + num +"_aaf_username"); + dmaap.setUser(u); + inputs.put(config + "_" + num +"_aaf_username", stringType); + + GetInput p = new GetInput(); + p.setBpInputName(config + "_" + num +"_aaf_password"); + dmaap.setPass(p); + inputs.put(config + "_" + num +"_aaf_password", stringType); + } + response.put("dmaap", dmaap); + response.put("inputs", inputs); + return response; + } + + // Method is used to create the Dmaap Data Router + public Map createDmaapDataRouter(Map> inputs, String config, String counter, boolean isDmaap) { + + Map response = new HashMap<>(); + Dmaap dmaap = new Dmaap(); + + if(!isDmaap){ + Map infoResponse = infoService.createDataRouterInfo(inputs, config); + inputs = (Map>) infoResponse.get("inputs"); + dmaap.setDmaap_info(infoResponse.get("info")); + } + else { + String infoType = "<<" + counter + ">>"; + dmaap.setDmaap_info(infoType); + } + response.put("dmaap", dmaap); + response.put("inputs", inputs); + return response; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java new file mode 100644 index 0000000..ab48ada --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateDataFactoryService.java @@ -0,0 +1,50 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 Nokia. All rights reserved. + * * Copyright (c) 2020 AT&T. 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.springframework.stereotype.Service; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add External Certificate Data Factory + */ + + +@Service +public abstract class ExternalCertificateDataFactoryService { + + // Method to concatenate Constant with field + protected static GetInput createPrefixedGetInput(String fieldName) { + return new GetInput(addPrefix(fieldName)); + } + + // Method to concatenate the Constant INPUT_PREFIX to the input field + protected static String addPrefix(String fieldName) { return Constants.INPUT_PREFIX + fieldName; } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java new file mode 100644 index 0000000..b739e4b --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalCertificateParametersFactoryService.java @@ -0,0 +1,71 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.ExternalCertificateParameters; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add External Certificate Parameters + */ + + +@Service +public class ExternalCertificateParametersFactoryService extends ExternalCertificateDataFactoryService { + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // method to create external certificate parameters + public ExternalCertificateParameters create() { + ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters(); + externalCertificateParameters.setCommonName(createPrefixedGetInput(Constants.COMMON_NAME_FIELD)); + externalCertificateParameters.setSans(createPrefixedGetInput(Constants.SANS_FIELD)); + return externalCertificateParameters; + } + + // method to create input list for external certificate parameters factory + public Map> createInputList() { + Map> retInputs = new LinkedHashMap<>(); + + LinkedHashMap commonNameInputMap = blueprintHelperService.createStringInput("Common name which should be present in certificate.",Constants.DEFAULT_COMMON_NAME); + retInputs.put(addPrefix(Constants.COMMON_NAME_FIELD), commonNameInputMap); + + LinkedHashMap sansInputMap = blueprintHelperService.createStringInput("\"List of Subject Alternative Names (SANs) which should be present in certificate. " + + "Delimiter - : Should contain a common_name value and other FQDNs under which the given " +"component is accessible.\"",Constants.DEFAULT_SANS); + retInputs.put(addPrefix(Constants.SANS_FIELD), sansInputMap); + + return retInputs; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java new file mode 100644 index 0000000..10364ab --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ExternalTlsInfoFactoryService.java @@ -0,0 +1,87 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.ExternalTlsInfo; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add External TLS Info + */ + + +@Service +public class ExternalTlsInfoFactoryService extends ExternalCertificateDataFactoryService { + + @Autowired + private ExternalCertificateParametersFactoryService externalCertificateParametersFactoryService; + + @Autowired + private BlueprintHelperService blueprintHelperService; + + //Method to create External TLS Info from Component Spec + public ExternalTlsInfo createFromComponentSpec(OnapComponentSpec cs) { + ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo(); + Map tlsInfoCs = cs.getAuxilary().getTls_info(); + + externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get(Constants.CERT_DIRECTORY_FIELD)); + externalTlsInfoBp.setUseExternalTls(createPrefixedGetInput(Constants.USE_EXTERNAL_TLS_FIELD)); + externalTlsInfoBp.setCaName(createPrefixedGetInput(Constants.CA_NAME_FIELD)); + externalTlsInfoBp.setCertType(createPrefixedGetInput(Constants.CERT_TYPE_FIELD)); + externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParametersFactoryService.create()); + + return externalTlsInfoBp; + } + + //Method to create Input List for External TLS Info from Component Spec + public Map> createInputListFromComponentSpec(OnapComponentSpec cs) { + + Map> retInputs = new HashMap<>(); + + Map externalTlsInfoCs = cs.getAuxilary().getTls_info(); + LinkedHashMap useTlsFlagInput = blueprintHelperService.createBooleanInput("Flag to indicate external tls enable/disable.",externalTlsInfoCs.get(Constants.USE_EXTERNAL_TLS_FIELD)); + retInputs.put(addPrefix(Constants.USE_EXTERNAL_TLS_FIELD), useTlsFlagInput); + + LinkedHashMap caNameInputMap = blueprintHelperService.createStringInput("Name of Certificate Authority configured on CertService side.",Constants.DEFAULT_CA); + retInputs.put(addPrefix(Constants.CA_NAME_FIELD), caNameInputMap); + + LinkedHashMap certTypeInputMap = blueprintHelperService.createStringInput("Format of provided certificates",Constants.DEFAULT_CERT_TYPE); + retInputs.put(addPrefix(Constants.CERT_TYPE_FIELD), certTypeInputMap); + + retInputs.putAll(externalCertificateParametersFactoryService.createInputList()); + return retInputs; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java new file mode 100644 index 0000000..cb9c03c --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ImportsService.java @@ -0,0 +1,98 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.blueprintgenerator.model.common.Imports; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: DCAE/ONAP - Blueprint Generator + * Common Module: Used by ONAP Blueprint Application + * Service: For Imports + */ + +@Service +public class ImportsService { + + @Value("${imports.onap.types}") + private String importsOnapTypes; + + @Value("${imports.onap.K8s.plugintypes}") + private String importsOnapK8sPlugintypes; + + @Value("${imports.onap.K8s.dcaepolicyplugin}") + private String importsOnapK8sDcaepolicyplugin; + + @Value("${imports.dmaap.dmaapplugin}") + private String importsDmaapDmaapplugin; + + @Value("${import.Postgres}") + private String importPostgres; + + @Value("${import.Clamp}") + private String importClamp; + + + @Qualifier("yamlObjectMapper") + @Autowired + protected ObjectMapper yamlObjectMapper; + + public List createImports(String bpType) { + List imports = new ArrayList<>(); + if (bpType.equals("o")) { + imports.add(importsOnapTypes); + imports.add(importsOnapK8sPlugintypes); + imports.add(importsOnapK8sDcaepolicyplugin); + imports.add(importPostgres); + imports.add(importClamp); + } + else { + imports.add(importsOnapTypes); + imports.add(importsOnapK8sPlugintypes); + imports.add(importsDmaapDmaapplugin); + imports.add(importPostgres); + imports.add(importClamp); + } + return imports; + } + + public List createImportsFromFile(String path) throws IOException { + File importPath = new File(path); + Imports imports = yamlObjectMapper.readValue(importPath, Imports.class); + imports.getImports().removeIf(String::isBlank); + return imports.getImports(); + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java new file mode 100644 index 0000000..bfd14a4 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/InterfacesService.java @@ -0,0 +1,67 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.model.common.Interfaces; +import org.onap.blueprintgenerator.model.common.Start; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add Interfaces + */ + + +@Service +public class InterfacesService { + + @Autowired + private StartService startService; + + // Method to create Interface to include Start and Start inputs sections in BP + public Map createInterface(Map> inputs, OnapComponentSpec onapComponentSpec){ + + Map response = new HashMap<>(); + Interfaces interfaces = new Interfaces(); + + Map startResponse = startService.createStart(inputs, onapComponentSpec); + inputs = (Map>) startResponse.get("inputs"); + + interfaces.setStart((Start) startResponse.get("start")); + + response.put("interfaces", interfaces); + response.put("inputs", inputs); + return response; + } + +} + diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java new file mode 100644 index 0000000..b8da0d7 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/NodeService.java @@ -0,0 +1,222 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.Interfaces; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.Properties; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.common.Publishes; +import org.onap.blueprintgenerator.model.componentspec.common.Subscribes; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.TreeMap; +import java.util.List; + + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add ONAP/DMAAP/Feed/Topic Nodes + */ + + +@Service +public class NodeService { + + @Autowired + private InterfacesService interfacesService; + + @Autowired + private PolicyNodeService policyNodeService; + + @Autowired + private PgaasNodeService pgaasNodeService; + + @Autowired + private PropertiesService propertiesService; + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // method to create Onap Node to include interface + public Map createOnapNode(Map> inputs, OnapComponentSpec onapComponentSpec, String override) { + + Map response = new HashMap<>(); + Node onapNode = new Node(); + + Map onapResponse = interfacesService.createInterface(inputs, onapComponentSpec); + inputs = (Map>) onapResponse.get("inputs"); + + Map interfaces = new TreeMap<>(); + interfaces.put(Constants.CLOUDIFY_INTERFACES_LEFECYCLE, (Interfaces) onapResponse.get("interfaces")); + onapNode.setInterfaces(interfaces); + + onapNode.setType(Constants.DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT); + + List> relationships = new ArrayList(); + + if(onapComponentSpec.getPolicyInfo() != null){ + List> policyRelationshipsList = policyNodeService.getPolicyRelationships(onapComponentSpec); + relationships.addAll(policyRelationshipsList); + } + + if(onapComponentSpec.getAuxilary().getDatabases() != null){ + List> pgaasRelationshipsList = pgaasNodeService.getPgaasNodeRelationships(onapComponentSpec); + relationships.addAll(pgaasRelationshipsList); + } + + onapNode.setRelationships(relationships); + + Map propertiesResponse = propertiesService.createOnapProperties(inputs, onapComponentSpec, override); + inputs = (Map>) propertiesResponse.get("inputs"); + onapNode.setProperties((org.onap.blueprintgenerator.model.common.Properties)propertiesResponse.get("properties")); + + response.put("onapNode", onapNode); + response.put("inputs", inputs); + return response; + } + + // method to create Dmaap Node to include interface + public Map createDmaapNode(OnapComponentSpec onapComponentSpec, Map> inputs, String override) { + + Map response = new HashMap<>(); + Node dmaapNode = new Node(); + + dmaapNode.setType(Constants.DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT_USING_DMAAP); + + Map dmaapResponse = interfacesService.createInterface(inputs, onapComponentSpec); + inputs = (Map>) dmaapResponse.get("inputs"); + + Map interfaces = new TreeMap<>(); + interfaces.put(Constants.CLOUDIFY_INTERFACES_LEFECYCLE, (Interfaces) dmaapResponse.get("interfaces")); + dmaapNode.setInterfaces(interfaces); + + List> relationships = new ArrayList(); + + if(onapComponentSpec.getStreams().getPublishes() != null) { + for(Publishes publishes: onapComponentSpec.getStreams().getPublishes()) { + Map pubRelations = new LinkedHashMap(); + if(blueprintHelperService.isMessageRouterType(publishes.getType())){ + pubRelations.put("type", Constants.PUBLISH_EVENTS); + pubRelations.put("target", publishes.getConfig_key() + Constants._TOPIC); + } else if(blueprintHelperService.isDataRouterType(publishes.getType())){ + pubRelations.put("type", Constants.PUBLISH_FILES); + pubRelations.put("target", publishes.getConfig_key() + Constants._FEED); + } + relationships.add(pubRelations); + } + } + + if(onapComponentSpec.getStreams().getSubscribes() != null) { + for(Subscribes subscribes: onapComponentSpec.getStreams().getSubscribes()) { + Map subRelations = new LinkedHashMap(); + if(blueprintHelperService.isMessageRouterType(subscribes.getType())){ + subRelations.put("type", Constants.SUBSCRIBE_TO_EVENTS); + subRelations.put("target", subscribes.getConfig_key() + Constants._TOPIC); + } else if(blueprintHelperService.isDataRouterType(subscribes.getType())){ + subRelations.put("type", Constants.SUBSCRIBE_TO_FILES); + subRelations.put("target", subscribes.getConfig_key() + Constants._FEED); + } + relationships.add(subRelations); + } + } + + if(onapComponentSpec.getPolicyInfo() != null){ + List> policyRelationshipsList = policyNodeService.getPolicyRelationships(onapComponentSpec); + relationships.addAll(policyRelationshipsList); + } + + if(onapComponentSpec.getAuxilary().getDatabases() != null){ + List> pgaasRelationshipsList = pgaasNodeService.getPgaasNodeRelationships(onapComponentSpec); + relationships.addAll(pgaasRelationshipsList); + } + + dmaapNode.setRelationships(relationships); + + Map propertiesResponse = propertiesService.createDmaapProperties(inputs, onapComponentSpec, override); + inputs = (Map>) propertiesResponse.get("inputs"); + dmaapNode.setProperties((org.onap.blueprintgenerator.model.common.Properties)propertiesResponse.get("properties")); + + response.put("dmaapNode", dmaapNode); + response.put("inputs", inputs); + return response; + } + + // method to create Feed Node for Streams + public Map createFeedNode(Map> inputs, String name){ + Map response = new HashMap<>(); + Node feedNode = new Node(); + + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + + feedNode.setType(Constants.FEED); + + org.onap.blueprintgenerator.model.common.Properties props = new org.onap.blueprintgenerator.model.common.Properties(); + GetInput topicInput = new GetInput(); + topicInput.setBpInputName(name + "_name"); + props.setFeed_name(topicInput); + props.setUseExisting(true); + inputs.put(name + "_name", stringType); + feedNode.setProperties(props); + + response.put("feedNode", feedNode); + response.put("inputs", inputs); + return response; + } + + // method to create Topic Node for Streams + public Map createTopicNode(Map> inputs, String name){ + Map response = new HashMap<>(); + Node topicNode = new Node(); + + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + + topicNode.setType(Constants.TOPIC); + + org.onap.blueprintgenerator.model.common.Properties props = new Properties(); + GetInput topicInput = new GetInput(); + topicInput.setBpInputName(name + "_name"); + props.setTopic_name(topicInput); + inputs.put(name + "_name", stringType); + topicNode.setProperties(props); + + response.put("topicNode", topicNode); + response.put("inputs", inputs); + return response; + } + + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java new file mode 100644 index 0000000..ff45701 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PgaasNodeService.java @@ -0,0 +1,138 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.exception.DatabasesNotFoundException; + + +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.PgaasNode; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.PgaasNodeProperties; +import org.onap.blueprintgenerator.model.common.GetAttribute; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add Pgaas Node + */ + + +@Service +public class PgaasNodeService { + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // method to create Pgaas Nodes and Inputs for Databases + public void addPgaasNodesAndInputs(OnapComponentSpec onapComponentSpec, Map nodeTemplate, Map> inputs) { + Map databases = onapComponentSpec.getAuxilary().getDatabases(); + for(Map.Entry database : databases.entrySet()){ + addPgaasNode(database, nodeTemplate); + addPgaasInputs(database, inputs); + } + } + + private void addPgaasInputs(Map.Entry database, Map> inputs) { + inputs.put(database.getKey() + Constants.NAME_POSTFIX, blueprintHelperService.createStringInput( "db name", "")); + inputs.put(database.getKey() + Constants.WRITER_FQDN_POSTFIX, blueprintHelperService.createStringInput( "db writerfqdn", "")); + } + + private void addPgaasNode(Map.Entry database, Map nodeTemplate) { + PgaasNode pgaasNode = new PgaasNode(); + String dbName = database.getKey(); + pgaasNode.setType(Constants.PGAAS_NODE_TYPE); + pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName)); + nodeTemplate.put(dbName + Constants.PGAAS_NODE_NAME_POSTFIX , pgaasNode); + } + + private PgaasNodeProperties buildPgaasNodeProperties(String dbName) { + PgaasNodeProperties pgaasNodeProperties = new PgaasNodeProperties(); + + GetInput nameValue = new GetInput(); + nameValue.setBpInputName(dbName + Constants.NAME_POSTFIX); + pgaasNodeProperties.setName(nameValue); + + GetInput writerfqdnValue = new GetInput(); + writerfqdnValue.setBpInputName(dbName + Constants.WRITER_FQDN_POSTFIX); + pgaasNodeProperties.setWriterfqdn(writerfqdnValue); + + pgaasNodeProperties.setUseExisting(Constants.USE_EXISTING); + + return pgaasNodeProperties; + } + + // method to create Pgaas Node Relationships for Databases + public List> getPgaasNodeRelationships(OnapComponentSpec onapComponentSpec) { + List> relationships = new ArrayList<>(); + for(Map.Entry database : onapComponentSpec.getAuxilary().getDatabases().entrySet()){ + Map relationship = new LinkedHashMap<>(); + relationship.put("type", Constants.DB_RELATIONSHIP_TYPE); + relationship.put("target", database.getKey() + Constants.PGAAS_NODE_NAME_POSTFIX); + relationships.add(relationship); + } + return relationships; + } + + // method to create Env Variables for Databases + public Map getEnvVariables(Map databases) { + Map envVariables = new LinkedHashMap<>(); + for(Map.Entry database : databases.entrySet()){ + String name = database.getKey().toUpperCase(); + envVariables.put("<<", "*envs"); + + GetInput nameValue = new GetInput(); + nameValue.setBpInputName(name.toLowerCase() + Constants.NAME_POSTFIX); + envVariables.put(name + "_DB_NAME", nameValue); + + GetAttribute adminHostValue = buildGetAttributeValue(name.toLowerCase(), "admin", "host"); + envVariables.put( name.toUpperCase() + "_DB_ADMIN_HOST", adminHostValue); + + GetAttribute adminUserValue = buildGetAttributeValue(name.toLowerCase(), "admin", "user"); + envVariables.put( name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue); + + GetAttribute adminPasswordValue = buildGetAttributeValue(name.toLowerCase(), "admin", "password"); + envVariables.put( name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue); + } + return envVariables; + } + + private GetAttribute buildGetAttributeValue(String dbName, String owner, String type) { + GetAttribute attribute = new GetAttribute(); + attribute.setAttribute(Arrays.asList(dbName + Constants.PGAAS_NODE_NAME_POSTFIX, owner, type)); + return attribute; + } +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java new file mode 100644 index 0000000..7f6c63d --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java @@ -0,0 +1,99 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.PolicyNode; +import org.onap.blueprintgenerator.model.common.PolicyNodeProperties; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.TypePolicy; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add Policy Node + */ + + +@Service("onapPolicyNodeService") +public class PolicyNodeService { + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // Method to add Policy Nodes and Inputs + public void addPolicyNodesAndInputs(OnapComponentSpec onapComponentSpec, Map nodeTemplate, Map> inputs) { + List policyList = onapComponentSpec.getPolicyInfo().getTypePolicyList(); + for(TypePolicy policy: policyList){ + addPolicyNodesToNodeTemplate(policy, nodeTemplate); + addPolicyInputs(policy, inputs); + } + } + + private void addPolicyInputs(TypePolicy policy, Map> inputs) { + String defaultValue = policy.getPolicy_id(); + defaultValue = defaultValue != null ? defaultValue : ""; + inputs.put(policy.getNode_label() + "_policy_id", blueprintHelperService.createStringInput("policy_id", defaultValue)); + } + + private void addPolicyNodesToNodeTemplate(TypePolicy policy, Map nodeTemplate) { + PolicyNode policyNode = new PolicyNode(); + policyNode.setType(Constants.POLICY_NODE_TYPE); + policyNode.setPolicyNodeProperties(getPolicyNodeProperties(policy)); + nodeTemplate.put(policy.getNode_label(), policyNode); + } + + private PolicyNodeProperties getPolicyNodeProperties(TypePolicy policy) { + PolicyNodeProperties policyNodeProperties = new PolicyNodeProperties(); + GetInput policyIdGetInput = new GetInput(); + policyIdGetInput.setBpInputName(policy.getNode_label() + "_policy_id"); + policyNodeProperties.setPolicyId(policyIdGetInput); + policyNodeProperties.setPolicyModelId(policy.getPolicy_model_id()); + return policyNodeProperties; + } + + // Method to add Policy Relationships + public List> getPolicyRelationships(OnapComponentSpec onapComponentSpec) { + List> relationships = new ArrayList<>(); + List policyList = onapComponentSpec.getPolicyInfo().getTypePolicyList(); + for(TypePolicy policy: policyList){ + Map relationship = new LinkedHashMap<>(); + relationship.put("type", Constants.POLICY_RELATIONSHIP_TYPE); + relationship.put("target", policy.getNode_label()); + relationships.add(relationship); + } + return relationships; + } +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java new file mode 100644 index 0000000..e858d88 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PropertiesService.java @@ -0,0 +1,259 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.Appconfig; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.ResourceConfig; +import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.common.Publishes; +import org.onap.blueprintgenerator.model.componentspec.common.Subscribes; +import org.onap.blueprintgenerator.model.dmaap.Streams; +import org.onap.blueprintgenerator.model.dmaap.TlsInfo; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.onap.blueprintgenerator.service.dmaap.StreamsService; +import org.onap.blueprintgenerator.model.common.Properties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to create Properties Node + */ + + + +@Service("onapPropertiesService") +public class PropertiesService { + + @Autowired + private AppConfigService appConfigService; + + @Autowired + private ResourceConfigService resourceConfigService; + + @Autowired + private StreamsService streamsService; + + @Autowired + private ExternalTlsInfoFactoryService externalTlsInfoFactoryService; + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // Method to create ONAP properties + public Map createOnapProperties(Map> inputs, OnapComponentSpec onapComponentSpec, String override) { + Map response = new HashMap<>(); + org.onap.blueprintgenerator.model.common.Properties properties = new org.onap.blueprintgenerator.model.common.Properties(); + + GetInput image = new GetInput(); + image.setBpInputName("image"); + properties.setImage(image); + + LinkedHashMap img = new LinkedHashMap<>(); + inputs.put("image", blueprintHelperService.createStringInput(onapComponentSpec.getArtifacts()[0].getUri())); + + + GetInput location = new GetInput(); + location.setBpInputName("location_id"); + properties.setLocation_id(location); + + LinkedHashMap locMap = new LinkedHashMap(); + inputs.put("location_id", blueprintHelperService.createStringInput(Constants.EMPTY_VALUE)); + + properties.setLog_info(onapComponentSpec.getAuxilary().getLog_info()); + + GetInput replica = new GetInput(); + replica.setBpInputName("replicas"); + properties.setReplicas(replica); + + LinkedHashMap replicas = blueprintHelperService.createIntegerInput("number of instances", 1); + inputs.put("replicas", replicas); + + OnapAuxilary onapAuxilary = onapComponentSpec.getAuxilary(); + + properties.setDocker_config(onapAuxilary); + + Map appConfigResponse = appConfigService.createAppconfig(inputs, onapComponentSpec, override, false); + inputs = (Map>) appConfigResponse.get("inputs"); + properties.setApplication_config((Appconfig) appConfigResponse.get("appconfig")); + + GetInput always_pull_image = new GetInput(); + always_pull_image.setBpInputName("always_pull_image"); + + properties.setAlways_pull_image(always_pull_image); + + LinkedHashMap inputAlwaysPullImage = blueprintHelperService.createBooleanInput("Set to true if the image should always be pulled",true); + inputs.put("always_pull_image", inputAlwaysPullImage); + + String sType = onapComponentSpec.getSelf().getName(); + sType = sType.replace('.', '-'); + properties.setService_component_type(sType); + + Map tls_info = onapComponentSpec.getAuxilary().getTls_info(); + if(tls_info != null) { + addTlsInfo(onapComponentSpec, inputs, properties); + if (tls_info.get(Constants.USE_EXTERNAL_TLS_FIELD) != null) { + inputs.putAll(addExternalTlsInfo(onapComponentSpec,properties)); + } + } + + Map resourceConfigResponse = resourceConfigService.createResourceConfig(inputs, onapComponentSpec.getSelf().getName()); + inputs = (Map>) resourceConfigResponse.get("inputs"); + properties.setResource_config((ResourceConfig) resourceConfigResponse.get("resourceConfig")); + + response.put("properties", properties); + response.put("inputs", inputs); + return response; + } + + // Method to create Dmaap properties + public Map createDmaapProperties(Map> inputs, OnapComponentSpec onapComponentSpec, String override) { + Map response = new HashMap<>(); + org.onap.blueprintgenerator.model.common.Properties properties = new org.onap.blueprintgenerator.model.common.Properties(); + + GetInput image = new GetInput(); + image.setBpInputName("tag_version"); + properties.setImage(image); + + LinkedHashMap img = new LinkedHashMap<>(); + inputs.put("tag_version", blueprintHelperService.createStringInput(onapComponentSpec.getArtifacts()[0].getUri())); + + GetInput location = new GetInput(); + location.setBpInputName("location_id"); + properties.setLocation_id(location); + + LinkedHashMap locMap = new LinkedHashMap(); + inputs.put("location_id", blueprintHelperService.createStringInput(Constants.EMPTY_VALUE)); + + properties.setLog_info(onapComponentSpec.getAuxilary().getLog_info()); + + String sType = onapComponentSpec.getSelf().getName(); + sType = sType.replace('.', '-'); + properties.setService_component_type(sType); + + Map tls_info = onapComponentSpec.getAuxilary().getTls_info(); + if(tls_info != null) { + addTlsInfo(onapComponentSpec, inputs, properties); + if (tls_info.get(Constants.USE_EXTERNAL_TLS_FIELD) != null) { + inputs.putAll(addExternalTlsInfo(onapComponentSpec,properties)); + } + } + + GetInput replica = new GetInput(); + replica.setBpInputName("replicas"); + properties.setReplicas(replica); + + LinkedHashMap rep = blueprintHelperService.createIntegerInput( "number of instances", 1); + inputs.put("replicas", rep); + + OnapAuxilary onapAuxilary = onapComponentSpec.getAuxilary(); + + properties.setDocker_config(onapAuxilary); + + Map appConfigResponse = appConfigService.createAppconfig(inputs, onapComponentSpec, override, true); + inputs = (Map>) appConfigResponse.get("inputs"); + properties.setApplication_config((Appconfig) appConfigResponse.get("appconfig")); + + + List pubStreams = new ArrayList(); + if(onapComponentSpec.getStreams() != null) { + if (onapComponentSpec.getStreams().getPublishes() != null) { + for (Publishes publishes : onapComponentSpec.getStreams().getPublishes()) { + if (blueprintHelperService.isMessageRouterType(publishes.getType())) { + String topic = publishes.getConfig_key() + Constants._TOPIC; + Map streamsMessageRouterResponse = streamsService.createStreams(inputs, topic, publishes.getType(), publishes.getConfig_key(), publishes.getRoute(), 'p'); + inputs = (Map>) streamsMessageRouterResponse.get("inputs"); + pubStreams.add((Streams) streamsMessageRouterResponse.get("streams")); + } else if (blueprintHelperService.isDataRouterType(publishes.getType())) { + String feed = publishes.getConfig_key() + Constants._FEED; + Map streamsDataRouterResponse = streamsService.createStreams(inputs, feed, publishes.getType(), publishes.getConfig_key(), publishes.getRoute(), 'p'); + inputs = (Map>) streamsDataRouterResponse.get("inputs"); + pubStreams.add((Streams) streamsDataRouterResponse.get("streams")); + } + } + } + } + + ArrayList subStreams = new ArrayList(); + if(onapComponentSpec.getStreams() != null) { + if (onapComponentSpec.getStreams().getSubscribes() != null) { + for (Subscribes subscribes : onapComponentSpec.getStreams().getSubscribes()) { + if (blueprintHelperService.isMessageRouterType(subscribes.getType())) { + String topic = subscribes.getConfig_key() + Constants._TOPIC; + Map streamsMessageRouterResponse = streamsService.createStreams(inputs, topic, subscribes.getType(), subscribes.getConfig_key(), subscribes.getRoute(), 's'); + inputs = (Map>) streamsMessageRouterResponse.get("inputs"); + subStreams.add((Streams) streamsMessageRouterResponse.get("streams")); + } else if (blueprintHelperService.isDataRouterType(subscribes.getType())) { + String feed = subscribes.getConfig_key() + Constants._FEED; + Map streamsDataRouterResponse = streamsService.createStreams(inputs, feed, subscribes.getType(), subscribes.getConfig_key(), subscribes.getRoute(), 's'); + inputs = (Map>) streamsDataRouterResponse.get("inputs"); + subStreams.add((Streams) streamsDataRouterResponse.get("streams")); + } + } + } + } + + if(!pubStreams.isEmpty()) + properties.setStreams_publishes(pubStreams); + + if(!subStreams.isEmpty()) + properties.setStreams_subscribes(subStreams); + + Map resourceConfigResponse = resourceConfigService.createResourceConfig(inputs, onapComponentSpec.getSelf().getName()); + inputs = (Map>) resourceConfigResponse.get("inputs"); + properties.setResource_config((ResourceConfig) resourceConfigResponse.get("resourceConfig")); + + response.put("properties", properties); + response.put("inputs", inputs); + return response; + } + + private void addTlsInfo(OnapComponentSpec onapComponentSpec, Map> inputs, Properties properties) { + TlsInfo tlsInfo = new TlsInfo(); + tlsInfo.setCertDirectory((String) onapComponentSpec.getAuxilary().getTls_info().get("cert_directory")); + GetInput useTLSFlag = new GetInput(); + useTLSFlag.setBpInputName("use_tls"); + tlsInfo.setUseTls(useTLSFlag); + properties.setTls_info(tlsInfo); + LinkedHashMap useTlsFlagInput = blueprintHelperService.createBooleanInput("flag to indicate tls enable/disable",onapComponentSpec.getAuxilary().getTls_info().get("use_tls")); + inputs.put("use_tls", useTlsFlagInput); + } + + private Map> addExternalTlsInfo(OnapComponentSpec onapComponentSpec, Properties properties) { + properties.setExternal_cert(externalTlsInfoFactoryService.createFromComponentSpec(onapComponentSpec)); + return externalTlsInfoFactoryService.createInputListFromComponentSpec(onapComponentSpec); + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java new file mode 100644 index 0000000..c79ec56 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/QuotationService.java @@ -0,0 +1,59 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.model.common.OnapBlueprint; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to set Quotations of generated Blueprint + */ + + +@Service +public class QuotationService { + + // Method to add Quotes for String Types + public OnapBlueprint setQuotations(OnapBlueprint bp) { + for(String s: bp.getInputs().keySet()) { + LinkedHashMap temp = bp.getInputs().get(s); + if(temp.get("type") == "string") { + String def = (String) temp.get("default"); + if(def != null){ + def = def.replaceAll("\"$", "").replaceAll("^\"", ""); + } + def = '"' + def + '"'; + temp.replace("default", def); + bp.getInputs().replace(s, temp); + } + } + return bp; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java new file mode 100644 index 0000000..7b03372 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java @@ -0,0 +1,98 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.ResourceConfig; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add ResourceConfig + */ + + +@Service("onapResourceConfigService") +public class ResourceConfigService { + + @Autowired + private BlueprintHelperService blueprintHelperService; + + //Method to create Resouce Config for properties + public Map createResourceConfig(Map> inputs, String name){ + Map response = new HashMap<>(); + ResourceConfig resourceConfig = new ResourceConfig(); + + LinkedHashMap memoryLimit = blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi); + + LinkedHashMap cpuLimit = blueprintHelperService.createStringInput( Constants.CPU_LIMIT_250m); + + name = blueprintHelperService.getNamePrefix(name); + + Map lim = new TreeMap<>(); + + GetInput cpu = new GetInput(); + cpu.setBpInputName(name + Constants.CPU_LIMIT); + lim.put("cpu", cpu); + + GetInput memL = new GetInput(); + memL.setBpInputName(name + Constants.MEMORY_LIMIT); + lim.put("memory", memL); + + inputs.put(name + Constants.CPU_LIMIT, cpuLimit); + inputs.put(name + Constants.MEMORY_LIMIT, memoryLimit); + + resourceConfig.setLimits(lim); + + Map req = new TreeMap<>(); + + GetInput cpuR = new GetInput(); + cpuR.setBpInputName(name + Constants.CPU_REQUEST); + req.put("cpu", cpuR); + + GetInput memR = new GetInput(); + memR.setBpInputName(name + Constants.MEMORY_REQUEST); + req.put("memory", memR); + + inputs.put(name + Constants.CPU_REQUEST, cpuLimit); + inputs.put(name + Constants.MEMORY_REQUEST, memoryLimit); + + resourceConfig.setRequests(req); + + response.put("resourceConfig", resourceConfig); + response.put("inputs", inputs); + return response; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java new file mode 100644 index 0000000..20c3656 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartInputsService.java @@ -0,0 +1,97 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.common.StartInputs; +import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add Start Inputs Node under Start + */ + + +@Service +public class StartInputsService { + + @Autowired + private PgaasNodeService pgaasNodeService; + + //Method to create Start Inputs for Start in Interfaces + public Map createStartInputs(Map> inputs, OnapComponentSpec onapComponentSpec){ + + Map response = new HashMap<>(); + StartInputs startInputs = new StartInputs(); + + int count = 0; + List portList = new ArrayList(); + OnapAuxilary aux = onapComponentSpec.getAuxilary(); + + if (aux.getPorts() != null) { + for(Object p : aux.getPorts()) { + String[] ports = p.toString().split(":"); + portList.add(String.format("concat: [\"%s:\", {get_input: external_port_%d}]" , ports[0], count)); + + LinkedHashMap portType = new LinkedHashMap(); + portType.put("type", "string"); + portType.put("default", ports[1]); + inputs.put("external_port_" + count, portType); + count++; + } + } + + startInputs.setPorts(portList); + + LinkedHashMap envMap = new LinkedHashMap(); + if(onapComponentSpec.getAuxilary().getDatabases() != null){ + Map envVars = pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases()); + startInputs.setEnvs(envVars); + envMap.put("default", "&envs {}"); + } + else { + GetInput env = new GetInput(); + env.setBpInputName("envs"); + startInputs.setEnvs(env); + envMap.put("default", "{}"); + } + inputs.put("envs", envMap); + + response.put("startInputs", startInputs); + response.put("inputs", inputs); + return response; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java new file mode 100644 index 0000000..3fbfdb1 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/StartService.java @@ -0,0 +1,65 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.common; + + +import org.onap.blueprintgenerator.model.common.Start; +import org.onap.blueprintgenerator.model.common.StartInputs; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Common ONAP Service used by ONAP and DMAAP Blueprint to add Start Node + */ + + +@Service +public class StartService { + + @Autowired + private StartInputsService startInputsService; + + // Method to create Start for Interfaces + public Map createStart(Map> inputs, OnapComponentSpec onapComponentSpec) { + Map response = new HashMap<>(); + Start start = new Start(); + + Map startInputsResponse = startInputsService.createStartInputs(inputs, onapComponentSpec); + inputs = (Map>) startInputsResponse.get("inputs"); + start.setInputs((StartInputs) startInputsResponse.get("startInputs")); + + response.put("start", start); + response.put("inputs", inputs); + return response; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java new file mode 100644 index 0000000..002bd6c --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/DmaapBlueprintService.java @@ -0,0 +1,144 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.dmaap; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.exception.BlueprintException; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.OnapBlueprint; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.model.componentspec.common.Publishes; +import org.onap.blueprintgenerator.model.componentspec.common.Subscribes; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.onap.blueprintgenerator.service.base.BlueprintService; +import org.onap.blueprintgenerator.service.common.ImportsService; +import org.onap.blueprintgenerator.service.common.NodeService; +import org.onap.blueprintgenerator.service.common.PgaasNodeService; +import org.onap.blueprintgenerator.service.common.PolicyNodeService; +import org.onap.blueprintgenerator.service.common.QuotationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Service to create DMAAP Blueprint + */ + +@Service +public class DmaapBlueprintService extends BlueprintService { + + @Autowired + protected ImportsService importsService; + + @Autowired + private NodeService nodeService; + + @Autowired + private PolicyNodeService policyNodeService; + + @Autowired + private PgaasNodeService pgaasNodeService; + + @Autowired + private QuotationService quotationService; + + @Autowired + private BlueprintHelperService blueprintHelperService; + + // method to generate Dmaap Blueprint + public OnapBlueprint createBlueprint(OnapComponentSpec onapComponentSpec, Input input) { + try { + OnapBlueprint blueprint = new OnapBlueprint(); + blueprint.setTosca_definitions_version(Constants.TOSCA_DEF_VERSION); + blueprint.setDescription(onapComponentSpec.getSelf().getDescription()); + + Map> inputs = new TreeMap<>(); + + //if (!"".equals(input.getImportPath())) + if (!StringUtils.isEmpty(input.getImportPath()) ) + blueprint.setImports(importsService.createImportsFromFile(input.getImportPath())); + else + blueprint.setImports(importsService.createImports(input.getBpType())); + + Map nodeTemplate = new TreeMap(); + + Map dmaapNodeResponse = nodeService.createDmaapNode(onapComponentSpec, inputs, input.getServiceNameOverride()); + inputs = (Map>) dmaapNodeResponse.get("inputs"); + nodeTemplate.put(onapComponentSpec.getSelf().getName(), (Node) dmaapNodeResponse.get("dmaapNode")); + + if (onapComponentSpec.getStreams() != null) { + if (onapComponentSpec.getStreams().getPublishes() != null) { + for (Publishes publishes : onapComponentSpec.getStreams().getPublishes()) { + if (blueprintHelperService.isMessageRouterType(publishes.getType())) { + String topic = publishes.getConfig_key() + Constants._TOPIC; + Map topicNodeResponse = nodeService.createTopicNode(inputs, topic); + inputs = (Map>) topicNodeResponse.get("inputs"); + nodeTemplate.put(topic, (Node) topicNodeResponse.get("topicNode")); + } else if (blueprintHelperService.isDataRouterType(publishes.getType())) { + String feed = publishes.getConfig_key() + Constants._FEED; + Map feedNodeResponse = nodeService.createFeedNode(inputs, feed); + inputs = (Map>) feedNodeResponse.get("inputs"); + nodeTemplate.put(feed, (Node) feedNodeResponse.get("feedNode")); + } + } + } + if (onapComponentSpec.getStreams().getSubscribes() != null) { + for (Subscribes s : onapComponentSpec.getStreams().getSubscribes()) { + if (blueprintHelperService.isMessageRouterType(s.getType())) { + String topic = s.getConfig_key() + Constants._TOPIC; + Map topicNodeResponse = nodeService.createTopicNode(inputs, topic); + inputs = (Map>) topicNodeResponse.get("inputs"); + nodeTemplate.put(topic, (Node) topicNodeResponse.get("topicNode")); + } else if (blueprintHelperService.isDataRouterType(s.getType())) { + String feed = s.getConfig_key() + Constants._FEED; + Map feedNodeResponse = nodeService.createFeedNode(inputs, feed); + inputs = (Map>) feedNodeResponse.get("inputs"); + nodeTemplate.put(feed, (Node) feedNodeResponse.get("feedNode")); + } + } + } + } + + if (onapComponentSpec.getPolicyInfo() != null) + policyNodeService.addPolicyNodesAndInputs(onapComponentSpec, nodeTemplate, inputs); + + if (onapComponentSpec.getAuxilary() != null && onapComponentSpec.getAuxilary().getDatabases() != null) + pgaasNodeService.addPgaasNodesAndInputs(onapComponentSpec, nodeTemplate, inputs); + + blueprint.setNode_templates(nodeTemplate); + blueprint.setInputs(inputs); + return quotationService.setQuotations(blueprint); + } catch (Exception ex) { + throw new BlueprintException("Unable to create ONAP DMAAP Blueprint Object from given input parameters", ex); + } + } +} \ No newline at end of file diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java new file mode 100644 index 0000000..16687fc --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/dmaap/StreamsService.java @@ -0,0 +1,104 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.service.dmaap; + +import org.onap.blueprintgenerator.model.common.GetInput; +import org.onap.blueprintgenerator.model.dmaap.Streams; +import org.onap.blueprintgenerator.service.base.BlueprintHelperService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Service to create Streams + */ + + +@Service +public class StreamsService { + + @Autowired + private BlueprintHelperService blueprintHelperService; + + //Methos to create streams for Dmaap Blueprint + public Map createStreams(Map> inputs, String name, String type, String key, String route, char o){ + Map response = new HashMap<>(); + Streams streams = new Streams(); + + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + + streams.setName(name); + streams.setType(type); + + GetInput location = new GetInput(); + location.setBpInputName(key + "_" + name + "_location"); + inputs.put(key + "_" + name + "_location", stringType); + streams.setLocation(location); + + if(blueprintHelperService.isDataRouterType(type)) { + if('s' == o) { + GetInput username = new GetInput(); + username.setBpInputName(key + "_" + name + "_username"); + streams.setUsername(username); + inputs.put(key + "_" + name + "_username", stringType); + + GetInput password = new GetInput(); + password.setBpInputName(key + "_" + name + "_password"); + streams.setPassword(password); + inputs.put(key + "_" + name + "_password", stringType); + + GetInput priviliged = new GetInput(); + priviliged.setBpInputName(key + "_" + name + "_priviliged"); + streams.setPrivileged(priviliged); + inputs.put(key + "_" + name + "_priviliged", stringType); + + GetInput decompress = new GetInput(); + decompress.setBpInputName(key + "_" + name + "_decompress"); + streams.setDecompress(decompress); + inputs.put(key + "_" + name + "_decompress", stringType); + + streams.setRoute(route); + streams.setScheme("https"); + } + + + } else { + GetInput client = new GetInput(); + client.setBpInputName(key + "_" + name + "_client_role"); + streams.setClient_role(client); + inputs.put(key + "_" + name + "_client_role", stringType); + } + response.put("streams", streams); + response.put("inputs", inputs); + return response; + } + +} diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelNodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelNodeService.java new file mode 100644 index 0000000..05dbcae --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelNodeService.java @@ -0,0 +1,150 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.policycreate.service; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.componentspec.common.EntrySchema; +import org.onap.blueprintgenerator.model.componentspec.common.Parameters; +import org.onap.blueprintgenerator.model.componentspec.common.PolicySchema; +import org.onap.policycreate.model.PolicyModelNode; +import org.onap.policycreate.model.PolicyProperties; +import org.springframework.stereotype.Service; + +import java.util.Map; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.TreeMap; +import java.util.List; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * To create Node Type, Data Type and Translate Entry Schema for Policy Model Node + */ + + +@Service("onapPolicyModelNodeService") +public class PolicyModelNodeService { + + // Method to create Nodes for Policy + public Map creatNodeType(String policyName, Parameters[] params) { + String hasEntrySchema = ""; + Map response = new HashMap<>(); + PolicyModelNode policyModelNode = new PolicyModelNode(); + + Map props = new TreeMap<>(); + for(Parameters p: params) { + if(p.getPolicy_group() != null && p.getPolicy_group().equals(policyName)) { + String name = p.getName(); + String type = p.getType(); + PolicyProperties polProps = new PolicyProperties(); + if(p.getPolicy_schema() != null) { + polProps.setType("map"); + ArrayList entrySchema = new ArrayList(); + entrySchema.add("type: onap.datatypes." + name); + polProps.setEntry_schema(entrySchema); + hasEntrySchema = name; + props.put(name, polProps); + } + else { + polProps.setType(type); + props.put(name, polProps); + } + } + } + policyModelNode.setDerived_from(Constants.TOSCA_DATATYPES_ROOT); + policyModelNode.setProperties(props); + response.put("hasEntrySchema", hasEntrySchema); + response.put("policyModelNode", policyModelNode); + return response; + } + + // Method to create Data Types for Policy + public Map createDataTypes(String param, Parameters[] parameters){ + Map dataType = new TreeMap<>(); + PolicyModelNode node = new PolicyModelNode(); + node.setDerived_from(Constants.TOSCA_DATATYPES_ROOT); + + Map properties = new TreeMap<>(); + Parameters par = new Parameters(); + for(Parameters p: parameters) { + if(param.equals(p.getName())) { + par = p; + break; + } + } + + for(PolicySchema pol: par.getPolicy_schema()) { + if(pol.getEntry_schema() != null) { + PolicyProperties prop =new PolicyProperties(); + prop.setType("map"); + ArrayList schema = new ArrayList(); + schema.add("type: onap.datatypes." + pol.getName()); + prop.setEntry_schema(schema); + properties.put(pol.getName(), prop); + dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName()); + } + else { + PolicyProperties prop = new PolicyProperties(); + prop.setType(pol.getType()); + properties.put(pol.getName(), prop); + } + } + + node.setProperties(properties); + dataType.put("onap.datatypes." + param, node); + return dataType; + } + + private Map translateEntrySchema(Map dataType, EntrySchema[] entry, String name){ + Map data = dataType; + PolicyModelNode node = new PolicyModelNode(); + node.setDerived_from(Constants.TOSCA_NODES_ROOT); + Map properties = new TreeMap<>(); + + for(EntrySchema e: entry) { + if(e.getEntry_schema() != null) { + PolicyProperties prop = new PolicyProperties(); + prop.setType("list"); + List schema = new ArrayList<>(); + schema.add("type: onap.datatypes." + e.getName()); + prop.setEntry_schema(schema); + properties.put(e.getName(), prop); + data = translateEntrySchema(data, e.getEntry_schema(), e.getName()); + node.setProperties(properties); + } else { + PolicyProperties prop = new PolicyProperties(); + prop.setType(e.getType()); + properties.put(e.getName(), prop); + node.setProperties(properties); + } + } + + dataType.put("onap.datatypes." + name, node); + return data; + } + +} + diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelService.java b/mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelService.java new file mode 100644 index 0000000..bbc6259 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/java/org/onap/policycreate/service/PolicyModelService.java @@ -0,0 +1,105 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.policycreate.service; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.componentspec.common.Parameters; +import org.onap.policycreate.exception.PolicyCreateException; +import org.onap.policycreate.model.PolicyModel; +import org.onap.policycreate.model.PolicyModelNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Service for Policy Model to create Policy Models, Policy Group Names and Convert Policy to Yaml + */ + + +@Service("onapPolicyModelService") +public class PolicyModelService { + + @Qualifier("yamlObjectMapper") + @Autowired + protected ObjectMapper yamlObjectMapper; + + @Autowired + private PolicyModelNodeService policyModelNodeService; + + // Method to create Policy Models + public void createPolicyModels(Parameters[] params, String filePath) { + try { + List policyGroups = getPolicyGroupNames(params); + for (String s : policyGroups) { + PolicyModel model = new PolicyModel(); + model.setTosca_definition_version(Constants.TOSCA_SIMPLE_YAML); + + Map response = policyModelNodeService.creatNodeType(s, params); + String nodeTypeName = "onap.policy." + s; + Map nodeType = new TreeMap<>(); + nodeType.put(nodeTypeName, (PolicyModelNode) response.get("policyModelNode")); + model.setNode_types(nodeType); + + if (!"".equals(response.get("hasEntrySchema"))) + model.setData_types(policyModelNodeService.createDataTypes((String) response.get("hasEntrySchema"), params)); + policyModelToYaml(filePath, model, s); + } + } catch (Exception ex) { + throw new PolicyCreateException("Unable to create Policies from given input parameters", ex); + } + } + + private List getPolicyGroupNames(Parameters[] params) { + List names = new ArrayList<>(); + for (Parameters p : params) { + if (p.isPolicy_editable()) { + if (names.isEmpty()) { + names.add(p.getPolicy_group()); + } else if (!names.contains(p.getPolicy_group())) { + names.add(p.getPolicy_group()); + } + } + } + return names; + } + + private void policyModelToYaml(String path, PolicyModel model, String name) throws IOException { + File outputFile = new File(path, name + ".yml"); + outputFile.getParentFile().mkdirs(); + yamlObjectMapper.writeValue(outputFile, model); + } + +} + diff --git a/mod/bpgenerator/onap/src/main/resources/application.properties b/mod/bpgenerator/onap/src/main/resources/application.properties new file mode 100644 index 0000000..3b70df6 --- /dev/null +++ b/mod/bpgenerator/onap/src/main/resources/application.properties @@ -0,0 +1,36 @@ +# +# /* +# * ============LICENSE_START======================================================= +# * org.onap.dcae +# * ================================================================================ +# * Copyright (c) 2020 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========================================================= +# */ +# +# + +spring.main.banner-mode=off +spring.output.ansi.enabled=ALWAYS + +imports.onap.types=https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml +imports.onap.K8s.plugintypes=plugin:k8splugin?version=3.4.2 +imports.onap.K8s.dcaepolicyplugin=plugin:dcaepolicyplugin?version=2.4.0 + +imports.dmaap.dmaapplugin=plugin:dmaap?version=1.5.0 + +import.Postgres=plugin:pgaas?version=1.3.0 +import.Clamp=plugin:clamppolicyplugin?version=1.1.0 + + diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTestSuite.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTestSuite.java new file mode 100644 index 0000000..b19a823 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTestSuite.java @@ -0,0 +1,40 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.test; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Test Suite for Test Cases + */ + + +@RunWith(Suite.class) +@Suite.SuiteClasses({ OnapComponentSpecTest.class, OnapBlueprintServiceTest.class,ExternalCertificateParametersFactoryServiceTest.class/*, BlueprintJarComparatorTest.class*/}) +public class BlueprintGeneratorTestSuite { +} diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTests.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTests.java new file mode 100644 index 0000000..ea324da --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintGeneratorTests.java @@ -0,0 +1,109 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.test; + +import org.onap.blueprintgenerator.BlueprintGeneratorMainApplication; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; +import org.onap.blueprintgenerator.service.OnapBlueprintService; +import org.onap.blueprintgenerator.service.common.ComponentSpecService; +import org.onap.blueprintgenerator.service.dmaap.DmaapBlueprintService; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Ignore; +import org.junit.runner.RunWith; +import org.onap.policycreate.service.PolicyModelService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Test Cases + */ + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = BlueprintGeneratorMainApplication.class, initializers = ConfigFileApplicationContextInitializer.class) +@TestPropertySource( + properties = { + "ves=ves.json", + "testImports=testImports.yaml", + "useTlsTrueAndUseExternalTlsTrueTest=testComponentSpec_withTlsTrueAndExternalTlsTrue.json", + "useTlsFalseAndUseExternalTlsFalseTest=testComponentSpec_withTlsFalseAndExternalTlsFalse.json", + "useTlsTrueAndNoExternalTlsFlagTest=testComponentSpec_withTlsTrueAndNoExternalTls.json", + "noTlsInfo=testComponentSpec_withoutTlsInfo.json" + } +) +@Ignore +public class BlueprintGeneratorTests { + + @Qualifier("objectMapper") + @Autowired + protected ObjectMapper objectMapper; + + @Qualifier("yamlObjectMapper") + @Autowired + protected ObjectMapper yamlObjectMapper; + + @Value("${ves}") + protected String ves; + + @Value("${testImports}") + protected String testImports; + + @Value("${useTlsTrueAndUseExternalTlsTrueTest}") + protected String useTlsTrueAndUseExternalTlsTrueTest; + + @Value("${useTlsFalseAndUseExternalTlsFalseTest}") + protected String useTlsFalseAndUseExternalTlsFalseTest; + + @Value("${useTlsTrueAndNoExternalTlsFlagTest}") + protected String useTlsTrueAndNoExternalTlsFlagTest; + + @Value("${noTlsInfo}") + protected String noTlsInfo; + + @Autowired + protected ComponentSpecService onapComponentSpecService; + + @Autowired + protected DmaapBlueprintService dmaapBlueprintService; + + @Autowired + protected OnapBlueprintService onapBlueprintService; + + @Autowired + protected PolicyModelService policyModelService; + + @Autowired + protected OnapTestUtils onapTestUtils; + + protected OnapComponentSpec onapComponentSpec = null; + +} diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintJarComparatorTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintJarComparatorTest.java new file mode 100644 index 0000000..d10d3ff --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/BlueprintJarComparatorTest.java @@ -0,0 +1,115 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.test; + +import org.apache.commons.io.FileUtils; +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.jupiter.api.Order; +import org.junit.runners.MethodSorters; +import org.onap.blueprintgenerator.test.BlueprintGeneratorTests; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; + + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Bueprint Jar Comparision with Previos version to make sure Bps are not broken with new changes + */ + + +@Ignore +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class BlueprintJarComparatorTest extends BlueprintGeneratorTests { + + private String previousJarVersion = "0.1"; + private String latestJarVersion = "1.0"; + private String previousVersion = "0_1"; + private String latestVersion = "1_0"; + private String latestJarPath = Paths.get("target").toAbsolutePath().toString() + "\\"; + private String previousJarPath = Paths.get("src", "test", "resources", "archives").toAbsolutePath().toString() + "\\"; + private String inputPath = Paths.get("src", "test", "resources", "componentspecs").toAbsolutePath().toString() + "\\"; + private String inputPolicyPath = Paths.get("src", "test", "resources", "policyjson").toAbsolutePath().toString() + "\\"; + private String outputPath = Paths.get("src", "test", "resources", "outputfiles").toAbsolutePath().toString() + "\\"; + private String previousJar = "onap-blueprint-generator-" + previousJarVersion + ".jar"; + private String latestJar = "onap-blueprint-generator-" + latestJarVersion + ".jar"; + + @Test + @Order(value=1) + public void filesCleanup() throws IOException { + FileUtils.deleteDirectory(new File(outputPath)); + } + + @Test + public void jarTestVeswithDmaapK8s() throws IOException, InterruptedException { + String inputFileName = ves; + String outputFileName = "dcae-ves-collector-dmaap-"; + String inputImportsFileName = testImports; + + String previousJarCommand = "java -jar " + previousJarPath + previousJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath + + " -n " + outputFileName + previousVersion + " -t " + inputPath + inputImportsFileName + " -d"; + Runtime.getRuntime().exec(previousJarCommand); + + String latestJarCommand = "java -jar " + latestJarPath + latestJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath + + " -n " + outputFileName + latestVersion + " -t " + inputPath + inputImportsFileName + " -d"; + Runtime.getRuntime().exec(latestJarCommand); + + Thread.sleep(8000); + + Assert.assertEquals("The BluePrint files (" + outputFileName + ") for " + inputFileName + " with -m option don't match!", + FileUtils.readFileToString(new File(outputPath + outputFileName + previousVersion + ".yaml"), "utf-8"), + FileUtils.readFileToString(new File(outputPath + outputFileName + latestVersion + ".yaml"), "utf-8")); + } + + @Test + public void jarTestVeswithoutDmaapK8s() throws IOException, InterruptedException { + String inputFileName = ves; + String outputFileName = "dcae-ves-collector-"; + String inputImportsFileName = testImports; + + String previousJarCommand = "java -jar " + previousJarPath + previousJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath + + " -n " + outputFileName + previousVersion + " -t " + inputPath + inputImportsFileName ; + Runtime.getRuntime().exec(previousJarCommand); + + String latestJarCommand = "java -jar " + latestJarPath + latestJar + " app ONAP -i " + inputPath + inputFileName + " -p " + outputPath + + " -n " + outputFileName + latestVersion + " -t " + inputPath + inputImportsFileName ; + Runtime.getRuntime().exec(latestJarCommand); + + Thread.sleep(8000); + + Assert.assertEquals("The BluePrint files (" + outputFileName + ") for " + inputFileName + " with -m option dont match!", + FileUtils.readFileToString(new File(outputPath + outputFileName + previousVersion + ".yaml"), "utf-8"), + FileUtils.readFileToString(new File(outputPath + outputFileName + latestVersion + ".yaml"), "utf-8")); + } + + +} + diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/ExternalCertificateParametersFactoryServiceTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/ExternalCertificateParametersFactoryServiceTest.java new file mode 100644 index 0000000..021bc49 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/ExternalCertificateParametersFactoryServiceTest.java @@ -0,0 +1,61 @@ +/*============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2020 Nokia Intellectual Property. All rights reserved. + Copyright (c) 2020 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.onap.blueprintgenerator.test; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.ExternalCertificateParameters; +import org.onap.blueprintgenerator.service.common.ExternalCertificateParametersFactoryService; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + + +import java.util.LinkedHashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.onap.blueprintgenerator.constants.Constants.COMMON_NAME_FIELD; +import static org.onap.blueprintgenerator.constants.Constants.SANS_FIELD; + +public class ExternalCertificateParametersFactoryServiceTest extends BlueprintGeneratorTests{ + + private static final String PREFIXED_COMMON_NAME_FIELD = Constants.INPUT_PREFIX + COMMON_NAME_FIELD; + private static final String PREFIXED_SANS_FIELD = Constants.INPUT_PREFIX + SANS_FIELD; + private static final String DEFAULT = "default"; + + @Autowired + private ExternalCertificateParametersFactoryService externalCertificateParametersFactoryService; + + @Test + public void shouldCreateExternalCertificatePropertiesObject() { + + ExternalCertificateParameters result = externalCertificateParametersFactoryService.create(); + assertEquals(result.getCommonName().getBpInputName(), PREFIXED_COMMON_NAME_FIELD); + assertEquals(result.getSans().getBpInputName(), PREFIXED_SANS_FIELD); + } + + @Test + public void shouldCreateCorrectInputListWithDefaultValuesTakenFromComponentSpec() { + + Map> result = externalCertificateParametersFactoryService.createInputList(); + assertEquals(Constants.DEFAULT_COMMON_NAME, result.get(PREFIXED_COMMON_NAME_FIELD).get(DEFAULT)); + assertEquals(Constants.DEFAULT_SANS, result.get(PREFIXED_SANS_FIELD).get(DEFAULT)); + } +} diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapBlueprintServiceTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapBlueprintServiceTest.java new file mode 100644 index 0000000..351f94e --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapBlueprintServiceTest.java @@ -0,0 +1,257 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.test; + +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.OnapBlueprint; +import org.onap.blueprintgenerator.model.common.Properties; +import org.junit.Test; +import org.junit.jupiter.api.DisplayName; +import picocli.CommandLine; + +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Paths; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertArrayEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP Blueprint Test Cases for ONAP and DMAAP + */ + + +public class OnapBlueprintServiceTest extends BlueprintGeneratorTests { + + private String outputfilesPath = Paths.get("src", "test", "resources", "outputfiles").toAbsolutePath().toString(); + + @DisplayName("Testing K8s Blueprint for Service Name Override Component Spec Input File") + @Test + public void testServiceNameOverrideK8sBlueprint() throws IOException { + Input input = onapTestUtils.getInput(Paths.get("src", "test", "resources", "componentspecs" , ves).toFile().getAbsolutePath(), outputfilesPath, "testServiceNameOverrideK8sBlueprint", "", "o", ""); + onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + assertNotNull("K8s Blueprint for Service Name Override Component Spec is NULL", onapComponentSpec); + + OnapBlueprint onapBlueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input); + onapBlueprintService.blueprintToYaml(onapComponentSpec, onapBlueprint, input); + System.out.println(onapBlueprintService.blueprintToString(onapComponentSpec, onapBlueprint, input)); + + onapTestUtils.verifyToscaDefVersion("Service Name Override K8s",onapBlueprint, Constants.TOSCA_DEF_VERSION); + onapTestUtils.verifyBpImports("Service Name Override K8s",onapBlueprint,false); + + Map> k8sBpInputs = onapBlueprint.getInputs(); + assertNotNull("Service Name Override K8s Blueprint Inputs Section is NULL", k8sBpInputs); + assertTrue("Service Name Override K8s Blueprint Inputs Section is Empty", k8sBpInputs.size() > 0); + + assertEquals("Service Name Override K8s Blueprint:Inputs " + Constants.ONAP_INPUT_CPU_LIMIT + " Default is not matching", k8sBpInputs.get(Constants.ONAP_INPUT_CPU_LIMIT).get("default"), Constants.ONAP_DEFAULT250m); + assertEquals("Service Name Override K8s Blueprint:Inputs " + Constants.SERVICE_COMPONENT_NAME_OVERRIDE + " Default is not matching", k8sBpInputs.get(Constants.SERVICE_COMPONENT_NAME_OVERRIDE).get("default"), Constants.ONAP_SERVICE_COMPONENTNAME_OVERRIDE_DEFAULT); + + Map k8sBpNodeTemplates = onapBlueprint.getNode_templates(); + assertNotNull("Service Name Override K8s Blueprint Node Templates Section is NULL in the K8s DMAAP Blueprint", k8sBpNodeTemplates); + assertTrue("Service Name Override K8s Blueprint Node Templates Section Size is Empty", k8sBpNodeTemplates.size() > 0); + + assertEquals("Service Name Override K8s Blueprint:NodeTemplates:Type is not Matching", k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES).getType(), Constants.ONAP_NODETEMPLATES_TYPE); + + Properties k8sBpNodeTemplateProperties = ((Node) k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES)).getProperties(); + assertNotNull("Service Name Override K8s Blueprint Node Templates:Properties Section is NULL", k8sBpNodeTemplateProperties); + + + Map> bpInputs = onapBlueprint.getInputs(); + onapTestUtils.verifyArtifacts("Service Name Override K8s",onapComponentSpec,bpInputs,"o"); + + onapTestUtils.verifyStreamsPublishes("Service Name Override K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyStreamsSubscribes("Service Name Override K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyAuxilary("Service Name Override K8s",onapComponentSpec); + onapTestUtils.verifyHealthCheck("Service Name Override K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyServicesCalls("Service Name Override K8s",onapComponentSpec); + onapTestUtils.verifyServicesProvides("Service Name Override K8s",onapComponentSpec); + onapTestUtils.verifyDockerConfig("Service Name Override K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyParameters("Service Name Override K8s",onapComponentSpec,k8sBpNodeTemplates); + onapTestUtils.verifyVolumes("Service Name Override K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + } + + @DisplayName("Testing K8s Blueprint for Service Name Override Component Spec Input File with Import File") + @Test + public void testServiceNameOverrideImportFileK8sBlueprint() throws IOException { + Input input = onapTestUtils.getInput(Paths.get("src", "test", "resources", "componentspecs", ves).toFile().getAbsolutePath(), "", "", Paths.get("src", "test", "resources", "componentspecs" , testImports).toFile().getAbsolutePath(), "o", ""); + onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + assertNotNull("K8s Blueprint for Service Name Override with Import File Component Spec is NULL", onapComponentSpec); + + OnapBlueprint onapBlueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input); + + onapTestUtils.verifyToscaDefVersion("Service Name Override with Import File K8s",onapBlueprint, Constants.TOSCA_DEF_VERSION); + onapTestUtils.verifyBpImportsFromFile("Service Name Override with Import File K8s",onapBlueprint,input.getImportPath()); + + + Map> k8sBpInputs = onapBlueprint.getInputs(); + assertNotNull("Service Name Override with Import File K8s Blueprint Inputs Section is NULL", k8sBpInputs); + assertTrue("Service Name Override with Import File K8s Blueprint Inputs Section is Empty", k8sBpInputs.size() > 0); + + assertEquals("Service Name Override with Import File K8s Blueprint:Inputs " + Constants.ONAP_INPUT_CPU_LIMIT + " Default is not matching", k8sBpInputs.get(Constants.ONAP_INPUT_CPU_LIMIT).get("default"), Constants.ONAP_DEFAULT250m); + assertEquals("Service Name Override with Import File K8s Blueprint:Inputs " + Constants.SERVICE_COMPONENT_NAME_OVERRIDE + " Default is not matching", k8sBpInputs.get(Constants.SERVICE_COMPONENT_NAME_OVERRIDE).get("default"), Constants.ONAP_SERVICE_COMPONENTNAME_OVERRIDE_DEFAULT); + + Map k8sBpNodeTemplates = onapBlueprint.getNode_templates(); + assertNotNull("Service Name Override with Import File K8s Blueprint Node Templates Section is NULL in the K8s DMAAP Blueprint", k8sBpNodeTemplates); + assertTrue("Service Name Override with Import File K8s Blueprint Node Templates Section Size is Empty", k8sBpNodeTemplates.size() > 0); + + assertEquals("Service Name Override with Import File K8s Blueprint:NodeTemplates:Type is not Matching", k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES).getType(), Constants.ONAP_NODETEMPLATES_TYPE); + + Properties k8sBpNodeTemplateProperties = ((Node) k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES)).getProperties(); + assertNotNull("Service Name Override with Import File K8s Blueprint Node Templates:Properties Section is NULL", k8sBpNodeTemplateProperties); + + + Map> bpInputs = onapBlueprint.getInputs(); + onapTestUtils.verifyArtifacts("Service Name Override with Import File K8s",onapComponentSpec,bpInputs,"o"); + + onapTestUtils.verifyStreamsPublishes("Service Name Override with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyStreamsSubscribes("Service Name Override with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyAuxilary("Service Name Override with Import File K8s",onapComponentSpec); + onapTestUtils.verifyHealthCheck("Service Name Override with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyServicesCalls("Service Name Override with Import File K8s",onapComponentSpec); + onapTestUtils.verifyServicesProvides("Service Name Override with Import File K8s",onapComponentSpec); + onapTestUtils.verifyDockerConfig("Service Name Override with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyParameters("Service Name Override with Import File K8s",onapComponentSpec,k8sBpNodeTemplates); + onapTestUtils.verifyVolumes("Service Name Override with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + } + + @DisplayName("Testing K8s Blueprint with DB") + @Test + public void testDMAAPK8sBlueprintWithDB() { + Input input = onapTestUtils.getInput(Paths.get("src", "test", "resources", "componentspecs", ves).toFile().getAbsolutePath(), outputfilesPath, "testDMAAPK8sBlueprintWithDB", "", "d", ""); + onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + assertNotNull("K8s Blueprint for DMAAP Component Spec is NULL", onapComponentSpec); + + OnapBlueprint onapBlueprint = dmaapBlueprintService.createBlueprint(onapComponentSpec, input); + onapBlueprintService.blueprintToYaml(onapComponentSpec, onapBlueprint, input); + } + + @DisplayName("Testing K8s Blueprint for DMAAP Component Spec Input File") + @Test + public void testDMAAPK8sBlueprint() { + Input input = onapTestUtils.getInput(Paths.get("src", "test", "resources", "componentspecs" , ves).toFile().getAbsolutePath(), outputfilesPath, "testDMAAPK8sBlueprint", "", "d", ""); + onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + assertNotNull("K8s Blueprint for DMAAP Component Spec is NULL", onapComponentSpec); + + OnapBlueprint onapBlueprint = dmaapBlueprintService.createBlueprint(onapComponentSpec, input); + onapBlueprintService.blueprintToYaml(onapComponentSpec, onapBlueprint, input); + System.out.println(onapBlueprintService.blueprintToString(onapComponentSpec, onapBlueprint, input)); + + policyModelService.createPolicyModels(onapComponentSpec.getParameters(), "models"); + + onapTestUtils.verifyToscaDefVersion("DMAAP K8s",onapBlueprint, Constants.TOSCA_DEF_VERSION); + //onapTestUtils.verifyBpImports("DMAAP K8s",onapBlueprint,false); + + Map> k8sBpInputs = onapBlueprint.getInputs(); + assertNotNull("DMAAP K8s Blueprint Inputs Section is NULL", k8sBpInputs); + assertTrue("DMAAP K8s Blueprint Inputs Section is Empty", k8sBpInputs.size() > 0); + + //assertEquals("DMAAP K8s Blueprint:Inputs " + Constants.ALWAYS_PULL_IMAGE + " Type is not matching", k8sBpInputs.get(Constants.ALWAYS_PULL_IMAGE).get("type"), "boolean"); + //assertEquals("DMAAP K8s Blueprint:Inputs Always Pull Image Default is not matching", k8sBpInputs.get(Constants.ALWAYS_PULL_IMAGE).get("default"), Constants.ALWAYS_PULL_IMAGE_DEFAULT); + assertEquals("DMAAP K8s Blueprint:Inputs " + Constants.ONAP_INPUT_CPU_LIMIT + " Default is not matching", k8sBpInputs.get(Constants.ONAP_INPUT_CPU_LIMIT).get("default"), Constants.ONAP_DEFAULT250m); + assertEquals("DMAAP K8s Blueprint:Inputs " + Constants.SERVICE_COMPONENT_NAME_OVERRIDE + " Default is not matching", k8sBpInputs.get(Constants.SERVICE_COMPONENT_NAME_OVERRIDE).get("default"), Constants.ONAP_SERVICE_COMPONENTNAME_OVERRIDE_DEFAULT); + + Map k8sBpNodeTemplates = onapBlueprint.getNode_templates(); + assertNotNull("DMAAP K8s Blueprint Node Templates Section is NULL in the K8s DMAAP Blueprint", k8sBpNodeTemplates); + assertTrue("DMAAP K8s Blueprint Node Templates Section Size is Empty", k8sBpNodeTemplates.size() > 0); + + assertEquals("DMAAP K8s Blueprint:NodeTemplates:Type is not Matching", k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES).getType(), Constants.DMAAP_NODETEMPLATES_TYPE); + + Properties k8sBpNodeTemplateProperties = ((Node) k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES)).getProperties(); + assertNotNull("DMAAP K8s Blueprint Node Templates:Properties Section is NULL", k8sBpNodeTemplateProperties); + + List bpNodeTemplateRelationships = ((Node) k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES)).getRelationships(); + assertNotNull("DMAAP K8s Blueprint Node Templates:Relationships Section is NULL", bpNodeTemplateRelationships); + + onapTestUtils.verifyStreamsPublishes("DMAAP K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyStreamsSubscribes("DMAAP K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyAuxilary("DMAAP K8s",onapComponentSpec); + onapTestUtils.verifyHealthCheck("DMAAP K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyServicesCalls("DMAAP K8s",onapComponentSpec); + onapTestUtils.verifyServicesProvides("DMAAP K8s",onapComponentSpec); + onapTestUtils.verifyDockerConfig("DMAAP K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyParameters("DMAAP K8s",onapComponentSpec,k8sBpNodeTemplates); + } + + @DisplayName("Testing K8s Blueprint for DMAAP Component Spec Input File with Import File") + @Test + public void testDMAAPK8sImportFileBlueprint() throws IOException { + Input input = onapTestUtils.getInput(Paths.get("src", "test", "resources", "componentspecs" , ves).toFile().getAbsolutePath(), "", "", Paths.get("src", "test", "resources", "componentspecs" , testImports).toFile().getAbsolutePath(), "d", ""); + onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(input.getComponentSpecPath()); + assertNotNull("K8s Blueprint for DMAAP Component Spec with Import File is NULL", onapComponentSpec); + + OnapBlueprint onapBlueprint = dmaapBlueprintService.createBlueprint(onapComponentSpec, input); + + onapTestUtils.verifyToscaDefVersion("DMAAP with Import File K8s",onapBlueprint, Constants.TOSCA_DEF_VERSION); + onapTestUtils.verifyBpImportsFromFile("DMAAP with Import File K8s",onapBlueprint,input.getImportPath()); + + Map> k8sBpInputs = onapBlueprint.getInputs(); + assertNotNull("DMAAP with Import File K8s Blueprint Inputs Section is NULL", k8sBpInputs); + assertTrue("DMAAP with Import File K8s Blueprint Inputs Section is Empty", k8sBpInputs.size() > 0); + + //assertEquals("DMAAP with Import File K8s Blueprint:Inputs " + Constants.ALWAYS_PULL_IMAGE + " Type is not matching", k8sBpInputs.get(Constants.ALWAYS_PULL_IMAGE).get("type"), "boolean"); + //assertEquals("DMAAP with Import File K8s Blueprint:Inputs Always Pull Image Default is not matching", k8sBpInputs.get(Constants.ALWAYS_PULL_IMAGE).get("default"), Constants.ALWAYS_PULL_IMAGE_DEFAULT); + assertEquals("DMAAP with Import File K8s Blueprint:Inputs " + Constants.ONAP_INPUT_CPU_LIMIT + " Default is not matching", k8sBpInputs.get(Constants.ONAP_INPUT_CPU_LIMIT).get("default"), Constants.ONAP_DEFAULT250m); + assertEquals("DMAAP with Import File K8s Blueprint:Inputs " + Constants.SERVICE_COMPONENT_NAME_OVERRIDE + " Default is not matching", k8sBpInputs.get(Constants.SERVICE_COMPONENT_NAME_OVERRIDE).get("default"), Constants.ONAP_SERVICE_COMPONENTNAME_OVERRIDE_DEFAULT); + + Map k8sBpNodeTemplates = onapBlueprint.getNode_templates(); + assertNotNull("DMAAP with Import File K8s Blueprint Node Templates Section is NULL in the K8s DMAAP Blueprint", k8sBpNodeTemplates); + assertTrue("DMAAP with Import File K8s Blueprint Node Templates Section Size is Empty", k8sBpNodeTemplates.size() > 0); + + assertEquals("DMAAP with Import File K8s Blueprint:NodeTemplates:Type is not Matching", k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES).getType(), Constants.DMAAP_NODETEMPLATES_TYPE); + + Properties k8sBpNodeTemplateProperties = ((Node) k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES)).getProperties(); + assertNotNull("DMAAP with Import File K8s Blueprint Node Templates:Properties Section is NULL", k8sBpNodeTemplateProperties); + + List bpNodeTemplateRelationships = ((Node) k8sBpNodeTemplates.get(Constants.ONAP_NODETEMPLATES)).getRelationships(); + assertNotNull("DMAAP with Import File K8s Blueprint Node Templates:Relationships Section is NULL", bpNodeTemplateRelationships); + + onapTestUtils.verifyStreamsPublishes("DMAAP with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyStreamsSubscribes("DMAAP with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyAuxilary("DMAAP with Import File K8s",onapComponentSpec); + onapTestUtils.verifyHealthCheck("DMAAP with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyServicesCalls("DMAAP with Import File K8s",onapComponentSpec); + onapTestUtils.verifyServicesProvides("DMAAP with Import File K8s",onapComponentSpec); + onapTestUtils.verifyDockerConfig("DMAAP with Import File K8s",onapComponentSpec,k8sBpNodeTemplateProperties); + onapTestUtils.verifyParameters("DMAAP with Import File K8s",onapComponentSpec,k8sBpNodeTemplates); + } + +} + + + diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapComponentSpecTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapComponentSpecTest.java new file mode 100644 index 0000000..633c205 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapComponentSpecTest.java @@ -0,0 +1,58 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.test; + + +import org.onap.blueprintgenerator.exception.ComponentSpecException; +import org.onap.blueprintgenerator.model.componentspec.base.ComponentSpec; +import org.junit.Test; +import org.junit.jupiter.api.DisplayName; + +import java.nio.file.Paths; + +import static org.junit.Assert.assertEquals; + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * ONAP ComponentSpec Test Cases + */ + +public class OnapComponentSpecTest extends BlueprintGeneratorTests { + + @DisplayName("Testing ComponentSpec File Generation for Invalid File") + @Test(expected = ComponentSpecException.class) + public void testComponentSpecForInvalidFile() { + onapComponentSpecService.createComponentSpecFromFile("invalid.json"); + } + + @DisplayName("Testing ComponentSpec File Generation for Valid DMAAP File") + @Test + public void testComponentSpecForValidVesFile(){ + ComponentSpec onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(Paths.get("src", "test", "resources", "componentspecs", ves).toFile().getAbsolutePath()); + assertEquals("ComponentSpec name not matching for Valid Ves File",onapComponentSpec.getSelf().getName(), "dcae-ves-collector"); + } + +} diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java new file mode 100644 index 0000000..9033fbe --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java @@ -0,0 +1,207 @@ +/* + * + * * ============LICENSE_START======================================================= + * * org.onap.dcae + * * ================================================================================ + * * Copyright (c) 2020 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.onap.blueprintgenerator.test; + +import org.onap.blueprintgenerator.constants.Constants; +import org.onap.blueprintgenerator.model.base.Blueprint; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.Properties; +import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary; +import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec; + +import org.onap.blueprintgenerator.model.componentspec.common.Calls; +import org.onap.blueprintgenerator.model.componentspec.common.Provides; +import org.onap.blueprintgenerator.model.componentspec.common.HealthCheck; +import org.onap.blueprintgenerator.model.componentspec.common.Parameters; +import org.onap.blueprintgenerator.model.componentspec.common.Volumes; +import org.onap.blueprintgenerator.model.componentspec.common.Artifacts; +import org.onap.blueprintgenerator.model.dmaap.Streams; +import org.junit.Ignore; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + + +/** + * @author : Ravi Mantena + * @date 10/16/2020 + * Application: ONAP - Blueprint Generator + * Test Utilities used in Test Suite and Test Cases + */ + +@Component +@Ignore +public class OnapTestUtils extends BlueprintGeneratorTests { + + @Value("${imports.onap.types}") + private String importsOnapTypes; + + @Value("${imports.onap.K8s.plugintypes}") + private String importsOnapK8sPlugintypes; + + @Value("${imports.onap.K8s.dcaepolicyplugin}") + private String importsOnapK8sDcaepolicyplugin; + + @Value("${imports.dmaap.dmaapplugin}") + private String importsDmaapDmaapplugin; + + @Value("${import.Postgres}") + private String importPostgres; + + @Value("${import.Clamp}") + private String importClamp; + + + + public Input getInput(String componentSpecPath,String outputPath,String bluePrintName,String importPath,String bpType,String serviceNameOverride){ + Input input = new Input(); + input.setComponentSpecPath(componentSpecPath); + input.setBluePrintName(bluePrintName); + input.setOutputPath(outputPath); + input.setBpType(bpType); + input.setServiceNameOverride(serviceNameOverride); + input.setImportPath(importPath); + return input; + } + + public Input getInput(String componentSpecPath){ + Input input = new Input(); + input.setComponentSpecPath(componentSpecPath); + return input; + } + + public void verifyToscaDefVersion(String type,Blueprint blueprint,String toscaDefVersion){ + String bpToscaDefVersion = blueprint.getTosca_definitions_version(); + assertNotNull(type + " TOSCA Definition Version is NULL", bpToscaDefVersion); + assertEquals(type + " TOSCA Definition Version is not Matching", bpToscaDefVersion, toscaDefVersion); + } + + public void verifyBpImports(String type,Blueprint blueprint, boolean validateimps) { + String[] bpImports = blueprint.getImports().toArray(new String[blueprint.getImports().size()]); + if (validateimps) { + String[] testImports = {importsOnapTypes,importsOnapK8sPlugintypes,importsDmaapDmaapplugin,importPostgres,importClamp}; + assertArrayEquals(type + " Blueprint Imports is not matching with default Dmaap K8s Blueprint imports", bpImports, testImports); + } + else{ + String[] testImports = {importsOnapTypes,importsOnapK8sPlugintypes,importsOnapK8sDcaepolicyplugin,importPostgres,importClamp}; + assertArrayEquals(type + " Blueprint Imports is not matching with default Onap K8s Blueprint imports", bpImports, testImports); + } + + } + + public void verifyBpImportsFromFile(String type,Blueprint blueprint, String importPath) throws IOException { + Blueprint importFileRead = yamlObjectMapper.readValue(new File(importPath), Blueprint.class); + String[] importFileImports = importFileRead.getImports().toArray(new String[importFileRead.getImports().size()]); + String[] bpImports = blueprint.getImports().toArray(new String[blueprint.getImports().size()]); + assertArrayEquals(type + " Blueprint Imports is not matching with default Dmaap K8s Blueprint imports", bpImports, importFileImports); + + } + + public void verifyStreamsPublishes(String type, OnapComponentSpec onapComponentSpec, Properties nodeTemplateProperties) { + List streamsPublishes = nodeTemplateProperties.getStreams_publishes(); + if (!(streamsPublishes == null)) { + assertNotNull(type + " Blueprint:NodeTemplates:Properties:StreamsPublishes is NULL", streamsPublishes); + assertTrue(type + " Blueprint:NodeTemplates:Properties:StreamsPublishes Section Size is 0", streamsPublishes.size() > 0); + assertEquals(type + " Blueprint:NodeTemplates:Properties:StreamsPublishes is Not Matching", streamsPublishes.get(0).getType(), Constants.MESSAGEROUTER_VALUE); + assertEquals(type + " Blueprint:NodeTemplates:Properties:StreamsPublishes is Not Matching", streamsPublishes.get(1).getType(), Constants.MESSAGEROUTER_VALUE); + } + } + + public void verifyStreamsSubscribes(String type,OnapComponentSpec onapComponentSpec, Properties nodeTemplateProperties){ + List streamsSubscribes = nodeTemplateProperties.getStreams_subscribes(); + if (!(streamsSubscribes == null)) { + assertNotNull(type + " Blueprint:NodeTemplates:Properties:StreamsSubscribes is NULL", streamsSubscribes); + assertTrue(type + " Blueprint:NodeTemplates:Properties:StreamsSubscribes Section Size is 0", streamsSubscribes.size() > 0); + assertEquals(type + " Blueprint:NodeTemplates:Properties:StreamsSubscribes is Not Matching", streamsSubscribes.get(0).getType(), Constants.MESSAGE_ROUTER); + assertEquals(type + " Blueprint:NodeTemplates:Properties:StreamsSubscribes is Not Matching", streamsSubscribes.get(1).getType(), Constants.DATA_ROUTER); + } + } + + public void verifyServicesCalls(String type, OnapComponentSpec onapComponentSpec){ + Calls[] csServicesCalls = onapComponentSpec.getServices().getCalls(); + assertNotNull(type + " ComponentSpec Services Calls is NULL", csServicesCalls); + //assertTrue(type + " ComponentSpec Services Calls Section Size is 0", csServicesCalls.length > 0); + } + + public void verifyServicesProvides(String type, OnapComponentSpec onapComponentSpec){ + Provides[] csServicesProvides = onapComponentSpec.getServices().getProvides(); + assertNotNull(type + " ComponentSpec Services Provides is NULL", csServicesProvides); + assertTrue(type + " ComponentSpec Services Provides Section Size is 0", csServicesProvides.length > 0); + } + + public void verifyDockerConfig(String type,OnapComponentSpec onapComponentSpec, Properties nodeTemplateProperties){ + OnapAuxilary dockerConfig = nodeTemplateProperties.getDocker_config(); + assertNotNull(type +" Blueprint Docker Config Section is NULL", dockerConfig); + } + + + public void verifyParameters(String type, OnapComponentSpec onapComponentSpec, Map nodeTemplates) { + Parameters[] csParameters = onapComponentSpec.getParameters(); + assertNotNull(type +" ComponentSpec Parameters Section is NULL", csParameters); + assertTrue(type + " ComponentSpec Parameters Section Size is 0", csParameters.length > 0); + } + + public void verifyAuxilary(String type, OnapComponentSpec onapComponentSpec){ + OnapAuxilary csAuxilary = onapComponentSpec.getAuxilary(); + assertNotNull(type +" ComponentSpec Auxilary Section is NULL", csAuxilary); + } + + public void verifyHealthCheck(String type,OnapComponentSpec onapComponentSpec, Properties nodeTemplateProperties){ + HealthCheck csAuxilaryHealthcheck = onapComponentSpec.getAuxilary().getHealthcheck(); + assertNotNull(type +" ComponentSpec Auxilary Health Check Section is NULL", csAuxilaryHealthcheck); + HealthCheck healthCheck = nodeTemplateProperties.getDocker_config().getHealthcheck(); + assertNotNull(type + " Blueprint:NodeTemplates:DockerConfig:Healthcheck Section is NULL", healthCheck); + assertEquals(type + " Blueprint:NodeTemplates:DockerConfig:Healthcheck:Interval Tag is not matching", healthCheck.getInterval(), csAuxilaryHealthcheck.getInterval()); + assertEquals(type + " Blueprint:NodeTemplates:DockerConfig:Healthcheck:Timeout Tag is not matching", healthCheck.getTimeout(), csAuxilaryHealthcheck.getTimeout()); + assertEquals(type + " Blueprint:NodeTemplates:DockerConfig:Healthcheck:Script Tag is not matching", healthCheck.getEndpoint(), csAuxilaryHealthcheck.getEndpoint()); + assertEquals(type + " Blueprint:NodeTemplates:DockerConfig:Healthcheck:Type Tag is not matching", healthCheck.getType(), csAuxilaryHealthcheck.getType()); + } + + public void verifyVolumes(String type,OnapComponentSpec onapComponentSpec, Properties nodeTemplateProperties){ + Volumes[] csAuxilaryVolumes = onapComponentSpec.getAuxilary().getVolumes(); + assertNotNull(type +" ComponentSpec Auxilary Live Health Check Section is NULL", csAuxilaryVolumes); + Volumes[] onapVolumes = nodeTemplateProperties.getDocker_config().getVolumes(); + assertNotNull(type + " Blueprint:NodeTemplates:DockerConfig:LiveHealthcheck Section is NULL", onapVolumes); + } + + public void verifyArtifacts(String type,OnapComponentSpec onapComponentSpec, Map> inputs,String bptype){ + Artifacts[] csArtifacts = onapComponentSpec.getArtifacts(); + assertNotNull(type + " ComponentSpec Artifacts Section is NULL", csArtifacts); + assertEquals(type + " Blueprint:Artifacts:image is not matching", ((String) inputs.get("image").get("default")), "\"" + csArtifacts[0].getUri() + "\""); + //assertEquals(type + " Blueprint:Artifacts:image is not matching", ((String) inputs.get("tag_version").get("default")), "\"" + csArtifacts[0].getUri() + "\""); + + } + +} diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java new file mode 100644 index 0000000..f4bbe3e --- /dev/null +++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/TlsInfoTest.java @@ -0,0 +1,168 @@ +/*============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2020 Nokia. All rights reserved. + Copyright (c) 2020 AT&T. 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.onap.blueprintgenerator.test; + + +import org.junit.Test; +import org.junit.runners.Parameterized; +import org.onap.blueprintgenerator.model.common.Input; +import org.onap.blueprintgenerator.model.common.Node; +import org.onap.blueprintgenerator.model.common.OnapBlueprint; +import org.onap.blueprintgenerator.model.common.ExternalCertificateParameters; +import org.onap.blueprintgenerator.model.common.ExternalTlsInfo; +import org.onap.blueprintgenerator.model.dmaap.TlsInfo; + + +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + + + +//@RunWith(Parameterized.class) +public class TlsInfoTest extends BlueprintGeneratorTests { + + @Parameterized.Parameter + public char bpType; + + @Parameterized.Parameters(name = "Blueprint type: {0}") + public static List data() { + return Arrays.asList('o', 'd'); + } + + + @Test + public void useTlsTrueAndUseExternalTlsTrueTest(){ + //Input input = input.setComponentSpecPath(componentSpecPath + "testComponentSpec_withTlsTrueAndExternalTlsTrue.json"); + OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", useTlsTrueAndUseExternalTlsTrueTest).toFile().getAbsolutePath()); + + assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, true); + assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true); + } + + @Test + public void useTlsFalseAndUseExternalTlsFalseTest(){ + OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", useTlsFalseAndUseExternalTlsFalseTest).toFile().getAbsolutePath()); + + assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, false); + assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, false); + } + + @Test + public void useTlsTrueAndNoExternalTlsFlagTest(){ + OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", useTlsTrueAndNoExternalTlsFlagTest).toFile().getAbsolutePath()); + + assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true); + assertBlueprintHasNoExternalTlsInfo(bp); + } + + @Test + public void noTlsInfo(){ + OnapBlueprint bp = createBlueprintFromFile(Paths.get("src", "test", "resources", "componentspecs", noTlsInfo).toFile().getAbsolutePath()); + + assertBlueprintHasNoTlsInfo(bp); + assertBlueprintHasNoExternalTlsInfo(bp); + } + + private void assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(OnapBlueprint bp, boolean useFlagDefault) { + //should create proper inputs + assertContainsInputWithDefault(bp, "external_cert_use_external_tls", useFlagDefault); + assertContainsInputWithDefault(bp, "external_cert_ca_name", "\"RA\""); + assertContainsInputWithDefault(bp, "external_cert_cert_type", "\"P12\""); + assertContainsInputWithDefault(bp, "external_cert_common_name", "\"sample.onap.org\""); + assertContainsInputWithDefault(bp, "external_cert_sans", + "\"sample.onap.org:component.sample.onap.org\""); + + Node node = bp.getNode_templates().get("test.component.spec"); + + //should create proper externalTlsInfo object in node properties + ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert(); + assertNotNull(externalTlsInfo); + + assertEquals("external_cert_ca_name", externalTlsInfo.getCaName().getBpInputName()); + assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getBpInputName()); + assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getBpInputName()); + assertEquals("/opt/app/dcae-certificate/", externalTlsInfo.getExternalCertDirectory()); + + ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters(); + assertNotNull(extCertParams); + + assertEquals("external_cert_common_name", extCertParams.getCommonName().getBpInputName()); + assertEquals("external_cert_sans", extCertParams.getSans().getBpInputName()); + } + + private void assertBlueprintContainsTlsInfoWithUseFlagDefault(OnapBlueprint bp, boolean useFlagDefault) { + //shold create proper inputs + assertContainsInputWithDefault(bp, "use_tls", useFlagDefault); + + Node node = bp.getNode_templates().get("test.component.spec"); + + //should create proper tlsInfo object in node properties + TlsInfo tlsInfo = node.getProperties().getTls_info(); + assertEquals("use_tls", tlsInfo.getUseTls().getBpInputName()); + assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory()); + + } + + private void assertBlueprintHasNoExternalTlsInfo(OnapBlueprint bp) { + //should not create inputs for external tls + assertFalse(bp.getInputs().containsKey("external_cert_use_external_tls")); + assertFalse(bp.getInputs().containsKey("external_cert_common_name")); + assertFalse(bp.getInputs().containsKey("external_cert_ca_name")); + assertFalse(bp.getInputs().containsKey("external_cert_sans")); + + Node node = bp.getNode_templates().get("test.component.spec"); + + //should not create externalTlsInfo object in node properties + ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert(); + assertNull(externalTlsInfo); + } + + + private void assertBlueprintHasNoTlsInfo(OnapBlueprint bp) { + //should not create inputs for tls + assertFalse(bp.getInputs().containsKey("use_tls")); + + Node node = bp.getNode_templates().get("test.component.spec"); + + //should not create tlsInfo object in node properties + assertNull(node.getProperties().getTls_info()); + } + + private void assertContainsInputWithDefault(OnapBlueprint bp, String inputName, Object defaultValue) { + LinkedHashMap input = bp.getInputs().get(inputName); + assertNotNull(input); + assertEquals(defaultValue, input.get("default")); + } + + private OnapBlueprint createBlueprintFromFile(String path) { + onapComponentSpec = onapComponentSpecService.createComponentSpecFromFile(path); + Input input = onapTestUtils.getInput(path, "", "", "", "o", ""); + OnapBlueprint onapBlueprint = onapBlueprintService.createBlueprint(onapComponentSpec, input); + return onapBlueprint; + } +} diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsFalseAndExternalTlsFalse.json b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsFalseAndExternalTlsFalse.json new file mode 100644 index 0000000..da75ab8 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsFalseAndExternalTlsFalse.json @@ -0,0 +1,43 @@ +{ + "self": { + "component_type": "docker", + "description": "Test component spec", + "name": "test.component.spec", + "version": "1.0.1" + }, + + "services": { + "calls": [], + "provides": [] + }, + + "streams": { + "publishes": [], + "subscribes": [] + }, + + "parameters": [], + + "auxilary": { + "healthcheck": { + "type": "docker", + "interval": "300s", + "timeout": "120s", + "script": "/etc/init.d/nagios status" + }, + "ports": [ + "80:80", + "99:99" + ], + "tls_info": { + "cert_directory": "/opt/app/dcae-certificate/", + "use_tls": false, + "use_external_tls": false + } + }, + "artifacts": [{ + "type": "docker image", + "uri": "test.tester" + }] + +} diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndExternalTlsTrue.json b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndExternalTlsTrue.json new file mode 100644 index 0000000..f13e3fd --- /dev/null +++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndExternalTlsTrue.json @@ -0,0 +1,43 @@ +{ + "self": { + "component_type": "docker", + "description": "Test component spec", + "name": "test.component.spec", + "version": "1.0.1" + }, + + "services": { + "calls": [], + "provides": [] + }, + + "streams": { + "publishes": [], + "subscribes": [] + }, + + "parameters": [], + + "auxilary": { + "healthcheck": { + "type": "docker", + "interval": "300s", + "timeout": "120s", + "script": "/etc/init.d/nagios status" + }, + "ports": [ + "80:80", + "99:99" + ], + "tls_info": { + "cert_directory": "/opt/app/dcae-certificate/", + "use_tls": true, + "use_external_tls": true + } + }, + "artifacts": [{ + "type": "docker image", + "uri": "test.tester" + }] + +} diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndNoExternalTls.json b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndNoExternalTls.json new file mode 100644 index 0000000..517c461 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withTlsTrueAndNoExternalTls.json @@ -0,0 +1,42 @@ +{ + "self": { + "component_type": "docker", + "description": "Test component spec", + "name": "test.component.spec", + "version": "1.0.1" + }, + + "services": { + "calls": [], + "provides": [] + }, + + "streams": { + "publishes": [], + "subscribes": [] + }, + + "parameters": [], + + "auxilary": { + "healthcheck": { + "type": "docker", + "interval": "300s", + "timeout": "120s", + "script": "/etc/init.d/nagios status" + }, + "ports": [ + "80:80", + "99:99" + ], + "tls_info": { + "cert_directory": "/opt/app/dcae-certificate/", + "use_tls": true + } + }, + "artifacts": [{ + "type": "docker image", + "uri": "test.tester" + }] + +} diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withoutTlsInfo.json b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withoutTlsInfo.json new file mode 100644 index 0000000..a94c987 --- /dev/null +++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/testComponentSpec_withoutTlsInfo.json @@ -0,0 +1,38 @@ +{ + "self": { + "component_type": "docker", + "description": "Test component spec", + "name": "test.component.spec", + "version": "1.0.1" + }, + + "services": { + "calls": [], + "provides": [] + }, + + "streams": { + "publishes": [], + "subscribes": [] + }, + + "parameters": [], + + "auxilary": { + "healthcheck": { + "type": "docker", + "interval": "300s", + "timeout": "120s", + "script": "/etc/init.d/nagios status" + }, + "ports": [ + "80:80", + "99:99" + ] + }, + "artifacts": [{ + "type": "docker image", + "uri": "test.tester" + }] + +} diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/testImports.yaml b/mod/bpgenerator/onap/src/test/resources/componentspecs/testImports.yaml new file mode 100644 index 0000000..42a482d --- /dev/null +++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/testImports.yaml @@ -0,0 +1,4 @@ +imports: + - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml + - plugin:k8splugin?version=3.0.0 + - plugin:dcaepolicyplugin?version=2.4.0 \ No newline at end of file diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json b/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json new file mode 100644 index 0000000..6655a2c --- /dev/null +++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json @@ -0,0 +1,337 @@ +{ + "self": { + "version": "1.5.0", + "name": "dcae-ves-collector", + "description": "Collector for receiving VES events through restful interface", + "component_type": "docker" + }, + "streams": { + "subscribes": [ + { + "format": "dataformat_Hello_World_PM", + "version": "1.0.0", + "route": "/TEST_HELLO_WORLD_SUB_MR", + "type": "message_router", + "config_key": "TEST-SUB-MR" + }, + { + "format": "dataformat_Hello_World_PM DR", + "version": "1.0.0", + "route": "/TEST_HELLO_WORLD_SUB_DR", + "type": "data_router", + "config_key": "TEST-SUB-DR" + } + ], + "publishes": [ + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-fault" + }, + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-measurement" + }, + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-other" + }, + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-heartbeat-secondary" + }, + { + "format": "VES_specification", + "version": "7.30.0", + "type": "message router", + "config_key": "ves-pnfRegistration" + }, + { + "format": "VES_specification", + "version": "7.30.0", + "type": "message router", + "config_key": "ves-notification" + } + ] + }, + "services": { + "calls": [], + "provides": [ + { + "route": "/eventListener/v1", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v2", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v3", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v4", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v5", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "5.28.4" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v7", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "7.30.0" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + } + ] + }, + "parameters": [ + { + "name": "collector.service.port", + "value": 8080, + "description": "standard http port collector will open for listening;", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.service.secure.port", + "value": 8443, + "description": "secure http port collector will open for listening ", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": true + }, + { + "name": "collector.keystore.file.location", + "value": "/opt/app/dcae-certificate/keystore.jks", + "description": "fs location of keystore file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.keystore.passwordfile", + "value": "/opt/app/dcae-certificate/.password", + "description": "location of keystore password file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.truststore.file.location", + "value": "/opt/app/dcae-certificate/truststore.jks", + "description": "fs location of truststore file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.truststore.passwordfile", + "value": "/opt/app/dcae-certificate/.trustpassword", + "description": "location of truststore password file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.dmaap.streamid", + "value": "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary", + "description": "domain-to-streamid mapping used by VESCollector to distributes events based on domain. Both primary and secondary config_key are included for resilency (multiple streamid can be included commma separated). The streamids MUST match to topic config_keys. For single site without resiliency deployment - configkeys with -secondary suffix can be removed", + "sourced_at_deployment": true, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "auth.method", + "value": "noAuth", + "description": "Property to manage application mode, possible configurations: noAuth - default option - no security (http) , certOnly - auth by certificate (https), basicAuth - auth by basic auth username and password (https),certBasicAuth - auth by certificate and basic auth username / password (https),", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "header.authlist", + "value": "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy", + "description": "List of id and base 64 encoded password.For each onboarding VNF - unique userid and password should be assigned and communicated to VNF owner. Password value should be base64 encoded in config here", + "policy_editable": false, + "sourced_at_deployment": true, + "designer_editable": true + }, + { + "name": "collector.schema.checkflag", + "value": 1, + "description": "Schema check validation flag. When enabled, collector will validate input VES events against VES Schema defined on collector.schema.file ", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.schema.file", + "value": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\",\"v7\":\"./etc/CommonEventFormat_30.json\"}", + "description": "VES schema file name per version used for validation", + "designer_editable": true, + "sourced_at_deployment": false, + "policy_editable": false + }, + { + "name": "event.transform.flag", + "value": 1, + "description": "flag to enable tranformation rules defined under eventTransform.json; this is applicable when event tranformation rules preset should be activated for transforming + ~ /* + ~ * ============LICENSE_START======================================================= + ~ * org.onap.dcae + ~ * ================================================================================ + ~ * Copyright (c) 2020 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========================================================= + ~ */ + ~ + --> - 4.0.0 - - org.onap.oparent - oparent - 2.0.0 - - org.onap.dcaegen2.platform.mod - blueprint-generator - 1.6.0-SNAPSHOT - - UTF-8 - ${project.basedir}/target/surefire-reports - ${project.basedir}/target/surefire-reports - ${project.basedir}/target/site/jacoco-ut/jacoco.xml - org.onap.blueprintgenerator.core.App - org.apache.maven.plugins.shade.resource.ManifestResourceTransformer - - - - - - - maven-assembly-plugin - 2.4.1 - - - src/assembly/dep.xml - - + 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"> + 4.0.0 - - + org.onap.dcaegen2.platform + blueprint-generator + 1.7.0-SNAPSHOT + pom - make-assembly - package - - single - - - + + common + onap + - + BlueprintGenerator + This is Parent Module used by DCAE and ONAP to generate Blueprints - - org.sonarsource.scanner.maven - sonar-maven-plugin - 3.0.2 - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.1 - - - - shade - - - true - executable - - - ${shade.main} - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - - - - + + org.onap.oparent + oparent + 2.0.0 + + - - - junit - junit - 4.12 - test - - - org.mockito - mockito-core - 3.1.0 - test - + + UTF-8 + UTF-8 + 11 + ${java.version} + ${java.version} + 2.2.9.RELEASE + 2.9.7 + 1.18.10 + 2.8.6 + 2.6 + 1.4 + 2.22.2 + 3.8.1 + 1.4.10 + onap/${project.groupId}.${project.artifactId} + 3.0.2 + ${project.basedir}/target/surefire-reports + ${project.basedir}/target/surefire-reports + ${project.basedir}/target/site/jacoco-ut/jacoco.xml + - - info.picocli - picocli - 3.9.6 - - - org.projectlombok - lombok - 1.18.2 - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - 2.9.8 - + + + org.springframework + spring-context + 5.2.0.RELEASE + + + org.springframework + spring-core + 5.2.0.RELEASE + + + org.springframework.boot + spring-boot-starter + 2.2.5.RELEASE + + + org.springframework.boot + spring-boot-starter-test + 2.2.5.RELEASE + test + + + org.springframework.boot + spring-boot-starter-validation + 2.2.5.RELEASE + + + org.projectlombok + lombok + ${lombok.version} + provided + + + com.google.code.gson + gson + ${gson.version} + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + ${jackson.version} + + + junit + junit + 4.12 + test + + + org.mockito + mockito-core + 3.1.0 + test + + + info.picocli + picocli + 3.9.6 + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + commons-io + commons-io + ${commons.io.version} + + + commons-cli + commons-cli + ${commons.cli.version} + + - - com.fasterxml.jackson.core - jackson-databind - 2.9.8 - - - com.fasterxml.jackson.core - jackson-annotations - 2.9.8 - - + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.6 + + + test + + report + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compilerplugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar.maven.plugin} + + + - + \ No newline at end of file diff --git a/mod/bpgenerator/src/assembly/dep.xml b/mod/bpgenerator/src/assembly/dep.xml deleted file mode 100644 index daf6771..0000000 --- a/mod/bpgenerator/src/assembly/dep.xml +++ /dev/null @@ -1,52 +0,0 @@ - - bundle - - tar.gz - - - - target/${project.artifactId}-${project.version}.jar - lib - - - - - - - src/main/resources/bin - bin - - **/*.* - - 0755 - - - src/main/resources/conf - conf - - - - - - - *:jar - - lib - - - diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java deleted file mode 100644 index c3b1453..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/common/blueprint/BlueprintHelper.java +++ /dev/null @@ -1,76 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.common.blueprint; - - -import lombok.experimental.UtilityClass; - -import java.util.LinkedHashMap; - -@UtilityClass -public class BlueprintHelper { - - public static final String INTEGER_TYPE = "integer"; - public static final String BOOLEAN_TYPE = "boolean"; - public static final String STRING_TYPE = "string"; - - public static LinkedHashMap createInputValue(String type, String description, Object defaultValue) { - LinkedHashMap inputMap = new LinkedHashMap<>(); - inputMap.put("type", type); - inputMap.put("description", description); - inputMap.put("default", defaultValue); - return inputMap; - } - - public static LinkedHashMap createInputValue(String type, Object defaultValue) { - LinkedHashMap inputMap = new LinkedHashMap<>(); - inputMap.put("type", type); - inputMap.put("default", defaultValue); - return inputMap; - } - - public static LinkedHashMap createIntegerInput(String description, Object defaultValue){ - return createInputValue(INTEGER_TYPE, description, defaultValue); - } - - public static LinkedHashMap createBooleanInput(String description, Object defaultValue){ - return createInputValue(BOOLEAN_TYPE, description, defaultValue); - } - - public static LinkedHashMap createStringInput(String description, Object defaultValue){ - return createInputValue(STRING_TYPE, description, defaultValue); - } - - public static LinkedHashMap createStringInput(Object defaultValue){ - return createInputValue(STRING_TYPE, defaultValue); - } - - public static String joinUnderscore(String firstValue, String secondValue){ - return firstValue + "_" + secondValue; - } - - public static boolean isDataRouterType(String type) { - return type.equals("data_router") || type.equals("data router"); - } - - public static boolean isMessageRouterType(String type) { - return type.equals("message_router") || type.equals("message router"); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java deleted file mode 100644 index 4775825..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/App.java +++ /dev/null @@ -1,40 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.core; - -import picocli.CommandLine; -import picocli.CommandLine.Command; - -@Command(subcommands = { - BlueprintCommand.class, - PolicyCommand.class -}) -public class App implements Runnable { - public static void main(String...args) { - CommandLine.run(new App(), args); - } - - @Override - public void run() { - CommandLine.usage(this, System.out); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java deleted file mode 100644 index 7627930..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/BlueprintCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.blueprintgenerator.core; - -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import picocli.CommandLine.Command; -import picocli.CommandLine.Option; - -@Command(name = "blueprint", description = "Command used to generate blueprints from component spec") -public class BlueprintCommand implements Runnable { - private static final char STANDARD_BLUEPRINT = 'o'; - private static final char DMAAP_BLUEPRINT = 'd'; - - @Option(names = {"-i", "--component-spec"}, description = "Path to component spec file", required = true) - private String componentSpecPath; - - @Option(names = {"-p", "--blueprint-path"}, description = "Path to directory that blueprints are output to", required = true) - private String blueprintOutputPath; - - @Option(names = {"-n", "--blueprint-name"}, description = "Name of the blueprint", defaultValue = "") - private String blueprintName; - - @Option(names = {"-t", "--imports"}, description = "Path to the import file", defaultValue = "") - private String importsPath; - - @Option(names={"-o", "--service-name-override"}, description="Value used to override the service name", defaultValue = "") - private String serviceNameOverride; - - @Option(names={"-d", "--dmaap-plugin"}, description = "Flag used to indicate blueprint uses the DMaaP plugin.") - private boolean dmaapPlugin; - - @Override - public void run() { - ComponentSpec inboundComponentSpec = new ComponentSpec(); - inboundComponentSpec.createComponentSpecFromFile(componentSpecPath); - System.out.println(dmaapPlugin ? DMAAP_BLUEPRINT : STANDARD_BLUEPRINT); - Blueprint generatedBlueprint = new Blueprint().createBlueprint(inboundComponentSpec, this.blueprintName, - dmaapPlugin ? DMAAP_BLUEPRINT : STANDARD_BLUEPRINT, importsPath, serviceNameOverride); - generatedBlueprint.blueprintToYaml(blueprintOutputPath, this.blueprintName, inboundComponentSpec); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java deleted file mode 100644 index 3a4b457..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java +++ /dev/null @@ -1,104 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.core; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -public class Fixes { - private static ArrayList lines = new ArrayList(); - private static String line = null; - - public static void fixSingleQuotes(File f) throws IOException { - File translateFile = f; - try { - FileReader fr = new FileReader(translateFile); - BufferedReader br = new BufferedReader(fr); - while((line = br.readLine()) != null) { -// lines.add(ensureNoSingleQuotes(line)); - if(line.contains("'")) { - line = line.replace("'", ""); - } - if(line.contains("\"\"") && (line.contains("m") || line.contains("M"))) { - line = line.replaceAll("\"\"", "\""); - } - lines.add(line); - - } - fr.close(); - br.close(); - FileWriter fw = new FileWriter(translateFile); - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f, true))); - for(String s: lines) { - out.println(); - out.write(s); - out.flush(); - } - - out.close(); - fw.close(); - line = null; - lines = new ArrayList(); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - } - - /** - * Remove single quotes from a line from a blueprint - */ - private static String ensureNoSingleQuotes(String line) { - // TODO: Should probably use regex instead - // REVIEW: The condition under which to remove the single quotes - if ((line.contains("concat") || line.contains("default: ")) && line.contains("'")) { - return line.replace("'", ""); - } else { - return line; - } - } - - /** - * Takes in an entire blueprint (YAML) in a string buffer and post processes it to apply - * "fixes" like removing unwanted single quotes. - */ - public static String applyFixes(String bp) { - List lines = new ArrayList(); - - String[] linesPre = bp.split("\n"); - System.out.println(String.format("To post-processing #lines: %d", linesPre.length)); - - for (String line : linesPre) { - lines.add(ensureNoSingleQuotes(line)); - } - - return String.join("\n", lines); - } - - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java deleted file mode 100644 index 7c3193e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java +++ /dev/null @@ -1,129 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.core; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.TreeMap; -import org.onap.blueprintgenerator.exception.DatabasesNotFoundException; -import org.onap.blueprintgenerator.models.GetAttribute; -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNode; -import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNodeProperties; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue; - -public class PgaasNodeBuilder { - - private static final String PGAAS_NODE_TYPE = "dcae.nodes.pgaas.database"; - private static final String PGAAS_NODE_NAME_POSTFIX = "_pgaasdb"; - private static final String WRITER_FQDN_POSTFIX = "_database_writerfqdn"; - private static final String NAME_POSTFIX = "_database_name"; - private static final boolean USE_EXISTING = true; - private static final String DB_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on"; - - - public static void addPgaasNodesAndInputs(ComponentSpec cs, TreeMap nodeTemplate, - TreeMap> inps) { - TreeMap databases = cs.getAuxilary().getDatabases(); - if (databases == null) { - throw new DatabasesNotFoundException("databases section not found in componentspec"); - } - for (Map.Entry database : databases.entrySet()) { - addPgaasNode(database, nodeTemplate); - addPgaasInputs(database, inps); - } - } - - private static void addPgaasInputs(Map.Entry database, - TreeMap> inps) { - inps.put(database.getKey() + NAME_POSTFIX, createInputValue("string", "db name", "")); - inps.put(database.getKey() + WRITER_FQDN_POSTFIX, createInputValue("string", "db writerfqdn", "")); - } - - private static void addPgaasNode(Map.Entry database, TreeMap nodeTemplate) { - PgaasNode pgaasNode = new PgaasNode(); - String dbName = database.getKey(); - pgaasNode.setType(PGAAS_NODE_TYPE); - pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName)); - nodeTemplate.put(dbName + PGAAS_NODE_NAME_POSTFIX, pgaasNode); - } - - private static PgaasNodeProperties buildPgaasNodeProperties(String dbName) { - PgaasNodeProperties pgaasNodeProperties = new PgaasNodeProperties(); - - GetInput nameValue = new GetInput(); - nameValue.setBpInputName(dbName + NAME_POSTFIX); - pgaasNodeProperties.setName(nameValue); - - GetInput writerfqdnValue = new GetInput(); - writerfqdnValue.setBpInputName(dbName + WRITER_FQDN_POSTFIX); - pgaasNodeProperties.setWriterfqdn(writerfqdnValue); - - pgaasNodeProperties.setUseExisting(USE_EXISTING); - - return pgaasNodeProperties; - } - - public static ArrayList> getPgaasNodeRelationships(ComponentSpec cs) { - ArrayList> relationships = new ArrayList<>(); - for (Map.Entry database : cs.getAuxilary().getDatabases().entrySet()) { - LinkedHashMap relationship = new LinkedHashMap<>(); - relationship.put("type", DB_RELATIONSHIP_TYPE); - relationship.put("target", database.getKey() + PGAAS_NODE_NAME_POSTFIX); - relationships.add(relationship); - } - return relationships; - } - - public static LinkedHashMap getEnvVariables(TreeMap databases) { - LinkedHashMap envVariables = new LinkedHashMap(); - for (Map.Entry database : databases.entrySet()) { - String name = database.getKey().toUpperCase(); - - envVariables.put("<<", "*envs"); - - GetInput nameValue = new GetInput(); - nameValue.setBpInputName(name.toLowerCase() + NAME_POSTFIX); - envVariables.put(name + "_DB_NAME", nameValue); - - GetAttribute adminHostValue = buildGetAttributeValue(name.toLowerCase(), "admin", "host"); - envVariables.put(name.toUpperCase() + "_DB_ADMIN_HOST", adminHostValue); - - GetAttribute adminUserValue = buildGetAttributeValue(name.toLowerCase(), "admin", "user"); - envVariables.put(name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue); - - GetAttribute adminPasswordValue = buildGetAttributeValue(name.toLowerCase(), "admin", "password"); - envVariables.put(name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue); - } - return envVariables; - } - - private static GetAttribute buildGetAttributeValue(String dbName, String owner, String type) { - GetAttribute attribute = new GetAttribute(); - attribute.setAttribute(Arrays.asList(dbName + PGAAS_NODE_NAME_POSTFIX, owner, type)); - return attribute; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java deleted file mode 100644 index 81a7911..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.blueprintgenerator.core; - -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.policymodel.PolicyModel; -import picocli.CommandLine.Command; -import picocli.CommandLine.Option; - -@Command(name = "policy", description = "Command used to generate policy model from component spec") -public class PolicyCommand implements Runnable{ - @Option(names = {"-i", "--component-spec"}, description = "Path to component spec file", required = true) - private String componentSpecPath; - - @Option(names = {"-p", "--model-path"}, description = "Path to directory that models are output to", required = true) - private String modelOutputPath; - - @Override - public void run() { - ComponentSpec inboundComponentSpec = new ComponentSpec(); - inboundComponentSpec.createComponentSpecFromFile(componentSpecPath); - new PolicyModel().createPolicyModels(inboundComponentSpec, this.modelOutputPath); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java deleted file mode 100644 index 1c3713b..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java +++ /dev/null @@ -1,92 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.core; - -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.policy.PolicyNode; -import org.onap.blueprintgenerator.models.blueprint.policy.PolicyNodeProperties; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.policy_info.TypePolicy; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.TreeMap; - -public class PolicyNodeBuilder { - - private static final String POLICY_NODE_TYPE = "clamp.nodes.policy"; - private static final String POLICY_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on"; - - public static void addPolicyNodesAndInputs(ComponentSpec cs, TreeMap nodeTemplate, - TreeMap> inps) { - List policyList = cs.getPolicyInfo().getTypePolicyList(); - for (TypePolicy policy : policyList) { - addPolicyNodesToNodeTemplate(policy, nodeTemplate); - addPolicyInputs(policy, inps); - } - } - - private static void addPolicyInputs(TypePolicy policy, TreeMap> inps) { - String defaultValue = policy.getPolicy_id() != null ? policy.getPolicy_id() : ""; - inps.put(policy.getNode_label() + "_policy_id", getInputValue("string", "policy_id", defaultValue)); - } - - private static LinkedHashMap getInputValue(String type, String description, Object defaultValue) { - LinkedHashMap inputValueMap = new LinkedHashMap(); - inputValueMap.put("type", type); - inputValueMap.put("description", description); - inputValueMap.put("default", defaultValue); - return inputValueMap; - } - - private static void addPolicyNodesToNodeTemplate(TypePolicy policy, TreeMap nodeTemplate) { - PolicyNode policyNode = new PolicyNode(); - policyNode.setType(POLICY_NODE_TYPE); - policyNode.setPolicyNodeProperties(getPolicyNodeProperties(policy)); - nodeTemplate.put(policy.getNode_label(), policyNode); - } - - private static PolicyNodeProperties getPolicyNodeProperties(TypePolicy policy) { - PolicyNodeProperties policyNodeProperties = new PolicyNodeProperties(); - - GetInput policyIdGetInput = new GetInput(); - policyIdGetInput.setBpInputName(policy.getNode_label() + "_policy_id"); - policyNodeProperties.setPolicyId(policyIdGetInput); - - policyNodeProperties.setPolicyModelId(policy.getPolicy_model_id()); - - return policyNodeProperties; - } - - public static ArrayList> getPolicyRelationships(ComponentSpec cs) { - ArrayList> relationships = new ArrayList<>(); - List policyList = cs.getPolicyInfo().getTypePolicyList(); - for (TypePolicy policy : policyList) { - LinkedHashMap relationship = new LinkedHashMap<>(); - relationship.put("type", POLICY_RELATIONSHIP_TYPE); - relationship.put("target", policy.getNode_label()); - relationships.add(relationship); - } - return relationships; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java deleted file mode 100644 index f9fa2cb..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/TestComponentSpec.java +++ /dev/null @@ -1,270 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.core; - -import java.util.ArrayList; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.componentspec.Artifacts; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.CallsObj; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Container; -import org.onap.blueprintgenerator.models.componentspec.HealthCheck; -import org.onap.blueprintgenerator.models.componentspec.Host; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.Policy; -import org.onap.blueprintgenerator.models.componentspec.ProvidesObj; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Self; -import org.onap.blueprintgenerator.models.componentspec.Services; -import org.onap.blueprintgenerator.models.componentspec.Streams; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; -import org.onap.blueprintgenerator.models.componentspec.Volumes; - -@Getter @Setter -public class TestComponentSpec { - private String componentSpecAsString = "{\r\n" + - " \"self\": {\r\n" + - " \"component_type\": \"docker\",\r\n" + - " \"description\": \"Test component spec\",\r\n" + - " \"name\": \"test.component.spec\",\r\n" + - " \"version\": \"1.0.1\"\r\n" + - " },\r\n" + - "\r\n" + - " \"service\": {\r\n" + - " \"calls\": [],\r\n" + - " \"provides\": []\r\n" + - " },\r\n" + - "\r\n" + - " \"streams\": {\r\n" + - " \"publishes\": [{\r\n" + - " \"config_key\": \"TEST-PUB-DR\",\r\n" + - " \"format\": \"dataformat_Hello_World_PM\",\r\n" + - " \"type\": \"data_router\",\r\n" + - " \"version\": \"1.0.0\"\r\n" + - " },\r\n" + - " {\r\n" + - " \"config_key\": \"TEST-PUB-MR\",\r\n" + - " \"format\": \"dataformat_Hello_World_PM\",\r\n" + - " \"type\": \"message_router\",\r\n" + - " \"version\": \"1.0.0\"\r\n" + - " }\r\n" + - " ],\r\n" + - "\r\n" + - " \"subscribes\": [{\r\n" + - " \"config_key\": \"TEST-SUB-MR\",\r\n" + - " \"format\": \"dataformat_Hello_World_PM\",\r\n" + - " \"route\": \"/TEST_HELLO_WORLD_SUB_MR\",\r\n" + - " \"type\": \"message_router\",\r\n" + - " \"version\": \"1.0.0\"\r\n" + - " },\r\n" + - " {\r\n" + - " \"config_key\": \"TEST-SUB-DR\",\r\n" + - " \"format\": \"dataformat_Hello_World_PM\",\r\n" + - " \"route\": \"/TEST-HELLO-WORLD-SUB-DR\",\r\n" + - " \"type\": \"data_router\",\r\n" + - " \"version\": \"1.0.0\"\r\n" + - " } \r\n" + - " ]\r\n" + - " },\r\n" + - "\r\n" + - " \"parameters\":\r\n" + - " [\r\n" + - " {\r\n" + - " \"name\": \"testParam1\",\r\n" + - " \"description\": \"test parameter 1\",\r\n" + - " \"value\": \"test-param-1\",\r\n" + - " \"type\": \"string\",\r\n" + - " \"sourced_at_deployment\": true,\r\n" + - " \"designer_editable\": true,\r\n" + - " \"policy_editable\": true,\r\n" + - " \"policy_group\": \"Test_Parameters\",\r\n" + - " \"required\": true\r\n" + - " }\r\n" + - " ],\r\n" + - "\r\n" + - " \"auxilary\": {\r\n" + - " \"healthcheck\": {\r\n" + - " \"type\": \"docker\",\r\n" + - " \"interval\": \"300s\",\r\n" + - " \"timeout\": \"120s\",\r\n" + - " \"script\": \"/etc/init.d/nagios status\"\r\n" + - " },\r\n" + - "\r\n" + - " \"databases\" : {\r\n" + - " \"TestDB1\": \"PGaaS\",\r\n" + - " \"TestDB2\": \"PGaaS\"\r\n" + - " },\r\n" + - "\r\n" + - " \"policy\": {\r\n" + - " \"trigger_type\": \"docker\",\r\n" + - " \"script_path\": \"/opt/app/manager/bin/reconfigure.sh\"\r\n" + - " },\r\n" + - " \"volumes\": [\r\n" + - " {\r\n" + - " \"container\": {\r\n" + - " \"bind\": \"/opt/app/manager/config/hostname\"\r\n" + - " },\r\n" + - " \"host\": {\r\n" + - " \"path\": \"/etc/hostname\",\r\n" + - " \"mode\": \"ro\"\r\n" + - " }\r\n" + - " }\r\n" + - "\r\n" + - " ],\r\n" + - " \"ports\": [\r\n" + - " \"80:80\"\r\n" + - " ]\r\n" + - " },\r\n" + - "\r\n" + - " \"artifacts\": [{\r\n" + - " \"type\": \"docker image\",\r\n" + - " \"uri\": \"test.tester\"\r\n" + - " }] \r\n" + - "\r\n" + - "}"; - private ComponentSpec componentSpec; - - public TestComponentSpec() { - this.componentSpec = createComponentSpec(); - } - - private ComponentSpec createComponentSpec(){ - //Manually fill a component spec object with the values from the file itself - ComponentSpec manualSpec = new ComponentSpec(); - - Self self = new Self(); - self.setComponent_type("docker"); - self.setDescription("Test component spec"); - self.setName("test.component.spec"); - self.setVersion("1.0.1"); - manualSpec.setSelf(self); - - Services services = new Services(); - CallsObj[] calls = new CallsObj[0]; - ProvidesObj[] provides = new ProvidesObj[0]; - services.setCalls(calls); - services.setProvides(provides); - manualSpec.setServices(null); - - Streams streams = new Streams(); - Publishes[] publishes = new Publishes[2]; - Publishes pub1 = new Publishes(); - pub1.setConfig_key("TEST-PUB-DR"); - pub1.setFormat("dataformat_Hello_World_PM"); - pub1.setType("data_router"); - pub1.setVersion("1.0.0"); - - Publishes pub2 = new Publishes(); - pub2.setConfig_key("TEST-PUB-MR"); - pub2.setFormat("dataformat_Hello_World_PM"); - pub2.setType("message_router"); - pub2.setVersion("1.0.0"); - publishes[0] = pub1; - publishes[1] = pub2; - streams.setPublishes(publishes); - - Subscribes[] subscribes = new Subscribes[2]; - Subscribes sub1 = new Subscribes(); - sub1.setConfig_key("TEST-SUB-MR"); - sub1.setFormat("dataformat_Hello_World_PM"); - sub1.setRoute("/TEST_HELLO_WORLD_SUB_MR"); - sub1.setType("message_router"); - sub1.setVersion("1.0.0"); - - Subscribes sub2 = new Subscribes(); - sub2.setConfig_key("TEST-SUB-DR"); - sub2.setFormat("dataformat_Hello_World_PM"); - sub2.setRoute("/TEST-HELLO-WORLD-SUB-DR"); - sub2.setType("data_router"); - sub2.setVersion("1.0.0"); - subscribes[0] = sub1; - subscribes[1] = sub2; - streams.setSubscribes(subscribes); - - manualSpec.setStreams(streams); - - Parameters[] parameters = new Parameters[1]; - Parameters par1 = new Parameters(); - par1.setName("testParam1"); - par1.setValue("test-param-1"); - par1.setDescription("test parameter 1"); - par1.setSourced_at_deployment(true); - par1.setDesigner_editable(true); - par1.setPolicy_editable(true); - par1.setPolicy_group("Test_Parameters"); - par1.setRequired(true); - par1.setType("string"); - parameters[0] = par1; - - manualSpec.setParameters(parameters); - - Auxilary auxilary = new Auxilary(); - HealthCheck healthcheck = new HealthCheck(); - healthcheck.setInterval("300s"); - healthcheck.setTimeout("120s"); - healthcheck.setScript("/etc/init.d/nagios status"); - healthcheck.setType("docker"); - auxilary.setHealthcheck(healthcheck); - - Volumes[] volumes = new Volumes[1]; - Volumes vol1 = new Volumes(); - Container con1 = new Container(); - con1.setBind("/opt/app/manager/config/hostname"); - Host host1 = new Host(); - host1.setPath("/etc/hostname"); - host1.setMode("ro"); - vol1.setContainer(con1); - vol1.setHost(host1); - - volumes[0] = vol1; - - auxilary.setVolumes(volumes); - - ArrayList ports = new ArrayList(); - ports.add("80:80"); - - TreeMap dataBases = new TreeMap<>(); - dataBases.put("TestDB1", "PGaaS"); - dataBases.put("TestDB2", "PGaaS"); - auxilary.setDatabases(dataBases); - - Policy pol = new Policy(); - pol.setTrigger_type("docker"); - pol.setScript_path("/opt/app/manager/bin/reconfigure.sh"); - auxilary.setPolicy(pol); - - auxilary.setPorts(ports); - - manualSpec.setAuxilary(auxilary); - - Artifacts[] artifacts = new Artifacts[1]; - Artifacts art = new Artifacts(); - art.setType("docker image"); - art.setUri("test.tester"); - - artifacts[0] = art; - manualSpec.setArtifacts(artifacts); - return manualSpec; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java deleted file mode 100644 index c9b2149..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java +++ /dev/null @@ -1,24 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.exception; - -public class DatabasesNotFoundException extends RuntimeException { - public DatabasesNotFoundException(String message) { super(message);} -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java deleted file mode 100644 index 56184ff..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java +++ /dev/null @@ -1,34 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 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.onap.blueprintgenerator.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -public class GetAttribute { - - @JsonProperty("get_attribute") - private Object attribute; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java deleted file mode 100644 index e9157ad..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java +++ /dev/null @@ -1,152 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.dmaap.DmaapObj; -import org.onap.blueprintgenerator.models.componentspec.CallsObj; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -@Getter -@Setter -public class Appconfig { - - private CallsObj[] service_calls; - private TreeMap streams_publishes; - private TreeMap streams_subscribes; - private TreeMap params; - - @JsonAnyGetter - public TreeMap getParams() { - return params; - } - - public TreeMap> createAppconfig( - TreeMap> inps, ComponentSpec componentSpec, String override, - boolean isDmaap) { - - service_calls = new CallsObj[0]; - streams_publishes = createStreamPublishes(componentSpec, inps, isDmaap); - streams_subscribes = createStreamSubscribes(componentSpec, inps, isDmaap); - params = createParameters(componentSpec, inps, override); - - return inps; - } - - private TreeMap createStreamPublishes(ComponentSpec componentSpec, - TreeMap> inps, boolean isDmaap) { - TreeMap streamPublishes = new TreeMap<>(); - for (Publishes publishes : componentSpec.getStreams().getPublishes()) { - String config = publishes.getConfig_key(); - DmaapObj pub = new DmaapObj(); - if (isDataRouterType(publishes.getType())) { - //in this case the data router information gets added to the params so for now leave it alone - String name = publishes.getConfig_key() + "_feed"; - pub.createOnapDmaapDRObj(inps, config, 'p', name, name, isDmaap); - } else if (isMessageRouterType(publishes.getType())) { - String name = publishes.getConfig_key() + "_topic"; - pub.createOnapDmaapMRObj(inps, config, 'p', name, name, isDmaap); - } - pub.setType(publishes.getType()); - streamPublishes.put(config, pub); - } - return streamPublishes; - } - - private TreeMap createStreamSubscribes(ComponentSpec componentSpec, - TreeMap> inputs, boolean isDmaap) { - TreeMap streamSubscribes = new TreeMap<>(); - for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) { - String config = subscribes.getConfig_key(); - DmaapObj sub = new DmaapObj(); - if (isDataRouterType(subscribes.getType())) { - //in this case the data router information gets added to the params so for now leave it alone - String name = subscribes.getConfig_key() + "_feed"; - sub.createOnapDmaapDRObj(inputs, config, 'p', name, name, isDmaap); - } else if (isMessageRouterType(subscribes.getType())) { - String name = subscribes.getConfig_key() + "_topic"; - sub.createOnapDmaapMRObj(inputs, config, 's', name, name, isDmaap); - } - sub.setType(subscribes.getType()); - streamSubscribes.put(config, sub); - } - return streamSubscribes; - } - - private TreeMap createParameters(ComponentSpec componentSpec, - TreeMap> inputs, - String override) { - TreeMap parameters = new TreeMap<>(); - for (Parameters params : componentSpec.getParameters()) { - String pName = params.getName(); - if (params.isSourced_at_deployment()) { - GetInput paramInput = new GetInput(); - paramInput.setBpInputName(pName); - parameters.put(pName, paramInput); - - if (!params.getValue().equals("")) { - LinkedHashMap input = createStringInput(params.getValue()); - inputs.put(pName, input); - } else { - LinkedHashMap input = new LinkedHashMap<>(); - input.put("type", "string"); - inputs.put(pName, input); - } - } else { - if ("string".equals(params.getType())) { - String val = (String) params.getValue(); - val = '"' + val + '"'; - parameters.put(pName, val); - } else { - parameters.put(pName, params.getValue()); - } - } - } - handleOverride(override, parameters, inputs); - return parameters; - } - - private void handleOverride(String override, TreeMap parameters, - TreeMap> inps) { - if (override != null) { - GetInput ov = new GetInput(); - ov.setBpInputName("service_component_name_override"); - parameters.put("service_component_name_override", ov); - LinkedHashMap over = new LinkedHashMap<>(); - over.put("type", "string"); - over.put("default", override); - inps.put("service_component_name_override", over); - } - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java deleted file mode 100644 index f2ef7aa..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java +++ /dev/null @@ -1,151 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import java.util.regex.Pattern; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.core.Fixes; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.dmaapbp.DmaapBlueprint; -import org.onap.blueprintgenerator.models.onapbp.OnapBlueprint; - -@Getter @Setter -@JsonInclude(JsonInclude.Include.NON_NULL) - -public class Blueprint { - - - private String tosca_definitions_version; - - private String description; - - private ArrayList imports; - - private TreeMap> inputs; - - private TreeMap node_templates; - - public Blueprint createBlueprint(ComponentSpec cs, String name, char bpType, String importPath, String override) { - Blueprint bp = new Blueprint(); - if(bpType == 'o') { - OnapBlueprint onap = new OnapBlueprint(); - bp = onap.createOnapBlueprint(cs, importPath, override); - bp = bp.setQuotations(bp); - } - - if(bpType == 'd') { - DmaapBlueprint dmaap = new DmaapBlueprint(); - bp = dmaap.createDmaapBlueprint(cs, importPath, override); - bp = bp.setQuotations(bp); - } - return bp; - } - - public Blueprint setQuotations(Blueprint bp) { - for(String s: bp.getInputs().keySet()) { - LinkedHashMap temp = bp.getInputs().get(s); - if(temp.get("type") == "string") { - String def = (String) temp.get("default"); - if(def != null){ - def = def.replaceAll("\"$", "").replaceAll("^\"", ""); - } - def = '"' + def + '"'; - temp.replace("default", def); - bp.getInputs().replace(s, temp); - } - } - - return bp; - } - - public void blueprintToYaml(String outputPath, String bluePrintName, ComponentSpec cs) { - File outputFile; - String name = bluePrintName.equals("") ? cs.getSelf().getName() : bluePrintName; - if(name.contains(".")) { - name = name.replaceAll(Pattern.quote("."), "_"); - } - if(name.contains(" ")) { - name = name.replaceAll(" ", ""); - } - String file = name + ".yaml"; - outputFile = new File(outputPath, file); - outputFile.getParentFile().mkdirs(); - try { - outputFile.createNewFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } - - String version = "#blueprint_version: " + cs.getSelf().getVersion() + '\n'; - String description = "#description: " + cs.getSelf().getDescription() + '\n'; - - try(BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, false))) { - writer.write(description); - writer.write(version); - } catch (IOException e1) { - throw new RuntimeException(e1); - } - - //read the translated blueprint into the file - ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - - try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true)))) { - blueprintMapper.writeValue(out, this); - } catch (IOException e) { - throw new RuntimeException(e); - } - - try { - Fixes.fixSingleQuotes(outputFile); - } catch (IOException e) { - throw new RuntimeException(e); - } - - System.out.println("Blueprint created"); - } - - public String blueprintToString() { - String ret = ""; - - ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - try { - ret = blueprintMapper.writerWithDefaultPrettyPrinter().writeValueAsString(this); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - - return Fixes.applyFixes(ret); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java deleted file mode 100644 index d0d79a4..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/BpConstants.java +++ /dev/null @@ -1,43 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia 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.onap.blueprintgenerator.models.blueprint; - -public final class BpConstants { - - private BpConstants() {} - - public static final String CLOUDIFY_DSL_1_3 = "cloudify_dsl_1_3"; - - public static final String CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP = "dcae.nodes.ContainerizedServiceComponentUsingDmaap"; - public static final String CONTENERIZED_SERVICE_COMPONENT = "dcae.nodes.ContainerizedServiceComponent"; - public static final String FEED = "dcaegen2.nodes.Feed"; - public static final String TOPIC = "dcaegen2.nodes.Topic"; - public static final String PUBLISH_EVENTS = "dcaegen2.relationships.publish_events"; - public static final String PUBLISH_FILES = "dcaegen2.relationships.publish_files"; - public static final String SUBSCRIBE_TO_EVENTS = "dcaegen2.relationships.subscribe_to_events"; - public static final String SUBSCRIBE_TO_FILES = "dcaegen2.relationships.subscribe_to_files"; - - public static final String TOSCA_DATATYPES_ROOT = "tosca.datatypes.Root"; - public static final String TOSCA_NODES_ROOT = "tosca.nodes.Root"; - public static final String TOSCA_SIMPLE_YAML = "tosca_simple_yaml_1_0_0"; - - public static final String MEMORY_LIMIT = "128Mi"; - public static final String CPU_LIMIT = "250m"; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java deleted file mode 100644 index edc257c..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java +++ /dev/null @@ -1,57 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import java.util.ArrayList; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonRawValue; - -import lombok.Getter; import lombok.Setter; -import lombok.NoArgsConstructor; - -// TODO: Auto-generated Javadoc -/** - * The Class ConcatObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter -//@Builder - -/** - * Instantiates a new concat obj. - */ -@NoArgsConstructor -@JsonInclude(value=Include.NON_NULL) - -public class ConcatObj { - - /** The concat. */ - private ArrayList concat; -} - diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java deleted file mode 100644 index 3d5ca3d..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java +++ /dev/null @@ -1,38 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class GetInput { - - @JsonProperty("get_input") - private Object bpInputName; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java deleted file mode 100644 index 1f9bf1c..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java +++ /dev/null @@ -1,55 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import java.util.ArrayList; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Getter; import lombok.Setter; -import lombok.NoArgsConstructor; - -// TODO: Auto-generated Javadoc -/** - * The Class GetProperty. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter -//@Builder - -/** - * Instantiates a new gets the property. - */ -@NoArgsConstructor -@JsonInclude(value=Include.NON_NULL) - -public class GetProperty { - - /** The get property. */ - private ArrayList get_property; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java deleted file mode 100644 index 7b55e17..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java +++ /dev/null @@ -1,67 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -@JsonInclude(value=Include.NON_NULL) -public class Imports { - /** The imports. */ - private ArrayList imports; - - public static ArrayList createOnapImports() { - ArrayList imps = new ArrayList<>(); - imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml"); - imps.add("plugin:k8splugin?version=3.4.2"); - imps.add("plugin:dcaepolicyplugin?version=2.4.0"); - return imps; - } - - public static ArrayList createDmaapImports(){ - ArrayList imps = new ArrayList<>(); - imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml"); - imps.add("plugin:k8splugin?version=3.4.2"); - imps.add("plugin:dmaap?version=1.5.0"); - return imps; - } - - public static ArrayList createImportsFromFile(String path) { - ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - File importPath = new File(path); - try { - Imports imports = importMapper.readValue(importPath, Imports.class); - imports.getImports().removeIf(String::isBlank); - return imports.getImports(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java deleted file mode 100644 index 435059e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java +++ /dev/null @@ -1,40 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import lombok.Getter; import lombok.Setter; - -@Getter @Setter -public class Interfaces { - private Start start; - public TreeMap> createInterface(TreeMap> inps, ComponentSpec cs){ - //create the start object - Start start = new Start(); - TreeMap> retInputs = start.createOnapStart(inps, cs); - this.setStart(start); - return retInputs; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java deleted file mode 100644 index ee75ce0..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java +++ /dev/null @@ -1,35 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import lombok.Getter; import lombok.Setter; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -@Getter @Setter -public class Node { - private String type; - private TreeMap interfaces; - private Properties properties; - private ArrayList> relationships; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java deleted file mode 100644 index 9aa5354..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java +++ /dev/null @@ -1,290 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createBooleanInput; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createIntegerInput; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.tls.ExternalCertificateParametersFactory; -import org.onap.blueprintgenerator.models.blueprint.tls.ExternalTlsInfoFactory; -import org.onap.blueprintgenerator.models.blueprint.tls.TlsInfo; -import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalTlsInfo; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; -import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams; - - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) -public class Properties { - - private static final String EMPTY_VALUE = ""; - - ArrayList streams_publishes; - ArrayList streams_subscribes; - private Appconfig application_config; - private Auxilary docker_config; - private Object image; - private GetInput location_id; - private String service_component_type; - private TreeMap log_info; - private String dns_name; - private Object replicas; - private String name; - private GetInput topic_name; - private GetInput feed_name; - private TlsInfo tls_info; - private ExternalTlsInfo external_cert; - private ResourceConfig resource_config; - private GetInput always_pull_image; - private Boolean useExisting; - @JsonIgnore - private ExternalTlsInfoFactory externalCertFactory; - - public Properties() { - ExternalCertificateParametersFactory externalCertificateDataFactory = new ExternalCertificateParametersFactory(); - externalCertFactory = new ExternalTlsInfoFactory(externalCertificateDataFactory); - } - - public TreeMap> createOnapProperties( - TreeMap> inps, ComponentSpec componentSpec, String override) { - TreeMap> retInputs = inps; - - //set the image - GetInput image = new GetInput(); - image.setBpInputName("image"); - this.setImage(image); - retInputs.put("image", createStringInput(componentSpec.getImageUri())); - - //set the location id - GetInput location = new GetInput(); - location.setBpInputName("location_id"); - this.setLocation_id(location); - retInputs.put("location_id", createStringInput(EMPTY_VALUE)); - - //set the log info - this.setLog_info(componentSpec.getAuxilary().getLog_info()); - - //set the replicas - GetInput replica = new GetInput(); - replica.setBpInputName("replicas"); - this.setReplicas(replica); - LinkedHashMap rep = createIntegerInput("number of instances", 1); - retInputs.put("replicas", rep); - - //set the dns name - //this.setDns_name(cs.getSelf().getName()); - - //set the name - //this.setName(cs.getSelf().getName()); - - //set the docker config - Auxilary aux = componentSpec.getAuxilary(); -// if(aux.getPorts() != null) { -// retInputs = aux.createPorts(retInputs); -// } - this.setDocker_config(aux); - - //set the app config - Appconfig app = new Appconfig(); - retInputs = app.createAppconfig(retInputs, componentSpec, override, false); - this.setApplication_config(app); - - // set always_pull_image - this.always_pull_image = new GetInput(); - this.always_pull_image.setBpInputName("always_pull_image"); - LinkedHashMap inputAlwaysPullImage = createBooleanInput( - "Set to true if the image should always be pulled", - true); - retInputs.put("always_pull_image", inputAlwaysPullImage); - - //set service component type - String serviceComponentType = componentSpec.getSelfName().replace('.', '-'); - this.setService_component_type(serviceComponentType); - - //set the tls info for internal and external communication - TreeMap tls_info = componentSpec.getAuxilary().getTls_info(); - if (tls_info != null) { - addTlsInfo(componentSpec, retInputs); - if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) { - retInputs.putAll(addExternalTlsInfo(componentSpec)); - } - } - - //set the reource config - ResourceConfig resource = new ResourceConfig(); - retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName()); - this.setResource_config(resource); - - return retInputs; - } - - public TreeMap> createDmaapProperties( - TreeMap> inps, ComponentSpec componentSpec, String override) { - TreeMap> retInputs = inps; - - //set the image - GetInput image = new GetInput(); - image.setBpInputName("tag_version"); - this.setImage(image); - retInputs.put("tag_version", createStringInput(componentSpec.getImageUri())); - - //set the location id - GetInput location = new GetInput(); - location.setBpInputName("location_id"); - this.setLocation_id(location); - retInputs.put("location_id", createStringInput(EMPTY_VALUE)); - - //set the log info - this.setLog_info(componentSpec.getAuxilary().getLog_info()); - - //set service component type - String serviceComponentType = componentSpec.getSelfName().replace('.', '-'); - this.setService_component_type(serviceComponentType); - - //set the tls info for internal and external communication - TreeMap tls_info = componentSpec.getAuxilary().getTls_info(); - if (tls_info != null) { - addTlsInfo(componentSpec, retInputs); - if (tls_info.get(USE_EXTERNAL_TLS_FIELD) != null) { - retInputs.putAll(addExternalTlsInfo(componentSpec)); - } - } - - //set the replicas - GetInput replica = new GetInput(); - replica.setBpInputName("replicas"); - this.setReplicas(replica); - LinkedHashMap rep = createIntegerInput("number of instances", 1); - retInputs.put("replicas", rep); - -// //set the dns name -// this.setDns_name(cs.getSelf().getName()); - -// //set the name -// this.setName(cs.getSelf().getName()); - - //set the docker config - Auxilary aux = componentSpec.getAuxilary(); -// if(aux.getPorts() != null) { -// retInputs = aux.createPorts(retInputs); -// } - this.setDocker_config(aux); - - //set the appconfig - Appconfig app = new Appconfig(); - retInputs = app.createAppconfig(retInputs, componentSpec, override, true); - this.setApplication_config(app); - - //set the stream publishes - ArrayList pubStreams = new ArrayList<>(); - if (componentSpec.getStreams().getPublishes() != null) { - for (Publishes publishes : componentSpec.getStreams().getPublishes()) { - if (isMessageRouterType(publishes.getType())) { - String topic = publishes.getConfig_key() + "_topic"; - DmaapStreams mrStreams = new DmaapStreams(); - retInputs = mrStreams - .createStreams(inps, componentSpec, topic, publishes.getType(), publishes.getConfig_key(), - publishes.getRoute(), 'p'); - pubStreams.add(mrStreams); - } else if (isDataRouterType(publishes.getType())) { - String feed = publishes.getConfig_key() + "_feed"; - DmaapStreams drStreams = new DmaapStreams(); - retInputs = drStreams - .createStreams(inps, componentSpec, feed, publishes.getType(), publishes.getConfig_key(), - publishes.getRoute(), 'p'); - pubStreams.add(drStreams); - } - } - } - - //set the stream subscribes - ArrayList subStreams = new ArrayList<>(); - if (componentSpec.getStreams().getSubscribes() != null) { - for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) { - if (isMessageRouterType(subscribes.getType())) { - String topic = subscribes.getConfig_key() + "_topic"; - DmaapStreams mrStreams = new DmaapStreams(); - retInputs = mrStreams - .createStreams(inps, componentSpec, topic, subscribes.getType(), subscribes.getConfig_key(), - subscribes.getRoute(), 's'); - subStreams.add(mrStreams); - } else if (isDataRouterType(subscribes.getType())) { - String feed = subscribes.getConfig_key() + "_feed"; - DmaapStreams drStreams = new DmaapStreams(); - retInputs = drStreams - .createStreams(inps, componentSpec, feed, subscribes.getType(), subscribes.getConfig_key(), - subscribes.getRoute(), 's'); - subStreams.add(drStreams); - } - } - } - - if (!pubStreams.isEmpty()) { - this.setStreams_publishes(pubStreams); - } - if (!subStreams.isEmpty()) { - this.setStreams_subscribes(subStreams); - } - - //set the reource config - ResourceConfig resource = new ResourceConfig(); - retInputs = resource.createResourceConfig(retInputs, componentSpec.getSelf().getName()); - this.setResource_config(resource); - - return retInputs; - } - - private void addTlsInfo(ComponentSpec cs, TreeMap> retInputs) { - TlsInfo tlsInfo = new TlsInfo(); - tlsInfo.setCertDirectory((String) cs.getAuxilary().getTls_info().get("cert_directory")); - GetInput useTLSFlag = new GetInput(); - useTLSFlag.setBpInputName("use_tls"); - tlsInfo.setUseTls(useTLSFlag); - this.setTls_info(tlsInfo); - LinkedHashMap useTlsFlagInput = createBooleanInput( - "flag to indicate tls enable/disable", - cs.getAuxilary().getTls_info().get("use_tls")); - retInputs.put("use_tls", useTlsFlagInput); - } - - private Map> addExternalTlsInfo(ComponentSpec cs) { - this.setExternal_cert(externalCertFactory.createFromComponentSpec(cs)); - return externalCertFactory.createInputListFromComponentSpec(cs); - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java deleted file mode 100644 index 3618be3..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java +++ /dev/null @@ -1,115 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createStringInput; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CPU_LIMIT; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.MEMORY_LIMIT; - -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -//TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter -@Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Builder - -/** - * Instantiates a new resource config obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new resource config obj. - * - * @param limits the limits - * @param requests the requests - */ -@AllArgsConstructor - -public class ResourceConfig { - - private TreeMap limits; - private TreeMap requests; - - - /** - * Creates the resource config. - * - * @param inputs the inputs - * @param name the name - * @return the tree map - */ - public TreeMap> createResourceConfig( - TreeMap> inputs, String name) { - - String namePrefix = getNamePrefix(name); - - limits = createInputs(inputs, namePrefix, "limit"); - requests = createInputs(inputs, namePrefix, "request"); - - return inputs; - } - - private TreeMap createInputs(TreeMap> inputs, - String namePrefix, - String inputType) { - - LinkedHashMap memoryLimit = createStringInput(MEMORY_LIMIT); - LinkedHashMap cpuLimit = createStringInput(CPU_LIMIT); - - final String cpuKey = namePrefix + "cpu_" + inputType; - final String memoryKey = namePrefix + "memory_" + inputType; - TreeMap inps = new TreeMap<>(); - - insertInput("cpu", cpuKey, inps); - insertInput("memory", memoryKey, inps); - - inputs.put(cpuKey, cpuLimit); - inputs.put(memoryKey, memoryLimit); - - return inps; - } - - private void insertInput(String type, String name, TreeMap inputs) { - GetInput input = new GetInput(); - input.setBpInputName(name); - inputs.put(type, input); - } - - private String getNamePrefix(String name) { - return (name == null || name.isEmpty()) ? "" : name + "_"; - } -} - diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java deleted file mode 100644 index 0b03777..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java +++ /dev/null @@ -1,47 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Getter; import lombok.Setter; -@Getter @Setter -@JsonInclude(value=Include.NON_NULL) -public class Start { - private StartInputs inputs; - private LinkedHashMap envs; - - public TreeMap> createOnapStart(TreeMap> inps, ComponentSpec cs) { - - //create the start inputs - StartInputs inputs = new StartInputs(); - inputs.createOnapStartInputs(inps, cs); - this.setInputs(inputs); - - return inps; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java deleted file mode 100644 index a0cfe20..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java +++ /dev/null @@ -1,118 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Getter; import lombok.Setter; - -@Getter @Setter -@JsonInclude(value=Include.NON_NULL) -public class StartInputs { - private ArrayList ports; - private Object envs; - - public TreeMap> createOnapStartInputs(TreeMap> inps, ComponentSpec cs){ - - int count = 0; - ArrayList portList = new ArrayList<>(); - Auxilary aux = cs.getAuxilary(); - - if (aux.getPorts() != null) { - - for(Object p : aux.getPorts()) { - String[] ports = p.toString().split(":"); - String internal - = String.format("concat: [\"%s:\", {get_input: external_port_%d}]" - , ports[0], count); - portList.add(internal); - - LinkedHashMap portType = new LinkedHashMap<>(); - portType.put("type", "string"); - portType.put("default", ports[1]); - inps.put("external_port_" + count, portType); - - count++; - } - - } - - this.setPorts(portList); -// ArrayList port = new ArrayList(); -// String external = ""; -// if(cs.getAuxilary().getPorts() != null) { -// for(String s: cs.getAuxilary().getPorts()) { -// //create the ports -// String portNumber = ""; -// StringBuffer buf = new StringBuffer(); -// for(int i = 0; i < s.length(); i++) { -// if(!(s.charAt(i) == ':')) { -// buf.append(s.charAt(i)); -// } -// else { -// external = s.replace(buf.toString() + ":", ""); -// break; -// } -// } -// portNumber = buf.toString(); -// String p = "concat: [" + '"' + portNumber + ":" + '"' +", {get_input: external_port }]"; -// port.add(p); -// } -// } -// this.setPorts(port); -// //add the external port input -// if(cs.getAuxilary().getPorts() != null) { -// stringType.put("type", "string"); -// stringType.put("description", "Kubernetes node port on which collector is exposed"); -// stringType.put("default", "'" + external + "'") ; -// retInputs.put("external_port", stringType); -// } - - //set the envs - LinkedHashMap eMap = new LinkedHashMap<>(); - if(cs.getAuxilary().getDatabases() != null){ - //set db env variables - LinkedHashMap envVars = PgaasNodeBuilder.getEnvVariables(cs.getAuxilary().getDatabases()); - this.setEnvs(envVars); - eMap.put("default", "&envs {}"); - } - else { - GetInput env = new GetInput(); - env.setBpInputName("envs"); - this.setEnvs(env); - eMap.put("default", "{}"); - } - inps.put("envs", eMap); - - - return inps; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java deleted file mode 100644 index 7137cdb..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java +++ /dev/null @@ -1,69 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.HealthCheck; -import org.onap.blueprintgenerator.models.onapbp.OnapNode; - -import lombok.Getter; import lombok.Setter; - - -public class TemplateNode extends OnapNode{ - -// public void createTemplateNode() { -// //dummy inputs just used for the inputs so i can reuse code -// TreeMap> inps = new TreeMap>(); -// -// //create a dummy componentspec to set the values later on -// ComponentSpec cs = new ComponentSpec(); -// Auxilary aux = new Auxilary(); -// HealthCheck health = new HealthCheck(); -// health.setEndpoint("/healthcheck"); -// health.setInterval("15s"); -// health.setTimeout("1s"); -// health.setType("https"); -// aux.setHealthcheck(health); -// String[] ports = new String[1]; -// ports[0] = "9999:9999"; -// aux.setPorts(ports); -// cs.setAuxilary(aux); -// -// //set the type -// this.setType("dcae.nodes.ContainerizedPlatformComponent"); -// -// //set the interface -// Interfaces inter = new Interfaces(); -// inter.createOnapInterface(inps, cs); -// TreeMap interfaces = new TreeMap(); -// interfaces.put("cloudify.interfaces.lifecycle", inter); -// this.setInterfaces(interfaces); -// -// -// //create the properties -// Properties props = new Properties(); -// props.createTemplateProperties(cs); -// this.setProperties(props); -// } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java deleted file mode 100644 index 0cec284..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.dmaap; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) -public class DmaapInfo { - - private static final String UNDERSCORE = "_"; - - private GetInput topic_url; - private GetInput username; - private GetInput password; - private GetInput location; - private GetInput delivery_url; - private GetInput subscriber_id; - - public TreeMap> createOnapDmaapMRInfo( - TreeMap> inps, String config, char type) { - LinkedHashMap stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - config = config.replaceAll("-", "_"); - if (type == 'p') { - config = config + "_publish_url"; - } else if (type == 's') { - config = config + "_subscribe_url"; - } - - GetInput topic = new GetInput(); - topic.setBpInputName(config); - this.setTopic_url(topic); - - inps.put(config, stringType); - - return inps; - } - - public TreeMap> createOnapDmaapDRInfo( - TreeMap> inps, String config, char type) { - TreeMap> retInputs = inps; - LinkedHashMap stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - String userNameInputName = createInputName(config, "username"); - GetInput username = new GetInput(userNameInputName); - this.setUsername(username); - retInputs.put(userNameInputName, stringType); - - String passwordInputName = createInputName(config, "password"); - GetInput password = new GetInput(passwordInputName); - this.setPassword(password); - retInputs.put(passwordInputName, stringType); - - String locationInputName = createInputName(config, "location"); - GetInput location = new GetInput(locationInputName); - this.setLocation(location); - retInputs.put(locationInputName, stringType); - - String deliveryUrlInputName = createInputName(config, "delivery_url"); - GetInput deliveryUrl = new GetInput(deliveryUrlInputName); - this.setDelivery_url(deliveryUrl); - retInputs.put(deliveryUrlInputName, stringType); - - String subscriberIdInputName = createInputName(config, "subscriber_id"); - GetInput subscriberID = new GetInput(subscriberIdInputName); - this.setSubscriber_id(subscriberID); - retInputs.put(subscriberIdInputName, stringType); - - return retInputs; - } - - private String createInputName(String config, String inputName) { - return config + UNDERSCORE + inputName; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java deleted file mode 100644 index 30f59e2..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/dmaap/DmaapObj.java +++ /dev/null @@ -1,83 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.dmaap; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -@JsonInclude(value=Include.NON_NULL) -@Getter @Setter -public class DmaapObj { - private Object dmaap_info; - private String type; - private GetInput pass; - private GetInput user; - - public TreeMap> createOnapDmaapMRObj(TreeMap> inps, - String config, char type, String n, String num, boolean isDmaap) { - LinkedHashMap stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //set the dmaapinfo - DmaapInfo info = new DmaapInfo(); - if(!isDmaap){ - info.createOnapDmaapMRInfo(inps, config, type); - this.setDmaap_info(info); - } - else{ - String infoType = "<<" + n + ">>"; - this.setDmaap_info(infoType); - //set username - GetInput u = new GetInput(); - u.setBpInputName(config + "_" + num +"_aaf_username"); - this.setUser(u); - inps.put(config + "_" + num +"_aaf_username", stringType); - - //set password - GetInput p = new GetInput(); - p.setBpInputName(config + "_" + num +"_aaf_password"); - this.setPass(p); - inps.put(config + "_" + num +"_aaf_password", stringType); - } - return inps; - } - public TreeMap> createOnapDmaapDRObj(TreeMap> inps, String config, char type, String n, String num, boolean isDmaap) { - - //set the dmaapinfo - DmaapInfo info = new DmaapInfo(); - if(!isDmaap){ - info.createOnapDmaapDRInfo(inps, config, type); - this.setDmaap_info(info); - } - else { - String infoType = "<<" + n + ">>"; - this.setDmaap_info(infoType); - } - return inps; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java deleted file mode 100644 index 35f958e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java +++ /dev/null @@ -1,35 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint.pgaas; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.Node; - -@Getter -@Setter -@NoArgsConstructor -public class PgaasNode extends Node { - - @JsonProperty("properties") - private PgaasNodeProperties pgaasNodeProperties; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java deleted file mode 100644 index 709c66e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java +++ /dev/null @@ -1,40 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint.pgaas; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -@Getter @Setter -@NoArgsConstructor -public class PgaasNodeProperties { - - @JsonProperty("writerfqdn") - private GetInput writerfqdn; - - @JsonProperty("name") - private GetInput name; - - @JsonProperty("use_existing") - private boolean useExisting; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java deleted file mode 100644 index b4740df..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java +++ /dev/null @@ -1,34 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint.policy; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.Node; - -@Getter @Setter -@NoArgsConstructor -public class PolicyNode extends Node { - - @JsonProperty("properties") - private PolicyNodeProperties policyNodeProperties; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java deleted file mode 100644 index 6d23b23..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java +++ /dev/null @@ -1,37 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.blueprint.policy; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -@Getter @Setter -@NoArgsConstructor -public class PolicyNodeProperties { - - @JsonProperty("policy_id") - private GetInput policyId; - - @JsonProperty("policy_model_id") - private String policyModelId; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java deleted file mode 100644 index 546a809..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactory.java +++ /dev/null @@ -1,74 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.tls; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_COMMON_NAME; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_SANS; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.SANS_FIELD; - -import java.util.LinkedHashMap; -import java.util.Map; -import org.onap.blueprintgenerator.models.blueprint.tls.api.ExternalCertificateDataFactory; -import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificateParameters; - -/** - * Factory class for providing parameters of ExternalCertificate. Allow to get ExternalCertificateParameters Object and - * input list - */ -public class ExternalCertificateParametersFactory extends ExternalCertificateDataFactory { - - /** - * Create ExternalCertificateParameters Object - * - * @return ExternalCertificateParameters - */ - public ExternalCertificateParameters create() { - ExternalCertificateParameters externalCertificateParameters = new ExternalCertificateParameters(); - externalCertificateParameters.setCommonName(createPrefixedGetInput(COMMON_NAME_FIELD)); - externalCertificateParameters.setSans(createPrefixedGetInput(SANS_FIELD)); - return externalCertificateParameters; - } - - /** - * Create input list for ExternalCertificateParameters - * - * @return Input list - */ - public Map> createInputList() { - Map> retInputs = new LinkedHashMap<>(); - - LinkedHashMap commonNameInputMap = createInputValue("string", - "Common name which should be present in certificate.", - DEFAULT_COMMON_NAME); - retInputs.put(addPrefix(COMMON_NAME_FIELD), commonNameInputMap); - - LinkedHashMap sansInputMap = createInputValue("string", - "\"List of Subject Alternative Names (SANs) which should be present in certificate. " + - "Delimiter - : Should contain common_name value and other FQDNs under which given " + - "component is accessible.\"", - DEFAULT_SANS); - retInputs.put(addPrefix(SANS_FIELD), sansInputMap); - - return retInputs; - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java deleted file mode 100644 index e954afc..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalTlsInfoFactory.java +++ /dev/null @@ -1,102 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia 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.onap.blueprintgenerator.models.blueprint.tls; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.createInputValue; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CA_NAME_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CERT_DIRECTORY_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CERT_TYPE_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_CA; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_CERT_TYPE; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD; - -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.TreeMap; -import org.onap.blueprintgenerator.models.blueprint.tls.api.ExternalCertificateDataFactory; -import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalTlsInfo; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -/** - * Factory class for providing ExternalTlsInfo data. Allow to get ExternalTlsInfo Object and Inputs list. - */ -public class ExternalTlsInfoFactory extends ExternalCertificateDataFactory { - - private ExternalCertificateParametersFactory externalCertificateParametersFactory; - - /** - * Constructor for ExternalTlsInfoFactory - * - * @param externalCertificateDataFactory Factory providing external certificate parameters. - */ - public ExternalTlsInfoFactory(ExternalCertificateParametersFactory externalCertificateDataFactory) { - this.externalCertificateParametersFactory = externalCertificateDataFactory; - } - - /** - * Create ExternalTlsInfo from ComponentSpec Object - * - * @param cs ComponentSpec Object - * @return ExternalTlsInfo Object - */ - public ExternalTlsInfo createFromComponentSpec(ComponentSpec cs) { - ExternalTlsInfo externalTlsInfoBp = new ExternalTlsInfo(); - TreeMap tlsInfoCs = cs.getAuxilary().getTls_info(); - - externalTlsInfoBp.setExternalCertDirectory((String) tlsInfoCs.get(CERT_DIRECTORY_FIELD)); - externalTlsInfoBp.setUseExternalTls(createPrefixedGetInput(USE_EXTERNAL_TLS_FIELD)); - externalTlsInfoBp.setCaName(createPrefixedGetInput(CA_NAME_FIELD)); - externalTlsInfoBp.setCertType(createPrefixedGetInput(CERT_TYPE_FIELD)); - externalTlsInfoBp.setExternalCertificateParameters(externalCertificateParametersFactory.create()); - - return externalTlsInfoBp; - } - - /** - * Create input list from ComponentSpec Object - * - * @param cs ComponentSpec Object - * @return Input list - */ - public Map> createInputListFromComponentSpec(ComponentSpec cs) { - Map> retInputs = new HashMap<>(); - - Map externalTlsInfoCs = cs.getAuxilary().getTls_info(); - LinkedHashMap useTlsFlagInput = createInputValue("boolean", - "Flag to indicate external tls enable/disable.", - externalTlsInfoCs.get(USE_EXTERNAL_TLS_FIELD)); - retInputs.put(addPrefix(USE_EXTERNAL_TLS_FIELD), useTlsFlagInput); - - LinkedHashMap caNameInputMap = createInputValue("string", - "Name of Certificate Authority configured on CertService side.", - DEFAULT_CA); - retInputs.put(addPrefix(CA_NAME_FIELD), caNameInputMap); - - LinkedHashMap certTypeInputMap = createInputValue("string", - "Format of provided certificates", - DEFAULT_CERT_TYPE); - retInputs.put(addPrefix(CERT_TYPE_FIELD), certTypeInputMap); - - retInputs.putAll(externalCertificateParametersFactory.createInputList()); - return retInputs; - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java deleted file mode 100644 index cdbfd32..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia 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.onap.blueprintgenerator.models.blueprint.tls; - -public class TlsConstants { - - public static final String EXTERNAL_CERT_DIRECTORY_FIELD = "external_cert_directory"; - public static final String CERT_DIRECTORY_FIELD = "cert_directory"; - public static final String INPUT_PREFIX = "external_cert_"; - public static final String USE_EXTERNAL_TLS_FIELD = "use_external_tls"; - public static final String CA_NAME_FIELD = "ca_name"; - public static final String EXTERNAL_CERTIFICATE_PARAMETERS_FIELD = "external_certificate_parameters"; - public static final String COMMON_NAME_FIELD = "common_name"; - public static final String SANS_FIELD = "sans"; - public static final String CERT_TYPE_FIELD = "cert_type"; - - public static final String DEFAULT_CA = "RA"; - public static final Object DEFAULT_CERT_TYPE = "P12"; - public static final String DEFAULT_COMMON_NAME = "sample.onap.org"; - public static final String DEFAULT_SANS = "sample.onap.org:component.sample.onap.org"; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java deleted file mode 100644 index 027f996..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/TlsInfo.java +++ /dev/null @@ -1,39 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.tls; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -@Getter -@Setter -@NoArgsConstructor -public class TlsInfo { - - @JsonProperty("cert_directory") - private String certDirectory; - - @JsonProperty("use_tls") - private GetInput useTls; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java deleted file mode 100644 index 21b20e4..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/api/ExternalCertificateDataFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.tls.api; - -import org.onap.blueprintgenerator.models.blueprint.GetInput; - - -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.INPUT_PREFIX; - -public abstract class ExternalCertificateDataFactory { - - protected static GetInput createPrefixedGetInput(String fieldName) { - return new GetInput(addPrefix(fieldName)); - } - - protected static String addPrefix(String fieldName) { - return INPUT_PREFIX + fieldName; - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java deleted file mode 100644 index e3ccca1..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalCertificateParameters.java +++ /dev/null @@ -1,43 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.tls.impl; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.SANS_FIELD; - - -@Getter -@Setter -@NoArgsConstructor -public class ExternalCertificateParameters { - - @JsonProperty(COMMON_NAME_FIELD) - private GetInput commonName; - - @JsonProperty(SANS_FIELD) - private GetInput sans; - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java deleted file mode 100644 index 588dbb5..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/tls/impl/ExternalTlsInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint.tls.impl; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.models.blueprint.GetInput; - -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CA_NAME_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.CERT_TYPE_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.EXTERNAL_CERTIFICATE_PARAMETERS_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.EXTERNAL_CERT_DIRECTORY_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.USE_EXTERNAL_TLS_FIELD; - -@Getter -@Setter -@NoArgsConstructor -public class ExternalTlsInfo { - - @JsonProperty(EXTERNAL_CERT_DIRECTORY_FIELD) - private String externalCertDirectory; - - @JsonProperty(USE_EXTERNAL_TLS_FIELD) - private GetInput useExternalTls; - - @JsonProperty(CA_NAME_FIELD) - private GetInput caName; - - @JsonProperty(CERT_TYPE_FIELD) - private GetInput certType; - - @JsonProperty(EXTERNAL_CERTIFICATE_PARAMETERS_FIELD) - private ExternalCertificateParameters externalCertificateParameters; - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java deleted file mode 100644 index 198dc19..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Artifacts.java +++ /dev/null @@ -1,63 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - - -/** - * Instantiates a new artifacts. - */ -@NoArgsConstructor - -/** - * Instantiates a new artifacts. - * - * @param type the type - * @param uri the uri - */ - -@JsonInclude(JsonInclude.Include.NON_NULL) -@EqualsAndHashCode -//Called in Component Spec Object -public class Artifacts { - - /** The type. */ - private String type; - - /** The uri. */ - private String uri; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java deleted file mode 100644 index 58e1e0c..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java +++ /dev/null @@ -1,127 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.ArrayList; -import java.util.TreeMap; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - - -/** - * Instantiates a new auxilary. - */ -@NoArgsConstructor - -/** - * Instantiates a new auxilary. - * - * @param healthcheck the healthcheck - * @param volumes the volumes - * @param policy the policy - * @param ports the ports - * @param reconfigs the reconfigs - * @param databases the databases - */ - -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in component Spec Object -public class Auxilary { - - /** The healthcheck. */ - private HealthCheck healthcheck; - - /**log-directory**/ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private TreeMap log_info; - - /**tls-info**/ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private TreeMap tls_info; - - /** The volumes. */ - private Volumes[] volumes; - - /** The policy. */ - private Policy policy; - - /** The ports. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private ArrayList ports; - - /** The reconfigs. */ - private ReconfigsObj reconfigs; - - /** The databases. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private TreeMap databases; - - -// public TreeMap> createPorts(TreeMap> inps) { -// TreeMap> retInputs = inps; -// LinkedHashMap portType = new LinkedHashMap(); -// portType.put("type", "string"); -// -// ArrayList ports = new ArrayList(); -// String external = ""; -// boolean foundPort = false; -// for(Object o: this.getPorts()) { -// String internal = ""; -// String p = o.toString(); -// for(int i = 0; i < p.length(); i++) { -// if(p.charAt(i) == ':') { -// internal = '"' + internal + '"'; -// internal = "concat: ['" + internal + "', {get_input: external_port}]"; -// ports.add(internal); -// } -// if(p.charAt(i) == ':' && !foundPort) { -// external = p.substring(i); -// portType.put("default", external); -// retInputs.put("external_port", portType); -// -// } -// internal = internal + p.charAt(i); -// -// } -// } -// -// this.setPorts(ports); -// return retInputs; -// } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java deleted file mode 100644 index d130632..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/CallsObj.java +++ /dev/null @@ -1,45 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - - -// TODO: Auto-generated Javadoc -/** - * The Class CallsObj. - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -//called from service obj -public class CallsObj { - - /** The config key. */ - private String config_key; - - /** The request. */ - private RequestResponseObj request; - - /** The response. */ - private RequestResponseObj response; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java deleted file mode 100644 index 0cd2b72..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java +++ /dev/null @@ -1,166 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.componentspec; - -import java.io.File; -import java.io.IOException; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; - -import lombok.Getter; -import lombok.Setter; -import lombok.NoArgsConstructor; -import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo; - -// TODO: Auto-generated Javadoc - -/** - * The Class ComponentSpec. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter -@Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new component spec. - */ -@NoArgsConstructor - -/** - * Instantiates a new component spec. - * - * @param self the self - * @param services the services - * @param streams the streams - * @param parameters the parameters - * @param auxilary the auxilary - * @param artifacts the artifacts - */ - -@JsonInclude(value = Include.NON_NULL) -//main object that the component spec file is written in -public class ComponentSpec { - - /** - * The self. - */ - private Self self; - - /** - * The services. - */ - private Services services; - - /** - * The streams. - */ - private Streams streams; - - /** - * The parameters. - */ - private Parameters[] parameters; - - /** - * The auxilary. - */ - private Auxilary auxilary; - - @JsonProperty("policy_info") - private PolicyInfo policyInfo; - - /** - * The artifacts. - */ - private Artifacts[] artifacts; - - /** - * Creates the component spec from file. - * - * @param path the path - */ - public void createComponentSpecFromFile(String path) { - ObjectMapper componentMapper = new ObjectMapper(); - File specPathFile = new File(path); - ComponentSpec cs = new ComponentSpec(); - - try { - cs = componentMapper.readValue(specPathFile, ComponentSpec.class); - } catch (IOException e) { - throw new RuntimeException(e); - } - - //set all the pieces of the component spec - this.setSelf(cs.getSelf()); - this.setArtifacts(cs.getArtifacts()); - this.setAuxilary(cs.getAuxilary()); - this.setParameters(cs.getParameters()); - this.setServices(cs.getServices()); - this.setStreams(cs.getStreams()); - this.setPolicyInfo(cs.getPolicyInfo()); - } - - - /** - * Creates the component spec from string. - * - * @param specString the spec string - */ - public void createComponentSpecFromString(String specString) { - ObjectMapper componentMapper = new ObjectMapper(); - ComponentSpec cs = new ComponentSpec(); - try { - cs = componentMapper.readValue(specString, ComponentSpec.class); - } catch (IOException e) { - throw new RuntimeException(e); - } - - //set all the pieces of the component spec - this.setSelf(cs.getSelf()); - this.setArtifacts(cs.getArtifacts()); - this.setAuxilary(cs.getAuxilary()); - this.setParameters(cs.getParameters()); - this.setServices(cs.getServices()); - this.setStreams(cs.getStreams()); - } - - public String getImageUri() { - return artifacts[0].getUri(); - } - - public String getSelfName() { - return this.self.getName(); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java deleted file mode 100644 index 785df35..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ConstraintsObj.java +++ /dev/null @@ -1,62 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -// TODO: Auto-generated Javadoc -/** - * The Class ConstraintsObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(value=Include.NON_NULL) - -public class ConstraintsObj { - - /** The equal. */ - private Object equal; - - /** The greater than. */ - private int greater_than; - - /** The greater or equal. */ - private int greater_or_equal; - - /** The less than. */ - private int less_than; - - /** The less or equal. */ - private int less_or_equal; - - /** The valid values. */ - private Object[] valid_values; - - /** The length. */ - private int length; - - /** The min length. */ - private int min_length; - - /** The max length. */ - private int max_length; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java deleted file mode 100644 index cbe02dc..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Container.java +++ /dev/null @@ -1,60 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new container. - */ -@NoArgsConstructor - -/** - * Instantiates a new container. - * - * @param bind the bind - * @param mode the mode - */ - -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -public class Container { - - /** The bind. */ - private String bind; - - /** The mode. */ - private String mode; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java deleted file mode 100644 index ef33aaf..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/EntrySchemaObj.java +++ /dev/null @@ -1,82 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/** - * The Class EntrySchemaObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new entry schema obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new entry schema obj. - * - * @param name the name - * @param description the description - * @param type the type - * @param value the value - * @param entry_schema the entry schema - * @param required the required - */ - -@JsonInclude(value=Include.NON_NULL) -//called from policy schema obj -public class EntrySchemaObj { - - /** The name. */ - private String name; - - /** The description. */ - private String description; - - /** The type. */ - private String type; - - /** The value. */ - private String value; - - /** The entry schema. */ - private EntrySchemaObj[] entry_schema; - - /** The required. */ - private boolean required; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java deleted file mode 100644 index 76e1036..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/HealthCheck.java +++ /dev/null @@ -1,72 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new health check. - */ -@NoArgsConstructor - -/** - * Instantiates a new health check. - * - * @param interval the interval - * @param timeout the timeout - * @param script the script - * @param type the type - */ - -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in Auxillary Object -public class HealthCheck { - - /** The interval. */ - private String interval; - - /** The timeout. */ - private String timeout; - - /** The script. */ - private String script; - - /** The type. */ - private String type; - - private String endpoint; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java deleted file mode 100644 index f178c94..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Host.java +++ /dev/null @@ -1,56 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/** - * Instantiates a new host. - */ -@NoArgsConstructor - -/** - * Instantiates a new host. - * - * @param path the path - * @param mode the mode - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -public class Host{ - - /** The path. */ - private String path; - - /** The mode. */ - private String mode; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java deleted file mode 100644 index eb95202..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Parameters.java +++ /dev/null @@ -1,106 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/** - * The Class Parameters. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new parameters. - */ -@NoArgsConstructor - -/** - * Instantiates a new parameters. - * - * @param name the name - * @param value the value - * @param description the description - * @param sourced_at_deployment the sourced at deployment - * @param designer_editable the designer editable - * @param policy_editable the policy editable - * @param required the required - * @param type the type - * @param policy_group the policy group - * @param policy_schema the policy schema - * @param entry_schema the entry schema - * @param constraints the constraints - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in component Spec Object -public class Parameters { - - /** The name. */ - private String name; - - /** The value. */ - private Object value; - - /** The description. */ - private String description; - - /** The sourced at deployment. */ - private boolean sourced_at_deployment; - - /** The designer editable. */ - private boolean designer_editable; - - /** The policy editable. */ - private boolean policy_editable; - - /** The required. */ - private boolean required; - - /** The type. */ - private String type; - - /** The policy group. */ - private String policy_group; - - /** The policy schema. */ - private PolicySchemaObj[] policy_schema; - - /** The entry schema. */ - private EntrySchemaObj[] entry_schema; - - /** The constraints. */ - private ConstraintsObj[] constraints; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java deleted file mode 100644 index d295ca4..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Policy.java +++ /dev/null @@ -1,62 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new policy. - */ -@NoArgsConstructor - -/** - * Instantiates a new policy. - * - * @param trigger_type the trigger type - * @param script_path the script path - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//called in auxilary -public class Policy { - - /** The trigger type. */ - private String trigger_type; - - /** The script path. */ - private String script_path; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java deleted file mode 100644 index aa38271..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/PolicySchemaObj.java +++ /dev/null @@ -1,86 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/** - * The Class PolicySchemaObj. - */ -@JsonIgnoreProperties(ignoreUnknown = true) - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new policy schema obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new policy schema obj. - * - * @param name the name - * @param description the description - * @param type the type - * @param value the value - * @param entry_schema the entry schema - * @param required the required - * @param constraints the constraints - */ -@JsonInclude(value=Include.NON_NULL) -//called from parameters obj -public class PolicySchemaObj { - - /** The name. */ - private String name; - - /** The description. */ - private String description; - - /** The type. */ - private String type; - - /** The value. */ - private String value; - - /** The entry schema. */ - private EntrySchemaObj[] entry_schema; - - /** The required. */ - private boolean required; - - /** The constraints. */ - private ConstraintsObj[] constraints; - } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java deleted file mode 100644 index 9ad24c3..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ProvidesObj.java +++ /dev/null @@ -1,63 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new provides obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new provides obj. - * - * @param route the route - * @param request the request - * @param response the response - */ -//called from service obj -public class ProvidesObj { - - /** The route. */ - private String route; - - /** The request. */ - private RequestResponseObj request; - - /** The response. */ - private RequestResponseObj response; - - private String verb; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java deleted file mode 100644 index 4f46313..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Publishes.java +++ /dev/null @@ -1,73 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - -/** - * Instantiates a new publishes. - */ -@NoArgsConstructor - -/** - * Instantiates a new publishes. - * - * @param config_key the config key - * @param format the format - * @param type the type - * @param version the version - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//Called in Streams Object -public class Publishes { - - /** The config key. */ - private String config_key; - - /** The format. */ - private String format; - - /** The route. */ - private String route; - /** The type. */ - private String type; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java deleted file mode 100644 index 6d78805..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ReconfigsObj.java +++ /dev/null @@ -1,60 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new reconfigs obj. - */ -@NoArgsConstructor - -/** - * Instantiates a new reconfigs obj. - * - * @param dti the dti - * @param policy the policy - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -public class ReconfigsObj { - - /** The dti. */ - private String dti; - - /** The policy. */ - private String policy; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java deleted file mode 100644 index 7ca1830..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/RequestResponseObj.java +++ /dev/null @@ -1,43 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - - -// TODO: Auto-generated Javadoc -/** - * The Class RequestResponseObj. - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -//called in calls obj -public class RequestResponseObj { - - /** The format. */ - private String format; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java deleted file mode 100644 index 8b5f35e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Self.java +++ /dev/null @@ -1,70 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new self. - */ -@NoArgsConstructor - -/** - * Instantiates a new self. - * - * @param component_type the component type - * @param description the description - * @param name the name - * @param version the version - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//called in Component Spec object -public class Self { - - /** The component type. */ - private String component_type; - - /** The description. */ - private String description; - - /** The name. */ - private String name; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java deleted file mode 100644 index 772d859..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Services.java +++ /dev/null @@ -1,61 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new services. - */ -@NoArgsConstructor - -/** - * Instantiates a new services. - * - * @param calls the calls - * @param provides the provides - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -//called in component spec object -public class Services { - - /** The calls. */ - private CallsObj[] calls; - - /** The provides. */ - private ProvidesObj[] provides; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java deleted file mode 100644 index 500f32d..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Streams.java +++ /dev/null @@ -1,63 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new streams. - */ -@NoArgsConstructor - -/** - * Instantiates a new streams. - * - * @param publishes the publishes - * @param subscribes the subscribes - */ -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//Called in Component Spec Object -public class Streams { - - /** The publishes. */ - private Publishes[] publishes; - - /** The subscribes. */ - private Subscribes[] subscribes; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java deleted file mode 100644 index ec4aa41..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Subscribes.java +++ /dev/null @@ -1,77 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ - - -/** - * Instantiates a new subscribes. - */ -@NoArgsConstructor - -/** - * Instantiates a new subscribes. - * - * @param config_key the config key - * @param format the format - * @param route the route - * @param type the type - * @param version the version - */ - -@JsonInclude(value=Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -@EqualsAndHashCode -//Called in Streams Object -public class Subscribes { - - /** The config key. */ - private String config_key; - - /** The format. */ - private String format; - - /** The route. */ - private String route; - - /** The type. */ - private String type; - - /** The version. */ - private String version; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java deleted file mode 100644 index 777bdeb..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Volumes.java +++ /dev/null @@ -1,61 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.componentspec; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -// TODO: Auto-generated Javadoc -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -@Getter @Setter - -/* (non-Javadoc) - * @see java.lang.Object#toString() - */ -/** - * Instantiates a new volumes. - */ -@NoArgsConstructor - -/** - * Instantiates a new volumes. - * - * @param container the container - * @param host the host - */ -@JsonInclude(value=Include.NON_NULL) -@EqualsAndHashCode -//Called in Auxillary Object -public class Volumes { - - /** The container. */ - private Container container; - - /** The host. */ - private Host host; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java deleted file mode 100644 index da746a7..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java +++ /dev/null @@ -1,35 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 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.onap.blueprintgenerator.models.componentspec.policy_info; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.List; - -@Getter @Setter -@NoArgsConstructor -public class PolicyInfo { - - @JsonProperty("policy") - private List typePolicyList; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java deleted file mode 100644 index 038c601..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java +++ /dev/null @@ -1,36 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019-2020 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.onap.blueprintgenerator.models.componentspec.policy_info; - -import com.fasterxml.jackson.annotation.JsonCreator; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter @Setter -@NoArgsConstructor -public class TypePolicy { - - private String node_label; - private String policy_id; - private String policy_model_id; - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java deleted file mode 100644 index 0c8f8a9..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java +++ /dev/null @@ -1,126 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.dmaapbp; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.joinUnderscore; -import static org.onap.blueprintgenerator.models.blueprint.Imports.createDmaapImports; -import static org.onap.blueprintgenerator.models.blueprint.Imports.createImportsFromFile; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3; - -public class DmaapBlueprint extends Blueprint { - - private static final String TOPIC = "topic"; - private static final String FEED = "feed"; - - public Blueprint createDmaapBlueprint(ComponentSpec componentSpec, String importPath, String override) { - Blueprint blueprint = new Blueprint(); - - //set tosca definition - blueprint.setTosca_definitions_version(CLOUDIFY_DSL_1_3); - - //set the description - blueprint.setDescription(componentSpec.getSelf().getDescription()); - - //create the inpus object that will be added to over the creation of the blueprint - TreeMap> inps = new TreeMap<>(); - - //set the imports - if (importPath.equals("")) { - blueprint.setImports(createDmaapImports()); - } else { - blueprint.setImports(createImportsFromFile(importPath)); - } - - //set and create the node templates - TreeMap nodeTemplate = new TreeMap(); - - //create and add the main dmaap node - DmaapNode dmaap = new DmaapNode(); - inps = dmaap.createDmaapNode(componentSpec, inps, override); - nodeTemplate.put(componentSpec.getSelf().getName(), dmaap); - - //create and add the topic/feed nodes - - //go through the streams publishes - if (componentSpec.getStreams().getPublishes() != null) { - for (Publishes publisher : componentSpec.getStreams().getPublishes()) { - if (isMessageRouterType(publisher.getType())) { - String topic = joinUnderscore(publisher.getConfig_key(), TOPIC); - DmaapNode topicNode = new DmaapNode(); - inps = topicNode.createTopicNode(componentSpec, inps, topic); - nodeTemplate.put(topic, topicNode); - } else if (isDataRouterType(publisher.getType())) { - String feed = joinUnderscore(publisher.getConfig_key(), FEED); - DmaapNode feedNode = new DmaapNode(); - inps = feedNode.createFeedNode(componentSpec, inps, feed); - nodeTemplate.put(feed, feedNode); - } - } - } - //go through the stream subscribes - if (componentSpec.getStreams().getSubscribes() != null) { - for (Subscribes subscriber : componentSpec.getStreams().getSubscribes()) { - if (isMessageRouterType(subscriber.getType())) { - String topic = joinUnderscore(subscriber.getConfig_key(), TOPIC); - DmaapNode topicNode = new DmaapNode(); - inps = topicNode.createTopicNode(componentSpec, inps, topic); - nodeTemplate.put(topic, topicNode); - } else if (isDataRouterType(subscriber.getType())) { - String feed = joinUnderscore(subscriber.getConfig_key(), FEED); - DmaapNode feedNode = new DmaapNode(); - inps = feedNode.createFeedNode(componentSpec, inps, feed); - nodeTemplate.put(feed, feedNode); - } - } - } - - //if present in component spec, populate policyNodes information in the blueprint - if (componentSpec.getPolicyInfo() != null) { - PolicyNodeBuilder.addPolicyNodesAndInputs(componentSpec, nodeTemplate, inps); - } - - //if present in component spec, populate pgaasNodes information in the blueprint - if (componentSpec.getAuxilary().getDatabases() != null) { - PgaasNodeBuilder.addPgaasNodesAndInputs(componentSpec, nodeTemplate, inps); - } - - blueprint.setNode_templates(nodeTemplate); - - blueprint.setInputs(inps); - return blueprint; - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java deleted file mode 100644 index 515099a..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java +++ /dev/null @@ -1,185 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.dmaapbp; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.blueprint.Interfaces; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.Properties; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isMessageRouterType; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_EVENTS; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.PUBLISH_FILES; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES; - -@JsonIgnoreProperties(ignoreUnknown = true) -@Getter -@Setter -@EqualsAndHashCode(callSuper = false) -@NoArgsConstructor -@JsonInclude(value = Include.NON_NULL) - -public class DmaapNode extends Node { - - public TreeMap> createDmaapNode(ComponentSpec componentSpec, - TreeMap> inps, String override) { - TreeMap> retInputs = inps; - - //set the type - this.setType(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP); - - //create the interface - Interfaces inter = new Interfaces(); - retInputs = inter.createInterface(retInputs, componentSpec); - TreeMap interfaces = new TreeMap<>(); - interfaces.put("cloudify.interfaces.lifecycle", inter); - this.setInterfaces(interfaces); - - //create and set the relationships - ArrayList> relationships = new ArrayList<>(); - - //go through the streams publishes - if (componentSpec.getStreams().getPublishes() != null) { - for (Publishes publishes : componentSpec.getStreams().getPublishes()) { - relationships.add(createTypeAndTargetPubRelations(publishes)); - } - } - //go through the stream subscribes - if (componentSpec.getStreams().getSubscribes() != null) { - for (Subscribes subscribes : componentSpec.getStreams().getSubscribes()) { - relationships.add(createTypeAndTargetSubRelations(subscribes)); - } - } - - //add relationship for policy if exist - if (componentSpec.getPolicyInfo() != null) { - ArrayList> policyRelationshipsList = PolicyNodeBuilder - .getPolicyRelationships(componentSpec); - relationships.addAll(policyRelationshipsList); - } - - //add relationships and env_variables for pgaas dbs if exist - if (componentSpec.getAuxilary().getDatabases() != null) { - ArrayList> pgaasRelationshipsList = PgaasNodeBuilder - .getPgaasNodeRelationships(componentSpec); - relationships.addAll(pgaasRelationshipsList); - } - - this.setRelationships(relationships); - - //create and set the properties - Properties props = new Properties(); - retInputs = props.createDmaapProperties(retInputs, componentSpec, override); - this.setProperties(props); - - return retInputs; - } - - public TreeMap> createFeedNode(ComponentSpec cs, - TreeMap> inps, String name) { - TreeMap> retInputs = inps; - LinkedHashMap stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //set the type - this.setType(FEED); - - //create and set the properties - Properties props = new Properties(); - GetInput topicInput = new GetInput(); - topicInput.setBpInputName(name + "_name"); - props.setFeed_name(topicInput); - props.setUseExisting(true); - retInputs.put(name + "_name", stringType); - this.setProperties(props); - - return retInputs; - } - - public TreeMap> createTopicNode(ComponentSpec cs, - TreeMap> inps, String name) { - TreeMap> retInputs = inps; - LinkedHashMap stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //set the type - this.setType(TOPIC); - - //create and set the properties - Properties props = new Properties(); - GetInput topicInput = new GetInput(); - topicInput.setBpInputName(name + "_name"); - props.setTopic_name(topicInput); - //props.setUseExisting(true); - retInputs.put(name + "_name", stringType); - this.setProperties(props); - - return retInputs; - } - - private LinkedHashMap createTypeAndTargetPubRelations(Publishes publishes) { - LinkedHashMap pubRelations = new LinkedHashMap<>(); - if (isMessageRouterType(publishes.getType())) { - pubRelations.put("type", PUBLISH_EVENTS); - pubRelations.put("target", publishes.getConfig_key() + "_topic"); - } else if (isDataRouterType(publishes.getType())) { - pubRelations.put("type", PUBLISH_FILES); - pubRelations.put("target", publishes.getConfig_key() + "_feed"); - } - return pubRelations; - } - - private LinkedHashMap createTypeAndTargetSubRelations(Subscribes subscribes) { - LinkedHashMap subRelations = new LinkedHashMap<>(); - if (isMessageRouterType(subscribes.getType())) { - subRelations.put("type", SUBSCRIBE_TO_EVENTS); - subRelations.put("target", subscribes.getConfig_key() + "_topic"); - } else if (isDataRouterType(subscribes.getType())) { - subRelations.put("type", SUBSCRIBE_TO_FILES); - subRelations.put("target", subscribes.getConfig_key() + "_feed"); - } - return subRelations; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java deleted file mode 100644 index 162337e..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java +++ /dev/null @@ -1,123 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.dmaapbp; - -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; - -import lombok.Getter; -import lombok.Setter; - -import static org.onap.blueprintgenerator.common.blueprint.BlueprintHelper.isDataRouterType; - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) -public class DmaapStreams { - - private String name; - private GetInput location; - private GetInput client_role; - private String type; - - private GetInput username; - private GetInput password; - //private GetInput delivery_url; - - private GetInput privileged; - private GetInput decompress; - - private String route; - private String scheme; - - public TreeMap> createStreams( - TreeMap> inps, ComponentSpec cs, String name, String type, String key, - String route, char o) { - TreeMap> retInputs = inps; - LinkedHashMap stringType = new LinkedHashMap(); - stringType.put("type", "string"); - - //set the name - this.setName(name); - - //set the type - this.setType(type); - - //set the location - GetInput location = new GetInput(); - location.setBpInputName(key + "_" + name + "_location"); - retInputs.put(key + "_" + name + "_location", stringType); - this.setLocation(location); - - //if its data router we need to add some more - if (isDataRouterType(type)) { - if ('s' == o) { - //set the username - GetInput username = new GetInput(); - username.setBpInputName(key + "_" + name + "_username"); - this.setUsername(username); - retInputs.put(key + "_" + name + "_username", stringType); - - //set the password - GetInput password = new GetInput(); - password.setBpInputName(key + "_" + name + "_password"); - this.setPassword(password); - retInputs.put(key + "_" + name + "_password", stringType); - - //set privileged - GetInput priviliged = new GetInput(); - priviliged.setBpInputName(key + "_" + name + "_priviliged"); - this.setPrivileged(priviliged); - retInputs.put(key + "_" + name + "_priviliged", stringType); - - //set decompress - GetInput decompress = new GetInput(); - decompress.setBpInputName(key + "_" + name + "_decompress"); - this.setDecompress(decompress); - retInputs.put(key + "_" + name + "_decompress", stringType); - - this.setRoute(route); - this.setScheme("https"); - } - -// //set the delivery url -// GetInput delivery = new GetInput(); -// delivery.setGet_input(name + "_delivery_url"); -// this.setDelivery_url(delivery); -// retInputs.put(name + "delivery_url", stringType); - - } else { - //set the client role - GetInput client = new GetInput(); - client.setBpInputName(key + "_" + name + "_client_role"); - this.setClient_role(client); - retInputs.put(key + "_" + name + "_client_role", stringType); - } - return retInputs; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java deleted file mode 100644 index c9e531f..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/LogDirectory.java +++ /dev/null @@ -1,28 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.onapbp; - -import lombok.Getter; import lombok.Setter; - -@Getter @Setter -public class LogDirectory { - private Object log_directory; -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java deleted file mode 100644 index d9f3c16..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java +++ /dev/null @@ -1,95 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.onapbp; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CLOUDIFY_DSL_1_3; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.Imports; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - - -@Getter -@Setter -@JsonInclude(value = Include.NON_NULL) - -public class OnapBlueprint extends Blueprint { - - public Blueprint createOnapBlueprint(ComponentSpec cs, String importPath, String override) { - - //create the inputs that will be used - TreeMap> inputs = new TreeMap>(); - //set the tosca definition which is the same for everything - this.setTosca_definitions_version(CLOUDIFY_DSL_1_3); - - //set the imports - if (!"".equals(importPath)) { - Imports imps = new Imports(); - this.setImports(imps.createImportsFromFile(importPath)); - } else { - Imports imps = new Imports(); - this.setImports(imps.createOnapImports()); - } - - //create the node template - TreeMap nodeTemplate = new TreeMap(); - String nodeName = cs.getSelf().getName(); - - //create the onap node that will be used - OnapNode node = new OnapNode(); - inputs = node.createOnapNode(inputs, cs, override); - nodeTemplate.put(nodeName, node); - this.setNode_templates(nodeTemplate); - - //if present in component spec, populate policyNode information in the blueprint - if (cs.getPolicyInfo() != null) { - PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs); - } - - //if present in component spec, populate pgaasNodes information in the blueprint - if (cs.getAuxilary().getDatabases() != null) { - PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs); - } - - //set the inputs - this.setInputs(inputs); - - Blueprint bp = new Blueprint(); - bp.setImports(this.getImports()); - bp.setInputs(this.getInputs()); - bp.setNode_templates(this.getNode_templates()); - bp.setTosca_definitions_version(this.getTosca_definitions_version()); - - return bp; - - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java deleted file mode 100644 index 9daea56..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java +++ /dev/null @@ -1,94 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.onapbp; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.onap.blueprintgenerator.core.PgaasNodeBuilder; -import org.onap.blueprintgenerator.core.PolicyNodeBuilder; -import org.onap.blueprintgenerator.models.blueprint.Interfaces; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.Properties; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -@JsonIgnoreProperties(ignoreUnknown = true) -@Getter -@Setter -@EqualsAndHashCode(callSuper = false) -@NoArgsConstructor -@JsonInclude(value = Include.NON_NULL) - -public class OnapNode extends Node { - - public TreeMap> createOnapNode( - TreeMap> inps, ComponentSpec cs, String override) { - TreeMap> retInputs = new TreeMap>(); - retInputs = inps; - - //create and set the interfaces - Interfaces inter = new Interfaces(); - retInputs = inter.createInterface(retInputs, cs); - TreeMap interfaces = new TreeMap(); - interfaces.put("cloudify.interfaces.lifecycle", inter); - this.setInterfaces(interfaces); - - //set the type - this.setType(CONTENERIZED_SERVICE_COMPONENT); - - //create and set the relationships - ArrayList> rets = new ArrayList(); - - //add relationship for policy if exist - if (cs.getPolicyInfo() != null) { - ArrayList> policyRelationshipsList = PolicyNodeBuilder - .getPolicyRelationships(cs); - rets.addAll(policyRelationshipsList); - } - - //add relationships and env_variables for pgaas dbs if exist - if (cs.getAuxilary().getDatabases() != null) { - ArrayList> pgaasRelationshipsList = PgaasNodeBuilder - .getPgaasNodeRelationships(cs); - rets.addAll(pgaasRelationshipsList); - } - - this.setRelationships(rets); - - //set the properties - Properties props = new Properties(); - retInputs = props.createOnapProperties(retInputs, cs, override); - this.setProperties(props); - - return retInputs; - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java deleted file mode 100644 index 81bc440..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModel.java +++ /dev/null @@ -1,136 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.policymodel; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_SIMPLE_YAML; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Parameters; - -@Getter -@Setter -@JsonInclude(JsonInclude.Include.NON_NULL) - -public class PolicyModel { - - private String tosca_definition_version; - private TreeMap node_types; - private TreeMap data_types; - - public ArrayList createPolicyModels(ComponentSpec cs, String filePath) { - ArrayList models = new ArrayList(); - Parameters[] params = cs.getParameters(); - - ArrayList groups = new ArrayList(); - groups = getModelGroups(params); - - for (String s : groups) { - PolicyModel model = new PolicyModel(); - model = model.createPolicyModel(s, params); - //models.add(model); - policyModelToYaml(filePath, model, s); - } - -// for(PolicyModel p: models) { -// policyModelToYaml(filePath, p); -// } - - return models; - } - - public ArrayList getModelGroups(Parameters[] params) { - ArrayList groups = new ArrayList(); - - for (Parameters p : params) { - if (p.isPolicy_editable()) { - if (groups.isEmpty()) { - groups.add(p.getPolicy_group()); - } else { - if (!groups.contains(p.getPolicy_group())) { - groups.add(p.getPolicy_group()); - } - } - } - } - - return groups; - } - - public PolicyModel createPolicyModel(String s, Parameters[] params) { - PolicyModel model = new PolicyModel(); - model.setTosca_definition_version(TOSCA_SIMPLE_YAML); - - PolicyModelNode node = new PolicyModelNode(); - String hasEntryScheme = node.createNodeType(s, params); - String nodeTypeName = "onap.policy." + s; - TreeMap nodeType = new TreeMap(); - nodeType.put(nodeTypeName, node); - model.setNode_types(nodeType); - - if (!hasEntryScheme.equals("")) { - PolicyModelNode data = new PolicyModelNode(); - TreeMap dataType = data.createDataTypes(hasEntryScheme, params); - model.setData_types(dataType); - } - - return model; - } - - public void policyModelToYaml(String path, PolicyModel p, String name) { - File outputFile; - String filePath = path + "/" + name + ".yml"; - File policyFile = new File(filePath); - ObjectMapper policyMapper = new ObjectMapper( - new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); - outputFile = new File(path, name + ".yml"); - outputFile.getParentFile().mkdirs(); - - try { - PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true))); - } catch (IOException e) { - e.printStackTrace(); - } - - try { - policyMapper.writeValue(outputFile, p); - } catch (IOException e) { - e.printStackTrace(); - } - System.out.println("model " + name + " created"); - } -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java deleted file mode 100644 index 89321de..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyModelNode.java +++ /dev/null @@ -1,147 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - ================================================================================ - Modifications Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.policymodel; - -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_DATATYPES_ROOT; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOSCA_NODES_ROOT; - -import com.fasterxml.jackson.annotation.JsonInclude; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.TreeMap; -import lombok.Getter; -import lombok.Setter; -import org.onap.blueprintgenerator.models.componentspec.EntrySchemaObj; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.PolicySchemaObj; - -@Getter -@Setter -@JsonInclude(JsonInclude.Include.NON_NULL) -public class PolicyModelNode { - - private String derived_from; - private TreeMap properties; - - public String createNodeType(String policyName, Parameters[] params) { - String hasEntrySchema = ""; - - TreeMap props = new TreeMap(); - for (Parameters p : params) { - if (p.getPolicy_group() != null) { - if (p.getPolicy_group().equals(policyName)) { - String name = p.getName(); - String type = p.getType(); - PolicyProperties polProps = new PolicyProperties(); - if (p.getPolicy_schema() != null) { - polProps.setType("map"); - HashMap entrySchema = new HashMap(); - entrySchema.put("type", "onap.datatypes." + name); - //ArrayList entrySchema = new ArrayList(); - //entrySchema.add("type: onap.data." + name); - polProps.setEntry_schema(entrySchema); - hasEntrySchema = name; - props.put(name, polProps); - } else { - polProps.setType(type); - props.put(name, polProps); - } - } - } - } - - this.setDerived_from(TOSCA_DATATYPES_ROOT); - this.setProperties(props); - return hasEntrySchema; - } - - public TreeMap createDataTypes(String param, Parameters[] parameters) { - TreeMap dataType = new TreeMap(); - - PolicyModelNode node = new PolicyModelNode(); - node.setDerived_from(TOSCA_DATATYPES_ROOT); - - TreeMap properties = new TreeMap(); - - Parameters par = new Parameters(); - for (Parameters p : parameters) { - if (p.getName().equals(param)) { - par = p; - break; - } - } - - for (PolicySchemaObj pol : par.getPolicy_schema()) { - if (pol.getEntry_schema() != null) { - PolicyProperties prop = new PolicyProperties(); - prop.setType("map"); - HashMap schema = new HashMap(); - schema.put("type", "onap.datatypes." + pol.getName()); -// prop.setType("list"); -// ArrayList schema = new ArrayList(); -// schema.add("type: onap.data." + pol.getName()); - prop.setEntry_schema(schema); - properties.put(pol.getName(), prop); - dataType = translateEntrySchema(dataType, pol.getEntry_schema(), pol.getName()); - } else { - PolicyProperties prop = new PolicyProperties(); - prop.setType(pol.getType()); - properties.put(pol.getName(), prop); - } - } - - node.setProperties(properties); - dataType.put("onap.datatypes." + param, node); - return dataType; - } - - private TreeMap translateEntrySchema(TreeMap dataType, - EntrySchemaObj[] entry, String name) { - TreeMap data = dataType; - PolicyModelNode node = new PolicyModelNode(); - node.setDerived_from(TOSCA_NODES_ROOT); - TreeMap properties = new TreeMap(); - - for (EntrySchemaObj e : entry) { - if (e.getEntry_schema() != null) { - PolicyProperties prop = new PolicyProperties(); - prop.setType("list"); - ArrayList schema = new ArrayList(); - schema.add("type: onap.datatypes." + e.getName()); - prop.setEntry_schema(schema); - properties.put(e.getName(), prop); - data = translateEntrySchema(data, e.getEntry_schema(), e.getName()); - node.setProperties(properties); - } else { - PolicyProperties prop = new PolicyProperties(); - prop.setType(e.getType()); - properties.put(e.getName(), prop); - node.setProperties(properties); - } - } - - dataType.put("onap.datatypes." + name, node); - return data; - } - -} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java deleted file mode 100644 index 6faf78d..0000000 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/policymodel/PolicyProperties.java +++ /dev/null @@ -1,41 +0,0 @@ -/**============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 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.onap.blueprintgenerator.models.policymodel; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; - -import org.onap.blueprintgenerator.models.blueprint.Node; - -import com.fasterxml.jackson.annotation.JsonInclude; - -import lombok.Getter; -import lombok.Setter; - -@Getter @Setter -@JsonInclude(JsonInclude.Include.NON_NULL) -public class PolicyProperties { - - private String type; - private Object entry_schema; - -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java deleted file mode 100644 index b978701..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/BlueprintGeneratorTest.java +++ /dev/null @@ -1,286 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.core; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.GetInput; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.dmaapbp.DmaapNode; -import org.onap.blueprintgenerator.models.onapbp.OnapNode; -import org.onap.blueprintgenerator.models.policymodel.PolicyModel; -import picocli.CommandLine; - -// TODO: Auto-generated Javadoc - -/** - * The Class BlueprintGeneratorTest. - */ -public class BlueprintGeneratorTest { - - /** - * Component spec test. - * - */ - @Test - public void componentSpecTest() { - ComponentSpec spec = new ComponentSpec(); - TestComponentSpec test = new TestComponentSpec(); - spec.createComponentSpecFromString(test.getComponentSpecAsString()); - ComponentSpec expectedSpec = test.getComponentSpec(); - - assertEquals(expectedSpec.getSelf(), spec.getSelf()); - assertEquals(expectedSpec.getServices(), spec.getServices()); - assertEquals(expectedSpec.getStreams(), spec.getStreams()); - assertArrayEquals(expectedSpec.getParameters(), spec.getParameters()); - assertEquals(expectedSpec.getAuxilary(), spec.getAuxilary()); - assertArrayEquals(expectedSpec.getArtifacts(), spec.getArtifacts()); - } - - /** - * Tosca definition test. - */ - @Test - public void toscaDefinitionTest() { - ComponentSpec cs = new ComponentSpec(); - TestComponentSpec test = new TestComponentSpec(); - cs.createComponentSpecFromString(test.getComponentSpecAsString()); - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - assertEquals("cloudify_dsl_1_3", bp.getTosca_definitions_version()); - } - - /** - * Imports test. - */ - @Test - public void importsTest() { - ComponentSpec cs = new ComponentSpec(); - TestComponentSpec test = new TestComponentSpec(); - cs.createComponentSpecFromString(test.getComponentSpecAsString()); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - ArrayList imps = new ArrayList<>(); - imps.add("https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml"); - imps.add("plugin:k8splugin?version=3.4.2"); - imps.add("plugin:dcaepolicyplugin?version=2.4.0"); - assertEquals(imps, bp.getImports()); - } - - @Test - public void inputTest() { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - TreeMap> inputs = new TreeMap<>(); - - //mr inputs - LinkedHashMap stringType = new LinkedHashMap<>(); - stringType.put("type", "string"); - - //necessary inputs - LinkedHashMap tag = new LinkedHashMap<>(); - tag.put("type", "string"); - String tester = "test.tester"; - tag.put("default", '"' + tester + '"'); - inputs.put("tag_version", tag); - - inputs.put("log_directory", stringType); - - LinkedHashMap cert = new LinkedHashMap<>(); - cert.put("type", "string"); - cert.put("default", ""); - inputs.put("cert_directory", cert); - - LinkedHashMap env = new LinkedHashMap<>(); - env.put("default", "{}"); - inputs.put("envs", env); - - LinkedHashMap port = new LinkedHashMap<>(); - port.put("type", "string"); - port.put("description", "Kubernetes node port on which collector is exposed"); - port.put("default", "99"); - inputs.put("external_port", port); - - LinkedHashMap rep = new LinkedHashMap<>(); - rep.put("type", "integer"); - rep.put("description", "number of instances"); - rep.put("default", 1); - inputs.put("replicas", rep); - - LinkedHashMap aaf = new LinkedHashMap<>(); - aaf.put("type", "boolean"); - aaf.put("default", false); - inputs.put("use_tls", aaf); - - //parmaeter input - LinkedHashMap test = new LinkedHashMap<>(); - test.put("type", "string"); - String testParam = "test-param-1"; - test.put("default", '"' + testParam + '"'); - inputs.put("testParam1", test); - - //mr/dr inputs - inputs.put("TEST-PUB-DR_feed0_client_role", stringType); - inputs.put("TEST-PUB-DR_feed0_password", stringType); - inputs.put("TEST-PUB-DR_feed0_username", stringType); - inputs.put("TEST-PUB-MR_topic1_aaf_password", stringType); - inputs.put("TEST-PUB-MR_topic1_aaf_username", stringType); - inputs.put("TEST-PUB-MR_topic1_client_role", stringType); - inputs.put("TEST-SUB-DR_feed1_client_role", stringType); - inputs.put("TEST-SUB-DR_feed1_password", stringType); - inputs.put("TEST-SUB-DR_feed1_username", stringType); - inputs.put("TEST-SUB-MR_topic0_client_role", stringType); - inputs.put("TEST-SUB-MR_topic2_aaf_password", stringType); - inputs.put("TEST-SUB-MR_topic2_aaf_username", stringType); - inputs.put("namespace", stringType); - inputs.put("idn_fqdn", cert); - inputs.put("feed0_name", stringType); - inputs.put("feed1_name", stringType); - inputs.put("topic0_name", stringType); - inputs.put("topic1_name", stringType); - - LinkedHashMap cpu = new LinkedHashMap<>(); - cpu.put("type", "string"); - cpu.put("default", "250m"); - inputs.put("test.component.spec_cpu_limit", cpu); - inputs.put("test.component.spec_cpu_request", cpu); - - LinkedHashMap mem = new LinkedHashMap<>(); - mem.put("type", "string"); - mem.put("default", "128Mi"); - inputs.put("test.component.spec_memory_limit", mem); - inputs.put("test.component.spec_memory_request", mem); - } - - @Test - public void interfaceTest() { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec"); - - OnapNode testNode = new OnapNode(); - - //set the type - testNode.setType("dcae.nodes.ContainerizedServiceComponent"); - - ArrayList ports = new ArrayList<>(); - ports.add("concat: [\"80:\", {get_input: external_port }]"); - ports.add("concat: [\"99:\", {get_input: external_port }]"); - } - - @Test - public void parametersTest() { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec"); - - GetInput par = (GetInput) node.getProperties().getApplication_config().getParams().get("testParam1"); - assertEquals("testParam1", par.getBpInputName()); - } - - @Test - public void streamPublishesTest() { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'o', "", ""); - - OnapNode node = (OnapNode) bp.getNode_templates().get("test.component.spec"); - - assertFalse(node.getProperties().getApplication_config().getStreams_publishes().isEmpty()); - } - - @Test - public void dmaapPluginTest() { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", 'd', "", ""); - - DmaapNode dmaap = (DmaapNode) bp.getNode_templates().get("test.component.spec"); - - //check if the stream publishes and subscribes are not null to see if the dmaap plugin was invoked properly - assertNotNull(dmaap.getProperties().getStreams_publishes()); - assertNotNull(dmaap.getProperties().getStreams_subscribes()); - } - - @Test - public void testPrintInstructionsBlueprintCommand() { - BlueprintCommand objUnderTest = new BlueprintCommand(); - CommandLine cli = new CommandLine(objUnderTest); - PrintStream mockStdOutWriter = Mockito.mock(PrintStream.class); - ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); - cli.usage(mockStdOutWriter); - verify(mockStdOutWriter, times(1)).print(any(Object.class)); - - } - - @Test - public void testPrintInstructionsPolicyCommand() { - PolicyCommand objUnderTest = new PolicyCommand(); - CommandLine cli = new CommandLine(objUnderTest); - PrintStream mockStdOutWriter = Mockito.mock(PrintStream.class); - ArgumentCaptor captor = ArgumentCaptor.forClass(String.class); - cli.usage(mockStdOutWriter); - verify(mockStdOutWriter, times(1)).print(any(Object.class)); - } - - @Test - public void testPolicyModels() { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - PolicyModel p = new PolicyModel(); - p.createPolicyModels(cs, "TestModels"); - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java deleted file mode 100644 index 8adf03d..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/core/TlsInfoTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.core; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.tls.TlsInfo; -import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificateParameters; -import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalTlsInfo; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -@RunWith(Parameterized.class) -public class TlsInfoTest { - - @Parameterized.Parameter - public char bpType; - - @Parameterized.Parameters(name = "Blueprint type: {0}") - public static List data() { - return Arrays.asList('o', 'd'); - } - - @Test - public void useTlsTrueAndUseExternalTlsTrueTest(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsTrueAndExternalTlsTrue.json"); - - assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, true); - assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true); - } - - @Test - public void useTlsFalseAndUseExternalTlsFalseTest(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsFalseAndExternalTlsFalse.json"); - - assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(bp, false); - assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, false); - } - - @Test - public void useTlsTrueAndNoExternalTlsFlagTest(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withTlsTrueAndNoExternalTls.json"); - - assertBlueprintContainsTlsInfoWithUseFlagDefault(bp, true); - assertBlueprintHasNoExternalTlsInfo(bp); - } - - @Test - public void noTlsInfo(){ - Blueprint bp = createBlueprintFromFile("TestCases/TlsInfo/testComponentSpec_withoutTlsInfo.json"); - - assertBlueprintHasNoTlsInfo(bp); - assertBlueprintHasNoExternalTlsInfo(bp); - } - - private void assertBlueprintContainsExternalTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) { - //should create proper inputs - assertContainsInputWithDefault(bp, "external_cert_use_external_tls", useFlagDefault); - assertContainsInputWithDefault(bp, "external_cert_ca_name", "\"RA\""); - assertContainsInputWithDefault(bp, "external_cert_cert_type", "\"P12\""); - assertContainsInputWithDefault(bp, "external_cert_common_name", "\"sample.onap.org\""); - assertContainsInputWithDefault(bp, "external_cert_sans", - "\"sample.onap.org:component.sample.onap.org\""); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should create proper externalTlsInfo object in node properties - ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert(); - assertNotNull(externalTlsInfo); - - assertEquals("external_cert_ca_name", externalTlsInfo.getCaName().getBpInputName()); - assertEquals("external_cert_cert_type", externalTlsInfo.getCertType().getBpInputName()); - assertEquals("external_cert_use_external_tls", externalTlsInfo.getUseExternalTls().getBpInputName()); - assertEquals("/opt/app/dcae-certificate/", externalTlsInfo.getExternalCertDirectory()); - - ExternalCertificateParameters extCertParams = externalTlsInfo.getExternalCertificateParameters(); - assertNotNull(extCertParams); - - assertEquals("external_cert_common_name", extCertParams.getCommonName().getBpInputName()); - assertEquals("external_cert_sans", extCertParams.getSans().getBpInputName()); - } - - private void assertBlueprintContainsTlsInfoWithUseFlagDefault(Blueprint bp, boolean useFlagDefault) { - //shold create proper inputs - assertContainsInputWithDefault(bp, "use_tls", useFlagDefault); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should create proper tlsInfo object in node properties - TlsInfo tlsInfo = node.getProperties().getTls_info(); - assertEquals("use_tls", tlsInfo.getUseTls().getBpInputName()); - assertEquals("/opt/app/dcae-certificate/", tlsInfo.getCertDirectory()); - - } - - private void assertBlueprintHasNoExternalTlsInfo(Blueprint bp) { - //should not create inputs for external tls - assertFalse(bp.getInputs().containsKey("external_cert_use_external_tls")); - assertFalse(bp.getInputs().containsKey("external_cert_common_name")); - assertFalse(bp.getInputs().containsKey("external_cert_ca_name")); - assertFalse(bp.getInputs().containsKey("external_cert_sans")); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should not create externalTlsInfo object in node properties - ExternalTlsInfo externalTlsInfo = node.getProperties().getExternal_cert(); - assertNull(externalTlsInfo); - } - - - private void assertBlueprintHasNoTlsInfo(Blueprint bp) { - //should not create inputs for tls - assertFalse(bp.getInputs().containsKey("use_tls")); - - Node node = bp.getNode_templates().get("test.component.spec"); - - //should not create tlsInfo object in node properties - assertNull(node.getProperties().getTls_info()); - } - - private void assertContainsInputWithDefault(Blueprint bp, String inputName, Object defaultValue) { - LinkedHashMap input = bp.getInputs().get(inputName); - assertNotNull(input); - assertEquals(defaultValue, input.get("default")); - } - - private Blueprint createBlueprintFromFile(String path) { - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile(path); - - Blueprint bp = new Blueprint(); - bp = bp.createBlueprint(cs, "", this.bpType, "", ""); - return bp; - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java deleted file mode 100644 index 173d230..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/AppconfigTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import static org.junit.Assert.assertEquals; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; -import java.util.TreeMap; -import java.util.stream.Collectors; -import org.junit.Test; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - -public class AppconfigTest { - - @Test - public void createAppconfigShouldReturnExpectedResult() throws FileNotFoundException { - TreeMap> inputs = new TreeMap>(); - ComponentSpec cs = new ComponentSpec(); - cs.createComponentSpecFromFile("TestCases/testComponentSpec.json"); - - TreeMap> result = new Appconfig().createAppconfig(inputs, cs, "", false); - - assertEquals(getExpectedStringFromFile(), result.toString()); - } - - private String getExpectedStringFromFile() throws FileNotFoundException { - File file = new File("TestCases/expects/createAppConfigResult.txt"); - InputStream inputStream = new FileInputStream(file); - return readFromInputStream(inputStream); - } - - private String readFromInputStream(InputStream inputStream) { - return new BufferedReader( - new InputStreamReader(inputStream, StandardCharsets.UTF_8)) - .lines() - .collect(Collectors.joining("")); - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java deleted file mode 100644 index 1ce296a..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ImportsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia 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.onap.blueprintgenerator.models.blueprint; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.junit.Test; - -public class ImportsTest { - - private final List expectedImports = Arrays.asList( - "https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml", - "plugin:k8splugin?version=3.4.1", - "plugin:pgaas?version=1.3.0", - "plugin:clamppolicyplugin?version=1.1.0", - "plugin:dmaap?version=1.5.0" - ); - - @Test - public void shouldReadImportsFromFile() { - ArrayList importsFromFile = Imports.createImportsFromFile("TestCases/imports/imports.yaml"); - assertEquals(expectedImports, importsFromFile); - } - - @Test - public void shouldRemoveBlankImportsFromFile() { - ArrayList importsFromFile = - Imports.createImportsFromFile("TestCases/imports/importsWithBlanks.yaml"); - assertEquals(expectedImports, importsFromFile); - } - -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java deleted file mode 100644 index cf12da1..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfigTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.blueprint; - -import static org.junit.Assert.assertEquals; - -import java.util.LinkedHashMap; -import java.util.TreeMap; -import org.junit.Test; - -public class ResourceConfigTest { - - @Test - public void createResourceConfig() { - TreeMap> result = new ResourceConfig() - .createResourceConfig(new TreeMap<>(), "demo"); - - String expectedResult = "{demo_cpu_limit={type=string, default=250m}, demo_cpu_request={type=string, default=250m}, demo_memory_limit={type=string, default=128Mi}, demo_memory_request={type=string, default=128Mi}}"; - assertEquals(expectedResult, result.toString()); - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java deleted file mode 100644 index 1cdb58b..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/blueprint/tls/ExternalCertificateParametersFactoryTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia 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.onap.blueprintgenerator.models.blueprint.tls; - -import org.junit.Test; -import org.onap.blueprintgenerator.models.blueprint.tls.impl.ExternalCertificateParameters; - -import java.util.LinkedHashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.COMMON_NAME_FIELD; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_COMMON_NAME; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.DEFAULT_SANS; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.INPUT_PREFIX; -import static org.onap.blueprintgenerator.models.blueprint.tls.TlsConstants.SANS_FIELD; - -public class ExternalCertificateParametersFactoryTest { - - private static final String PREFIXED_COMMON_NAME_FIELD = INPUT_PREFIX + COMMON_NAME_FIELD; - private static final String PREFIXED_SANS_FIELD = INPUT_PREFIX + SANS_FIELD; - private static final String DEFAULT = "default"; - - @Test - public void shouldCreateExternalCertificatePropertiesObject() { - // given - ExternalCertificateParametersFactory cut = new ExternalCertificateParametersFactory(); - // when - ExternalCertificateParameters result = cut.create(); - // then - assertEquals(result.getCommonName().getBpInputName(), PREFIXED_COMMON_NAME_FIELD); - assertEquals(result.getSans().getBpInputName(), PREFIXED_SANS_FIELD); - } - - @Test - public void shouldCreateCorrectInputListWithDefaultValuesTakenFromComponentSpec() { - // given - ExternalCertificateParametersFactory cut = new ExternalCertificateParametersFactory(); - // when - Map> result = cut.createInputList(); - // then - assertEquals(DEFAULT_COMMON_NAME, result.get(PREFIXED_COMMON_NAME_FIELD).get(DEFAULT)); - assertEquals(DEFAULT_SANS, result.get(PREFIXED_SANS_FIELD).get(DEFAULT)); - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java deleted file mode 100644 index 9e31002..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprintTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.dmaapbp; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - -import java.util.ArrayList; -import java.util.List; -import org.junit.Test; -import org.onap.blueprintgenerator.models.blueprint.Blueprint; -import org.onap.blueprintgenerator.models.componentspec.Artifacts; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Parameters; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Self; -import org.onap.blueprintgenerator.models.componentspec.Streams; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -public class DmaapBlueprintTest { - - private static final String MOCKED_NAME = "sample.name"; - private static final String MESSAGE_ROUTER_TYPE_1 = "message_router"; - private static final String MESSAGE_ROUTER_TYPE_2 = "message router"; - private static final String DATA_ROUTER_TYPE_1 = "data_router"; - private static final String DATA_ROUTER_TYPE_2 = "data router"; - private static final String CONFIG_KEY_1 = "Configkey1"; - private static final String CONFIG_KEY_2 = "Configkey2"; - - private static final String TOPIC_NODE_1 = CONFIG_KEY_1 + "_topic"; - private static final String TOPIC_NODE_2 = CONFIG_KEY_2 + "_topic"; - private static final String FEED_NODE_1 = CONFIG_KEY_1 + "_feed"; - private static final String FEED_NODE_2 = CONFIG_KEY_2 + "_feed"; - - private static final String SAMPLE_FORMAT = "Format"; - private static final String SAMPLE_VERSION = "1.0.0"; - private static final String SAMPLE_ROUTE = "SampleRoute"; - private static final String SAMPLE_DESCRIPTION = "sample description"; - private static final String SAMPLE_PORTS = "8080:8080"; - private static final String SAMPLE_ARTIFACT_TYPE = "test"; - private static final String SAMPLE_ARTIFACT_URI = "test_uri"; - - @Test - public void dmaapBlueprintShouldHaveNodeTemplateWithDmaapNode() { - - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertTrue(resultBlueprint.getNode_templates().get(MOCKED_NAME) instanceof DmaapNode); - } - - @Test - public void nodeTemplateHasTopicNodeWhenAddMessageRouterAsPublishes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(getMessageRouterPublishes()); - streams.setSubscribes(new Subscribes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_2)); - - } - - @Test - public void nodeTemplateHasTopicNodeWhenAddMessageRouterAsSubscribes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(new Publishes[0]); - streams.setSubscribes(getMessageRouterSubscribes()); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(TOPIC_NODE_2)); - - } - - @Test - public void nodeTemplateHasFeedNodeWhenAddDataRouterAsPublishes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(getDataRouterPublishes()); - streams.setSubscribes(new Subscribes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_2)); - - } - - @Test - public void nodeTemplateHasFeedNodeWhenAddDataRouterAsSubscribes() { - //given - ComponentSpec componentSpec = getMockedComponentSpec(); - Streams streams = new Streams(); - streams.setPublishes(new Publishes[0]); - streams.setSubscribes(getDataRouterSubscribes()); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapBlueprint dmaapBlueprint = new DmaapBlueprint(); - - //when - Blueprint resultBlueprint = dmaapBlueprint.createDmaapBlueprint(componentSpec, "", ""); - - //then - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_1)); - assertNotNull(resultBlueprint.getNode_templates().get(FEED_NODE_2)); - - } - - private Publishes[] getMessageRouterPublishes() { - List publishesList = new ArrayList<>(); - - publishesList.add(createSamplePublishes(MESSAGE_ROUTER_TYPE_1, CONFIG_KEY_1)); - publishesList.add(createSamplePublishes(MESSAGE_ROUTER_TYPE_2, CONFIG_KEY_2)); - return publishesList.toArray(new Publishes[0]); - } - - private Subscribes[] getMessageRouterSubscribes() { - List subscribesList = new ArrayList<>(); - - subscribesList.add(createSampleSubscribes(MESSAGE_ROUTER_TYPE_1, CONFIG_KEY_1)); - subscribesList.add(createSampleSubscribes(MESSAGE_ROUTER_TYPE_2, CONFIG_KEY_2)); - return subscribesList.toArray(new Subscribes[0]); - } - - private Publishes[] getDataRouterPublishes() { - List publishesList = new ArrayList<>(); - - publishesList.add(createSamplePublishes(DATA_ROUTER_TYPE_1, CONFIG_KEY_1)); - publishesList.add(createSamplePublishes(DATA_ROUTER_TYPE_2, CONFIG_KEY_2)); - return publishesList.toArray(new Publishes[0]); - } - - private Subscribes[] getDataRouterSubscribes() { - List subscribesList = new ArrayList<>(); - - subscribesList.add(createSampleSubscribes(DATA_ROUTER_TYPE_1, CONFIG_KEY_1)); - subscribesList.add(createSampleSubscribes(DATA_ROUTER_TYPE_2, CONFIG_KEY_2)); - return subscribesList.toArray(new Subscribes[0]); - } - - private Publishes createSamplePublishes(String type, String key) { - Publishes publishes = new Publishes(); - - publishes.setType(type); - publishes.setConfig_key(key); - publishes.setFormat(SAMPLE_FORMAT); - publishes.setVersion(SAMPLE_VERSION); - publishes.setRoute(SAMPLE_ROUTE); - - return publishes; - } - - private Subscribes createSampleSubscribes(String type, String key) { - Subscribes subscribes = new Subscribes(); - - subscribes.setType(type); - subscribes.setConfig_key(key); - subscribes.setFormat(SAMPLE_FORMAT); - subscribes.setVersion(SAMPLE_FORMAT); - subscribes.setRoute(SAMPLE_ROUTE); - - return subscribes; - } - - private ComponentSpec getMockedComponentSpec() { - Self self = mock(Self.class); - when(self.getDescription()).thenReturn(SAMPLE_DESCRIPTION); - when(self.getName()).thenReturn(MOCKED_NAME); - - Auxilary auxilary = mock(Auxilary.class); - ArrayList ports = new ArrayList<>(); - ports.add(SAMPLE_PORTS); - when(auxilary.getPorts()).thenReturn(ports); - - Streams streams = mock(Streams.class); - when(streams.getPublishes()).thenReturn(new Publishes[0]); - when(streams.getSubscribes()).thenReturn(new Subscribes[0]); - - Artifacts artifact = new Artifacts(); - artifact.setType(SAMPLE_ARTIFACT_TYPE); - artifact.setUri(SAMPLE_ARTIFACT_URI); - - Artifacts[] arrayArtifacts = new Artifacts[10]; - arrayArtifacts[0] = artifact; - - ComponentSpec componentSpec = mock(ComponentSpec.class); - when(componentSpec.getSelf()).thenReturn(self); - when(componentSpec.getAuxilary()).thenReturn(auxilary); - when(componentSpec.getStreams()).thenReturn(streams); - when(componentSpec.getArtifacts()).thenReturn(arrayArtifacts); - when(componentSpec.getParameters()).thenReturn(new Parameters[0]); - when(componentSpec.getSelfName()).thenReturn(MOCKED_NAME); - return componentSpec; - } -} diff --git a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java b/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java deleted file mode 100644 index 83419e5..0000000 --- a/mod/bpgenerator/src/test/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNodeTest.java +++ /dev/null @@ -1,224 +0,0 @@ -/*============LICENSE_START======================================================= - org.onap.dcae - ================================================================================ - Copyright (c) 2020 Nokia. 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.onap.blueprintgenerator.models.dmaapbp; - -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.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.FEED; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_EVENTS; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.SUBSCRIBE_TO_FILES; -import static org.onap.blueprintgenerator.models.blueprint.BpConstants.TOPIC; - -import java.util.Map; -import java.util.TreeMap; -import org.junit.Test; -import org.onap.blueprintgenerator.core.TestComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Auxilary; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.Publishes; -import org.onap.blueprintgenerator.models.componentspec.Streams; -import org.onap.blueprintgenerator.models.componentspec.Subscribes; - -public class DmaapNodeTest { - - private static final String DATA_ROUTER_TYPE = "data_router"; - private static final String MESSAGE_ROUTER_TYPE = "message_router"; - - private static final String CONFIG_KEY = "Configkey"; - - private static final String SAMPLE_FORMAT = "Format"; - private static final String SAMPLE_VERSION = "1.0.0"; - private static final String SAMPLE_ROUTE = "SampleRoute"; - private static final String TYPE = "type"; - private static final String TARGET = "target"; - - - @Test - public void dmaapNodeShouldHaveExpectedNodeType() { - - ComponentSpec mockedComponentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(mockedComponentSpec, new TreeMap<>(), ""); - - assertEquals(CONTENERIZED_SERVICE_COMPONENT_USING_DMAAP, dmaapNode.getType()); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForMessageRouterPublishes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(new Subscribes[0]); - streams.setPublishes(createSamplePublishes(MESSAGE_ROUTER_TYPE)); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map relationship = dmaapNode.getRelationships().get(0); - - assertNotNull(relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForDataRouterPublishes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(new Subscribes[0]); - streams.setPublishes(createSamplePublishes(DATA_ROUTER_TYPE)); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map relationship = dmaapNode.getRelationships().get(0); - - assertNotNull(relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForMessageRouterSubscribes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(createSampleSubscribes(MESSAGE_ROUTER_TYPE)); - streams.setPublishes(new Publishes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map relationship = dmaapNode.getRelationships().get(0); - - assertEquals(SUBSCRIBE_TO_EVENTS, relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createdDmaapNodeShouldHaveRelationshipWithTypeAndTargetForDataRouterSubscribes() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - Streams streams = new Streams(); - streams.setSubscribes(createSampleSubscribes(DATA_ROUTER_TYPE)); - streams.setPublishes(new Publishes[0]); - - when(componentSpec.getStreams()).thenReturn(streams); - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createDmaapNode(componentSpec, new TreeMap<>(), ""); - - Map relationship = dmaapNode.getRelationships().get(0); - - assertEquals(SUBSCRIBE_TO_FILES, relationship.get(TYPE)); - assertNotNull(relationship.get(TARGET)); - } - - @Test - public void createFeedNodeShouldSetFeedNodeType() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createFeedNode(componentSpec, new TreeMap<>(), ""); - - assertEquals(FEED, dmaapNode.getType()); - } - - @Test - public void feedNodePropertiesShouldHaveUseExistingField() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createFeedNode(componentSpec, new TreeMap<>() ,""); - - assertTrue(dmaapNode.getProperties().getUseExisting()); - } - - @Test - public void createTopicNodeShouldSetTopicNodeType() { - - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createTopicNode(componentSpec, new TreeMap<>(), ""); - - assertEquals(TOPIC, dmaapNode.getType()); - } - - @Test - public void topicNodePropertiesShouldNotHaveUseExistingField() { - ComponentSpec componentSpec = getSpiedComponentSpecWithoutRelationships(); - - DmaapNode dmaapNode = new DmaapNode(); - dmaapNode.createTopicNode(componentSpec, new TreeMap<>() ,""); - - assertNull(dmaapNode.getProperties().getUseExisting()); - } - - private Publishes[] createSamplePublishes(String type) { - Publishes publishes = new Publishes(); - - publishes.setType(type); - publishes.setConfig_key(CONFIG_KEY); - publishes.setFormat(SAMPLE_FORMAT); - publishes.setVersion(SAMPLE_VERSION); - publishes.setRoute(SAMPLE_ROUTE); - - return new Publishes[]{publishes}; - } - - private Subscribes[] createSampleSubscribes(String type) { - Subscribes subscribes = new Subscribes(); - - subscribes.setType(type); - subscribes.setConfig_key(CONFIG_KEY); - subscribes.setFormat(SAMPLE_FORMAT); - subscribes.setVersion(SAMPLE_VERSION); - subscribes.setRoute(SAMPLE_ROUTE); - - return new Subscribes[]{subscribes}; - } - - private ComponentSpec getSpiedComponentSpecWithoutRelationships() { - ComponentSpec baseComponentSpec = new ComponentSpec(); - baseComponentSpec.createComponentSpecFromString(new TestComponentSpec().getComponentSpecAsString()); - ComponentSpec componentSpec = spy(baseComponentSpec); - - Streams streams = new Streams(); - streams.setSubscribes(new Subscribes[0]); - streams.setPublishes(new Publishes[0]); - when(componentSpec.getStreams()).thenReturn(streams); - - Auxilary auxilary = spy(baseComponentSpec.getAuxilary()); - when(auxilary.getDatabases()).thenReturn(null); - - when(componentSpec.getAuxilary()).thenReturn(auxilary); - when(componentSpec.getPolicyInfo()).thenReturn(null); - - return componentSpec; - } -} diff --git a/mod/bpgenerator/version.properties b/mod/bpgenerator/version.properties deleted file mode 100644 index eabef1f..0000000 --- a/mod/bpgenerator/version.properties +++ /dev/null @@ -1,6 +0,0 @@ -major=1 -minor=6 -patch=0 -base_version=${major}.${minor}.${patch} -release_version=${base_version} -snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg