diff options
140 files changed, 2733 insertions, 2888 deletions
@@ -8,7 +8,7 @@ project_lead: &onap_releng_ptl email: 'dtimoney@att.com' id: 'djtimoney' company: 'ATT' - timezone: 'America/New York' + timezone: 'America/New_York' primary_contact: *onap_releng_ptl issue_tracking: type: 'jira' @@ -33,12 +33,12 @@ committers: email: 'jflucas@research.att.com' company: 'ATT' id: 'jackl' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Jun (Nicolas) Hu' email: 'jh245g@att.com' company: 'ATT' id: 'jh245g' - timezone: 'America/New York' + timezone: 'America/New_York' - name: 'Gaurav Agrawal' email: 'gaurav.agrawal@huawei.com' company: 'Huawei' @@ -48,21 +48,9 @@ committers: email: 'brindasanth@in.ibm.com' company: 'IBM' id: 'brindasanthm' - timezone: 'America/New York' + timezone: 'America/New_York' repositories: - - ccsdk-apps - - ccsdk-cds - - ccsdk-distribution - - ccsdk-features - - ccsdk-parent - - ccsdk-platform-blueprints - - ccsdk-platform-plugins - - ccsdk-sli-adaptors - - ccsdk-sli-core - - ccsdk-sli-northbound - - ccsdk-sli-plugins - - ccsdk-storage-esaas - - ccsdk-utils + - ccsdk/cds tsc: approval: 'https://lists.onap.org/pipermail/onap-tsc' changes: diff --git a/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts b/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts index 08c76df5b..fd7af89ba 100644 --- a/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts +++ b/cds-ui/client/src/app/common/shared/pipes/search.pipe.ts @@ -31,8 +31,8 @@ export class SearchPipe implements PipeTransform{ if(!searchText) return items; searchText = searchText.toLowerCase(); return items.filter( it => { - if(it.tags) { - return it.tags.toLowerCase().includes(searchText); + if(it.name) { + return it.name.toLowerCase().includes(searchText); } else { return items; } diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html index 9cab6c44d..5c8435160 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html @@ -39,6 +39,7 @@ limitations under the License. <mat-card-content class="card-content"> {{option.blueprintModel.artifactName}} <br>{{option.blueprintModel.updatedBy}} + <br>{{option.blueprintModel.artifactVersion}} </mat-card-content> <mat-card-actions class="flexBox"> <button matStepperNext mat-menu-item (click)="editCBA(option.blueprintModel.artifactName,option.blueprintModel.artifactVersion,1)">Edit</button> diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss index f84213f48..158a5cf54 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.scss @@ -62,7 +62,7 @@ button.mat-menu-item { } .searchcontainer { - min-height: 300px; + // min-height: 300px; overflow-x: hidden; overflow-y: scroll; } diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts index 1341b8bd1..58ed036aa 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts @@ -93,11 +93,9 @@ export class SearchFromDatabaseComponent implements OnInit { .then(blob => { const formData = new FormData(); formData.append("file", blob); - // this.editorService.enrich("/enrich-blueprint/", formData) this.searchService.getBlueprintZip(artifactName + "/" + artifactVersion) .subscribe( (response) => { - // console.log(response); this.zipFile.files = {}; this.zipFile.loadAsync(response) .then((zip) => { @@ -105,7 +103,7 @@ export class SearchFromDatabaseComponent implements OnInit { this.buildFileViewData(zip); } }); - // this.alertService.success('Blueprint enriched successfully'); + }, (error) => { this.alertService.error('Blue print error' + error.message); @@ -116,12 +114,9 @@ export class SearchFromDatabaseComponent implements OnInit { async buildFileViewData(zip) { this.validfile = false; this.paths = []; - // console.log(zip.files); for (var file in zip.files) { console.log("name: " + zip.files[file].name); this.fileObject = { - // nameForUIDisplay: this.uploadedFileName + '/' + zip.files[file].name, - // name: zip.files[file].name, name: this.uploadedFileName + '/' + zip.files[file].name, data: '' }; diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts index ee6e9631e..ed01e63b2 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts @@ -99,7 +99,7 @@ export class SearchTemplateComponent implements OnInit { entryDefinition: this.entryDefinition } this.store.dispatch(new SetBlueprintState(blueprintState)) - // this.store.dispatch(new LoadBlueprintSuccess(data)); + } async buildFileViewData(zip) { diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts index a4e30a494..d79f9d870 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.module.ts @@ -26,7 +26,6 @@ import { SearchTemplateComponent } from './search-template.component'; import { ReactiveFormsModule } from '@angular/forms'; import { AppMaterialModule } from 'src/app/common/modules/app-material.module'; import { SharedModule} from 'src/app/common/shared/shared.module'; -// import { SelectTemplateService } from 'src/app/feature-modules/blueprint/select-template/select-template.service'; @NgModule({ declarations: [ @@ -42,6 +41,6 @@ import { SharedModule} from 'src/app/common/shared/shared.module'; SearchTemplateComponent, SearchFromDatabaseComponent ], - // providers:[ SelectTemplateService] + }) export class SearchTemplateModule { } diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/data_types.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/data_types.json index 8c304c40b..b7109251e 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/data_types.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/data_types.json @@ -1,3 +1,448 @@ { - "data_types" : { } + "data_types" : { + "dt-resource-assignment-properties" : { + "description" : "Dynamic DataType definition for workflow(resource-assignment).", + "version" : "1.0.0", + "properties" : { + "nf-role" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "default" : "vSN", + "entry_schema" : { + "type" : "" + } + }, + "vm-type" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vnf-id" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "public_net_id" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "value" : "public_net_id", + "default" : "public_net_id", + "entry_schema" : { + "type" : "" + } + }, + "vnf_name" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vfw_private_ip_1" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "unprotected-prefix-id" : { + "description" : "", + "required" : false, + "type" : "integer", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "onap_private_subnet_id" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vfw_private_ip_0" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "aic-cloud-region" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "sec_group" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "default" : "onap_sg_PUhf", + "entry_schema" : { + "type" : "" + } + }, + "vfw_private_ip_2" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vnfc-model-invariant-uuid" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "nfc-naming-code" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "private-prefix-id" : { + "description" : "", + "required" : false, + "type" : "integer", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf-module-model-customization-uuid" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vfw_name_0" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf_module_name" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "nexus_artifact_repo" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "value" : "nexus_artifact_repo", + "default" : "nexus_artifact_repo", + "entry_schema" : { + "type" : "" + } + }, + "onap_private_net_cidr" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "image_name" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf-nf-code" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf-module-id" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf-module-label" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vsn_private_ip_0" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vpg_name_0" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vpg_private_ip_1" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "protected_private_net_cidr" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf-naming-policy" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "default" : "SDNC_Policy.Config_MS_ONAP_VSN_NAMING_TIMESTAMP", + "entry_schema" : { + "type" : "" + } + }, + "vpg_private_ip_0" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vsn_private_ip_1" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vfccustomizationuuid" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "unprotected_private_net_cidr" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vsn_name_0" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "onap_private_net_id" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vnfc-model-version" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "service-instance-id" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vf-module-type" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vnf-model-customization-uuid" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "pub_key" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "key_name" : { + "description" : "", + "required" : false, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "protected-prefix-id" : { + "description" : "", + "required" : false, + "type" : "integer", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + }, + "vnf-name" : { + "description" : "", + "required" : true, + "type" : "string", + "status" : "", + "constraints" : [ { } ], + "entry_schema" : { + "type" : "" + } + } + }, + "derived_from" : "tosca.datatypes.Dynamic" + } + } }
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/node_types.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/node_types.json index 599e37704..e812db1cf 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/node_types.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/node_types.json @@ -24,6 +24,12 @@ "required" : false, "type" : "string" }, + "occurrence" : { + "description" : "Number of time to perform the resolution.", + "required" : false, + "type" : "integer", + "default" : 1 + }, "store-result" : { "description" : "Whether or not to store the output.", "required" : false, @@ -115,18 +121,6 @@ }, "derived_from" : "tosca.nodes.ResourceSource" }, - "source-default" : { - "description" : "This is Default Resource Source Node Type", - "version" : "1.0.0", - "properties" : { }, - "derived_from" : "tosca.nodes.ResourceSource" - }, - "source-input" : { - "description" : "This is Input Resource Source Node Type", - "version" : "1.0.0", - "properties" : { }, - "derived_from" : "tosca.nodes.ResourceSource" - }, "source-db" : { "description" : "This is Database Resource Source Node Type", "version" : "1.0.0", @@ -136,7 +130,8 @@ "type" : "string", "constraints" : [ { "valid_values" : [ "SQL", "PLSQL" ] - } ] + } ], + "default" : "SQL" }, "endpoint-selector" : { "required" : false, @@ -170,6 +165,18 @@ }, "derived_from" : "tosca.nodes.ResourceSource" }, + "source-default" : { + "description" : "This is Default Resource Source Node Type", + "version" : "1.0.0", + "properties" : { }, + "derived_from" : "tosca.nodes.ResourceSource" + }, + "source-input" : { + "description" : "This is Input Resource Source Node Type", + "version" : "1.0.0", + "properties" : { }, + "derived_from" : "tosca.nodes.ResourceSource" + }, "source-rest" : { "description" : "This is Rest Resource Source Node Type", "version" : "1.0.0", @@ -250,4 +257,4 @@ "derived_from" : "tosca.nodes.Root" } } -} +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/resources_definition_types.json index 1a62972ca..240624094 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/resources_definition_types.json @@ -81,15 +81,30 @@ "description" : "nexus_artifact_repo", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, "default" : { "type" : "source-default", "properties" : { } }, - "input" : { - "type" : "source-input", - "properties" : { } + "sdnc" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/nexus_artifact_repo", + "path" : "/param/0/value", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "nexus_artifact_repo" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } } } }, @@ -129,11 +144,19 @@ "description" : "nfc-naming-code", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", "input-key-mapping" : { @@ -154,13 +177,38 @@ "description" : "onap_private_net_cidr", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, + "sdnc" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/onap_private_net_cidr", + "path" : "/param/0/value", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "onap_private_net_cidr" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private\"", + "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"management\"", + "input-key-mapping" : { }, "output-key-mapping" : { "onap_private_net_cidr" : "prefix" } @@ -175,11 +223,15 @@ "description" : "onap_private_net_id", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { "input" : { "type" : "source-input" }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "sdnc" : { "type" : "source-rest", "properties" : { @@ -205,11 +257,15 @@ "description" : "onap_private_subnet_id", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { "input" : { "type" : "source-input" }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "sdnc" : { "type" : "source-rest", "properties" : { @@ -235,13 +291,22 @@ "description" : "private-prefix-id", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private\"", + "input-key-mapping" : { }, "output-key-mapping" : { "private-prefix-id" : "prefix_id" } @@ -298,11 +363,15 @@ "description" : "pub_key", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { "input" : { "type" : "source-input" }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "sdnc" : { "type" : "source-rest", "properties" : { @@ -328,14 +397,30 @@ "description" : "public_net_id", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, "default" : { "type" : "source-default", "properties" : { } }, - "input" : { - "type" : "source-input" + "sdnc" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/public_net_id", + "path" : "/param/0/value", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "public_net_id" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } } } }, @@ -346,15 +431,30 @@ "description" : "sec_group", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, "default" : { "type" : "source-default", "properties" : { } }, - "input" : { - "type" : "source-input", - "properties" : { } + "sdnc" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/sec_group", + "path" : "/param/0/value", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "sec_group" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } } } }, @@ -465,8 +565,15 @@ "description" : "vf-module-label", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { @@ -490,10 +597,13 @@ "description" : "vf-module-model-customization-uuid", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { "input" : { - "type" : "source-input", + "type" : "source-input" + }, + "default" : { + "type" : "source-default", "properties" : { } } } @@ -593,17 +703,25 @@ } }, "vfccustomizationuuid" : { - "tags" : "vfccustomizationuuid, tosca.datatypes.Root, data_type", + "tags" : "vfccustomizationuuid", "name" : "vfccustomizationuuid", "property" : { "description" : "vfccustomizationuuid", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", "input-key-mapping" : { @@ -717,11 +835,19 @@ "description" : "vm-type", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", "query" : "select VFC_MODEL.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", "input-key-mapping" : { @@ -742,11 +868,30 @@ "description" : "vnf-id", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { "input" : { - "type" : "source-input", + "type" : "source-input" + }, + "default" : { + "type" : "source-default", "properties" : { } + }, + "sdnc" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf-id", + "path" : "/param/0/value", + "input-key-mapping" : { + "service-instance-id" : "service-instance-id", + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vnf-id" : "value" + }, + "key-dependencies" : [ "service-instance-id", "vnf-id" ] + } } } }, @@ -766,29 +911,51 @@ } }, "vnf-name" : { - "tags" : "vnf-name, tosca.datatypes.Root, data_type", + "tags" : "vnf-name", "name" : "vnf-name", "property" : { "description" : "vnf-name", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "sdnc" : { "type" : "source-rest", "properties" : { "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-name/vnf-data/vnf-topology/vnf-parameters-data/param/vnf-name", "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", "input-key-mapping" : { "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" + "vnf-name" : "vnf-name" }, "output-key-mapping" : { "vnf-name" : "value" }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] + "key-dependencies" : [ "service-instance-id", "vnf-name" ] + } + }, + "aai-data" : { + "type" : "source-rest", + "properties" : { + "type" : "JSON", + "verb" : "GET", + "url-path" : "/aai/v14/network/generic-vnfs/generic-vnf/$vnf-id", + "path" : "", + "input-key-mapping" : { + "vnf-id" : "vnf-id" + }, + "output-key-mapping" : { + "vnf-name" : "vnf-name" + }, + "key-dependencies" : [ "vnf-id" ] } } } @@ -832,14 +999,22 @@ "tags" : "vnfc-model-invariant-uuid", "name" : "vnfc-model-invariant-uuid", "property" : { - "description" : "vnfc-model-invariant-uuid for SRIOV VPE template", + "description" : "vnfc-model-invariant-uuid", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", "query" : "select VFC_MODEL.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", "input-key-mapping" : { @@ -857,14 +1032,22 @@ "tags" : "vnfc-model-version", "name" : "vnfc-model-version", "property" : { - "description" : "vnfc-model-version for SRIOV VPE template", + "description" : "vnfc-model-version", "type" : "string" }, - "updated-by" : "Singal, Kapil <ks220y@att.com>", + "updated-by" : "MALAKOV, YURIY <yuriy.malakov@att.com>", "sources" : { + "input" : { + "type" : "source-input" + }, + "default" : { + "type" : "source-default", + "properties" : { } + }, "processor-db" : { "type" : "source-db", "properties" : { + "endpoint-selector" : "dynamic-db-source", "type" : "SQL", "query" : "select VFC_MODEL.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", "input-key-mapping" : { @@ -1001,4 +1184,4 @@ } } } -} +}
\ No newline at end of file diff --git a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json index a4d90adfe..9ff4f3a1f 100644 --- a/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json +++ b/components/model-catalog/blueprint-model/service-blueprint/vFW/Definitions/vFW_spinup.json @@ -1,19 +1,31 @@ { - "metadata": { - "template_author": "Alexis de Talhouët", - "author-email": "adetalhouet89@gmail.com", - "user-groups": "ADMIN, OPERATION", - "template_name": "vFW_spinup", - "template_version": "1.0.0", - "template_tags": "vFW" + "tosca_definitions_version" : "controller_blueprint_1_0_0", + "metadata" : { + "template_author" : "Alexis de Talhouët", + "author-email" : "adetalhouet89@gmail.com", + "user-groups" : "ADMIN, OPERATION", + "template_name" : "vFW_spinup", + "template_version" : "1.0.0", + "template_tags" : "vFW" }, - "topology_template": { - "workflows": { - "resource-assignment": { - "steps": { - "resource-assignment": { - "description": "Resource Assign Workflow", - "target": "resource-assignment" + "imports" : [ { + "file" : "Definitions/data_types.json" + }, { + "file" : "Definitions/relationship_types.json" + }, { + "file" : "Definitions/artifact_types.json" + }, { + "file" : "Definitions/node_types.json" + }, { + "file" : "Definitions/policy_types.json" + } ], + "topology_template" : { + "workflows" : { + "resource-assignment" : { + "steps" : { + "resource-assignment" : { + "description" : "Resource Assign Workflow", + "target" : "resource-assignment" } }, "inputs" : { @@ -23,22 +35,24 @@ "entry_schema" : { "type" : "string" } + }, + "resource-assignment-properties" : { + "description" : "Dynamic PropertyDefinition for workflow(resource-assignment).", + "required" : true, + "type" : "dt-resource-assignment-properties" } }, - "outputs": { - "meshed-template": { - "type": "json", - "value": { - "get_attribute": [ - "resource-assignment", - "assignment-params" - ] + "outputs" : { + "meshed-template" : { + "type" : "json", + "value" : { + "get_attribute" : [ "resource-assignment", "assignment-params" ] } } } } }, - "node_templates": { + "node_templates" : { "resource-assignment" : { "type" : "component-resource-resolution", "interfaces" : { @@ -54,46 +68,46 @@ } } }, - "artifacts": { - "base-template": { - "type": "artifact-template-velocity", - "file": "Templates/base-template.vtl" + "artifacts" : { + "base-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/base-template.vtl" }, - "base-mapping": { - "type": "artifact-mapping-resource", - "file": "Templates/base-mapping.json" + "base-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/base-mapping.json" }, - "vfw-template": { - "type": "artifact-template-velocity", - "file": "Templates/vfw-template.vtl" + "vfw-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/vfw-template.vtl" }, - "vfw-mapping": { - "type": "artifact-mapping-resource", - "file": "Templates/vfw-mapping.json" + "vfw-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/vfw-mapping.json" }, - "vfw-vnf-template": { - "type": "artifact-template-velocity", - "file": "Templates/vfw-vnf-template.vtl" + "vfw-vnf-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/vfw-vnf-template.vtl" }, - "vfw-vnf-mapping": { - "type": "artifact-mapping-resource", - "file": "Templates/vfw-vnf-mapping.json" + "vfw-vnf-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/vfw-vnf-mapping.json" }, - "vpg-template": { - "type": "artifact-template-velocity", - "file": "Templates/vpg-template.vtl" + "vpg-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/vpg-template.vtl" }, - "vpg-mapping": { - "type": "artifact-mapping-resource", - "file": "Templates/vpg-mapping.json" + "vpg-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/vpg-mapping.json" }, - "vsn-template": { - "type": "artifact-template-velocity", - "file": "Templates/vsn-template.vtl" + "vsn-template" : { + "type" : "artifact-template-velocity", + "file" : "Templates/vsn-template.vtl" }, - "vsn-mapping": { - "type": "artifact-mapping-resource", - "file": "Templates/vsn-mapping.json" + "vsn-mapping" : { + "type" : "artifact-mapping-resource", + "file" : "Templates/vsn-mapping.json" } } } diff --git a/components/model-catalog/blueprint-model/uat-blueprints/echo/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/echo/Tests/uat.yaml index 116230929..5036a6fa2 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/echo/Tests/uat.yaml +++ b/components/model-catalog/blueprint-model/uat-blueprints/echo/Tests/uat.yaml @@ -26,9 +26,3 @@ processes: message: success payload: echo-response: {} - stepData: - name: echo - properties: - resource-assignment-params: - echo: *message - status: success diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml index 3a5903c49..fbdb2eea8 100644 --- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml +++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Tests/uat.yaml @@ -31,32 +31,6 @@ processes: message: success payload: config-assign-response: {} - stepData: - name: config-assign - properties: - resource-assignment-params: - config-assign: &assignPatch - ietf-restconf:yang-patch: - patch-id: patch-1 - edit: - - edit-id: edit1 - operation: merge - target: / - value: { netconflist: { netconf: [ { netconf-id: "10", netconf-param: "1000" }]}} - - edit-id: edit2 - operation: merge - target: / - value: { netconflist: { netconf: [ { netconf-id: "20", netconf-param: "2000" }]}} - - edit-id: edit3 - operation: merge - target: / - value: { netconflist: { netconf: [ { netconf-id: "30", netconf-param: "3000" }]}} - status: success - responseNormalizerSpec: - stepData: - properties: - resource-assignment-params: - config-assign: ?from-json(.stepData.properties.resource-assignment-params.config-assign) - name: config-deploy request: commonHeader: *commonHeader @@ -84,11 +58,6 @@ processes: errorMessage: null eventType: EVENT_COMPONENT_EXECUTED message: success - stepData: - name: config-deploy - properties: - response-data: "" - status: success external-services: - selector: sdncodl @@ -127,7 +96,22 @@ external-services: path: [*configUri, *configletResourcePath] headers: Content-Type: application/yang.patch+json - body: *assignPatch + body: + ietf-restconf:yang-patch: + patch-id: patch-1 + edit: + - edit-id: edit1 + operation: merge + target: / + value: { netconflist: { netconf: [ { netconf-id: "10", netconf-param: "1000" }]}} + - edit-id: edit2 + operation: merge + target: / + value: { netconflist: { netconf: [ { netconf-id: "20", netconf-param: "2000" }]}} + - edit-id: edit3 + operation: merge + target: / + value: { netconflist: { netconf: [ { netconf-id: "30", netconf-param: "3000" }]}} - request: method: DELETE path: *configUri diff --git a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto index 3349443d4..2e0693c28 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto @@ -1,29 +1,62 @@ syntax = "proto3"; +import "google/protobuf/struct.proto"; import "BluePrintCommon.proto"; option java_multiple_files = true; package org.onap.ccsdk.cds.controllerblueprints.management.api; message BluePrintUploadInput { - org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; - FileChunk fileChunk = 2; + org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; + FileChunk fileChunk = 2; + org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers actionIdentifiers = 3; + // Extra optional dynamic properties used during upload. + google.protobuf.Struct properties = 4; +} + +message BluePrintDownloadInput { + org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; + org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers actionIdentifiers = 2; + // Extra optional dynamic properties used to download. + google.protobuf.Struct properties = 3; } message BluePrintRemoveInput { - org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; + org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; + string blueprintName = 2; + string blueprintVersion = 3; } message BluePrintManagementOutput { - org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; - org.onap.ccsdk.cds.controllerblueprints.common.api.Status status = 3; + org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; + // Optional file chunk sent back to the client for Enrich and Download this is mandatory. + FileChunk fileChunk = 2; + org.onap.ccsdk.cds.controllerblueprints.common.api.Status status = 3; + // Extra optional dynamic properties. + google.protobuf.Struct properties = 4; } message FileChunk { - bytes chunk = 1; + bytes chunk = 1; +} +// Values used in BluePrintDownloadInput/actionIdentifiers/action +enum DownloadAction { + // Default is SEARCH the cba and download the cba + SEARCH = 0; + // Download the starter cba with corresponding property options + STARTER = 1; + // clone cba with corresponding property options + CLONE = 2; +} + +enum UploadAction { + // Default is DRAFT + DRAFT = 0; + ENRICH = 1; + VALIDATE = 2; + PUBLISH = 3; } service BluePrintManagementService { - rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintManagementOutput); - rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintManagementOutput); + rpc downloadBlueprint (BluePrintDownloadInput) returns (BluePrintManagementOutput); + rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintManagementOutput); + rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintManagementOutput); } diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/processor-db-source.json b/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json index c946165bf..ce062726a 100644 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/processor-db-source.json +++ b/components/model-catalog/resource-dictionary/starter-dictionary/db-source.json @@ -1,5 +1,5 @@ { - "name": "processor-db-source", + "name": "db-source", "property" :{ "description": "name of the ", "type": "string" diff --git a/docs/designtime.rst b/docs/designtime.rst index 20a03efbc..68da0a1f6 100644 --- a/docs/designtime.rst +++ b/docs/designtime.rst @@ -5,29 +5,27 @@ Design Time User Guide ====================== -Bellow are the requirements to enable automation for a service within ONAP. +Below are the requirements to enable automation for a service within ONAP. For instantiation, the goal is to be able to automatically resolve all the HEAT/Helm variables, called cloud parameters. For post-instantiation, the goal is to configure the VNF with initial configuration. Prerequisite -============ +------------ * Gather the cloud parameters: instantiation: +~~~~~~~~~~~~~~ -Have the HEAT template along with the HEAT environment file. - -or - -Have the Helm chart along with the Values.yaml file +Have the HEAT template along with the HEAT environment file (or) Have the Helm chart along with the Values.yaml file (CDS supports, but whether SO → Multicloud support for Helm/K8S is different story) Post-instantiation: +~~~~~~~~~~~~~~~~~~~ Have the configuration template to apply on the VNF. @@ -35,9 +33,8 @@ Have the configuration template to apply on the VNF. * JSON / XML for RESTCONF * not supported yet - CLI * JSON for Ansible [not supported yet] - -*Identify which template parameters are static and dynamic -*Create and fill-in the a table for all the dynamic values +* Identify which template parameters are static and dynamic +* Create and fill-in the a table for all the dynamic values While doing so, identify the resources using the same process to be resolved; for instance, if two IPs has to be resolved through the same IPAM, the process the resolve the IP is the same. @@ -51,6 +48,3 @@ Services: CBA/index datadictionary/index resourceassignment - component - template - resquirement diff --git a/docs/index.rst b/docs/index.rst index 183bbbf9f..0e43fd51c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -96,14 +96,12 @@ Library ~~~~~~~ * NetconfClient -~~~~~~~~~~~~~~~ In order to facilitate NETCONF interaction within scripts, a python NetconfClient binded to our Kotlin implementation is made available. This NetconfClient can be used when using the component-netconf-executor. The client can be find here: https://github.com/onap/ccsdk-cds/blob/master/components/scripts/python/ccsdk_netconf/netconfclient.py * ResolutionHelper -~~~~~~~~~~~~~~~~~~ When executing a component executor script, designer might want to perform resource resolution along with template meshing directly from the script @@ -126,7 +124,8 @@ User Guide .. toctree:: :maxdepth: 1 - userguide + installation + designtime Controller Design Studio Presentation diff --git a/docs/installation.rst b/docs/installation.rst index ac72b425f..2f9ce48e7 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -3,19 +3,19 @@ .. Copyright (C) 2019 IBM. Installation -============ +------------ ONAP is meant to be deployed within a Kubernetes environment. Hence, the de-facto way to deploy CDS is through Kubernetes. ONAP also package Kubernetes manifest as Chart, using Helm. Prerequisite -============ +------------ https://docs.onap.org/en/latest/guides/onap-developer/settingup/index.html Setup local Helm -================ +---------------- helm repo @@ -23,7 +23,7 @@ helm repo * helm repo add local http://127.0.0.1:8879 Get the chart -============= +------------- Make sure to checkout the release to use, by replacing $release-tag in bellow command @@ -33,31 +33,34 @@ cd oom/kubernetes make cds Install CDS -=========== +----------- helm install --name cds cds Result -====== - -$ kubectl get all --selector=release=cds -NAME READY STATUS RESTARTS AGE -pod/cds-blueprints-processor-54f758d69f-p98c2 0/1 Running 1 2m -pod/cds-cds-6bd674dc77-4gtdf 1/1 Running 0 2m -pod/cds-cds-db-0 1/1 Running 0 2m -pod/cds-controller-blueprints-545bbf98cf-zwjfc 1/1 Running 0 2m -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -service/blueprints-processor ClusterIP 10.43.139.9 <none> 8080/TCP,9111/TCP 2m -service/cds NodePort 10.43.254.69 <none> 3000:30397/TCP 2m -service/cds-db ClusterIP None <none> 3306/TCP 2m -service/controller-blueprints ClusterIP 10.43.207.152 <none> 8080/TCP 2m -NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE -deployment.apps/cds-blueprints-processor 1 1 1 0 2m -deployment.apps/cds-cds 1 1 1 1 2m -deployment.apps/cds-controller-blueprints 1 1 1 1 2m -NAME DESIRED CURRENT READY AGE -replicaset.apps/cds-blueprints-processor-54f758d69f 1 1 0 2m -replicaset.apps/cds-cds-6bd674dc77 1 1 1 2m -replicaset.apps/cds-controller-blueprints-545bbf98cf 1 1 1 2m -NAME DESIRED CURRENT AGE -statefulset.apps/cds-cds-db 1 1 2m
\ No newline at end of file +------ + +.. code-block:: json + :linenos: + + $ kubectl get all --selector=release=cds + NAME READY STATUS RESTARTS AGE + pod/cds-blueprints-processor-54f758d69f-p98c2 0/1 Running 1 2m + pod/cds-cds-6bd674dc77-4gtdf 1/1 Running 0 2m + pod/cds-cds-db-0 1/1 Running 0 2m + pod/cds-controller-blueprints-545bbf98cf-zwjfc 1/1 Running 0 2m + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE + service/blueprints-processor ClusterIP 10.43.139.9 <none> 8080/TCP,9111/TCP 2m + service/cds NodePort 10.43.254.69 <none> 3000:30397/TCP 2m + service/cds-db ClusterIP None <none> 3306/TCP 2m + service/controller-blueprints ClusterIP 10.43.207.152 <none> 8080/TCP 2m + NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE + deployment.apps/cds-blueprints-processor 1 1 1 0 2m + deployment.apps/cds-cds 1 1 1 1 2m + deployment.apps/cds-controller-blueprints 1 1 1 1 2m + NAME DESIRED CURRENT READY AGE + replicaset.apps/cds-blueprints-processor-54f758d69f 1 1 0 2m + replicaset.apps/cds-cds-6bd674dc77 1 1 1 2m + replicaset.apps/cds-controller-blueprints-545bbf98cf 1 1 1 2m + NAME DESIRED CURRENT AGE + statefulset.apps/cds-cds-db 1 1 2m
\ No newline at end of file diff --git a/docs/userguide.rst b/docs/userguide.rst deleted file mode 100644 index fcc1b8882..000000000 --- a/docs/userguide.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. This work is licensed under a Creative Commons Attribution 4.0 International License. -.. http://creativecommons.org/licenses/by/4.0 -.. Copyright (C) 2019 IBM. - -User guide ----------- - -.. toctree:: - :maxdepth: 1 - - installation - designtime - diff --git a/ms/blueprintsprocessor/application/opt/app/onap/config/application.properties b/ms/blueprintsprocessor/application/opt/app/onap/config/application.properties deleted file mode 100755 index e69de29bb..000000000 --- a/ms/blueprintsprocessor/application/opt/app/onap/config/application.properties +++ /dev/null diff --git a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties index 019c5aabc..2fd595102 100755 --- a/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties +++ b/ms/blueprintsprocessor/application/src/main/resources/application-dev.properties @@ -99,10 +99,15 @@ blueprintsprocessor.cliExecutor.enabled=true blueprintprocessor.remoteScriptCommand.enabled=false # Kafka-message-lib Configurations -blueprintsprocessor.messageclient.self-service-api.topic=producer.t -blueprintsprocessor.messageclient.self-service-api.type=kafka-basic-auth -blueprintsprocessor.messageclient.self-service-api.bootstrapServers=127.0.0.1:9092 -blueprintsprocessor.messageclient.self-service-api.consumerTopic=receiver.t -blueprintsprocessor.messageclient.self-service-api.groupId=receiver-id -blueprintsprocessor.messageclient.self-service-api.clientId=default-client-id -blueprintsprocessor.messageclient.self-service-api.kafkaEnable=false +blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable=false +blueprintsprocessor.messageconsumer.self-service-api.type=kafka-basic-auth +blueprintsprocessor.messageconsumer.self-service-api.bootstrapServers=127.0.0.1:9092 +blueprintsprocessor.messageconsumer.self-service-api.groupId=receiver-id +blueprintsprocessor.messageconsumer.self-service-api.topic=receiver.t +blueprintsprocessor.messageconsumer.self-service-api.clientId=default-client-id +blueprintsprocessor.messageconsumer.self-service-api.pollMillSec=1000 + +blueprintsprocessor.messageproducer.self-service-api.type=kafka-basic-auth +blueprintsprocessor.messageproducer.self-service-api.bootstrapServers=127.0.0.1:9092 +blueprintsprocessor.messageproducer.self-service-api.clientId=default-client-id +blueprintsprocessor.messageproducer.self-service-api.topic=producer.t
\ No newline at end of file diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties index 4a4f79459..75d9cbaad 100755 --- a/ms/blueprintsprocessor/application/src/main/resources/application.properties +++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties @@ -92,10 +92,15 @@ blueprintsprocessor.restclient.aai-data.username=aai@aai.onap.org blueprintsprocessor.restclient.aai-data.password=demo123456! # Kafka-message-lib Configuration -blueprintsprocessor.messageclient.self-service-api.topic=producer.t -blueprintsprocessor.messageclient.self-service-api.type=kafka-basic-auth -blueprintsprocessor.messageclient.self-service-api.bootstrapServers=127.0.0.1:9092 -blueprintsprocessor.messageclient.self-service-api.consumerTopic=receiver.t -blueprintsprocessor.messageclient.self-service-api.groupId=receiver-id -blueprintsprocessor.messageclient.self-service-api.clientId=default-client-id -blueprintsprocessor.messageclient.self-service-api.kafkaEnable=false +blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable=false +blueprintsprocessor.messageconsumer.self-service-api.type=kafka-basic-auth +blueprintsprocessor.messageconsumer.self-service-api.bootstrapServers=127.0.0.1:9092 +blueprintsprocessor.messageconsumer.self-service-api.topic=receiver.t +blueprintsprocessor.messageconsumer.self-service-api.groupId=receiver-id +blueprintsprocessor.messageconsumer.self-service-api.clientId=default-client-id +blueprintsprocessor.messageconsumer.self-service-api.pollMillSec=1000 + +blueprintsprocessor.messageproducer.self-service-api.type=kafka-basic-auth +blueprintsprocessor.messageproducer.self-service-api.bootstrapServers=127.0.0.1:9092 +blueprintsprocessor.messageproducer.self-service-api.clientId=default-client-id +blueprintsprocessor.messageproducer.self-service-api.topic=producer.t diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt index eafcaf44b..180ad7b48 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutor.kt @@ -15,9 +15,10 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor +package org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots import com.github.fge.jsonpatch.diff.JsonDiff +import org.apache.logging.log4j.util.Strings import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.ResourceConfigSnapshot import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.ResourceConfigSnapshot.Status.RUNNING @@ -144,18 +145,20 @@ open class ComponentConfigSnapshotsExecutor(private val cfgSnapshotService: Reso */ private suspend fun compareConfigurationSnapshot(resourceId: String, resourceType: String, contentType : String) { + val cfgRunning = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, RUNNING) + val cfgCandidate = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, CANDIDATE) + + if (cfgRunning.isEmpty() || cfgCandidate.isEmpty()) { + setNodeOutputProperties(OUTPUT_STATUS_SUCCESS, Strings.EMPTY) + return + } + when (contentType.toUpperCase()) { DIFF_JSON -> { - val cfgRunning = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, RUNNING) - val cfgCandidate = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, CANDIDATE) - val patchNode = JsonDiff.asJson(cfgRunning.jsonAsJsonType(), cfgCandidate.jsonAsJsonType()) setNodeOutputProperties(OUTPUT_STATUS_SUCCESS, patchNode.toString()) } DIFF_XML -> { - val cfgRunning = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, RUNNING) - val cfgCandidate = cfgSnapshotService.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, CANDIDATE) - val myDiff = DiffBuilder .compare(Input.fromString(cfgRunning)) .withTest(Input.fromString(cfgCandidate)) diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt index 50c90f332..5fcba5b0c 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotService.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import org.apache.logging.log4j.util.Strings import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.ResourceConfigSnapshot.Status.RUNNING import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.slf4j.LoggerFactory @@ -40,7 +41,7 @@ class ResourceConfigSnapshotService(private val repository: ResourceConfigSnapsh status : ResourceConfigSnapshot.Status = RUNNING): String = withContext(Dispatchers.IO) { repository.findByResourceIdAndResourceTypeAndStatus(resourceId, resourceType, status) - ?.config_snapshot ?: throw NoSuchElementException() + ?.config_snapshot ?: Strings.EMPTY } suspend fun write(snapshot: String, resId: String, resType: String, diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt index 79dd93037..c212908b9 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/ComponentConfigSnapshotsExecutorTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor +package org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots import com.fasterxml.jackson.databind.JsonNode import kotlinx.coroutines.runBlocking @@ -27,11 +27,12 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.db.BluePrintDBLibConfiguration -import org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor.ComponentConfigSnapshotsExecutor.Companion.DIFF_JSON -import org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor.ComponentConfigSnapshotsExecutor.Companion.DIFF_XML -import org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor.ComponentConfigSnapshotsExecutor.Companion.OPERATION_DIFF -import org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor.ComponentConfigSnapshotsExecutor.Companion.OPERATION_FETCH -import org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor.ComponentConfigSnapshotsExecutor.Companion.OPERATION_STORE +import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor +import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.DIFF_JSON +import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.DIFF_XML +import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.OPERATION_DIFF +import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.OPERATION_FETCH +import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.ComponentConfigSnapshotsExecutor.Companion.OPERATION_STORE import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.ResourceConfigSnapshot import org.onap.ccsdk.cds.blueprintsprocessor.functions.config.snapshots.db.ResourceConfigSnapshotService import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException @@ -192,9 +193,7 @@ class ComponentConfigSnapshotsExecutorTest { return@runBlocking } - // then; we should get error and the PAYLOAD payload in our output properties - assertTrue( bluePrintRuntimeService.getBluePrintError().errors.size > 0 ) - assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_ERROR.asJsonPrimitive(), + assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_SUCCESS.asJsonPrimitive(), bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName, ComponentConfigSnapshotsExecutor.OUTPUT_STATUS)) } @@ -234,7 +233,10 @@ class ComponentConfigSnapshotsExecutorTest { runBlocking { // when; asking for unknown content type diff operation; should get an error response try { - prepareRequestProperties(OPERATION_DIFF, "asdasd", "PNF", "YANG") + val resId = "121111" + val resType = "PNF" + cfgSnapshotService.write("snapshotConfig", resId, resType, ResourceConfigSnapshot.Status.CANDIDATE) + prepareRequestProperties(OPERATION_DIFF, resId, resType, "YANG") cfgSnapshotComponent.processNB(executionRequest) @@ -245,7 +247,6 @@ class ComponentConfigSnapshotsExecutorTest { } // then; we should get error in our output properties - assertTrue( bluePrintRuntimeService.getBluePrintError().errors.size == 1 ) assertEquals(ComponentConfigSnapshotsExecutor.OUTPUT_STATUS_ERROR.asJsonPrimitive(), bluePrintRuntimeService.getNodeTemplateAttributeValue(nodeTemplateName, ComponentConfigSnapshotsExecutor.OUTPUT_STATUS)) diff --git a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt index 2830cb547..3c989c154 100644 --- a/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt +++ b/ms/blueprintsprocessor/functions/config-snapshots/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/config/snapshots/db/ResourceConfigSnapshotServiceTest.kt @@ -48,18 +48,6 @@ class ResourceConfigSnapshotServiceTest { } } - @Test(expected = NoSuchElementException::class) - fun notFoundEntryReturnsExceptionTest() { - val tr = ResourceConfigSnapshot() - runBlocking { - every { - cfgRepository.findByResourceIdAndResourceTypeAndStatus(any(), any(), any()) - } returns tr - val snap = cfgService.findByResourceIdAndResourceTypeAndStatus("MISSING_ID", "UNKNOWN_TYPE") - assertTrue ( snap.isBlank(), "Not found but returned a non empty string" ) - } - } - @Test fun createNewResourceConfigSnapshotTest() { val tr = ResourceConfigSnapshot() diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt index 2a9218df3..769644288 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt @@ -29,5 +29,4 @@ object ResourceResolutionConstants { const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence" const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id" const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type" - val DATA_DICTIONARY_SECRET_SOURCE_TYPES = arrayOf("vault-data") //Add more secret data dictionary source type here }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt index 641175ca2..51170a9b2 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt @@ -28,6 +28,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.proc import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceDefinitionUtils.createResourceAssignments import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintTemplateService import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils @@ -151,7 +152,9 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList()) resolvedContent = blueprintTemplateService.generateContent(bluePrintRuntimeService, nodeTemplateName, - artifactTemplate, resolvedParamJsonContent) + artifactTemplate, resolvedParamJsonContent, false, + mutableMapOf(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to + properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive())) if (isToStore(properties)) { templateResolutionDBService.write(properties, resolvedContent, bluePrintRuntimeService, artifactPrefix) @@ -330,7 +333,9 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica resourceAssignmentList.forEach { if (compareOne(resourceResolution, it)) { log.info("Resource ({}) already resolve: value=({})", it.name, resourceResolution.value) - val value = resourceResolution.value!!.asJsonPrimitive() + + // Make sure to recreate value as per the defined type. + val value = resourceResolution.value!!.asJsonType(it.property!!.type) it.property!!.value = value it.status = resourceResolution.status ResourceAssignmentUtils.setResourceDataValue(it, raRuntimeService, value) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt index 01cfd723b..117df1e5b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt @@ -1,6 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2019 IBM. + * Modifications Copyright (c) 2019 IBM, Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.uti import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.ArrayNode +import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.databind.node.TextNode import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService @@ -194,85 +195,214 @@ class ResourceAssignmentUtils { @Throws(BluePrintProcessorException::class) fun parseResponseNode(responseNode: JsonNode, resourceAssignment: ResourceAssignment, raRuntimeService: ResourceAssignmentRuntimeService, outputKeyMapping: MutableMap<String, String>): JsonNode { + try { + if ((resourceAssignment.property?.type).isNullOrEmpty()) { + throw BluePrintProcessorException("Couldn't get data dictionary type for dictionary name (${resourceAssignment.name})") + } + val type = resourceAssignment.property!!.type + return when (type) { + in BluePrintTypes.validPrimitiveTypes() -> { + parseResponseNodeForPrimitiveTypes(responseNode, resourceAssignment, outputKeyMapping) + } + in BluePrintTypes.validCollectionTypes() -> { + // Array Types + parseResponseNodeForCollection(responseNode, resourceAssignment, raRuntimeService, outputKeyMapping) + } + else -> { + // Complex Types + parseResponseNodeForComplexType(responseNode, resourceAssignment, raRuntimeService, outputKeyMapping) + } + } + } catch (e: Exception) { + logger.error("Fail to parse response data, error message $e") + throw BluePrintProcessorException("${e.message}", e) + } + } + + private fun parseResponseNodeForPrimitiveTypes(responseNode: JsonNode, resourceAssignment: ResourceAssignment, + outputKeyMapping: MutableMap<String, String>): JsonNode { val dName = resourceAssignment.dictionaryName - val dSource = resourceAssignment.dictionarySource - val type = nullToEmpty(resourceAssignment.property?.type) - lateinit var entrySchemaType: String - when (type) { - in BluePrintTypes.validPrimitiveTypes() -> { - if (dSource !in ResourceResolutionConstants.DATA_DICTIONARY_SECRET_SOURCE_TYPES) - logger.info("For template key (${resourceAssignment.name}) setting value as ($responseNode)") - val result = if (responseNode is ArrayNode) - responseNode.get(0) - else - responseNode - return if (result.isComplexType()) { - check(result.has(outputKeyMapping[dName])) { - "Fail to find output key mapping ($dName) in result." + logger.info("For template key (${resourceAssignment.name}) setting value as ($responseNode)") + + var result: JsonNode? = responseNode + if (responseNode.isComplexType()) { + val key = outputKeyMapping.keys.firstOrNull() + var returnNode: JsonNode? = responseNode + if (responseNode is ArrayNode) { + val arrayNode = responseNode.toList() + val firstElement = if (key.isNullOrEmpty()) { + arrayNode.first() + } + else{ + arrayNode.firstOrNull { element -> + element.isComplexType() && element.has(outputKeyMapping[key]) + } + } + + if (firstElement.isNull() || (firstElement!!.isComplexType() && !firstElement!!.has(outputKeyMapping[key])) + || (!result!!.isComplexType() && result is NullNode)) { + if (key.isNullOrEmpty()) { + throw BluePrintProcessorException("Fail to find mapping in the responseNode.") + } + else { + throw BluePrintProcessorException("Fail to find response with output key mapping ($key) in result.") } - result[outputKeyMapping[dName]] - } else { - result } + returnNode = firstElement } - in BluePrintTypes.validCollectionTypes() -> { - // Array Types - entrySchemaType = checkNotEmpty(resourceAssignment.property?.entrySchema?.type) { - "Entry schema is not defined for dictionary ($dName) info" + result = if (returnNode!!.isComplexType()) { + returnNode[outputKeyMapping[key]] + } + else { + returnNode + } + } + return result!! + } + + private fun parseResponseNodeForCollection(responseNode: JsonNode, resourceAssignment: ResourceAssignment, + raRuntimeService: ResourceAssignmentRuntimeService, + outputKeyMapping: MutableMap<String, String>): JsonNode { + val dName = resourceAssignment.dictionaryName + if ((resourceAssignment.property?.entrySchema?.type).isNullOrEmpty()) { + throw BluePrintProcessorException("Couldn't get data type for dictionary type " + + "(${resourceAssignment.property!!.type}) and dictionary name ($dName)") + } + val entrySchemaType = resourceAssignment.property!!.entrySchema!!.type + + var arrayNode = JacksonUtils.objectMapper.createArrayNode() + + if (outputKeyMapping.isNotEmpty()) { + when (responseNode) { + is ArrayNode -> { + val responseArrayNode = responseNode.toList() + for (responseSingleJsonNode in responseArrayNode) { + val arrayChildNode = parseArrayNodeElementWithOutputKeyMapping(raRuntimeService, responseSingleJsonNode, + outputKeyMapping, entrySchemaType) + arrayNode.add(arrayChildNode) + } } - val arrayNode = JacksonUtils.objectMapper.createArrayNode() - lateinit var responseValueNode: JsonNode - lateinit var propertyType: String - outputKeyMapping.map { - val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + is ObjectNode -> { val responseArrayNode = responseNode.rootFieldsToMap() - outer@ for ((key, responseSingleJsonNode) in responseArrayNode) { - if (key == it.key) { - if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) { - responseValueNode = responseSingleJsonNode - propertyType = entrySchemaType - - } else { - responseValueNode = responseSingleJsonNode.get(it.key) - propertyType = getPropertyType(raRuntimeService, entrySchemaType, it.key) - } - if (resourceAssignment.dictionarySource !in ResourceResolutionConstants.DATA_DICTIONARY_SECRET_SOURCE_TYPES) - logger.info("For List Type Resource: key (${it.key}), value ($responseValueNode), " + - "type ({$propertyType})") - JacksonUtils.populateJsonNodeValues(it.value, - responseValueNode, propertyType, arrayChildNode) - arrayNode.add(arrayChildNode) - break@outer - } - } + val arrayNodeResult = parseObjectNodeWithOutputKeyMapping(responseArrayNode, outputKeyMapping, entrySchemaType) + arrayNode.addAll(arrayNodeResult) + } + else -> { + throw BluePrintProcessorException("Key-value response expected to match the responseNode.") } - if (resourceAssignment.dictionarySource !in ResourceResolutionConstants.DATA_DICTIONARY_SECRET_SOURCE_TYPES) - logger.info("For template key (${resourceAssignment.name}) setting value as ($arrayNode)") - - return arrayNode } - else -> { - // Complex Types - entrySchemaType = checkNotEmpty(resourceAssignment.property?.type) { - "Entry schema is not defined for dictionary ($dName) info" + } + else { + when (responseNode) { + is ArrayNode -> { + responseNode.forEach { elementNode -> + arrayNode.add(elementNode) + } } - val objectNode = JacksonUtils.objectMapper.createObjectNode() + is ObjectNode -> { + val responseArrayNode = responseNode.rootFieldsToMap() + for ((key, responseSingleJsonNode) in responseArrayNode) { + val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + JacksonUtils.populateJsonNodeValues(key, responseSingleJsonNode, entrySchemaType, arrayChildNode) + arrayNode.add(arrayChildNode) + } + } + else -> { + arrayNode.add(responseNode) + } + } + } + + logger.info("For template key (${resourceAssignment.name}) setting value as ($arrayNode)") + + return arrayNode + } + + private fun parseResponseNodeForComplexType(responseNode: JsonNode, resourceAssignment: ResourceAssignment, + raRuntimeService: ResourceAssignmentRuntimeService, + outputKeyMapping: MutableMap<String, String>): JsonNode { + val entrySchemaType = resourceAssignment.property!!.type + val dictionaryName = resourceAssignment.dictionaryName!! + + var result: ObjectNode + if (checkOutputKeyMappingInDataTypeProperties(entrySchemaType, outputKeyMapping, raRuntimeService)) + { + result = parseArrayNodeElementWithOutputKeyMapping(raRuntimeService, responseNode, outputKeyMapping, entrySchemaType) + } + else { + val childNode = JacksonUtils.objectMapper.createObjectNode() + if (outputKeyMapping.isNotEmpty()) { outputKeyMapping.map { - val responseKeyValue = responseNode.get(it.key) - val propertyTypeForDataType = ResourceAssignmentUtils - .getPropertyType(raRuntimeService, entrySchemaType, it.key) + val responseKeyValue = if (responseNode.has(it.key)) { + responseNode.get(it.key) + } + else { + NullNode.getInstance() + } - if (resourceAssignment.dictionarySource !in ResourceResolutionConstants.DATA_DICTIONARY_SECRET_SOURCE_TYPES) - logger.info("For List Type Resource: key (${it.key}), value ($responseKeyValue), type ({$propertyTypeForDataType})") - JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, objectNode) + JacksonUtils.populateJsonNodeValues(it.value, + responseKeyValue, entrySchemaType, childNode) } + } + else { + JacksonUtils.populateJsonNodeValues(dictionaryName, responseNode, entrySchemaType, childNode) + } + result = childNode + } + return result + } + + private fun parseArrayNodeElementWithOutputKeyMapping(raRuntimeService: ResourceAssignmentRuntimeService, + responseSingleJsonNode: JsonNode, outputKeyMapping: + MutableMap<String, String>, entrySchemaType: String): ObjectNode { + val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + + outputKeyMapping.map { + val responseKeyValue = if (responseSingleJsonNode.has(it.key)) { + responseSingleJsonNode.get(it.key) + } + else { + NullNode.getInstance() + } + val propertyTypeForDataType = ResourceAssignmentUtils + .getPropertyType(raRuntimeService, entrySchemaType, it.key) + + logger.info("For List Type Resource: key (${it.key}), value ($responseKeyValue), " + + "type ({$propertyTypeForDataType})") - if (resourceAssignment.dictionarySource !in ResourceResolutionConstants.DATA_DICTIONARY_SECRET_SOURCE_TYPES) - logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)") + JacksonUtils.populateJsonNodeValues(it.value, + responseKeyValue, propertyTypeForDataType, arrayChildNode) + } + + return arrayChildNode + } + + private fun parseObjectNodeWithOutputKeyMapping(responseArrayNode: MutableMap<String, JsonNode>, + outputKeyMapping: MutableMap<String, String>, + entrySchemaType: String): ArrayNode { + val arrayNode = JacksonUtils.objectMapper.createArrayNode() + outputKeyMapping.map { + val objectNode = JacksonUtils.objectMapper.createObjectNode() + val responseSingleJsonNode = responseArrayNode.filterKeys { key -> key == it.key }.entries.firstOrNull() - return objectNode + if (responseSingleJsonNode == null) { + JacksonUtils.populateJsonNodeValues(it.value, NullNode.getInstance(), entrySchemaType, objectNode) } + else + { + JacksonUtils.populateJsonNodeValues(it.value, responseSingleJsonNode.value, entrySchemaType, objectNode) + } + arrayNode.add(objectNode) } + + return arrayNode + } + + private fun checkOutputKeyMappingInDataTypeProperties(dataTypeName: String, outputKeyMapping: MutableMap<String, String>, + raRuntimeService: ResourceAssignmentRuntimeService): Boolean { + val dataTypeProps = raRuntimeService.bluePrintContext().dataTypeByName(dataTypeName)?.properties + val result = outputKeyMapping.filterKeys { !dataTypeProps!!.containsKey(it) }.keys.firstOrNull() + return result == null } } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt index 9b87c12eb..9365c3e34 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (c) 2019 IBM, Bell Canada. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,16 +19,86 @@ * ============LICENSE_END========================================================= */ - package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode import com.fasterxml.jackson.databind.node.TextNode +import io.mockk.every +import io.mockk.spyk +import org.junit.Before import org.junit.Test +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType +import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType +import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment import kotlin.test.assertEquals +data class IpAddress(val port: String, val ip: String) +data class Host(val name: String, val ipAddress: IpAddress) +data class ExpectedResponseIp(val ip: String) +data class ExpectedResponsePort(val port: String) + class ResourceAssignmentUtilsTest { + private lateinit var resourceAssignmentRuntimeService: ResourceAssignmentRuntimeService + + @Before + fun setup() { + + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + + resourceAssignmentRuntimeService = spyk(ResourceAssignmentRuntimeService("1234", bluePrintContext)) + + val propertiesDefinition1 = PropertyDefinition().apply { + type = "string" + id = "port" + } + + val propertiesDefinition2 = PropertyDefinition().apply { + type = "string" + id = "ip" + } + + val propertiesDefinition3 = PropertyDefinition().apply { + type = "string" + id = "name" + } + + val propertiesDefinition4 = PropertyDefinition().apply { + type = "ip-address" + id = "ipAddress" + } + + var mapOfPropertiesIpAddress = mutableMapOf<String, PropertyDefinition>() + mapOfPropertiesIpAddress["port"] = propertiesDefinition1 + mapOfPropertiesIpAddress["ip"] = propertiesDefinition2 + + var mapOfPropertiesHost = mutableMapOf<String, PropertyDefinition>() + mapOfPropertiesHost["name"] = propertiesDefinition3 + mapOfPropertiesHost["ipAddress"] = propertiesDefinition4 + + val myDataTypeIpaddress = DataType().apply { + id = "ip-address" + properties = mapOfPropertiesIpAddress + } + + val myDataTypeHost = DataType().apply { + id = "host" + properties = mapOfPropertiesHost + } + + every { resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("ip-address") } returns myDataTypeIpaddress + + every { resourceAssignmentRuntimeService.bluePrintContext().dataTypeByName("host") } returns myDataTypeHost + + every { resourceAssignmentRuntimeService.setNodeTemplateAttributeValue(any(), any(), any()) } returns Unit + } @Test fun `generateResourceDataForAssignments - positive test`() { @@ -43,7 +114,6 @@ class ResourceAssignmentUtilsTest { //then the assignment should produce a valid result val expected = "{\n" + " \"pnf-id\" : \"valid_value\"\n" + "}" assertEquals(expected, outcome, "unexpected outcome generated") - } @Test @@ -76,4 +146,243 @@ class ResourceAssignmentUtilsTest { } return resourceAssignmentForTest } + + @Test + fun parseResponseNodeTestForPrimitivesTypes(){ + // Input values for primitive type + val keyValue = mutableMapOf<String, String>() + keyValue["value"]= "1.2.3.1" + val expectedPrimitiveType = TextNode("1.2.3.1") + + var outcome = prepareResponseNodeForTest("sample-value", "string", + "", "1.2.3.1".asJsonPrimitive()) + assertEquals(expectedPrimitiveType, outcome, "Unexpected outcome returned for primitive type of simple String") + outcome = prepareResponseNodeForTest("sample-key-value", "string", "", keyValue) + assertEquals(expectedPrimitiveType, outcome, "Unexpected outcome returned for primitive type of key-value String") + } + + @Test + fun parseResponseNodeTestForCollectionsOfString(){ + // Input values for collection type + val mapOfString = mutableMapOf<String, String>() + mapOfString["value1"] = "1.2.3.1" + mapOfString["port"] = "8888" + mapOfString["value2"] = "1.2.3.2" + val arrayOfKeyValue = arrayListOf(ExpectedResponseIp("1.2.3.1"), + ExpectedResponsePort( "8888"), ExpectedResponseIp("1.2.3.2")) + + val mutableMapKeyValue = mutableMapOf<String, String>() + mutableMapKeyValue["value1"] = "1.2.3.1" + mutableMapKeyValue["port"] = "8888" + + //List + val expectedListOfString = arrayOfKeyValue.asJsonType() + var outcome = prepareResponseNodeForTest("listOfString", "list", + "string", mapOfString.asJsonType()) + assertEquals(expectedListOfString, outcome, "unexpected outcome returned for list of String") + + //Map + val expectedMapOfString = mutableMapOf<String, JsonNode>() + expectedMapOfString["ip"] = "1.2.3.1".asJsonPrimitive() + expectedMapOfString["port"] = "8888".asJsonPrimitive() + + val arrayNode = JacksonUtils.objectMapper.createArrayNode() + expectedMapOfString.map { + val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + arrayChildNode.set(it.key, it.value) + arrayNode.add(arrayChildNode) + } + val arrayChildNode1 = JacksonUtils.objectMapper.createObjectNode() + arrayChildNode1.set("ip", NullNode.getInstance()) + arrayNode.add(arrayChildNode1) + outcome = prepareResponseNodeForTest("mapOfString", "map", "string", + mutableMapKeyValue.asJsonType()) + assertEquals(arrayNode, outcome, "unexpected outcome returned for map of String") + } + + @Test + fun parseResponseNodeTestForCollectionsOfJsonNode(){ + // Input values for collection type + val mapOfString = mutableMapOf<String, JsonNode>() + mapOfString["value1"] = "1.2.3.1".asJsonPrimitive() + mapOfString["port"] = "8888".asJsonPrimitive() + mapOfString["value2"] = "1.2.3.2".asJsonPrimitive() + val arrayOfKeyValue = arrayListOf(ExpectedResponseIp("1.2.3.1"), + ExpectedResponsePort( "8888"), ExpectedResponseIp("1.2.3.2")) + + val mutableMapKeyValue = mutableMapOf<String, JsonNode>() + mutableMapKeyValue["value1"] = "1.2.3.1".asJsonPrimitive() + mutableMapKeyValue["port"] = "8888".asJsonPrimitive() + + //List + val expectedListOfString = arrayOfKeyValue.asJsonType() + var outcome = prepareResponseNodeForTest("listOfString", "list", + "string", mapOfString.asJsonType()) + assertEquals(expectedListOfString, outcome, "unexpected outcome returned for list of String") + + //Map + val expectedMapOfString = mutableMapOf<String, JsonNode>() + expectedMapOfString["ip"] = "1.2.3.1".asJsonPrimitive() + expectedMapOfString["port"] = "8888".asJsonPrimitive() + val arrayNode = JacksonUtils.objectMapper.createArrayNode() + expectedMapOfString.map { + val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + arrayChildNode.set(it.key, it.value) + arrayNode.add(arrayChildNode) + } + val arrayChildNode1 = JacksonUtils.objectMapper.createObjectNode() + arrayChildNode1.set("ip", NullNode.getInstance()) + arrayNode.add(arrayChildNode1) + outcome = prepareResponseNodeForTest("mapOfString", "map", + "string", mutableMapKeyValue.asJsonType()) + assertEquals(arrayNode, outcome, "unexpected outcome returned for map of String") + } + + @Test + fun parseResponseNodeTestForCollectionsOfComplexType(){ + // Input values for collection type + val mapOfComplexType = mutableMapOf<String, JsonNode>() + mapOfComplexType["value1"] = IpAddress("1111", "1.2.3.1").asJsonType() + mapOfComplexType["value2"] = IpAddress("2222", "1.2.3.2").asJsonType() + mapOfComplexType["value3"] = IpAddress("3333", "1.2.3.3").asJsonType() + + //List + val arrayNode = JacksonUtils.objectMapper.createArrayNode() + mapOfComplexType.map { + val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + arrayChildNode.set("ipAddress", it.value) + arrayNode.add(arrayChildNode) + } + var outcome = prepareResponseNodeForTest("listOfMyDataType", "list", + "ip-address", mapOfComplexType.asJsonType()) + assertEquals(arrayNode, outcome, "unexpected outcome returned for list of String") + } + + @Test + fun `parseResponseNodeTestForComplexType find one output key mapping`(){ + // Input values for complex type + val objectNode = JacksonUtils.objectMapper.createObjectNode() + + // Input values for collection type + val mapOfComplexType = mutableMapOf<String, JsonNode>() + mapOfComplexType["value"] = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType() + mapOfComplexType["port"] = "8888".asJsonType() + mapOfComplexType["something"] = "1.2.3.2".asJsonType() + + val expectedComplexType = objectNode.set("ipAddress", Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType()) + val outcome = prepareResponseNodeForTest("complexTypeOneKeys", "host", + "", mapOfComplexType.asJsonType()) + assertEquals(expectedComplexType, outcome, "Unexpected outcome returned for complex type") + } + + @Test + fun `parseResponseNodeTestForComplexType find all output key mapping`(){ + // Input values for complex type + val objectNode = JacksonUtils.objectMapper.createObjectNode() + + // Input values for collection type + val mapOfComplexType = mutableMapOf<String, JsonNode>() + mapOfComplexType["name"] = "my-ipAddress".asJsonType() + mapOfComplexType["ipAddress"] = IpAddress("1111", "1.2.3.1").asJsonType() + + val expectedComplexType = Host("my-ipAddress", IpAddress("1111", "1.2.3.1")).asJsonType() + val outcome = prepareResponseNodeForTest("complexTypeAllKeys", "host", + "", mapOfComplexType.asJsonType()) + assertEquals(expectedComplexType, outcome, "Unexpected outcome returned for complex type") + } + + private fun prepareResponseNodeForTest(dictionary_source: String, sourceType: String, entrySchema: String, + response: Any): JsonNode { + + val resourceAssignment = when (sourceType) { + "list", "map" -> { + prepareRADataDictionaryCollection(dictionary_source, sourceType, entrySchema) + } + "string" -> { + prepareRADataDictionaryOfPrimaryType(dictionary_source) + } + else -> { + prepareRADataDictionaryComplexType(dictionary_source, sourceType, entrySchema) + } + } + + val responseNode = checkNotNull(JacksonUtils.getJsonNode(response)) { + "Failed to get database query result into Json node." + } + + val outputKeyMapping = prepareOutputKeyMapping(dictionary_source) + + return ResourceAssignmentUtils.parseResponseNode(responseNode, resourceAssignment, resourceAssignmentRuntimeService, outputKeyMapping) + } + + private fun prepareRADataDictionaryOfPrimaryType(dictionary_source: String): ResourceAssignment { + return ResourceAssignment().apply { + name = "ipAddress" + dictionaryName = "sample-ip" + dictionarySource = "$dictionary_source" + property = PropertyDefinition().apply { + type = "string" + } + } + } + + private fun prepareRADataDictionaryCollection(dictionary_source: String, sourceType: String, schema: String): ResourceAssignment { + return ResourceAssignment().apply { + name = "ipAddress-list" + dictionaryName = "sample-licenses" + dictionarySource = "$dictionary_source" + property = PropertyDefinition().apply { + type = "$sourceType" + entrySchema = EntrySchema().apply { + type = "$schema" + } + } + } + } + + private fun prepareRADataDictionaryComplexType(dictionary_source: String, sourceType: String, schema: String): ResourceAssignment { + return ResourceAssignment().apply { + name = "ipAddress-complexType" + dictionaryName = "sample-licenses" + dictionarySource = "$dictionary_source" + property = PropertyDefinition().apply { + type = "$sourceType" + } + } + } + + private fun prepareOutputKeyMapping(dictionary_source: String): MutableMap<String, String> { + val outputMapping = mutableMapOf<String, String>() + + when (dictionary_source) { + "listOfString", "mapOfString" -> { + //List of string + outputMapping["value1"] = "ip" + outputMapping["port"] = "port" + outputMapping["value2"] = "ip" + } + "listOfMyDataType", "mapOfMyDataType" -> { + //List or map of complex Type + outputMapping["value1"] = "ipAddress" + outputMapping["value2"] = "ipAddress" + outputMapping["value3"] = "ipAddress" + } + "sample-key-value", "sample-value" -> { + //Primary Type + if (dictionary_source=="sample-key-value") + outputMapping["sample-ip"] = "value" + } + else -> { + //Complex Type + if (dictionary_source == "complexTypeOneKeys") + outputMapping["value"] = "ipAddress" + else { + outputMapping["name"] = "name" + outputMapping["ipAddress"] = "ipAddress" + } + + } + } + return outputMapping + } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt index 63c44d209..9ce45d11e 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt @@ -127,7 +127,7 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu blueprintModel.id = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL blueprintModel.published = metadata[BluePrintConstants.PROPERTY_BLUEPRINT_VALID] - ?: BluePrintConstants.FLAG_Y + ?: BluePrintConstants.FLAG_N blueprintModel.artifactName = artifactName blueprintModel.artifactVersion = artifactVersion blueprintModel.updatedBy = metadata[BluePrintConstants.METADATA_TEMPLATE_AUTHOR]!! diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt index 644c51860..27a444bdc 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibConfiguration.kt @@ -17,6 +17,11 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageConsumerService +import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageProducerService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration @@ -26,10 +31,36 @@ import org.springframework.context.annotation.Configuration @EnableConfigurationProperties open class BluePrintMessageLibConfiguration +/** + * Exposed Dependency Service by this Message Lib Module + */ +fun BluePrintDependencyService.messageLibPropertyService(): BluePrintMessageLibPropertyService = + instance(MessageLibConstants.SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY) + +/** Extension functions for message producer service **/ +fun BluePrintDependencyService.messageProducerService(selector: String): BlueprintMessageProducerService { + return messageLibPropertyService().blueprintMessageProducerService(selector) +} + + +fun BluePrintDependencyService.messageProducerService(jsonNode: JsonNode): BlueprintMessageProducerService { + return messageLibPropertyService().blueprintMessageProducerService(jsonNode) +} + +/** Extension functions for message consumer service **/ +fun BluePrintDependencyService.messageConsumerService(selector: String): BlueprintMessageConsumerService { + return messageLibPropertyService().blueprintMessageConsumerService(selector) +} + +fun BluePrintDependencyService.messageConsumerService(jsonNode: JsonNode): BlueprintMessageConsumerService { + return messageLibPropertyService().blueprintMessageConsumerService(jsonNode) +} + class MessageLibConstants { companion object { const val SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY = "blueprint-message-lib-property-service" - const val PROPERTY_MESSAGE_CLIENT_PREFIX = "blueprintsprocessor.messageclient." + const val PROPERTY_MESSAGE_CONSUMER_PREFIX = "blueprintsprocessor.messageconsumer." + const val PROPERTY_MESSAGE_PRODUCER_PREFIX = "blueprintsprocessor.messageproducer." const val TYPE_KAFKA_BASIC_AUTH = "kafka-basic-auth" } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt index e621ec66f..ab04054fe 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/BluePrintMessageLibData.kt @@ -16,7 +16,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message - +/** Producer Properties **/ open class MessageProducerProperties @@ -24,4 +24,18 @@ open class KafkaBasicAuthMessageProducerProperties : MessageProducerProperties() lateinit var bootstrapServers: String var topic: String? = null var clientId: String? = null -}
\ No newline at end of file +} + +/** Consumer Properties **/ + +open class MessageConsumerProperties + +open class KafkaMessageConsumerProperties : MessageConsumerProperties() { + lateinit var bootstrapServers: String + lateinit var groupId: String + var clientId: String? = null + var topic: String? = null + var pollMillSec: Long = 1000 +} + +open class KafkaBasicAuthMessageConsumerProperties : KafkaMessageConsumerProperties() diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt index fb01ce179..7c56ea432 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BluePrintMessageLibPropertyService.kt @@ -18,9 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.message.service import com.fasterxml.jackson.databind.JsonNode import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties -import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaBasicAuthMessageProducerProperties -import org.onap.ccsdk.cds.blueprintsprocessor.message.MessageLibConstants -import org.onap.ccsdk.cds.blueprintsprocessor.message.MessageProducerProperties +import org.onap.ccsdk.cds.blueprintsprocessor.message.* import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils import org.springframework.stereotype.Service @@ -28,22 +26,22 @@ import org.springframework.stereotype.Service @Service(MessageLibConstants.SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY) open class BluePrintMessageLibPropertyService(private var bluePrintProperties: BluePrintProperties) { - fun blueprintMessageClientService(jsonNode: JsonNode): BlueprintMessageProducerService { - val messageClientProperties = messageClientProperties(jsonNode) - return blueprintMessageClientService(messageClientProperties) + fun blueprintMessageProducerService(jsonNode: JsonNode): BlueprintMessageProducerService { + val messageClientProperties = messageProducerProperties(jsonNode) + return blueprintMessageProducerService(messageClientProperties) } - fun blueprintMessageClientService(selector: String): BlueprintMessageProducerService { - val prefix = "${MessageLibConstants.PROPERTY_MESSAGE_CLIENT_PREFIX}$selector" - val messageClientProperties = messageClientProperties(prefix) - return blueprintMessageClientService(messageClientProperties) + fun blueprintMessageProducerService(selector: String): BlueprintMessageProducerService { + val prefix = "${MessageLibConstants.PROPERTY_MESSAGE_PRODUCER_PREFIX}$selector" + val messageClientProperties = messageProducerProperties(prefix) + return blueprintMessageProducerService(messageClientProperties) } - fun messageClientProperties(prefix: String): MessageProducerProperties { + fun messageProducerProperties(prefix: String): MessageProducerProperties { val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java) return when (type) { MessageLibConstants.TYPE_KAFKA_BASIC_AUTH -> { - kafkaBasicAuthMessageClientProperties(prefix) + kafkaBasicAuthMessageProducerProperties(prefix) } else -> { throw BluePrintProcessorException("Message adaptor($type) is not supported") @@ -51,7 +49,7 @@ open class BluePrintMessageLibPropertyService(private var bluePrintProperties: B } } - fun messageClientProperties(jsonNode: JsonNode): MessageProducerProperties { + fun messageProducerProperties(jsonNode: JsonNode): MessageProducerProperties { val type = jsonNode.get("type").textValue() return when (type) { MessageLibConstants.TYPE_KAFKA_BASIC_AUTH -> { @@ -63,7 +61,7 @@ open class BluePrintMessageLibPropertyService(private var bluePrintProperties: B } } - private fun blueprintMessageClientService(MessageProducerProperties: MessageProducerProperties) + private fun blueprintMessageProducerService(MessageProducerProperties: MessageProducerProperties) : BlueprintMessageProducerService { when (MessageProducerProperties) { @@ -76,9 +74,67 @@ open class BluePrintMessageLibPropertyService(private var bluePrintProperties: B } } - private fun kafkaBasicAuthMessageClientProperties(prefix: String): KafkaBasicAuthMessageProducerProperties { + private fun kafkaBasicAuthMessageProducerProperties(prefix: String): KafkaBasicAuthMessageProducerProperties { return bluePrintProperties.propertyBeanType( prefix, KafkaBasicAuthMessageProducerProperties::class.java) } + /** Consumer Property Lib Service Implementation **/ + + /** Return Message Consumer Service for [jsonNode] definitions. */ + fun blueprintMessageConsumerService(jsonNode: JsonNode): BlueprintMessageConsumerService { + val messageConsumerProperties = messageConsumerProperties(jsonNode) + return blueprintMessageConsumerService(messageConsumerProperties) + } + + /** Return Message Consumer Service for [selector] definitions. */ + fun blueprintMessageConsumerService(selector: String): BlueprintMessageConsumerService { + val prefix = "${MessageLibConstants.PROPERTY_MESSAGE_CONSUMER_PREFIX}$selector" + val messageClientProperties = messageConsumerProperties(prefix) + return blueprintMessageConsumerService(messageClientProperties) + } + + /** Return Message Consumer Properties for [prefix] definitions. */ + fun messageConsumerProperties(prefix: String): MessageConsumerProperties { + val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java) + return when (type) { + MessageLibConstants.TYPE_KAFKA_BASIC_AUTH -> { + kafkaBasicAuthMessageConsumerProperties(prefix) + } + else -> { + throw BluePrintProcessorException("Message adaptor($type) is not supported") + } + } + } + + fun messageConsumerProperties(jsonNode: JsonNode): MessageConsumerProperties { + val type = jsonNode.get("type").textValue() + return when (type) { + MessageLibConstants.TYPE_KAFKA_BASIC_AUTH -> { + JacksonUtils.readValue(jsonNode, KafkaBasicAuthMessageConsumerProperties::class.java)!! + } + else -> { + throw BluePrintProcessorException("Message adaptor($type) is not supported") + } + } + } + + private fun blueprintMessageConsumerService(messageConsumerProperties: MessageConsumerProperties) + : BlueprintMessageConsumerService { + + when (messageConsumerProperties) { + is KafkaBasicAuthMessageConsumerProperties -> { + return KafkaBasicAuthMessageConsumerService(messageConsumerProperties) + } + else -> { + throw BluePrintProcessorException("couldn't get Message client service for") + } + } + } + + private fun kafkaBasicAuthMessageConsumerProperties(prefix: String): KafkaBasicAuthMessageConsumerProperties { + return bluePrintProperties.propertyBeanType( + prefix, KafkaBasicAuthMessageConsumerProperties::class.java) + } + } diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt new file mode 100644 index 000000000..25f0bf44d --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerService.kt @@ -0,0 +1,32 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.message.service + +import kotlinx.coroutines.channels.Channel + +interface BlueprintMessageConsumerService { + + /** Subscribe to the Kafka channel with [additionalConfig] */ + suspend fun subscribe(additionalConfig: Map<String, Any>?): Channel<String> + + /** Subscribe to the Kafka channel with [additionalConfig] for dynamic [topics]*/ + suspend fun subscribe(topics: List<String>, additionalConfig: Map<String, Any>? = null): Channel<String> + + /** close the channel, consumer and other resources */ + suspend fun shutDown() + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt new file mode 100644 index 000000000..5a9e61bfd --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageConsumerService.kt @@ -0,0 +1,116 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.message.service + +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.apache.kafka.clients.CommonClientConfigs +import org.apache.kafka.clients.consumer.Consumer +import org.apache.kafka.clients.consumer.ConsumerConfig +import org.apache.kafka.clients.consumer.KafkaConsumer +import org.apache.kafka.common.serialization.StringDeserializer +import org.onap.ccsdk.cds.blueprintsprocessor.message.KafkaBasicAuthMessageConsumerProperties +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import java.time.Duration +import kotlin.concurrent.thread + +class KafkaBasicAuthMessageConsumerService( + private val messageConsumerProperties: KafkaBasicAuthMessageConsumerProperties) + : BlueprintMessageConsumerService { + + private val channel = Channel<String>() + private var kafkaConsumer: Consumer<String, String>? = null + val log = logger(KafkaBasicAuthMessageConsumerService::class) + + @Volatile + var keepGoing = true + + fun kafkaConsumer(additionalConfig: Map<String, Any>? = null): Consumer<String, String> { + val configProperties = hashMapOf<String, Any>() + configProperties[CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG] = messageConsumerProperties.bootstrapServers + configProperties[ConsumerConfig.GROUP_ID_CONFIG] = messageConsumerProperties.groupId + configProperties[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "latest" + configProperties[ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG] = StringDeserializer::class.java + configProperties[ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG] = StringDeserializer::class.java + if (messageConsumerProperties.clientId != null) { + configProperties[ConsumerConfig.CLIENT_ID_CONFIG] = messageConsumerProperties.clientId!! + } + // TODO("Security Implementation based on type") + /** add or override already set properties */ + additionalConfig?.let { configProperties.putAll(it) } + /** Create Kafka consumer */ + return KafkaConsumer(configProperties) + } + + override suspend fun subscribe(additionalConfig: Map<String, Any>?): Channel<String> { + /** get to topic names */ + val consumerTopic = messageConsumerProperties.topic?.split(",")?.map { it.trim() } + check(!consumerTopic.isNullOrEmpty()) { "couldn't get topic information" } + return subscribe(consumerTopic, additionalConfig) + } + + + override suspend fun subscribe(consumerTopic: List<String>, additionalConfig: Map<String, Any>?): Channel<String> { + /** Create Kafka consumer */ + kafkaConsumer = kafkaConsumer(additionalConfig) + + checkNotNull(kafkaConsumer) { + "failed to create kafka consumer for " + + "server(${messageConsumerProperties.bootstrapServers})'s " + + "topics(${messageConsumerProperties.bootstrapServers})" + } + + kafkaConsumer!!.subscribe(consumerTopic) + log.info("Successfully consumed topic($consumerTopic)") + + thread(start = true, name = "KafkaConsumer") { + keepGoing = true + kafkaConsumer!!.use { kc -> + while (keepGoing) { + val consumerRecords = kc.poll(Duration.ofMillis(messageConsumerProperties.pollMillSec)) + runBlocking { + consumerRecords?.forEach { consumerRecord -> + /** execute the command block */ + consumerRecord.value()?.let { + launch { + if (!channel.isClosedForSend) { + channel.send(it) + } else { + log.error("Channel is closed to receive message") + } + } + } + } + } + } + log.info("message listener shutting down.....") + } + } + return channel + } + + override suspend fun shutDown() { + /** stop the polling loop */ + keepGoing = false + /** Close the Channel */ + channel.cancel() + /** TO shutdown gracefully, need to wait for the maximum poll time */ + delay(messageConsumerProperties.pollMillSec) + } +} diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt index 008e92437..1c93bb0fc 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/KafkaBasicAuthMessageProducerService.kt @@ -83,7 +83,6 @@ class KafkaBasicAuthMessageProducerService( } fun messageTemplate(additionalConfig: Map<String, Any>? = null): KafkaTemplate<String, Any> { - log.info("Prepering templates") if (kafkaTemplate == null) { kafkaTemplate = KafkaTemplate(producerFactory(additionalConfig)) } diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt new file mode 100644 index 000000000..2b84eaa78 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageConsumerServiceTest.kt @@ -0,0 +1,140 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.message.service + +import io.mockk.every +import io.mockk.spyk +import kotlinx.coroutines.channels.consumeEach +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.apache.kafka.clients.consumer.ConsumerRecord +import org.apache.kafka.clients.consumer.MockConsumer +import org.apache.kafka.clients.consumer.OffsetResetStrategy +import org.apache.kafka.common.TopicPartition +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.message.BluePrintMessageLibConfiguration +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.annotation.DirtiesContext +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.assertNotNull +import kotlin.test.assertTrue + + +@RunWith(SpringRunner::class) +@DirtiesContext +@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class]) +@TestPropertySource(properties = +["blueprintsprocessor.messageconsumer.sample.type=kafka-basic-auth", + "blueprintsprocessor.messageconsumer.sample.bootstrapServers=127.0.0.1:9092", + "blueprintsprocessor.messageconsumer.sample.groupId=sample-group", + "blueprintsprocessor.messageconsumer.sample.topic=default-topic", + "blueprintsprocessor.messageconsumer.sample.clientId=default-client-id", + "blueprintsprocessor.messageconsumer.sample.pollMillSec=10", + + "blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth", + "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092", + "blueprintsprocessor.messageproducer.sample.topic=default-topic", + "blueprintsprocessor.messageproducer.sample.clientId=default-client-id" +]) +open class BlueprintMessageConsumerServiceTest { + val log = logger(BlueprintMessageConsumerServiceTest::class) + + @Autowired + lateinit var bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService + + @Test + fun testKafkaBasicAuthConsumerService() { + runBlocking { + val blueprintMessageConsumerService = bluePrintMessageLibPropertyService + .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService + assertNotNull(blueprintMessageConsumerService, "failed to get blueprintMessageConsumerService") + + val spyBlueprintMessageConsumerService = spyk(blueprintMessageConsumerService, recordPrivateCalls = true) + + val topic = "default-topic" + val partitions: MutableList<TopicPartition> = arrayListOf() + val topicsCollection: MutableList<String> = arrayListOf() + partitions.add(TopicPartition(topic, 1)) + val partitionsBeginningMap: MutableMap<TopicPartition, Long> = mutableMapOf() + val partitionsEndMap: MutableMap<TopicPartition, Long> = mutableMapOf() + + val records: Long = 10 + partitions.forEach { partition -> + partitionsBeginningMap[partition] = 0L + partitionsEndMap[partition] = records + topicsCollection.add(partition.topic()) + } + val mockKafkaConsumer = MockConsumer<String, String>(OffsetResetStrategy.EARLIEST) + mockKafkaConsumer.subscribe(topicsCollection) + mockKafkaConsumer.rebalance(partitions) + mockKafkaConsumer.updateBeginningOffsets(partitionsBeginningMap) + mockKafkaConsumer.updateEndOffsets(partitionsEndMap) + for (i in 1..10) { + val record = ConsumerRecord<String, String>(topic, 1, i.toLong(), "key_$i", + "I am message $i") + mockKafkaConsumer.addRecord(record) + } + + every { spyBlueprintMessageConsumerService.kafkaConsumer(any()) } returns mockKafkaConsumer + val channel = spyBlueprintMessageConsumerService.subscribe(null) + launch { + channel.consumeEach { + assertTrue(it.startsWith("I am message"), "failed to get the actual message") + } + } + delay(10) + spyBlueprintMessageConsumerService.shutDown() + } + } + + /** Integration Kafka Testing, Enable and use this test case only for local desktop testing with real kafka broker */ + //@Test + fun testKafkaIntegration() { + runBlocking { + val blueprintMessageConsumerService = bluePrintMessageLibPropertyService + .blueprintMessageConsumerService("sample") as KafkaBasicAuthMessageConsumerService + assertNotNull(blueprintMessageConsumerService, "failed to get blueprintMessageConsumerService") + + val channel = blueprintMessageConsumerService.subscribe(null) + launch { + channel.consumeEach { + log.info("Consumed Message : $it") + } + } + + /** Send message with every 1 sec */ + val blueprintMessageProducerService = bluePrintMessageLibPropertyService + .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService + launch { + repeat(5) { + delay(1000) + blueprintMessageProducerService.sendMessage("this is my message($it)") + } + } + delay(10000) + blueprintMessageConsumerService.shutDown() + } + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt index 0f8367d7e..31bcc1517 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/message/service/BlueprintMessageProducerServiceTest.kt @@ -41,10 +41,10 @@ import kotlin.test.assertTrue @ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class]) @TestPropertySource(properties = -["blueprintsprocessor.messageclient.sample.type=kafka-basic-auth", - "blueprintsprocessor.messageclient.sample.bootstrapServers=127:0.0.1:9092", - "blueprintsprocessor.messageclient.sample.topic=default-topic", - "blueprintsprocessor.messageclient.sample.clientId=default-client-id" +["blueprintsprocessor.messageproducer.sample.type=kafka-basic-auth", + "blueprintsprocessor.messageproducer.sample.bootstrapServers=127.0.0.1:9092", + "blueprintsprocessor.messageproducer.sample.topic=default-topic", + "blueprintsprocessor.messageproducer.sample.clientId=default-client-id" ]) open class BlueprintMessageProducerServiceTest { @@ -52,10 +52,10 @@ open class BlueprintMessageProducerServiceTest { lateinit var bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService @Test - fun testKafkaBasicAuthClientService() { + fun testKafkaBasicAuthProducertService() { runBlocking { - val bluePrintMessageClientService = bluePrintMessageLibPropertyService - .blueprintMessageClientService("sample") as KafkaBasicAuthMessageProducerService + val blueprintMessageProducerService = bluePrintMessageLibPropertyService + .blueprintMessageProducerService("sample") as KafkaBasicAuthMessageProducerService val mockKafkaTemplate = mockk<KafkaTemplate<String, Any>>() @@ -64,11 +64,11 @@ open class BlueprintMessageProducerServiceTest { every { mockKafkaTemplate.send(any(), any()) } returns future - val spyBluePrintMessageClientService = spyk(bluePrintMessageClientService, recordPrivateCalls = true) + val spyBluePrintMessageProducerService = spyk(blueprintMessageProducerService, recordPrivateCalls = true) - every { spyBluePrintMessageClientService.messageTemplate(any()) } returns mockKafkaTemplate + every { spyBluePrintMessageProducerService.messageTemplate(any()) } returns mockKafkaTemplate - val response = spyBluePrintMessageClientService.sendMessage("Testing message") + val response = spyBluePrintMessageProducerService.sendMessage("Testing message") assertTrue(response, "failed to get command response") } } diff --git a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/resources/logback-test.xml index 626b8f911..3868440c7 100644 --- a/ms/blueprintsprocessor/modules/commons/message-lib/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/modules/commons/message-lib/src/test/resources/logback-test.xml @@ -19,7 +19,7 @@ <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> <encoder> - <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern> </encoder> </appender> diff --git a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt index c45ebc127..5a6ba0661 100644 --- a/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt +++ b/ms/blueprintsprocessor/modules/commons/processor-core/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.core.api.data import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ObjectNode import io.swagger.annotations.ApiModelProperty @@ -40,6 +41,7 @@ open class ExecutionServiceInput { " and the input for resource resolution located within the xxx-request block, contained within xxx-properties") lateinit var payload: ObjectNode @get:ApiModelProperty(hidden = true) + @get:JsonIgnore var stepData: StepData? = null } @@ -56,6 +58,7 @@ open class ExecutionServiceOutput { " and the input for resource resolution located within the xxx-request block, contained within xxx-properties") lateinit var payload: ObjectNode @get:ApiModelProperty(hidden = true) + @get:JsonIgnore var stepData: StepData? = null } diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt index 75a9409fd..68672f227 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/BluePrintRestLibData.kt @@ -1,6 +1,7 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2019 Huawei. + * Modifications Copyright © 2019 Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest open class RestClientProperties { lateinit var type: String lateinit var url: String + var additionalHeaders: Map<String, String>? = null } open class SSLRestClientProperties : RestClientProperties() { @@ -63,4 +65,4 @@ open class PolicyManagerRestClientProperties : RestClientProperties() { lateinit var env: String lateinit var clientAuth: String lateinit var authorisation: String -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt index 3190cd1c6..bb6937d7c 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt @@ -18,6 +18,10 @@ package org.onap.ccsdk.cds.blueprintsprocessor.rest.service import org.apache.http.message.BasicHeader import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants +import org.onap.ccsdk.cds.blueprintsprocessor.rest.utils.WebClientUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.springframework.http.HttpHeaders import org.springframework.http.MediaType import java.nio.charset.Charset @@ -25,42 +29,43 @@ import java.util.* class BasicAuthRestClientService(private val restClientProperties: BasicAuthRestClientProperties) : - BlueprintWebClientService { + BlueprintWebClientService { override fun defaultHeaders(): Map<String, String> { val encodedCredentials = setBasicAuth(restClientProperties.username, - restClientProperties.password) + restClientProperties.password) return mapOf( - HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials") + HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials") } override fun host(uri: String): String { return restClientProperties.url + uri } - override fun convertToBasicHeaders(headers: Map<String, String>): - Array<BasicHeader> { + override fun convertToBasicHeaders(headers: Map<String, String>): + Array<BasicHeader> { val customHeaders: MutableMap<String, String> = headers.toMutableMap() + //inject additionalHeaders + customHeaders.putAll(verifyAdditionalHeaders(restClientProperties)) + if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) { val encodedCredentials = setBasicAuth( - restClientProperties.username, - restClientProperties.password) + restClientProperties.username, + restClientProperties.password) customHeaders[HttpHeaders.AUTHORIZATION] = - "Basic $encodedCredentials" + "Basic $encodedCredentials" } return super.convertToBasicHeaders(customHeaders) } private fun setBasicAuth(username: String, password: String): String { - val credentialsString = "$username:$password" return Base64.getEncoder().encodeToString( - credentialsString.toByteArray(Charset.defaultCharset())) + credentialsString.toByteArray(Charset.defaultCharset())) } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt index 4f6865764..8d4f0ca63 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt @@ -38,7 +38,7 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) { open fun blueprintWebClientService(jsonNode: JsonNode): - BlueprintWebClientService { + BlueprintWebClientService { val restClientProperties = restClientProperties(jsonNode) return blueprintWebClientService(restClientProperties) } @@ -51,7 +51,7 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: fun restClientProperties(prefix: String): RestClientProperties { val type = bluePrintProperties.propertyBeanType( - "$prefix.type", String::class.java) + "$prefix.type", String::class.java) return when (type) { RestLibConstants.TYPE_BASIC_AUTH -> { basicAuthRestClientProperties(prefix) @@ -76,7 +76,7 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: } else -> { throw BluePrintProcessorException("Rest adaptor($type) is" + - " not supported") + " not supported") } } } @@ -86,43 +86,35 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: val type = jsonNode.get("type").textValue() return when (type) { RestLibConstants.TYPE_TOKEN_AUTH -> { - JacksonUtils.readValue(jsonNode, - TokenAuthRestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, TokenAuthRestClientProperties::class.java)!! } RestLibConstants.TYPE_BASIC_AUTH -> { - JacksonUtils.readValue(jsonNode, - BasicAuthRestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!! } RestLibConstants.TYPE_DME2_PROXY -> { - JacksonUtils.readValue(jsonNode, - DME2RestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, DME2RestClientProperties::class.java)!! } RestLibConstants.TYPE_POLICY_MANAGER -> { - JacksonUtils.readValue(jsonNode, - PolicyManagerRestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, PolicyManagerRestClientProperties::class.java)!! } RestLibConstants.TYPE_SSL_BASIC_AUTH -> { - JacksonUtils.readValue(jsonNode, - SSLBasicAuthRestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, SSLBasicAuthRestClientProperties::class.java)!! } RestLibConstants.TYPE_SSL_TOKEN_AUTH -> { - JacksonUtils.readValue(jsonNode, - SSLTokenAuthRestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, SSLTokenAuthRestClientProperties::class.java)!! } RestLibConstants.TYPE_SSL_NO_AUTH -> { - JacksonUtils.readValue( - jsonNode, SSLRestClientProperties::class.java)!! + JacksonUtils.readValue(jsonNode, SSLRestClientProperties::class.java)!! } else -> { - throw BluePrintProcessorException("Rest adaptor($type) is" + - " not supported") + throw BluePrintProcessorException( + "Rest adaptor($type) is not supported") } } } - - private fun blueprintWebClientService( - restClientProperties: RestClientProperties): - BlueprintWebClientService { + + private fun blueprintWebClientService(restClientProperties: RestClientProperties): + BlueprintWebClientService { when (restClientProperties) { is SSLRestClientProperties -> { @@ -138,66 +130,65 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: return DME2ProxyRestClientService(restClientProperties) } else -> { - throw BluePrintProcessorException("couldn't get rest " + - "service for") + throw BluePrintProcessorException("couldn't get rest service for type:${restClientProperties.type} uri: ${restClientProperties.url}") } } } private fun tokenRestClientProperties(prefix: String): - TokenAuthRestClientProperties { + TokenAuthRestClientProperties { return bluePrintProperties.propertyBeanType( - prefix, TokenAuthRestClientProperties::class.java) + prefix, TokenAuthRestClientProperties::class.java) } private fun basicAuthRestClientProperties(prefix: String): - BasicAuthRestClientProperties { + BasicAuthRestClientProperties { return bluePrintProperties.propertyBeanType( - prefix, BasicAuthRestClientProperties::class.java) + prefix, BasicAuthRestClientProperties::class.java) } private fun sslBasicAuthRestClientProperties(prefix: String): - SSLRestClientProperties { + SSLRestClientProperties { val sslProps: SSLBasicAuthRestClientProperties = - bluePrintProperties.propertyBeanType( - prefix, SSLBasicAuthRestClientProperties::class.java) - val basicProps : BasicAuthRestClientProperties = - bluePrintProperties.propertyBeanType( - prefix, BasicAuthRestClientProperties::class.java) + bluePrintProperties.propertyBeanType( + prefix, SSLBasicAuthRestClientProperties::class.java) + val basicProps: BasicAuthRestClientProperties = + bluePrintProperties.propertyBeanType( + prefix, BasicAuthRestClientProperties::class.java) sslProps.basicAuth = basicProps return sslProps } private fun sslTokenAuthRestClientProperties(prefix: String): - SSLRestClientProperties { + SSLRestClientProperties { val sslProps: SSLTokenAuthRestClientProperties = - bluePrintProperties.propertyBeanType(prefix, - SSLTokenAuthRestClientProperties::class.java) - val basicProps : TokenAuthRestClientProperties = - bluePrintProperties.propertyBeanType(prefix, - TokenAuthRestClientProperties::class.java) + bluePrintProperties.propertyBeanType(prefix, + SSLTokenAuthRestClientProperties::class.java) + val basicProps: TokenAuthRestClientProperties = + bluePrintProperties.propertyBeanType(prefix, + TokenAuthRestClientProperties::class.java) sslProps.tokenAuth = basicProps return sslProps } private fun sslNoAuthRestClientProperties(prefix: String): - SSLRestClientProperties { + SSLRestClientProperties { return bluePrintProperties.propertyBeanType( - prefix, SSLRestClientProperties::class.java) + prefix, SSLRestClientProperties::class.java) } private fun dme2ProxyClientProperties(prefix: String): - DME2RestClientProperties { + DME2RestClientProperties { return bluePrintProperties.propertyBeanType( - prefix, DME2RestClientProperties::class.java) + prefix, DME2RestClientProperties::class.java) } private fun policyManagerRestClientProperties(prefix: String): - PolicyManagerRestClientProperties { + PolicyManagerRestClientProperties { return bluePrintProperties.propertyBeanType( - prefix, PolicyManagerRestClientProperties::class.java) + prefix, PolicyManagerRestClientProperties::class.java) } } diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt index 1acd07b7b..26c808874 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BlueprintWebClientService.kt @@ -28,11 +28,14 @@ import org.apache.http.entity.StringEntity import org.apache.http.impl.client.CloseableHttpClient import org.apache.http.impl.client.HttpClients import org.apache.http.message.BasicHeader +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants import org.onap.ccsdk.cds.blueprintsprocessor.rest.utils.WebClientUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintRetryException import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintIOUtils import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.springframework.http.HttpHeaders import org.springframework.http.HttpMethod import java.io.IOException import java.io.InputStream @@ -46,9 +49,9 @@ interface BlueprintWebClientService { fun httpClient(): CloseableHttpClient { return HttpClients.custom() - .addInterceptorFirst(WebClientUtils.logRequest()) - .addInterceptorLast(WebClientUtils.logResponse()) - .build() + .addInterceptorFirst(WebClientUtils.logRequest()) + .addInterceptorLast(WebClientUtils.logResponse()) + .build() } /** High performance non blocking Retry function, If execution block [block] throws BluePrintRetryException @@ -82,10 +85,12 @@ interface BlueprintWebClientService { HttpMethod.POST -> post(path, request, convertedHeaders, String::class.java) HttpMethod.PUT -> put(path, request, convertedHeaders, String::class.java) HttpMethod.PATCH -> patch(path, request, convertedHeaders, String::class.java) - else -> throw BluePrintProcessorException("Unsupported methodType($methodType)") + else -> throw BluePrintProcessorException( + "Unsupported methodType($methodType) attempted on path($path)") } } + //TODO: convert to multi-map fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> { return headers.map { BasicHeader(it.key, it.value) }.toTypedArray() } @@ -135,8 +140,8 @@ interface BlueprintWebClientService { @Throws(IOException::class, ClientProtocolException::class) private fun <T> performCallAndExtractTypedWebClientResponse( - httpUriRequest: HttpUriRequest, responseType: Class<T>): - WebClientResponse<T> { + httpUriRequest: HttpUriRequest, responseType: Class<T>): + WebClientResponse<T> { val httpResponse = httpClient().execute(httpUriRequest) val statusCode = httpResponse.statusLine.statusCode httpResponse.entity.content.use { @@ -154,7 +159,7 @@ interface BlueprintWebClientService { } suspend fun <T> getNB(path: String, additionalHeaders: Array<BasicHeader>?, responseType: Class<T>): - WebClientResponse<T> = withContext(Dispatchers.IO) { + WebClientResponse<T> = withContext(Dispatchers.IO) { get(path, additionalHeaders!!, responseType) } @@ -191,27 +196,27 @@ interface BlueprintWebClientService { } suspend fun <T> deleteNB(path: String, additionalHeaders: Array<BasicHeader>?): - WebClientResponse<String> { + WebClientResponse<String> { return deleteNB(path, additionalHeaders, String::class.java) } suspend fun <T> deleteNB(path: String, additionalHeaders: Array<BasicHeader>?, responseType: Class<T>): - WebClientResponse<T> = withContext(Dispatchers.IO) { + WebClientResponse<T> = withContext(Dispatchers.IO) { delete(path, additionalHeaders!!, responseType) } suspend fun <T> patchNB(path: String, request: Any, additionalHeaders: Array<BasicHeader>?, responseType: Class<T>): - WebClientResponse<T> = withContext(Dispatchers.IO) { + WebClientResponse<T> = withContext(Dispatchers.IO) { patch(path, request, additionalHeaders!!, responseType) } suspend fun exchangeNB(methodType: String, path: String, request: Any): WebClientResponse<String> { return exchangeNB(methodType, path, request, hashMapOf(), - String::class.java) + String::class.java) } suspend fun exchangeNB(methodType: String, path: String, request: Any, additionalHeaders: Map<String, String>?): - WebClientResponse<String> { + WebClientResponse<String> { return exchangeNB(methodType, path, request, additionalHeaders, String::class.java) } @@ -249,7 +254,7 @@ interface BlueprintWebClientService { } private fun basicHeaders(headers: Map<String, String>?): - Array<BasicHeader> { + Array<BasicHeader> { val basicHeaders = mutableListOf<BasicHeader>() defaultHeaders().forEach { (name, value) -> basicHeaders.add(BasicHeader(name, value)) @@ -263,11 +268,29 @@ interface BlueprintWebClientService { // Non Blocking Rest Implementation suspend fun httpClientNB(): CloseableHttpClient { return HttpClients.custom() - .addInterceptorFirst(WebClientUtils.logRequest()) - .addInterceptorLast(WebClientUtils.logResponse()) - .build() + .addInterceptorFirst(WebClientUtils.logRequest()) + .addInterceptorLast(WebClientUtils.logResponse()) + .build() } //TODO maybe there could be cases where we care about return headers? data class WebClientResponse<T>(val status: Int, val body: T) + + fun verifyAdditionalHeaders(restClientProperties: RestClientProperties): Map<String, String> { + val customHeaders: MutableMap<String, String> = mutableMapOf() + //Extract additionalHeaders from the requestProperties and + //throw an error if HttpHeaders.AUTHORIZATION key (headers are case-insensitive) + restClientProperties.additionalHeaders?.let { + if (it.keys.map { k -> k.toLowerCase().trim() }.contains(HttpHeaders.AUTHORIZATION.toLowerCase())) { + val errMsg = "Error in definition of endpoint ${restClientProperties.url}." + + " User-supplied \"additionalHeaders\" cannot contain AUTHORIZATION header with" + + " auth-type \"${RestLibConstants.TYPE_BASIC_AUTH}\"" + WebClientUtils.log.error(errMsg) + throw BluePrintProcessorException(errMsg) + } else { + customHeaders.putAll(it) + } + } + return customHeaders + } } diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt index 30dd49018..2acf776ca 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/SSLRestClientService.kt @@ -33,25 +33,31 @@ import java.io.FileInputStream import java.security.KeyStore import java.security.cert.X509Certificate -class SSLRestClientService(private val restClientProperties: - SSLRestClientProperties) : - BlueprintWebClientService { +class SSLRestClientService(private val restClientProperties: SSLRestClientProperties) : + BlueprintWebClientService { var auth: BlueprintWebClientService? = null init { - auth = getAuthService() + auth = getAuthService() } - private fun getAuthService() : BlueprintWebClientService? { - - return when(restClientProperties) { + private fun getAuthService(): BlueprintWebClientService? { + //type,url and additional headers don't get carried over to TokenAuthRestClientProperties from SSLTokenAuthRestClientProperties + //set them in auth obj to be consistent. TODO: refactor + return when (restClientProperties) { is SSLBasicAuthRestClientProperties -> { - val basic = restClientProperties.basicAuth!! - BasicAuthRestClientService(basic) + val basicAuthProps = restClientProperties.basicAuth!! + basicAuthProps.additionalHeaders = restClientProperties.additionalHeaders + basicAuthProps.url = restClientProperties.url + basicAuthProps.type = restClientProperties.type + BasicAuthRestClientService(basicAuthProps) } is SSLTokenAuthRestClientProperties -> { - val token = restClientProperties.tokenAuth!! + val token = restClientProperties.tokenAuth!! + token.additionalHeaders = restClientProperties.additionalHeaders + token.url = restClientProperties.url + token.type = restClientProperties.type TokenAuthRestClientService(token) } else -> { @@ -61,19 +67,16 @@ class SSLRestClientService(private val restClientProperties: } } - override fun defaultHeaders(): Map<String, String> { - if (auth != null) { return auth!!.defaultHeaders() } return mapOf( - HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE) + HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE) } override fun host(uri: String): String { - return restClientProperties.url + uri } @@ -85,8 +88,9 @@ class SSLRestClientService(private val restClientProperties: val sslTrust = restClientProperties.sslTrust val sslTrustPwd = restClientProperties.sslTrustPassword - val acceptingTrustStrategy = { chain: Array<X509Certificate>, - authType: String -> true } + val acceptingTrustStrategy = { _: Array<X509Certificate>, _: String -> + true + } val sslContext = SSLContextBuilder.create() if (sslKey != null && sslKeyPwd != null) { @@ -98,13 +102,12 @@ class SSLRestClientService(private val restClientProperties: } sslContext.loadTrustMaterial(File(sslTrust), sslTrustPwd.toCharArray(), - acceptingTrustStrategy) + acceptingTrustStrategy) val csf = SSLConnectionSocketFactory(sslContext.build()) return HttpClients.custom() - .addInterceptorFirst(WebClientUtils.logRequest()) - .addInterceptorLast(WebClientUtils.logResponse()) - .setSSLSocketFactory(csf).build() - + .addInterceptorFirst(WebClientUtils.logRequest()) + .addInterceptorLast(WebClientUtils.logResponse()) + .setSSLSocketFactory(csf).build() } // Non Blocking Rest Implementation @@ -113,13 +116,15 @@ class SSLRestClientService(private val restClientProperties: } override fun convertToBasicHeaders(headers: Map<String, String>): Array<BasicHeader> { - var head1: Map<String, String> = defaultHeaders() - var head2: MutableMap<String, String> = head1.toMutableMap() - head2.putAll(headers) + val mergedDefaultAndSuppliedHeaders = defaultHeaders().plus(headers) + //During the initialization, getAuthService() sets the auth variable. + //If it's not null, then we have an authentication mechanism. + //If null - indicates no-auth used if (auth != null) { - return auth!!.convertToBasicHeaders(head2) + return auth!!.convertToBasicHeaders(mergedDefaultAndSuppliedHeaders) } - return super.convertToBasicHeaders(head2) + //inject additionalHeaders + return super.convertToBasicHeaders(mergedDefaultAndSuppliedHeaders + .plus(verifyAdditionalHeaders(restClientProperties))) } - -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt index 82446994c..73b534143 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/TokenAuthRestClientService.kt @@ -23,20 +23,20 @@ import org.springframework.http.MediaType class TokenAuthRestClientService(private val restClientProperties: TokenAuthRestClientProperties) : - BlueprintWebClientService { + BlueprintWebClientService { override fun defaultHeaders(): Map<String, String> { - return mapOf( - HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE, - HttpHeaders.AUTHORIZATION to restClientProperties.token!!) + HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.AUTHORIZATION to restClientProperties.token!!) } override fun convertToBasicHeaders(headers: Map<String, String>): - Array<BasicHeader> { - + Array<BasicHeader> { val customHeaders: MutableMap<String, String> = headers.toMutableMap() + //inject additionalHeaders + customHeaders.putAll(verifyAdditionalHeaders(restClientProperties)) if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) { customHeaders[HttpHeaders.AUTHORIZATION] = restClientProperties.token!! } diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt index 37a797f78..b617dab90 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt @@ -2,6 +2,7 @@ * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. * Modifications Copyright © 2019 Huawei. + * Modifications Copyright © 2019 Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,11 +29,15 @@ import org.onap.ccsdk.cds.blueprintsprocessor.rest.BluePrintRestLibConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLBasicAuthRestClientProperties import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLRestClientProperties import org.onap.ccsdk.cds.blueprintsprocessor.rest.SSLTokenAuthRestClientProperties +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.HttpHeaders +import org.springframework.http.MediaType import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertNotNull @RunWith(SpringRunner::class) @@ -63,26 +68,25 @@ import kotlin.test.assertNotNull "blueprintsprocessor.restclient.ssl.sslKeyPassword=changeit" ]) class BluePrintRestLibPropertyServiceTest { - @Autowired lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService @Test fun testRestClientProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.sample") + "blueprintsprocessor.restclient.sample") assertNotNull(properties, "failed to create property bean") assertNotNull(properties.url, "failed to get url property in" + - " property bean") + " property bean") } @Test fun testSSLBasicProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.sslbasic") + "blueprintsprocessor.restclient.sslbasic") assertNotNull(properties, "failed to create property bean") val p: SSLBasicAuthRestClientProperties = - properties as SSLBasicAuthRestClientProperties + properties as SSLBasicAuthRestClientProperties assertEquals(p.basicAuth!!.username, "admin") assertEquals(p.basicAuth!!.password, "cds") @@ -94,11 +98,11 @@ class BluePrintRestLibPropertyServiceTest { @Test fun testSSLTokenProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.ssltoken") + "blueprintsprocessor.restclient.ssltoken") assertNotNull(properties, "failed to create property bean") val p: SSLTokenAuthRestClientProperties = - properties as SSLTokenAuthRestClientProperties + properties as SSLTokenAuthRestClientProperties assertEquals(p.tokenAuth!!.token!!, "72178473kjshdkjgvbsdkjv903274908") assertEquals(p.sslTrust, "src/test/resources/keystore.p12") @@ -109,11 +113,11 @@ class BluePrintRestLibPropertyServiceTest { @Test fun testSSLNoAuthProperties() { val properties = bluePrintRestLibPropertyService.restClientProperties( - "blueprintsprocessor.restclient.ssl") + "blueprintsprocessor.restclient.ssl") assertNotNull(properties, "failed to create property bean") val p: SSLRestClientProperties = - properties as SSLRestClientProperties + properties as SSLRestClientProperties assertEquals(p.sslTrust, "src/test/resources/keystore.p12") assertEquals(p.sslTrustPassword, "changeit") @@ -125,113 +129,370 @@ class BluePrintRestLibPropertyServiceTest { @Test fun testSSLBasicPropertiesAsJson() { - val json: String = "{\n" + - " \"type\" : \"ssl-basic-auth\",\n" + - " \"url\" : \"https://localhost:8443\",\n" + - " \"keyStoreInstance\" : \"PKCS12\",\n" + - " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + - " \"sslTrustPassword\" : \"changeit\",\n" + - " \"basicAuth\" : {\n" + - " \"username\" : \"admin\",\n" + - " \"password\" : \"cds\"\n" + - " }\n" + - "}" - val mapper = ObjectMapper() - val actualObj: JsonNode = mapper.readTree(json) + val actualObj: JsonNode = defaultMapper.readTree(sslBasicAuthEndpointWithHeadersField()) val properties = bluePrintRestLibPropertyService.restClientProperties( - actualObj) + actualObj) assertNotNull(properties, "failed to create property bean") - val p: SSLBasicAuthRestClientProperties = - properties as SSLBasicAuthRestClientProperties + val p: SSLBasicAuthRestClientProperties = properties as SSLBasicAuthRestClientProperties - assertEquals(p.basicAuth!!.username, "admin") - assertEquals(p.basicAuth!!.password, "cds") - assertEquals(p.sslTrust, "src/test/resources/keystore.p12") - assertEquals(p.sslTrustPassword, "changeit") - assertEquals(p.keyStoreInstance, "PKCS12") + assertEquals("admin", p.basicAuth!!.username) + assertEquals("cds", p.basicAuth!!.password) + assertEquals("src/test/resources/keystore.p12", p.sslTrust) + assertEquals("changeit", p.sslTrustPassword) + assertEquals("PKCS12", p.keyStoreInstance) + assertEquals("ssl-basic-auth", p.type) + assertEquals("https://localhost:8443", p.url) } @Test fun testSSLTokenPropertiesAsJson() { - val json: String = "{\n" + - " \"type\" : \"ssl-token-auth\",\n" + - " \"url\" : \"https://localhost:8443\",\n" + - " \"keyStoreInstance\" : \"PKCS12\",\n" + - " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + - " \"sslTrustPassword\" : \"changeit\",\n" + - " \"tokenAuth\" : {\n" + - " \"token\" : \"72178473kjshdkjgvbsdkjv903274908\"\n" + - " }\n" + - "}" - val mapper = ObjectMapper() - val actualObj: JsonNode = mapper.readTree(json) - val properties = bluePrintRestLibPropertyService.restClientProperties( - actualObj) + val actualObj: JsonNode = defaultMapper.readTree(sslTokenAuthEndpointWithHeadersField()) + val properties = + bluePrintRestLibPropertyService.restClientProperties(actualObj) assertNotNull(properties, "failed to create property bean") - val p: SSLTokenAuthRestClientProperties = - properties as SSLTokenAuthRestClientProperties + val p: SSLTokenAuthRestClientProperties = properties as SSLTokenAuthRestClientProperties - assertEquals(p.tokenAuth!!.token!!, "72178473kjshdkjgvbsdkjv903274908") - assertEquals(p.sslTrust, "src/test/resources/keystore.p12") - assertEquals(p.sslTrustPassword, "changeit") - assertEquals(p.keyStoreInstance, "PKCS12") + assertEquals("72178473kjshdkjgvbsdkjv903274908", p.tokenAuth!!.token!!) + assertEquals("src/test/resources/keystore.p12", p.sslTrust) + assertEquals("changeit", p.sslTrustPassword) + assertEquals("PKCS12", p.keyStoreInstance) + assertEquals("ssl-token-auth", p.type) + assertEquals("https://localhost:8443", p.url) } @Test fun testSSLNoAuthPropertiesAsJson() { - val json: String = "{\n" + - " \"type\" : \"ssl-basic-auth\",\n" + - " \"url\" : \"https://localhost:8443\",\n" + - " \"keyStoreInstance\" : \"PKCS12\",\n" + - " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + - " \"sslTrustPassword\" : \"changeit\",\n" + - " \"sslKey\" : \"src/test/resources/keystore.p12\",\n" + - " \"sslKeyPassword\" : \"changeit\"\n" + - "}" - val mapper = ObjectMapper() - val actualObj: JsonNode = mapper.readTree(json) + val actualObj: JsonNode = defaultMapper.readTree(sslNoAuthEndpointWithHeadersField()) val properties = bluePrintRestLibPropertyService.restClientProperties( - actualObj) + actualObj) assertNotNull(properties, "failed to create property bean") val p: SSLRestClientProperties = - properties as SSLRestClientProperties + properties as SSLRestClientProperties - assertEquals(p.sslTrust, "src/test/resources/keystore.p12") - assertEquals(p.sslTrustPassword, "changeit") - assertEquals(p.keyStoreInstance, "PKCS12") - assertEquals(p.sslKey, "src/test/resources/keystore.p12") - assertEquals(p.sslKeyPassword, "changeit") + assertEquals("src/test/resources/keystore.p12", p.sslTrust) + assertEquals("changeit", p.sslTrustPassword) + assertEquals("PKCS12", p.keyStoreInstance) + assertEquals("src/test/resources/keystore.p12", p.sslKey) + assertEquals("changeit", p.sslKeyPassword) + assertEquals("ssl-no-auth", p.type) + assertEquals("https://localhost:8443", p.url) } @Test fun testBlueprintWebClientService() { val blueprintWebClientService = bluePrintRestLibPropertyService - .blueprintWebClientService("sample") - assertNotNull(blueprintWebClientService, "failed to create blu" + - "eprintWebClientService") + .blueprintWebClientService("sample") + assertNotNull(blueprintWebClientService, + "failed to create blueprintWebClientService") } @Test fun testBlueprintWebClientServiceWithJsonNode() { - val json: String = "{\n" + - " \"type\" : \"ssl-basic-auth\",\n" + - " \"url\" : \"https://localhost:8443\",\n" + - " \"keyStoreInstance\" : \"PKCS12\",\n" + - " \"sslTrust\" : \"src/test/resources/keystore.p12\",\n" + - " \"sslTrustPassword\" : \"changeit\",\n" + - " \"basicAuth\" : {\n" + - " \"username\" : \"admin\",\n" + - " \"password\" : \"cds\"\n" + - " }\n" + - "}" - val mapper = ObjectMapper() - val actualObj: JsonNode = mapper.readTree(json) + val actualObj: JsonNode = defaultMapper.readTree(sslBasicAuthEndpointWithHeadersField()) val blueprintWebClientService = bluePrintRestLibPropertyService - .blueprintWebClientService(actualObj) - assertNotNull(blueprintWebClientService, "failed to create blu" + - "eprintWebClientService") + .blueprintWebClientService(actualObj) + assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService") + } + + //pass the result of $typeEndpointWithHeadersField() output with and without headers to compare. + private fun validateHeadersDidNotChangeWithEmptyAdditionalHeaders(noHeaders: String, withHeaders: String) { + val parsedObj: JsonNode = defaultMapper.readTree(noHeaders) + val bpWebClientService = + bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj) + val extractedHeaders = bpWebClientService.convertToBasicHeaders(mapOf()) + + val parsedObjWithHeaders: JsonNode = defaultMapper.readTree(withHeaders) + val bpWebClientServiceWithHeaders = + bluePrintRestLibPropertyService.blueprintWebClientService(parsedObjWithHeaders) + val extractedHeadersWithAdditionalHeaders = bpWebClientServiceWithHeaders.convertToBasicHeaders(mapOf()) + //Array<BasicHeader<>> -> Map<String,String> + val headersMap = extractedHeaders.map { it.name to it.value }.toMap() + val additionalHeadersMap = extractedHeadersWithAdditionalHeaders.map { it.name to it.value }.toMap() + assertEquals(headersMap, additionalHeadersMap) + } + + @Test + fun `BasicAuth WebClientService with empty additionalHeaders does not modify headers`() { + val endPointJson = basicAuthEndpointWithHeadersField() + val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(emptyAdditionalHeaders) + validateHeadersDidNotChangeWithEmptyAdditionalHeaders(endPointJson, endPointWithHeadersJson) + } + + private fun acceptsOneAdditionalHeadersTest(endPointWithHeadersJson: String) { + val parsedObj: JsonNode = defaultMapper.readTree(endPointWithHeadersJson) + val bpWebClientService = + bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj) + val extractedHeaders = bpWebClientService.convertToBasicHeaders(mapOf()) + assertEquals(1, extractedHeaders.filter { it.name == "key1" }.count()) + } + + @Test + fun `BasicAuth WebClientService accepts one additionalHeaders`() { + val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(oneAdditionalParameter) + acceptsOneAdditionalHeadersTest(endPointWithHeadersJson) + } + + private fun acceptsMultipleAdditionalHeaders(endPointWithHeadersJson: String) { + val parsedObj: JsonNode = defaultMapper.readTree(endPointWithHeadersJson) + val bpWebClientService = + bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj) + val extractedHeaders = bpWebClientService.convertToBasicHeaders(mapOf()) + assertEquals(1, extractedHeaders.filter { it.name == "key1" }.count()) + assertEquals(1, extractedHeaders.filter { it.name == "key2" }.count()) + assertEquals(1, extractedHeaders.filter { it.name == "key3" }.count()) + } + + @Test + fun `BasicAuth WebClientService accepts multiple additionalHeaders`() { + val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(threeAdditionalHeaders) + acceptsMultipleAdditionalHeaders(endPointWithHeadersJson) + } + + private fun additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson: String) { + val parsedObj: JsonNode = defaultMapper.readTree(endPointWithHeadersJson) + val bpWebClientService = + bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj) + val extractedHeaders = bpWebClientService.convertToBasicHeaders(mapOf()) + assertEquals(MediaType.APPLICATION_XML.toString(), + extractedHeaders.filter { it.name == HttpHeaders.CONTENT_TYPE }[0].value!!) + } + + @Test + fun `BasicAuth WebClientService additionalHeaders can overwrite default Content-Type`() { + //default content type is application/json + val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(contentTypeAdditionalHeader) + additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) + } + + //called from within "assertFailsWith(exceptionClass = BluePrintProcessorException::class) {" + private fun attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson: String) { + val parsedObj: JsonNode = defaultMapper.readTree(endPointWithHeadersJson) + val bpWebClientService = + bluePrintRestLibPropertyService.blueprintWebClientService(parsedObj) + bpWebClientService.convertToBasicHeaders(mapOf()) + } + + @Test + fun `BasicAuth WebClientService throws BlueprintProcessorException if additionalHeaders contain Authorization`() { + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(additionalHeadersWithAuth) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + //spec says headers are case insensitive... + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = basicAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + } + + @Test + fun `TokenAuth WebClientService with empty additionalHeaders does not modify headers`() { + val endPointJson = sslTokenAuthEndpointWithHeadersField() + val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(emptyAdditionalHeaders) + validateHeadersDidNotChangeWithEmptyAdditionalHeaders(endPointJson, endPointWithHeadersJson) + } + + @Test + fun `TokenAuth WebClientService accepts one additionalHeaders`() { + val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(oneAdditionalParameter) + acceptsOneAdditionalHeadersTest(endPointWithHeadersJson) + } + + @Test + fun `TokenAuth WebClientService accepts multiple additionalHeaders`() { + val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(threeAdditionalHeaders) + acceptsMultipleAdditionalHeaders(endPointWithHeadersJson) + } + + @Test + fun `TokenAuth WebClientService additionalHeaders can overwrite default Content-Type`() { + //default content type is application/json + val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(contentTypeAdditionalHeader) + additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) + } + + @Test + fun `TokenAuth WebClientService throws BlueprintProcessorException if additionalHeaders contain Authorization`() { + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(additionalHeadersWithAuth) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + //spec says headers are case insensitive... + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = sslTokenAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + } + + //TESTS FOR SSL BASIC AUTH headers + @Test + fun `SSLBasicAuth WebClientService with empty additionalHeaders does not modify headers`() { + val endPointJson = sslBasicAuthEndpointWithHeadersField() + val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(emptyAdditionalHeaders) + validateHeadersDidNotChangeWithEmptyAdditionalHeaders(endPointJson, endPointWithHeadersJson) + } + + @Test + fun `SSLBasicAuth WebClientService accepts one additionalHeaders`() { + val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(oneAdditionalParameter) + acceptsOneAdditionalHeadersTest(endPointWithHeadersJson) + } + + @Test + fun `SSLBasicAuth WebClientService accepts multiple additionalHeaders`() { + val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(threeAdditionalHeaders) + acceptsMultipleAdditionalHeaders(endPointWithHeadersJson) + } + + @Test + fun `SSLBasicAuth WebClientService additionalHeaders can overwrite default Content-Type`() { + //default content type is application/json + val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(contentTypeAdditionalHeader) + additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) + } + + @Test + fun `SSLBasicAuth WebClientService throws BlueprintProcessorException if additionalHeaders contain Authorization`() { + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(additionalHeadersWithAuth) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + //spec says headers are case insensitive... + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = sslBasicAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + } + + //SSL-NO-AUTH headers tests + @Test + fun `SSLNoAuth WebClientService with empty additionalHeaders does not modify headers`() { + val endPointJson = sslNoAuthEndpointWithHeadersField() + val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(emptyAdditionalHeaders) + validateHeadersDidNotChangeWithEmptyAdditionalHeaders(endPointJson, endPointWithHeadersJson) + } + + @Test + fun `SSLNoAuth WebClientService accepts one additionalHeaders`() { + val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(oneAdditionalParameter) + acceptsOneAdditionalHeadersTest(endPointWithHeadersJson) + } + + @Test + fun `SSLNoAuth WebClientService accepts multiple additionalHeaders`() { + val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(threeAdditionalHeaders) + acceptsMultipleAdditionalHeaders(endPointWithHeadersJson) + } + + @Test + fun `SSLNoAuth WebClientService additionalHeaders can overwrite default Content-Type`() { + //default content type is application/json + val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(contentTypeAdditionalHeader) + additionalHeadersChangedContentTypeToAPPLICATION_XML(endPointWithHeadersJson) + } + + @Test + fun `SSLNoAuth WebClientService throws BlueprintProcessorException if additionalHeaders contain Authorization`() { + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(additionalHeadersWithAuth) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + //spec says headers are case insensitive... + assertFailsWith(exceptionClass = BluePrintProcessorException::class) { + val endPointWithHeadersJson = sslNoAuthEndpointWithHeadersField(additionalHeadersWithAuthLowercased) + attemptToPutAuthorizationHeaderIntoAdditionalHeaders(endPointWithHeadersJson) + } + } + + companion object BluePrintRestLibPropertyServiceTest { + val defaultMapper = ObjectMapper() + val expectedTokenAuthDefaultHeaders = mapOf<String, String>( + "Content-Type" to "application/json", + "Accept" to "application/json", + "Authorization" to "72178473kjshdkjgvbsdkjv903274908") + + val endPointWithHeadersJsonWithBasicAuthHeader = basicAuthEndpointWithHeadersField(""", + "additionalHeaders" : { + "authorization": "Basic aGF2ZTphbmljZWRheQo=" + }""".trimIndent()) + + private fun sslTokenAuthEndpointWithHeadersField(headers: String = ""): String = + """{ + "type" : "ssl-token-auth", + "url" : "https://localhost:8443", + "keyStoreInstance" : "PKCS12", + "sslTrust" : "src/test/resources/keystore.p12", + "sslTrustPassword" : "changeit", + "tokenAuth" : { + "token" : "72178473kjshdkjgvbsdkjv903274908" + }$headers + } + """.trimIndent() + + private fun sslBasicAuthEndpointWithHeadersField(headers: String = ""): String = + """{ + "type" : "ssl-basic-auth", + "url" : "https://localhost:8443", + "keyStoreInstance" : "PKCS12", + "sslTrust" : "src/test/resources/keystore.p12", + "sslTrustPassword" : "changeit", + "basicAuth" : { + "username" : "admin", + "password" : "cds" + }$headers + }""".trimIndent() + + private fun sslNoAuthEndpointWithHeadersField(headers: String = ""): String = """{ + "type" : "ssl-no-auth", + "url" : "https://localhost:8443", + "keyStoreInstance" : "PKCS12", + "sslTrust" : "src/test/resources/keystore.p12", + "sslTrustPassword" : "changeit", + "sslKey" : "src/test/resources/keystore.p12", + "sslKeyPassword" : "changeit"$headers + }""".trimIndent() + + //Don't forget to supply "," as the first char to make valid JSON + private fun basicAuthEndpointWithHeadersField(headers: String = ""): String = + """{ + "type": "basic-auth", + "url": "http://127.0.0.1:8000", + "username": "user", + "password": "pass"$headers + }""".trimIndent() + + private val emptyAdditionalHeaders = """, + "additionalHeaders" : { + }""".trimIndent() + + private val oneAdditionalParameter = """, + "additionalHeaders" : { + "key1": "value1" + }""".trimIndent() + + private val threeAdditionalHeaders = """, + "additionalHeaders" : { + "key1": "value1", + "key2": "value2", + "key3": "value3" + }""".trimIndent() + + private val contentTypeAdditionalHeader = """, + "additionalHeaders" : { + "${HttpHeaders.CONTENT_TYPE}": "${MediaType.APPLICATION_XML}" + }""".trimIndent() + + private val additionalHeadersWithAuth = """, + "additionalHeaders" : { + "Authorization": "Basic aGF2ZTphbmljZWRheQo=" + }""".trimIndent() + + private val additionalHeadersWithAuthLowercased = """, + "additionalHeaders" : { + "authorization": "Basic aGF2ZTphbmljZWRheQo=" + }""".trimIndent() } } diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt index c3f18fcba..b4c1ad0e0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/configs/api/ResourceConfigSnapshotControllerTest.kt @@ -129,14 +129,15 @@ class ResourceConfigSnapshotControllerTest { } @Test - fun `get returns 404 if entry not found`() { + fun `get returns 200 if entry not found`() { runBlocking { webTestClient .get() .uri("/api/v1/configs?resourceId=MISSING&resourceType=PNF") .exchange() - .expectStatus().isNotFound + .expectStatus().is2xxSuccessful + .expectBody() } } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt index 451f827b6..0116680cf 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt @@ -24,21 +24,19 @@ import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.currentTimestamp import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.common.api.Status +import org.onap.ccsdk.cds.controllerblueprints.core.* import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration -import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile -import org.onap.ccsdk.cds.controllerblueprints.core.reCreateDirs -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.management.api.* import org.slf4j.LoggerFactory import org.springframework.security.access.prepost.PreAuthorize import org.springframework.stereotype.Service import java.io.File import java.util.* +// TODO("move to management-api or designer-api module") @Service open class BluePrintManagementGRPCHandler(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, private val blueprintsProcessorCatalogService: BluePrintCatalogService) @@ -53,19 +51,48 @@ open class BluePrintManagementGRPCHandler(private val bluePrintLoadConfiguration log.info("request(${request.commonHeader.requestId})") val uploadId = UUID.randomUUID().toString() + val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, uploadId) + val blueprintWorking = normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId) try { - val cbaFile = normalizedFile(bluePrintLoadConfiguration.blueprintArchivePath, uploadId, "cba-zip") + val cbaFile = normalizedFile(blueprintArchive, "cba.zip") saveToDisk(request, cbaFile) - val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(uploadId, cbaFile) - responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...", request.commonHeader)) + val uploadAction = request.actionIdentifiers?.actionName.emptyTONull() + ?: UploadAction.DRAFT.toString() + + when (uploadAction) { + UploadAction.DRAFT.toString() -> { + val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(uploadId, cbaFile, false) + responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...", + request.commonHeader)) + } + UploadAction.PUBLISH.toString() -> { + val blueprintId = blueprintsProcessorCatalogService.saveToDatabase(uploadId, cbaFile, true) + responseObserver.onNext(successStatus("Successfully uploaded CBA($blueprintId)...", + request.commonHeader)) + } + UploadAction.VALIDATE.toString() -> { + //TODO("Not Implemented") + responseObserver.onError(failStatus("Not Implemented", + BluePrintProcessorException("Not Implemented"))) + } + UploadAction.ENRICH.toString() -> { + //TODO("Not Implemented") + responseObserver.onError(failStatus("Not Implemented", + BluePrintProcessorException("Not Implemented"))) + } + } responseObserver.onCompleted() } catch (e: Exception) { responseObserver.onError(failStatus("request(${request.commonHeader.requestId}): Failed to upload CBA", e)) } finally { - deleteDir(bluePrintLoadConfiguration.blueprintArchivePath, uploadId) - deleteDir(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId) + // Clean blueprint script cache + val cacheKey = BluePrintFileUtils + .compileCacheKey(normalizedPathName(bluePrintLoadConfiguration.blueprintWorkingPath, uploadId)) + BluePrintCompileCache.cleanClassLoader(cacheKey) + deleteNBDir(blueprintArchive) + deleteNBDir(blueprintWorking) } } } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt new file mode 100644 index 000000000..b339903c5 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumer.kt @@ -0,0 +1,108 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api + +import kotlinx.coroutines.channels.consumeEach +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageConsumerService +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsType +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.boot.context.event.ApplicationReadyEvent +import org.springframework.context.event.EventListener +import org.springframework.stereotype.Service +import javax.annotation.PreDestroy + +@ConditionalOnProperty(name = ["blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable"], + havingValue = "true") +@Service +open class BluePrintProcessingKafkaConsumer( + private val bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService, + private val executionServiceHandler: ExecutionServiceHandler) { + + val log = logger(BluePrintProcessingKafkaConsumer::class) + + private lateinit var blueprintMessageConsumerService: BlueprintMessageConsumerService + + companion object { + const val CONSUMER_SELECTOR = "self-service-api" + const val PRODUCER_SELECTOR = "self-service-api" + } + + @EventListener(ApplicationReadyEvent::class) + fun setupMessageListener() = runBlocking { + try { + log.info("Setting up message consumer($CONSUMER_SELECTOR) and " + + "message producer($PRODUCER_SELECTOR)...") + + /** Get the Message Consumer Service **/ + blueprintMessageConsumerService = try { + bluePrintMessageLibPropertyService + .blueprintMessageConsumerService(CONSUMER_SELECTOR) + } catch (e: Exception) { + throw BluePrintProcessorException("failed to create consumer service ${e.message}") + } + + /** Get the Message Producer Service **/ + val blueprintMessageProducerService = try { + bluePrintMessageLibPropertyService + .blueprintMessageProducerService(PRODUCER_SELECTOR) + } catch (e: Exception) { + throw BluePrintProcessorException("failed to create producer service ${e.message}") + } + + launch { + /** Subscribe to the consumer topics */ + val additionalConfig: MutableMap<String, Any> = hashMapOf() + val channel = blueprintMessageConsumerService.subscribe(additionalConfig) + channel.consumeEach { message -> + launch { + try { + log.trace("Consumed Message : $message") + val executionServiceInput = message.jsonAsType<ExecutionServiceInput>() + val executionServiceOutput = executionServiceHandler.doProcess(executionServiceInput) + //TODO("In future, Message publisher configuration vary with respect to request") + /** Send the response message */ + blueprintMessageProducerService.sendMessage(executionServiceOutput) + } catch (e: Exception) { + log.error("failed in processing the consumed message : $message", e) + } + } + } + } + } catch (e: Exception) { + log.error("failed to start message consumer($CONSUMER_SELECTOR) and " + + "message producer($PRODUCER_SELECTOR) ", e) + } + } + + @PreDestroy + fun shutdownMessageListener() = runBlocking { + try { + log.info("Shutting down message consumer($CONSUMER_SELECTOR) and " + + "message producer($PRODUCER_SELECTOR)...") + blueprintMessageConsumerService.shutDown() + } catch (e: Exception) { + log.error("failed to shutdown message listener($CONSUMER_SELECTOR)", e) + } + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt index 9dd04bf95..2f8878034 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt @@ -49,6 +49,7 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString()) + //TODO("Remove from self service api and move to designer api module") suspend fun upload(filePart: FilePart): String { val saveId = UUID.randomUUID().toString() val blueprintArchive = normalizedPathName(bluePrintLoadConfiguration.blueprintArchivePath, saveId) @@ -74,6 +75,7 @@ class ExecutionServiceHandler(private val bluePrintLoadConfiguration: BluePrintL } } + //TODO("Remove from self service api and move to designer api module") suspend fun remove(name: String, version: String) { blueprintsProcessorCatalogService.deleteFromDatabase(name, version) } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/MessagingConfig.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/MessagingConfig.kt deleted file mode 100644 index 17e157d15..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/MessagingConfig.kt +++ /dev/null @@ -1,58 +0,0 @@ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api - -import com.fasterxml.jackson.databind.DeserializationFeature -import com.fasterxml.jackson.databind.ObjectMapper -import org.apache.kafka.clients.CommonClientConfigs -import org.apache.kafka.clients.consumer.ConsumerConfig -import org.apache.kafka.common.serialization.StringDeserializer -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory -import org.springframework.kafka.core.ConsumerFactory -import org.springframework.kafka.core.DefaultKafkaConsumerFactory -import org.springframework.kafka.support.serializer.ErrorHandlingDeserializer2 -import org.springframework.kafka.support.serializer.JsonDeserializer - -@Configuration -open class MessagingConfig { - - @Value("\${blueprintsprocessor.messageclient.self-service-api.groupId}") - lateinit var groupId: String - - @Value("\${blueprintsprocessor.messageclient.self-service-api.bootstrapServers}") - lateinit var bootstrapServers: String - - open fun consumerFactory(): ConsumerFactory<String, ExecutionServiceInput>? { - val configProperties = hashMapOf<String, Any>() - configProperties[CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG] = bootstrapServers - configProperties[ConsumerConfig.GROUP_ID_CONFIG] = groupId - configProperties[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "latest" - configProperties[ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG] = StringDeserializer::class.java - configProperties[ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG] = ErrorHandlingDeserializer2::class.java - configProperties[ErrorHandlingDeserializer2.VALUE_DESERIALIZER_CLASS] = JsonDeserializer::class.java.name - - val deserializer = JsonDeserializer<ExecutionServiceInput>() - deserializer.setRemoveTypeHeaders(true) - deserializer.addTrustedPackages("*") - - val jsonDeserializer = JsonDeserializer(ExecutionServiceInput::class.java, - ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)) - - return DefaultKafkaConsumerFactory(configProperties, StringDeserializer(), - ErrorHandlingDeserializer2<ExecutionServiceInput>(jsonDeserializer)) - } - - /** - * Creation of a Kafka MessageListener Container - * - * @return KafkaListener instance. - */ - @Bean - open fun kafkaListenerContainerFactory(): ConcurrentKafkaListenerContainerFactory<String, ExecutionServiceInput> { - val factory = ConcurrentKafkaListenerContainerFactory<String, ExecutionServiceInput>() - factory.consumerFactory = consumerFactory() - return factory - } -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/MessagingController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/MessagingController.kt deleted file mode 100644 index 54cc0c129..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/MessagingController.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright © 2019 Bell Canada - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api - -import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking -import org.apache.commons.lang3.builder.ToStringBuilder -import org.apache.kafka.clients.consumer.ConsumerRecord -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService -import org.slf4j.LoggerFactory -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty -import org.springframework.kafka.annotation.KafkaListener -import org.springframework.stereotype.Service - -@ConditionalOnProperty(name = ["blueprintsprocessor.messageclient.self-service-api.kafkaEnable"], havingValue = "true") -@Service -open class MessagingController(private val propertyService: BluePrintMessageLibPropertyService, - private val executionServiceHandler: ExecutionServiceHandler) { - - private val log = LoggerFactory.getLogger(MessagingController::class.java)!! - - companion object { - // TODO PREFIX should be retrieved from model or from request. - const val PREFIX = "self-service-api" - const val EXECUTION_STATUS = 200 - } - - @KafkaListener(topics = ["\${blueprintsprocessor.messageclient.self-service-api.consumerTopic}"]) - open fun receive(record: ConsumerRecord<String, ExecutionServiceInput>) { - - runBlocking { - log.info("Successfully received a message: {}", ToStringBuilder.reflectionToString(record.value())) - - // Process the message. - async { - processMessage(record.value()) - }.await() - } - } - - private suspend fun processMessage(executionServiceInput: ExecutionServiceInput) { - - val executionServiceOutput = executionServiceHandler.doProcess(executionServiceInput) - - if (executionServiceOutput.status.code == EXECUTION_STATUS) { - val bluePrintMessageClientService = propertyService - .blueprintMessageClientService(PREFIX) - - val payload = executionServiceOutput.payload - - log.info("The payload to publish is {}", payload) - - bluePrintMessageClientService.sendMessage(payload) - } - else { - log.error("Fail to process the given event due to {}", executionServiceOutput.status.errorMessage) - } - } -} diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt index e084c60cf..9629aa4b5 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt @@ -23,19 +23,14 @@ import io.grpc.testing.GrpcServerRule import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.messaginglib.MessagingControllerTest -import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.messaginglib.ProducerConfiguration +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintRemoveInput -import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput -import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk +import org.onap.ccsdk.cds.controllerblueprints.management.api.* import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.FilterType import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @@ -47,9 +42,7 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @EnableAutoConfiguration @DirtiesContext -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"], - excludeFilters = [ComponentScan.Filter(value = [MessagingConfig::class, MessagingController::class, ProducerConfiguration::class, - MessagingControllerTest.ConsumerConfiguration::class, MessagingControllerTest::class], type = FilterType.ASSIGNABLE_TYPE)]) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintManagementGRPCHandlerTest { @@ -75,7 +68,7 @@ class BluePrintManagementGRPCHandlerTest { fun `test upload blueprint`() { val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel) val id = "123_upload" - val req = createUploadInputRequest(id) + val req = createUploadInputRequest(id, UploadAction.PUBLISH.toString()) val output = blockingStub.uploadBlueprint(req) assertEquals(200, output.status.code) @@ -87,7 +80,7 @@ class BluePrintManagementGRPCHandlerTest { fun `test delete blueprint`() { val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel) val id = "123_delete" - val req = createUploadInputRequest(id) + val req = createUploadInputRequest(id, UploadAction.DRAFT.toString()) var output = blockingStub.uploadBlueprint(req) assertEquals(200, output.status.code) @@ -99,7 +92,7 @@ class BluePrintManagementGRPCHandlerTest { assertEquals(200, output.status.code) } - private fun createUploadInputRequest(id: String): BluePrintUploadInput { + private fun createUploadInputRequest(id: String, action: String): BluePrintUploadInput { val file = normalizedFile("./src/test/resources/test-cba.zip") assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") @@ -110,11 +103,18 @@ class BluePrintManagementGRPCHandlerTest { .setRequestId(id) .setSubRequestId("1234-56").build() + val actionIdentifier = ActionIdentifiers.newBuilder() + .setActionName(action) + .setBlueprintName("sample") + .setBlueprintVersion("1.0.0") + .build() + val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes())) .build() return BluePrintUploadInput.newBuilder() .setCommonHeader(commonHeader) + .setActionIdentifiers(actionIdentifier) .setFileChunk(fileChunk) .build() } diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt index ce5acd400..8bedc9628 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt @@ -1,6 +1,7 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2019 Bell Canada. + * Modifications Copyright © 2019 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,6 @@ import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.FilterType import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @@ -44,8 +44,8 @@ import kotlin.test.BeforeTest @RunWith(SpringRunner::class) @DirtiesContext @EnableAutoConfiguration -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"], - excludeFilters =arrayOf(ComponentScan.Filter(value = [(MessagingController::class)], type = FilterType.ASSIGNABLE_TYPE))) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", + "org.onap.ccsdk.cds.controllerblueprints"]) @TestPropertySource(locations = ["classpath:application-test.properties"]) class BluePrintProcessingGRPCHandlerTest { private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java) diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt new file mode 100644 index 000000000..7d43f533f --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingKafkaConsumerTest.kt @@ -0,0 +1,66 @@ +/* + * Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api + +import io.mockk.coEvery +import io.mockk.mockk +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.message.BluePrintMessageLibConfiguration +import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.Test +import kotlin.test.assertNotNull + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [BluePrintMessageLibConfiguration::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) +class BluePrintProcessingKafkaConsumerTest { + + @Autowired + lateinit var bluePrintMessageLibPropertyService: BluePrintMessageLibPropertyService + + @Test + fun testExecutionInputMessageConsumer() { + runBlocking { + assertNotNull(bluePrintMessageLibPropertyService, + "failed to initialise bluePrintMessageLibPropertyService") + + val executionServiceHandle = mockk<ExecutionServiceHandler>() + + coEvery { executionServiceHandle.doProcess(any()) } returns mockk() + + val bluePrintProcessingKafkaConsumer = BluePrintProcessingKafkaConsumer(bluePrintMessageLibPropertyService, + executionServiceHandle) + + launch { + bluePrintProcessingKafkaConsumer.setupMessageListener() + } + delay(100) + bluePrintProcessingKafkaConsumer.shutdownMessageListener() + } + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt new file mode 100644 index 000000000..fc6c4890c --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt @@ -0,0 +1,100 @@ +/* + * Copyright © 2019 Bell Canada + * Modifications Copyright © 2019 IBM. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api + +import kotlinx.coroutines.reactive.awaitSingle +import kotlinx.coroutines.runBlocking +import org.junit.After +import org.junit.Before +import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.boot.autoconfigure.security.SecurityProperties +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.context.annotation.ComponentScan +import org.springframework.core.io.ByteArrayResource +import org.springframework.http.client.MultipartBodyBuilder +import org.springframework.test.annotation.DirtiesContext +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import org.springframework.test.web.reactive.server.WebTestClient +import org.springframework.test.web.reactive.server.returnResult +import org.springframework.web.reactive.function.BodyInserters +import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import kotlin.test.Test + +@RunWith(SpringRunner::class) +@EnableAutoConfiguration +@ContextConfiguration(classes = [ExecutionServiceControllerTest::class, SecurityProperties::class]) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) +@DirtiesContext +@WebFluxTest +class ExecutionServiceControllerTest { + + private val log = LoggerFactory.getLogger(ExecutionServiceControllerTest::class.java)!! + + @Autowired + lateinit var webTestClient: WebTestClient + + var event: ExecutionServiceInput? = null + + @Before + fun setup() { + deleteDir("target", "blueprints") + } + + @After + fun clean() { + deleteDir("target", "blueprints") + } + + @Test + fun uploadBluePrint() { + runBlocking { + val body = MultipartBodyBuilder().apply { + part("file", object : ByteArrayResource(Files.readAllBytes(loadCbaArchive().toPath())) { + override fun getFilename(): String { + return "test-cba.zip" + } + }) + }.build() + + webTestClient + .post() + .uri("/api/v1/execution-service/upload") + .body(BodyInserters.fromMultipartData(body)) + .exchange() + .expectStatus().isOk + .returnResult<String>() + .responseBody + .awaitSingle() + } + } + + private fun loadCbaArchive(): File { + return Paths.get("./src/test/resources/cba-for-kafka-integration_enriched.zip").toFile() + } +} + + diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt index d9e352bff..a480b115b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt @@ -30,7 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.security.SecurityProperties import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.FilterType import org.springframework.core.io.ByteArrayResource import org.springframework.http.client.MultipartBodyBuilder import org.springframework.test.context.ContextConfiguration @@ -49,9 +48,10 @@ import kotlin.test.assertTrue @RunWith(SpringRunner::class) @WebFluxTest -@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, BluePrintCatalogService::class, SecurityProperties::class]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"], - excludeFilters =arrayOf(ComponentScan.Filter(value = [(MessagingController::class)], type = FilterType.ASSIGNABLE_TYPE))) +@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, + BluePrintCatalogService::class, SecurityProperties::class]) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", + "org.onap.ccsdk.cds.controllerblueprints"]) @TestPropertySource(locations = ["classpath:application-test.properties"]) class ExecutionServiceHandlerTest { diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/messaginglib/MessagingControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/messaginglib/MessagingControllerTest.kt deleted file mode 100644 index facbec585..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/messaginglib/MessagingControllerTest.kt +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright © 2019 Bell Canada - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.messaginglib - -import com.fasterxml.jackson.databind.node.ObjectNode -import kotlinx.coroutines.reactive.awaitSingle -import kotlinx.coroutines.runBlocking -import org.apache.commons.lang.builder.ToStringBuilder -import org.apache.kafka.clients.CommonClientConfigs -import org.apache.kafka.clients.consumer.ConsumerConfig -import org.apache.kafka.common.serialization.StringDeserializer -import org.junit.After -import org.junit.Before -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData -import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.MessagingController -import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir -import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.autoconfigure.EnableAutoConfiguration -import org.springframework.boot.autoconfigure.security.SecurityProperties -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.Configuration -import org.springframework.core.io.ByteArrayResource -import org.springframework.http.client.MultipartBodyBuilder -import org.springframework.kafka.annotation.EnableKafka -import org.springframework.kafka.annotation.KafkaListener -import org.springframework.kafka.annotation.PartitionOffset -import org.springframework.kafka.annotation.TopicPartition -import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory -import org.springframework.kafka.core.ConsumerFactory -import org.springframework.kafka.core.DefaultKafkaConsumerFactory -import org.springframework.kafka.core.KafkaTemplate -import org.springframework.kafka.support.serializer.JsonDeserializer -import org.springframework.kafka.test.context.EmbeddedKafka -import org.springframework.test.annotation.DirtiesContext -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.TestPropertySource -import org.springframework.test.context.junit4.SpringRunner -import org.springframework.test.web.reactive.server.WebTestClient -import org.springframework.test.web.reactive.server.returnResult -import org.springframework.web.reactive.function.BodyInserters -import java.io.File -import java.nio.file.Files -import java.nio.file.Paths -import kotlin.test.assertNotNull -//FIXME("testReceive method is failing in server build, It is not stable, may be timing issue.") -@Ignore -@RunWith(SpringRunner::class) -@EnableAutoConfiguration -@ContextConfiguration(classes = [MessagingControllerTest::class, SecurityProperties::class]) -@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) -@TestPropertySource(locations = ["classpath:application-test.properties"]) -@DirtiesContext -@EmbeddedKafka(ports = [9092]) -@WebFluxTest -class MessagingControllerTest { - - private val log = LoggerFactory.getLogger(MessagingControllerTest::class.java)!! - - @Autowired - lateinit var controller: MessagingController - - @Value("\${blueprintsprocessor.messageclient.self-service-api.consumerTopic}") - lateinit var topicUsedForConsumer: String - - @Autowired - lateinit var kt: KafkaTemplate<String, ExecutionServiceInput> - - @Autowired - lateinit var webTestClient: WebTestClient - - var event: ExecutionServiceInput? = null - - @Before - fun setup() { - deleteDir("target", "blueprints") - uploadBluePrint() - } - - @After - fun clean() { - deleteDir("target", "blueprints") - } - - @Test - fun testReceive() { - val samplePayload = "{\n" + - " \"resource-assignment-request\": {\n" + - " \"artifact-name\": [\"hostname\"],\n" + - " \"store-result\": true,\n" + - " \"resource-assignment-properties\" : {\n" + - " \"hostname\": \"demo123\"\n" + - " }\n" + - " }\n" + - " }" - - kt.defaultTopic = topicUsedForConsumer - - val input = ExecutionServiceInput().apply { - commonHeader = CommonHeader().apply { - originatorId = "1" - requestId = "1234" - subRequestId = "1234-1234" - } - - actionIdentifiers = ActionIdentifiers().apply { - blueprintName = "golden" - blueprintVersion = "1.0.0" - actionName = "resource-assignment" - mode = "sync" - } - - stepData = StepData().apply { - name = "resource-assignment" - } - - payload = JacksonUtils.jsonNode(samplePayload) as ObjectNode - } - - kt.sendDefault(input) - log.info("test-sender sent message='{}'", ToStringBuilder.reflectionToString(input)) - - Thread.sleep(1000) - - assertNotNull(event) - } - - @KafkaListener(topicPartitions = [TopicPartition(topic = "\${blueprintsprocessor.messageclient.self-service-api.topic}", partitionOffsets = [PartitionOffset(partition = "0", initialOffset = "0")])]) - fun receivedEventFromBluePrintProducer(receivedEvent: ExecutionServiceInput) { - event = receivedEvent - } - - private fun uploadBluePrint() { - runBlocking { - val body = MultipartBodyBuilder().apply { - part("file", object : ByteArrayResource(Files.readAllBytes(loadCbaArchive().toPath())) { - override fun getFilename(): String { - return "test-cba.zip" - } - }) - }.build() - - webTestClient - .post() - .uri("/api/v1/execution-service/upload") - .body(BodyInserters.fromMultipartData(body)) - .exchange() - .expectStatus().isOk - .returnResult<String>() - .responseBody - .awaitSingle() - } - } - - private fun loadCbaArchive():File { - return Paths.get("./src/test/resources/cba-for-kafka-integration_enriched.zip").toFile() - } - - @Configuration - @EnableKafka - open class ConsumerConfiguration { - - @Value("\${blueprintsprocessor.messageclient.self-service-api.bootstrapServers}") - lateinit var bootstrapServers: String - - @Value("\${blueprintsprocessor.messageclient.self-service-api.groupId}") - lateinit var groupId:String - - @Bean - open fun consumerFactory2(): ConsumerFactory<String, ExecutionServiceInput>? { - val configProperties = hashMapOf<String, Any>() - configProperties[CommonClientConfigs.BOOTSTRAP_SERVERS_CONFIG] = bootstrapServers - configProperties[ConsumerConfig.GROUP_ID_CONFIG] = groupId - configProperties[ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG] = StringDeserializer::class.java.name - configProperties[ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG] = JsonDeserializer::class.java.name - configProperties[ConsumerConfig.AUTO_OFFSET_RESET_CONFIG] = "earliest" - configProperties[ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG] = 1000 - - return DefaultKafkaConsumerFactory(configProperties, StringDeserializer(), - JsonDeserializer(ExecutionServiceInput::class.java)) - } - - @Bean - open fun listenerFactory(): ConcurrentKafkaListenerContainerFactory<String, ExecutionServiceInput> { - val factory = ConcurrentKafkaListenerContainerFactory<String, ExecutionServiceInput>() - factory.consumerFactory = consumerFactory2() - return factory - } - } -} - - diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/messaginglib/ProducerConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/messaginglib/ProducerConfiguration.kt deleted file mode 100644 index dc1f38a63..000000000 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/messaginglib/ProducerConfiguration.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2019 Bell Canada - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.messaginglib - -import org.apache.kafka.clients.producer.ProducerConfig -import org.apache.kafka.common.serialization.StringSerializer -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.springframework.beans.factory.annotation.Value -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration -import org.springframework.kafka.annotation.EnableKafka -import org.springframework.kafka.core.DefaultKafkaProducerFactory -import org.springframework.kafka.core.KafkaTemplate -import org.springframework.kafka.core.ProducerFactory -import org.springframework.kafka.support.serializer.JsonSerializer - -@Configuration -open class ProducerConfiguration { - - @Value("\${blueprintsprocessor.messageclient.self-service-api.bootstrapServers}") - lateinit var bootstrapServers: String - - open fun kpf(): ProducerFactory<String, ExecutionServiceInput> { - val configs = HashMap<String, Any>() - configs[ProducerConfig.BOOTSTRAP_SERVERS_CONFIG] = bootstrapServers - configs[ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG] = StringSerializer::class.java - configs[ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG] = JsonSerializer::class.java - return DefaultKafkaProducerFactory(configs) - } - - @Bean - open fun kt(): KafkaTemplate<String, ExecutionServiceInput> { - return KafkaTemplate<String, ExecutionServiceInput>(kpf()) - } -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties index ab3bac88f..d18b70010 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties @@ -33,10 +33,15 @@ blueprints.processor.functions.python.executor.executionPath=./../../../../compo blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints # Kafka-message-lib Configuration -blueprintsprocessor.messageclient.self-service-api.kafkaEnable=true -blueprintsprocessor.messageclient.self-service-api.topic=producer.t -blueprintsprocessor.messageclient.self-service-api.type=kafka-basic-auth -blueprintsprocessor.messageclient.self-service-api.bootstrapServers=127.0.0.1:9092 -blueprintsprocessor.messageclient.self-service-api.consumerTopic=receiver.t -blueprintsprocessor.messageclient.self-service-api.groupId=receiver-id -blueprintsprocessor.messageclient.self-service-api.clientId=default-client-id +blueprintsprocessor.messageconsumer.self-service-api.kafkaEnable=false +blueprintsprocessor.messageconsumer.self-service-api.type=kafka-basic-auth +blueprintsprocessor.messageconsumer.self-service-api.bootstrapServers=127.0.0.1:9092 +blueprintsprocessor.messageconsumer.self-service-api.topic=receiver.t +blueprintsprocessor.messageconsumer.self-service-api.groupId=receiver-id +blueprintsprocessor.messageconsumer.self-service-api.clientId=default-client-id +blueprintsprocessor.messageconsumer.self-service-api.pollMillSec=10 + +blueprintsprocessor.messageproducer.self-service-api.type=kafka-basic-auth +blueprintsprocessor.messageproducer.self-service-api.bootstrapServers=127.0.0.1:9092 +blueprintsprocessor.messageproducer.self-service-api.clientId=default-client-id +blueprintsprocessor.messageproducer.self-service-api.topic=producer.t diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback-test.xml index 0c8d93bf0..dd81657a4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback-test.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-bpmn-camunda.json deleted file mode 100644 index cae06c18f..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-bpmn-camunda.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Camunda BPM File", - "version": "1.0.0", - "file_ext": [ - "bpmn" - ], - "derived_from": "tosca.artifacts.Implementation" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-directed-graph.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-directed-graph.json deleted file mode 100644 index 10bf7d2c4..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-directed-graph.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "description": "Directed Graph File", - "version": "1.0.0", - "file_ext": [ - "json", - "xml" - ], - "derived_from": "tosca.artifacts.Implementation" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json deleted file mode 100644 index f50562890..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Velocity and jinja Templates Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-script-python.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-script-python.json deleted file mode 100644 index 22af3b0a9..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-script-python.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-jinja.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-jinja.json deleted file mode 100644 index e32da5ef0..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-jinja.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": "Jinja Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "jinja" - ], - "derived_from": "tosca.artifacts.Implementation" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json deleted file mode 100644 index 20f94c946..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json deleted file mode 100644 index d75f33760..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "TOSCA base type for implementation artifacts", - "version": "1.0.0", - "derived_from": "tosca.artifacts.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-property.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-property.json deleted file mode 100644 index d3ecffd17..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-property.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json deleted file mode 100644 index 8fa595a15..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "status": { - "required": false, - "type": "string" - }, - "message": { - "required": false, - "type": "string" - }, - "updated-date": { - "required": false, - "type": "string" - }, - "updated-by": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-license-key.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-license-key.json deleted file mode 100644 index 27e25fe17..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-license-key.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-plicense-key Data Type", - "properties": { - "license-key": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json deleted file mode 100644 index 4f7be2dba..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-v4-aggregate Data Type", - "properties": { - "ipv4-address": { - "required": true, - "type": "string" - }, - "ipv4-plen": { - "required": false, - "type": "integer" - } - }, - "derived_from": "tosca.datatypes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json deleted file mode 100644 index 68d91652f..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "1.0.0", - "description": "Credential", - "properties": { - "protocol": { - "required": false, - "type": "string" - }, - "token_type": { - "required": true, - "type": "string", - "default" : "password" - }, - "token": { - "required": false, - "type": "string" - }, - "keys": { - "required": false, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "user": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json deleted file mode 100644 index 142066121..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "description": "This is Configuration Velocity and Jinja Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json deleted file mode 100644 index 3d90986a0..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "description": "This is Generate Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-config-generator-service-ConfigGeneratorNode": { - "operations": { - "process": { - "inputs": { - "template-data": { - "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "template-content": { - "description": "Conditional : Dynamic Template used to generate Configuration.", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "action-name": { - "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "template-name": { - "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - } - }, - "outputs": { - "generated-config": { - "description": "Generated Configuration for the Template adn Resource Data", - "required": true, - "type": "string" - }, - "mask-info": { - "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.cds.controllerblueprints.core.data.custom.MaskInfo ", - "required": false, - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-netconf-executor.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-netconf-executor.json deleted file mode 100644 index 22f5c9b3c..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-netconf-executor.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "description": "This is Netconf Transaction Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vnf-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "org-onap-ccsdk-netconf-adaptor-service-NetconfExecutorNode": { - "operations": { - "process": { - "inputs": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "service-template-name": { - "description": "Service Template Name", - "required": true, - "type": "string" - }, - "service-template-version": { - "description": "Service Template Version", - "required": true, - "type": "string" - }, - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-id": { - "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "reservation-id": { - "description": "Reservation Id used to send to NPM", - "required": false, - "type": "string" - }, - "execution-script": { - "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.", - "required": true, - "type": "string" - } - }, - "outputs": { - "response-data": { - "description": "Execution Response Data in JSON format.", - "required": false, - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-resource-assignment.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-resource-assignment.json deleted file mode 100644 index e009f8583..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-resource-assignment.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "ResourceAssignmentComponent": { - "operations": { - "process": { - "inputs": { - "service-template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "service-template-version": { - "description": "Service Template Version.", - "required": true, - "type": "string" - }, - "resource-type": { - "description": "Request type.", - "required": true, - "type": "string" - }, - "template-names": { - "description": "Name of the artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "request-id": { - "description": "Request Id, Unique Id for the request.", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Resource Id.", - "required": true, - "type": "string" - }, - "action-name": { - "description": "Action Name of the process", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-activate-netconf.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-activate-netconf.json deleted file mode 100644 index c17a36c1b..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-activate-netconf.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "description": "This is Download Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ActivateNetconf": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - - "derived_from": "tosca.nodes.Workflow" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json deleted file mode 100644 index 4d5343c3a..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "This is Activate DG for Config Generator Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-config-generator", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "GenerateConfiguration": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Workflow" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json deleted file mode 100644 index f44486416..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "description": "This is Resource Assign and Activate Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "ra-component": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - }, - "netconf-component": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignAndActivate": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Workflow" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assignment.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assignment.json deleted file mode 100644 index d13668aaf..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assignment.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Workflow" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json deleted file mode 100644 index 4db3f73c8..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Deprecated Artifact Node Type.", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json deleted file mode 100644 index d559216af..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is default Component Node", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json deleted file mode 100644 index eb8cac0ae..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Directed Graph Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json deleted file mode 100644 index c2f5b8687..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is VNF Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json deleted file mode 100644 index 908e5682e..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Python Component", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json deleted file mode 100644 index b226a0cf8..000000000 --- a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "description": "This is VNF Device with Netconf Capability", - "version": "1.0.0", - "capabilities": { - "netconf": { - "type": "tosca.capability.Netconf", - "properties": { - "login-key": { - "required": true, - "type": "string", - "default": "sdnc" - }, - "login-account": { - "required": true, - "type": "string", - "default": "sdnc-tacacs" - }, - "source": { - "required": true, - "type": "string", - "default": "npm" - }, - "target-ip-address": { - "required": true, - "type": "string" - }, - "port-number": { - "required": true, - "type": "integer", - "default": 830 - }, - "connection-time-out": { - "required": false, - "type": "integer", - "default": 30 - } - } - } - }, - "derived_from": "tosca.nodes.Vnf" - -} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt index 08bc6c3fd..b74b7e4cf 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/CustomFunctions.kt @@ -54,6 +54,10 @@ fun String.asJsonPrimitive(): TextNode { return TextNode(this) } +inline fun <reified T : Any> String.jsonAsType(): T { + return JacksonUtils.readValue<T>(this.trim()) +} + // If you know the string is json content, then use the function directly fun String.jsonAsJsonType(): JsonNode { return JacksonUtils.jsonNode(this.trim()) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt index ac4fc6aea..47b4f2179 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -28,7 +28,7 @@ import kotlin.test.assertNotNull */ class BluePrintRepoFileServiceTest { - private val basePath = "load/model_type" + private val basePath = "./../../../../components/model-catalog/definition-type/starter-type" private val bluePrintRepoFileService = BluePrintRepoFileService(basePath) @Test @@ -39,7 +39,7 @@ class BluePrintRepoFileServiceTest { @Test fun testGetNodeType() { - val nodeType = bluePrintRepoFileService.getNodeType("component-resource-assignment") + val nodeType = bluePrintRepoFileService.getNodeType("component-resource-resolution") assertNotNull(nodeType, "Failed to get NodeType from repo") } diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt index 2ef70164a..d49348152 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/validation/utils/PropertyAssignmentValidationUtils.kt @@ -1,5 +1,6 @@ /* * Copyright © 2019 IBM. + * Modifications Copyright © 2019 Bell Canada. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +52,7 @@ open class PropertyAssignmentValidationUtils(private val bluePrintContext: BlueP properties: MutableMap<String, JsonNode>) { properties.forEach { propertyName, propertyAssignment -> val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] - ?: throw BluePrintException("failed to get definition for the property ($propertyName)") + ?: throw BluePrintException("validatePropertyAssignments failed to get definition for the property ($propertyName)") validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) @@ -91,7 +92,7 @@ open class PropertyAssignmentValidationUtils(private val bluePrintContext: BlueP } check(isValid) { - throw BluePrintException("property($propertyName) defined of type($propertyType) is not comptable with the value ($propertyAssignment)") + throw BluePrintException("property($propertyName) defined of type($propertyType) is not compatible with the value ($propertyAssignment)") } } diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json deleted file mode 100644 index 95a9801dc..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "description": "This is Custom Java Component Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": false, - "type": "string", - "default" : "DYNAMIC", - "constraints": [ - { - "validValues": [ - "DYNAMIC" - ] - } - ] - }, - "class-name": { - "required": true, - "type": "string", - "description" : "Fully Qualified Class Name ( <Package Name> + . + <Class Name> )" - }, - "key-dependencies": { - "required": false, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json deleted file mode 100644 index 13e234e1b..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "This is Default Resource Source Node Type", - "version": "1.0.0", - "properties": { - "key": { - "required": false, - "type": "string" - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json deleted file mode 100644 index 126ea30bd..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "This is Input Resource Source Node Type", - "version": "1.0.0", - "properties": { - "key": { - "required": false, - "type": "string" - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-processor-db.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-processor-db.json deleted file mode 100644 index 661a9503b..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-processor-db.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "description": "This is Database Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": true, - "type": "string", - "constraints": [ - { - "valid_values": [ - "SQL", - "PLSQL" - ] - } - ] - }, - "query": { - "required": true, - "type": "string" - }, - "input-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "output-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json deleted file mode 100644 index f8dd8b6fc..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "description": "This is Rest Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "JSON", - "constraints": [ - { - "valid_values": [ - "JSON" - ] - } - ] - }, - "url-path": { - "required": true, - "type": "string" - }, - "path": { - "required": true, - "type": "string" - }, - "expression-type": { - "required": false, - "type": "string", - "default": "JSON_PATH", - "constraints": [ - { - "valid_values": [ - "JSON_PATH", - "JSON_POINTER" - ] - } - ] - }, - "input-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "output-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json b/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json deleted file mode 100644 index 2ef553e24..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "TOSCA base type for Resource Sources", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/address.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/address.json deleted file mode 100644 index e999938cf..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/address.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "address", - "tags" : "address", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "address", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "address" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic-cloud-region.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic-cloud-region.json deleted file mode 100644 index 2528fc7fc..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic-cloud-region.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "aic-cloud-region", - "tags" : "aic-cloud-region", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "aic-cloud-region", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "aic-cloud-region" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic_clli.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic_clli.json deleted file mode 100644 index 9e5a6d52a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic_clli.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "aic_clli", - "tags" : "aic_clli", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "aic_clli", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "aic_clli" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/availability_zone_0.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/availability_zone_0.json deleted file mode 100644 index fc88ced6a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/availability_zone_0.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "availability_zone_0", - "tags" : "availability_zone_0", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "availability_zone_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "availability_zone_0" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json deleted file mode 100644 index 42059ad8e..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", - "name": "default-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "sources": { - "default": { - "type": "source-default", - "properties": { - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json deleted file mode 100644 index e876c537a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "input-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": null, - "sources": { - "input": { - "type": "source-input", - "properties": { - "key": "action-name" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json deleted file mode 100644 index 0bc80296a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "tags": "oam-local-ipv4-address", - "name": "mdsal-source", - "property" :{ - "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "sources": { - "sdnc": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", - "path": "/v4-assigned-ip-list/0/v4-ip-prefix", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "network-role": "network-role", - "v4-ip-type": "v4-ip-type", - "vm-type": "vm-type" - }, - "output-key-mapping": { - "oam-local-ipv4-address": "v4-ip-prefix" - }, - "key-dependencies": [ - "service-instance-id", - "network-role", - "v4-ip-type", - "vm-type" - ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/name_0.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/name_0.json deleted file mode 100644 index 6be5bc182..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/name_0.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "name_0", - "tags" : "name_0", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "name_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "name_0" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nf-role.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nf-role.json deleted file mode 100644 index 51c45961b..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nf-role.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "nf-role", - "tags" : "nf-role", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnf/nf-role", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid", - "input-key-mapping" : { - "vnfmodelcustomizationuuid" : "vnf-model-customization-uuid" - }, - "output-key-mapping" : { - "nf-role" : "vf_model_role" - }, - "key-dependencies" : [ "vnf-model-customization-uuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nfc-naming-code.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nfc-naming-code.json deleted file mode 100644 index f2450becb..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nfc-naming-code.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "nfc-naming-code", - "tags" : "nfc-naming-code", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "nfc-naming-code", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "nfc-naming-code" : "nfc_naming_code" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_cidr.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_cidr.json deleted file mode 100644 index 15648adc2..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_cidr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "onap_private_net_cidr", - "tags" : "onap_private_net_cidr", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "onap_private_net_cidr", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = private", - "output-key-mapping" : { - "onap_private_net_cidr" : "prefix" - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_id.json deleted file mode 100644 index 75cc69638..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_id.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "onap_private_net_id", - "tags" : "onap_private_net_id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "onap_private_net_id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "onap_private_net_id" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/private-prefix-id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/private-prefix-id.json deleted file mode 100644 index 38e4ae1c6..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/private-prefix-id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "private-prefix-id", - "tags" : "private-prefix-id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "private-prefix-id", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = private", - "output-key-mapping" : { - "private-prefix-id" : "prefix_id" - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected-prefix-id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected-prefix-id.json deleted file mode 100644 index 1ddad0920..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected-prefix-id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "protected-prefix-id", - "tags" : "protected-prefix-id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "protected-prefix-id", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = protected", - "output-key-mapping" : { - "protected-prefix-id" : "prefix_id" - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected_private_net_cidr.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected_private_net_cidr.json deleted file mode 100644 index badc9484d..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected_private_net_cidr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "protected_private_net_cidr", - "tags" : "protected_private_net_cidr", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "protected_private_net_cidr", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = protected", - "output-key-mapping" : { - "protected_private_net_cidr" : "prefix" - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/public_net_id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/public_net_id.json deleted file mode 100644 index 17ad96bdb..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/public_net_id.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "public_net_id", - "tags" : "public_net_id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "public_net_id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "public_net_id" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/service-instance-id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/service-instance-id.json deleted file mode 100644 index db089f0d8..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/service-instance-id.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "service-instance-id", - "tags" : "service-instance-id, tosca.datatypes.Root, data_type", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "To be provided", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "service-instance-id" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected-prefix-id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected-prefix-id.json deleted file mode 100644 index 2e135679a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected-prefix-id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "unprotected-prefix-id", - "tags" : "unprotected-prefix-id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "unprotected-prefix-id", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = unprotected", - "output-key-mapping" : { - "unprotected-prefix-id" : "prefix_id" - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json deleted file mode 100644 index acb379b52..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "unprotected_private_net_cidr", - "tags" : "unprotected_private_net_cidr", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "unprotected_private_net_cidr", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = unprotected", - "output-key-mapping" : { - "unprotected_private_net_cidr" : "prefix" - } - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-id.json deleted file mode 100644 index 5203bb30e..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-id.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vf-module-id", - "tags" : "vf-module-id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf-module-id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vf-module-id" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-label.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-label.json deleted file mode 100644 index 95b78aff6..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-label.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-module-label", - "tags" : "vf-module-label", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf-module-label", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", - "input-key-mapping" : { - "customizationid" : "vf-module-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-module-label" : "vf_module_label" - }, - "key-dependencies" : [ "vf-module-model-customization-uuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json deleted file mode 100644 index dd4791879..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vf-module-model-customization-uuid", - "tags" : "vf-module-model-customization-uuid", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf-module-model-customization-uuid", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vf-module-model-customization-uuid" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-type.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-type.json deleted file mode 100644 index 6aa6db114..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-type.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-module-type", - "tags" : "vf-module-type", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf-module-type", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", - "input-key-mapping" : { - "customizationid" : "vf-module-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-module-type" : "vf_module_type" - }, - "key-dependencies" : [ "vf-module-model-customization-uuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-naming-policy.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-naming-policy.json deleted file mode 100644 index df00ba2db..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-naming-policy.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-naming-policy", - "tags" : "vf-naming-policy", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf-naming-policy", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", - "input-key-mapping" : { - "vnf_model_customization_uuid" : "vnf-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-naming-policy" : "vf_naming_policy" - }, - "key-dependencies" : [ "vnf-model-customization-uuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-nf-code.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-nf-code.json deleted file mode 100644 index 1bf36ef39..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-nf-code.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-nf-code", - "tags" : "vf-nf-code", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf-nf-code", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid", - "input-key-mapping" : { - "customizationid" : "vnf-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-nf-code" : "vf_nf_code" - }, - "key-dependencies" : [ "vnf-model-customization-uuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf_module_name.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf_module_name.json deleted file mode 100644 index 3d958919a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf_module_name.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vf_module_name", - "tags" : "vf_module_name", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vf_module_name", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vf_module_name" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfccustomizationuuid.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfccustomizationuuid.json deleted file mode 100644 index bf14f74b7..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfccustomizationuuid.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vfccustomizationuuid", - "tags" : "vfccustomizationuuid, tosca.datatypes.Root, data_type", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vfccustomizationuuid", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", - "input-key-mapping" : { - "vfmodulecustomizationuuid" : "vf-module-model-customization-uuid" - }, - "output-key-mapping" : { - "vfccustomizationuuid" : "vnf_customid" - }, - "key-dependencies" : [ "vf-module-model-customization-uuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_0.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_0.json deleted file mode 100644 index b54d8a4bd..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_0.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name" : "vfw_private_ip_0", - "tags" : "vfw_private_ip_0", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vfw_private_ip_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vfw_private_ip_0" - } - }, - "sdnc" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vfw_private_ip_0", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id", - "vf-module-id" : "vf-module-id" - }, - "output-key-mapping" : { - "vfw_private_ip_0" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_1.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_1.json deleted file mode 100644 index 04d6f5872..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_1.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name" : "vfw_private_ip_1", - "tags" : "vfw_private_ip_1", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vfw_private_ip_1", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vfw_private_ip_1" - } - }, - "sdnc" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vfw_private_ip_1", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id", - "vf-module-id" : "vf-module-id" - }, - "output-key-mapping" : { - "vfw_private_ip_1" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_2.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_2.json deleted file mode 100644 index 9e5106470..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_2.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vfw_private_ip_2", - "tags" : "vfw_private_ip_2", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vfw_private_ip_2", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vfw_private_ip_2" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vm-type.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vm-type.json deleted file mode 100644 index d67ab1a25..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vm-type.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vm-type", - "tags" : "vm-type", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vm-type", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select vfc_model.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "vm-type" : "vm_type" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-id.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-id.json deleted file mode 100644 index 5ea0fbcfd..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-id.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vnf-id", - "tags" : "vnf-id", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnf-id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vnf-id" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json deleted file mode 100644 index d36fe740a..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vnf-model-customization-uuid", - "tags" : "vnf-model-customization-uuid", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnf-model-customization-uuid", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vnf-model-customization-uuid" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-name.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-name.json deleted file mode 100644 index bba92c8fa..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-name.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name" : "vnf-name", - "tags" : "vnf-name, tosca.datatypes.Root, data_type", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnf-name", - "type" : "string" - }, - "sources" : { - "sdnc": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-name/vnf-data/vnf-topology/vnf-parameters-data/param/vnf-name", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-name": "vnf-name" - }, - "output-key-mapping": { - "vnf-name": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-name" - ] - } - }, - "aai-data": { - "type": "source-rest", - "properties": { - "type": "JSON", - "verb": "GET", - "url-path": "/aai/v14/network/generic-vnfs/generic-vnf/$vnf-id", - "path": "", - "input-key-mapping": { - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "vnf-name": "vnf-name" - }, - "key-dependencies": [ - "vnf-id" - ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf_name.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf_name.json deleted file mode 100644 index 99a6198d5..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf_name.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name" : "vnf_name", - "tags" : "vnf_name", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnf_name", - "type" : "string" - }, - "sources" : { - "sdnc" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vnf_name" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json deleted file mode 100644 index 022face08..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vnfc-model-invariant-uuid", - "tags" : "vnfc-model-invariant-uuid", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnfc-model-invariant-uuid for vFW template", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select vfc_model.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "vnfc-model-invariant-uuid" : "vfc_invariant_uuid" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-version.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-version.json deleted file mode 100644 index 02c487cc9..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-version.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vnfc-model-version", - "tags" : "vnfc-model-version", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vnfc-model-version for vFW template", - "type" : "string" - }, - "sources" : { - "processor-db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select vfc_model.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "vnfc-model-version" : "vnfc_model_version" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_0.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_0.json deleted file mode 100644 index 6e9b8dc45..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_0.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name" : "vpg_private_ip_0", - "tags" : "vpg_private_ip_0", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vpg_private_ip_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vpg_private_ip_0" - } - }, - "sdnc" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vpg_private_ip_0", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id", - "vf-module-id" : "vf-module-id" - }, - "output-key-mapping" : { - "vpg_private_ip_0" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_1.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_1.json deleted file mode 100644 index 23c42e0c7..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_1.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vpg_private_ip_1", - "tags" : "vpg_private_ip_1", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vpg_private_ip_1", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vpg_private_ip_1" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_0.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_0.json deleted file mode 100644 index f86c95ab4..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_0.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name" : "vsn_private_ip_0", - "tags" : "vsn_private_ip_0", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vsn_private_ip_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vsn_private_ip_0" - } - }, - "sdnc" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vf-modules/$vf-module-id/vf-module-data/vf-module-topology/vf-module-parameters/param/vsn_private_ip_0", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id", - "vf-module-id" : "vf-module-id" - }, - "output-key-mapping" : { - "vsn_private_ip_0" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id", "vf-module-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_1.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_1.json deleted file mode 100644 index 88750b25e..000000000 --- a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_1.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name" : "vsn_private_ip_1", - "tags" : "vsn_private_ip_1", - "updated-by" : "Singal, Kapil <ks220y@att.com>", - "property" : { - "description" : "vsn_private_ip_1", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - "key" : "vsn_private_ip_1" - } - } - } -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java index 26a3a2871..fd38db0bf 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/cds/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory; public class ResourceDefinitionTest { private Logger log = LoggerFactory.getLogger(ResourceDefinitionTest.class); - private String basePath = "load/resource_dictionary"; + private String basePath = "./../../../../components/model-catalog/resource-dictionary/starter-dictionary"; @Test public void testDictionaryDefinitionInputSource(){ @@ -46,7 +46,7 @@ public class ResourceDefinitionTest { @Test public void testDictionaryDefinitionDBSource(){ - String fileName = basePath + "/processor-db-source.json"; + String fileName = basePath + "/db-source.json"; ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); Assert.assertNotNull("Failed to populate dictionaryDefinition for processor-db type", resourceDefinition); } |