From 2eccea2a6533769f4c787c183437de65b0f46f69 Mon Sep 17 00:00:00 2001 From: bravof Date: Fri, 12 Feb 2021 16:17:54 -0300 Subject: [PATCH] feat(configurations): now VNF/VDU/KDU configurations are in the same place, compatible with SOL006 Change-Id: Ia2d03e26987b7c319373005d7afed7d42ec54e3a Signed-off-by: bravof --- models/augments/configuration.yang | 58 --------- models/augments/day1-2.yang | 28 ++-- models/augments/kdu.yang | 25 ---- models/augments/scaling.yang | 2 +- osm_im/im_translation.py | 31 ++++- .../hackfest_charmed_vnfd_sol006.yaml | 54 ++++---- tests/examples/vepc_sol006.yaml | 121 +++++++++--------- 7 files changed, 123 insertions(+), 196 deletions(-) delete mode 100644 models/augments/configuration.yang diff --git a/models/augments/configuration.yang b/models/augments/configuration.yang deleted file mode 100644 index 8120c5a..0000000 --- a/models/augments/configuration.yang +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2020 Whitestack LLC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -module configuration { - yang-version 1.1; - namespace "urn:etsi:osm:yang:configuration"; - prefix "configuration"; - - import etsi-nfv-vnfd { - prefix vnfd; - } - - import day1-2 { - prefix day1-2; - } - - grouping extended-vnf-configuration { - leaf vnf-configuration-id { - description - "Reference for the VNF configuration to use in this DF"; - type leafref { - path "/vnfd:vnfd/day1-2:vnf-configuration/day1-2:id"; - } - } - } - - grouping extended-vdu-configuration { - leaf vdu-configuration-id { - description - "Reference for the VDU configuration to use in this DF"; - type leafref { - path "/vnfd:vnfd/day1-2:vdu-configuration/day1-2:id"; - } - } - } - - augment "/vnfd:vnfd/vnfd:df" { - uses extended-vnf-configuration; - } - - augment "/vnfd:vnfd/vnfd:df/vnfd:vdu-profile" { - uses extended-vdu-configuration; - } -} diff --git a/models/augments/day1-2.yang b/models/augments/day1-2.yang index e66ce16..cf3b841 100644 --- a/models/augments/day1-2.yang +++ b/models/augments/day1-2.yang @@ -29,37 +29,31 @@ module day1-2 { } grouping extended-vnf-configuration { - list vnf-configuration { + list day1-2 { key "id"; leaf id { description - "Internal identifier for the VNF configuration"; + "Internal identifier for the VNF/VDU/KNF/KDU configuration"; type string; } uses common:vnfc-configuration; uses common:vnfc-relations; uses common:vdu-config-access; - } - } - grouping extended-vdu-configuration { - list vdu-configuration { - key "id"; - leaf id { + leaf-list blacklist-config-primitive { description - "Internal identifier for the VDU configuration"; - type string; + "List of blacklisted config primitives from the list of + default kdu config primitives"; + + type enumeration { + enum upgrade; + enum rollback; + } } - uses common:vnfc-configuration; - uses common:vdu-config-access; } } - augment "/vnfd:vnfd" { + augment "/vnfd:vnfd/vnfd:df/vnfd:lcm-operations-configuration/vnfd:operate-vnf-op-config" { uses extended-vnf-configuration; } - - augment "/vnfd:vnfd" { - uses extended-vdu-configuration; - } } \ No newline at end of file diff --git a/models/augments/kdu.yang b/models/augments/kdu.yang index 3f7d2e7..bd8b8fb 100644 --- a/models/augments/kdu.yang +++ b/models/augments/kdu.yang @@ -24,10 +24,6 @@ module kdu { prefix vnfd; } - import common-augments { - prefix common; - } - grouping extended-ext-cpd { leaf k8s-cluster-net { description @@ -40,24 +36,6 @@ module kdu { } } - grouping extended-kdu-configuration { - container kdu-configuration { - uses common:vnfc-configuration; - uses common:vdu-config-access; - - leaf-list blacklist-config-primitive { - description - "List of blacklisted config primitives from the list of - default kdu config primitives"; - - type enumeration { - enum upgrade; - enum rollback; - } - } - } - } - grouping extended-kdu { list kdu { description @@ -116,9 +94,6 @@ module kdu { } } } - - uses extended-kdu-configuration; - } container k8s-cluster { diff --git a/models/augments/scaling.yang b/models/augments/scaling.yang index 647edf1..69ff163 100644 --- a/models/augments/scaling.yang +++ b/models/augments/scaling.yang @@ -156,7 +156,7 @@ module scaling { description "Reference to the VNF config primitive"; type leafref { - path "/vnfd:vnfd/day1-2:vnf-configuration/day1-2:config-primitive/day1-2:name"; + path "/vnfd:vnfd/vnfd:df/vnfd:lcm-operations-configuration/vnfd:operate-vnf-op-config/day1-2:day1-2/day1-2:config-primitive/day1-2:name"; } } } diff --git a/osm_im/im_translation.py b/osm_im/im_translation.py index 9216f45..78a2931 100644 --- a/osm_im/im_translation.py +++ b/osm_im/im_translation.py @@ -286,7 +286,7 @@ def _add_im_vdus_to_sol006_vnfd(im_vnfd, sol006_vnfd): vdu_level = _get_instantiation_level_vdu_level_from_im_vdu(vdu) if vdu.get("vdu-configuration"): vdu_configuration = vdu["vdu-configuration"] - vdu_configuration["id"] = "{}-vdu-configuration".format(vdu["id"]) + vdu_configuration["id"] = vdu["id"] vdu_configurations.append(vdu_configuration) df["vdu-profile"].append(vdu_profile) df["instantiation-level"][0]["vdu-level"].append(vdu_level) @@ -299,7 +299,8 @@ def _add_im_vdus_to_sol006_vnfd(im_vnfd, sol006_vnfd): if len(ext_cpds) > 0: sol006_vnfd["ext-cpd"] = ext_cpds if len(vdu_configurations) > 0: - sol006_vnfd["vdu-configuration"] = vdu_configurations + _prepare_dict_entries_for_configurations(sol006_vnfd) + sol006_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"].extend(vdu_configurations) def _add_im_vdu_images_to_sol006_vdu(im_vdu, sol006_vdu): @@ -365,8 +366,6 @@ def _get_vdu_profile_from_im_vdu(im_vdu, im_vnfd): sgd_min_instances = int(scaling_group_descriptor.get("min-instance-count", 0)) vdu_profile["min-number-of-instances"] = sgd_min_instances + initial_instances vdu_profile["max-number-of-instances"] = sgd_max_instances + initial_instances - if im_vdu.get("vdu-configuration"): - vdu_profile["vdu-configuration-id"] = "{}-vdu-configuration".format(im_vdu["id"]) return vdu_profile @@ -409,14 +408,22 @@ def _add_im_internal_vld_connection_point_refs_to_sol006_vnfd(ivld, im_vnfd, sol if int_cpd["id"] == sol006_int_cpd_id: int_cpd["int-virtual-link-desc"] = ivld["id"] +def _prepare_dict_entries_for_configurations(sol006_vnfd): + sol006_vnfd["df"] = sol006_vnfd.get("df", [{}]) + if not sol006_vnfd["df"][0].get("lcm-operations-configuration"): + sol006_vnfd["df"][0]["lcm-operations-configuration"] = { + "operate-vnf-op-config": { + "day1-2": [] + } + } def _add_im_vnf_configuration_to_sol006_vnfd(im_vnfd, sol006_vnfd): vnf_configuration = im_vnfd.get("vnf-configuration") if not vnf_configuration: return - vnf_configuration["id"] = "default-vnf-configuration" - sol006_vnfd["vnf-configuration"] = [vnf_configuration] - sol006_vnfd["df"][0]["vnf-configuration-id"] = vnf_configuration["id"] + vnf_configuration["id"] = im_vnfd.get("id") + _prepare_dict_entries_for_configurations(sol006_vnfd) + sol006_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"].append(vnf_configuration) def _add_im_ip_profiles_to_sol006_vnfd(im_vnfd, sol006_vnfd): @@ -513,8 +520,18 @@ def _add_im_scaling_group_descriptors_to_sol006_vnfd(im_vnfd, sol006_vnfd): def _add_im_kdus_to_sol006_vnfd(im_vnfd, sol006_vnfd): if im_vnfd.get("kdu"): sol006_vnfd["kdu"] = im_vnfd["kdu"] + kdu_configs = [] + for a_kdu in sol006_vnfd["kdu"]: + if "kdu-configuration" in a_kdu: + kdu_config = a_kdu.pop("kdu-configuration") + kdu_config["id"] = a_kdu["name"] + kdu_configs.append(kdu_config) if len(sol006_vnfd.get("df", ())) == 0: sol006_vnfd["df"] = [{"id": "default-df"}] + if len(kdu_configs) > 0: + _prepare_dict_entries_for_configurations(sol006_vnfd) + sol006_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"].extend(kdu_configs) + def _add_im_k8s_clusters_to_sol006_vnfd(im_vnfd, sol006_vnfd): diff --git a/tests/examples/hackfest_charmed_vnfd_sol006.yaml b/tests/examples/hackfest_charmed_vnfd_sol006.yaml index 069198b..ab55af8 100644 --- a/tests/examples/hackfest_charmed_vnfd_sol006.yaml +++ b/tests/examples/hackfest_charmed_vnfd_sol006.yaml @@ -107,7 +107,6 @@ vnfd: df: - id: default-df - vnf-configuration-id: default-vnf-configuration vdu-profile: - id: mgmtVM min-number-of-instances: 1 @@ -149,29 +148,30 @@ vnfd: vnf-config-primitive-name-ref: touch - trigger: pre-scale-in vnf-config-primitive-name-ref: touch - - vnf-configuration: - - id: default-vnf-configuration - initial-config-primitive: - - seq: "1" - name: config - parameter: - - name: ssh-hostname - value: - - name: ssh-username - value: ubuntu - - name: ssh-password - value: osm4u - - seq: "2" - name: touch - parameter: - - name: filename - value: - config-primitive: - - name: touch - parameter: - - data-type: STRING - default-value: - name: filename - juju: - charm: simple + lcm-operations-configuration: + operate-vnf-op-config: + day1-2: + - id: hackfest3charmed-vnf + initial-config-primitive: + - seq: "1" + name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - name: ssh-password + value: osm4u + - seq: "2" + name: touch + parameter: + - name: filename + value: + config-primitive: + - name: touch + parameter: + - data-type: STRING + default-value: + name: filename + juju: + charm: simple \ No newline at end of file diff --git a/tests/examples/vepc_sol006.yaml b/tests/examples/vepc_sol006.yaml index e5863e7..f248efd 100644 --- a/tests/examples/vepc_sol006.yaml +++ b/tests/examples/vepc_sol006.yaml @@ -104,13 +104,11 @@ vnfd: type: PARAVIRT df: - id: default-df - vnf-configuration-id: default-vnf-configuration vdu-profile: - id: spgwmme min-number-of-instances: 1 - id: hss min-number-of-instances: 1 - vdu-configuration-id: hss-vdu-configuration instantiation-level: - id: default-instantiation-level vdu-level: @@ -128,65 +126,66 @@ vnfd: ip-version: ipv4 cidr: 10.0.6.0/24 dhcp-enabled: true - vdu-configuration: - - id: hss-vdu-configuration - initial-config-primitive: - - seq: "1" - name: config - parameter: - - name: ssh-hostname - value: - - name: ssh-username - value: ubuntu - - name: ssh-password - value: - - seq: "2" - name: configure-hss - parameter: - - name: spgw-ip - data-type: STRING - value: - - name: hss-ip - data-type: STRING - value: - - seq: "3" - name: restart-hss - juju: - charm: hsscharm - vnf-configuration: - - id: default-vnf-configuration - initial-config-primitive: - - seq: "1" - name: config - parameter: - - name: ssh-hostname - value: - - name: ssh-username - value: ubuntu - - name: ssh-password - value: - - seq: "2" - name: configure-spgw - parameter: - - name: spgw-ip - data-type: STRING - value: - - name: hss-ip - data-type: STRING - value: - - seq: "3" - name: restart-spgw - config-primitive: - - name: add-route - parameter: - - name: external-prefix - data-type: STRING - default-value: "8.8.8.8/32" - - name: next-hop - data-type: STRING - default-value: "192.168.2.1" - juju: - charm: spgwcharm + lcm-operations-configuration: + operate-vnf-op-config: + day1-2: + - id: vEPC_vnfd + initial-config-primitive: + - seq: "1" + name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - name: ssh-password + value: + - seq: "2" + name: configure-spgw + parameter: + - name: spgw-ip + data-type: STRING + value: + - name: hss-ip + data-type: STRING + value: + - seq: "3" + name: restart-spgw + config-primitive: + - name: add-route + parameter: + - name: external-prefix + data-type: STRING + default-value: "8.8.8.8/32" + - name: next-hop + data-type: STRING + default-value: "192.168.2.1" + juju: + charm: spgwcharm + - id: hss + initial-config-primitive: + - seq: "1" + name: config + parameter: + - name: ssh-hostname + value: + - name: ssh-username + value: ubuntu + - name: ssh-password + value: + - seq: "2" + name: configure-hss + parameter: + - name: spgw-ip + data-type: STRING + value: + - name: hss-ip + data-type: STRING + value: + - seq: "3" + name: restart-hss + juju: + charm: hsscharm int-virtual-link-desc: - id: s6a ext-cpd: -- 2.17.1