diff options
author | DylanB95EST <dylan.byrne@est.tech> | 2021-12-14 16:34:38 +0000 |
---|---|---|
committer | DylanB95EST <dylan.byrne@est.tech> | 2022-01-28 14:32:11 +0000 |
commit | 63132cec2c18363a8224646039cc23b6144d8e6c (patch) | |
tree | 0821e401a14655ecba60d213f5dbacac12e8f0b4 /cps-ri | |
parent | a5ce86d02493f141848f9d609c65883d2198894a (diff) |
Support 'public' Cm Handle Properties
Add support for new Public Additional Properties list to Register CM Handles API
Issue-ID: CPS-677
Change-Id: I6efc88734da2416f72f71a403622e519398b502d
Signed-off-by: DylanB95EST <dylan.byrne@est.tech>
Diffstat (limited to 'cps-ri')
5 files changed, 176 insertions, 1 deletions
diff --git a/cps-ri/src/main/resources/changelog/db/changes/09-loadData-dmi-registry-schema-set.yaml b/cps-ri/src/main/resources/changelog/db/changes/09-loadData-dmi-registry-schema-set.yaml index fe2428e0c3..723c2b9ecb 100644 --- a/cps-ri/src/main/resources/changelog/db/changes/09-loadData-dmi-registry-schema-set.yaml +++ b/cps-ri/src/main/resources/changelog/db/changes/09-loadData-dmi-registry-schema-set.yaml @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (C) 2021 Nordix Foundation. +# Copyright (C) 2021-2022 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -160,3 +160,51 @@ databaseChangeLog: delete from schema_set_yang_resources where schema_set_id = (select id from schema_set where name = 'ncmp-dmi-registry-model') and yang_resource_id = (select id from yang_resource where name = 'dmi-registry@2021-10-20.yang') + + - changeSet: + author: cps + label: dmi-registry-schema-preload + id: 9.7 + loadUpdateData: + encoding: UTF-8 + file: 'changelog/db/changes/data/dmi//generated-csv/generated_yang_resource_dmi-registry@2021-12-13.csv' + onlyUpdate: 'false' + primaryKey: 'id' + quotchar: '"' + separator: '|' + tableName: 'yang_resource' + columns: + - column: + header: name + name: name + type: STRING + - column: + header: content + name: content + type: STRING + - column: + header: checksum + name: checksum + type: STRING + rollback: + - sql: + sql: delete from yang_resource where name = 'dmi-registry@2021-12-13.yang' + + - changeSet: + author: cps + label: dmi-registry-schema-preload + id: 9.8 + loadUpdateData: + encoding: UTF-8 + file: 'changelog/db/changes/data/dmi/schema_set_yang_resources@2021-12-13.csv' + quotchar: '"' + primaryKey: 'schema_set_id,yang_resource_id' + separator: '|' + tableName: 'schema_set_yang_resources' + usePreparedStatements: true + rollback: + - sql: + sql: > + delete from schema_set_yang_resources + where schema_set_id = (select id from schema_set where name = 'ncmp-dmi-registry-model') + and yang_resource_id = (select id from yang_resource where name = 'dmi-registry@2021-12-13.yang')
\ No newline at end of file diff --git a/cps-ri/src/main/resources/changelog/db/changes/data/dmi/generated-csv/README.md b/cps-ri/src/main/resources/changelog/db/changes/data/dmi/generated-csv/README.md new file mode 100644 index 0000000000..212acb9006 --- /dev/null +++ b/cps-ri/src/main/resources/changelog/db/changes/data/dmi/generated-csv/README.md @@ -0,0 +1,23 @@ +<!-- + ============LICENSE_START======================================================= + Copyright (C) 2022 Nordix Foundation. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + SPDX-License-Identifier: Apache-2.0 + ============LICENSE_END========================================================= +--> + +##Placeholder folder for generated CSV files as part of yang models. + +Do not remove this folder
\ No newline at end of file diff --git a/cps-ri/src/main/resources/changelog/db/changes/data/dmi/schema_set_yang_resources@2021-12-13.csv b/cps-ri/src/main/resources/changelog/db/changes/data/dmi/schema_set_yang_resources@2021-12-13.csv new file mode 100644 index 0000000000..3e8afdd4e5 --- /dev/null +++ b/cps-ri/src/main/resources/changelog/db/changes/data/dmi/schema_set_yang_resources@2021-12-13.csv @@ -0,0 +1,3 @@ +schema_set_id|yang_resource_id +(select id from schema_set where name='ncmp-dmi-registry-model')|(select id from yang_resource where name='dmi-registry@2021-12-13.yang') + diff --git a/cps-ri/src/main/resources/changelog/db/changes/data/yang-models/dmi-registry@2021-12-13.yang b/cps-ri/src/main/resources/changelog/db/changes/data/yang-models/dmi-registry@2021-12-13.yang new file mode 100644 index 0000000000..ed3559bf61 --- /dev/null +++ b/cps-ri/src/main/resources/changelog/db/changes/data/yang-models/dmi-registry@2021-12-13.yang @@ -0,0 +1,63 @@ +module dmi-registry { + + yang-version 1.1; + + namespace "org:onap:cps:ncmp"; + + prefix dmi-reg; + + contact "dylan.byrne@est.tech"; + + revision "2021-05-20" { + description + "Initial Version"; + } + + revision "2021-10-20" { + description + "Added dmi-data-service-name & dmi-model-service-name to allow separate DMI instances for each responsibility"; + } + + revision "2021-12-13" { + description + "Added new list of public additonal properties for a Cm-Handle which are exposed to clients of the NCMP interface"; + } + + container dmi-registry { + list cm-handles { + key "id"; + leaf id { + type string; + } + leaf dmi-service-name { + type string; + } + leaf dmi-data-service-name { + type string; + } + leaf dmi-model-service-name { + type string; + } + + list additional-properties { + key "name"; + leaf name { + type string; + } + leaf value { + type string; + } + } + + list public-properties { + key "name"; + leaf name { + type string; + } + leaf value { + type string; + } + } + } + } +}
\ No newline at end of file diff --git a/cps-ri/src/main/resources/yangResourceCsvGenerator.py b/cps-ri/src/main/resources/yangResourceCsvGenerator.py new file mode 100644 index 0000000000..9a4077bbd2 --- /dev/null +++ b/cps-ri/src/main/resources/yangResourceCsvGenerator.py @@ -0,0 +1,38 @@ +# ============LICENSE_START======================================================= +# Copyright (C) 2022 Nordix Foundation +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + + +import csv +import hashlib +import sys + +yang_source = '' +checksum = '' + +for yang_source in sys.argv[1:]: + checksum = hashlib.sha256(str(yang_source).encode()).hexdigest() + +with open('changelog/db/changes/data/yang-models/' + yang_source + '.yang') as content: + dmiRegistry = content.read() + +# open the file in the write mode +with open('changelog/db/changes/data/dmi/generated-csv/generated_yang_resource_' + yang_source + '.csv', 'w', newline='') \ + as file: + writer = csv.writer(file, delimiter='|') + writer.writerow(["name", "content", "checksum"]) + writer.writerow([yang_source + '.yang', dmiRegistry, checksum]) |