X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=osm_nbi%2Fdescriptor_topics.py;h=d986963cf116718bb3da05eee6d41337cd8a490e;hb=refs%2Fchanges%2F34%2F13534%2F4;hp=ca10c424d3a559207685d0dba2f03486d4247a0c;hpb=6d83f8f3c7ac8c18982b3a994a539acbb033fab5;p=osm%2FNBI.git diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index ca10c42..d986963 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -20,6 +20,7 @@ import copy import os import shutil import functools +import re # import logging from deepdiff import DeepDiff @@ -51,10 +52,14 @@ from osm_nbi import utils __author__ = "Alfonso Tierno " +valid_helm_chart_re = re.compile( + r"^[a-z0-9]([-a-z0-9]*[a-z0-9]/)?([a-z0-9]([-a-z0-9]*[a-z0-9])?)*$" +) + class DescriptorTopic(BaseTopic): def __init__(self, db, fs, msg, auth): - BaseTopic.__init__(self, db, fs, msg, auth) + super().__init__(db, fs, msg, auth) def _validate_input_new(self, indata, storage_params, force=False): return indata @@ -847,9 +852,23 @@ class VnfdTopic(DescriptorTopic): self.validate_internal_virtual_links(indata) self.validate_monitoring_params(indata) self.validate_scaling_group_descriptor(indata) + self.validate_helm_chart(indata) return indata + @staticmethod + def validate_helm_chart(indata): + kdus = indata.get("kdu", []) + for kdu in kdus: + helm_chart_value = kdu.get("helm-chart") + if not helm_chart_value: + continue + if not valid_helm_chart_re.match(helm_chart_value): + raise EngineException( + "helm-chart '{}' is not valid".format(helm_chart_value), + http_code=HTTPStatus.UNPROCESSABLE_ENTITY, + ) + @staticmethod def validate_mgmt_interface_connection_point(indata): if not indata.get("vdu"): @@ -1375,7 +1394,7 @@ class NsdTopic(DescriptorTopic): topic_msg = "nsd" def __init__(self, db, fs, msg, auth): - DescriptorTopic.__init__(self, db, fs, msg, auth) + super().__init__(db, fs, msg, auth) def pyangbind_validation(self, item, data, force=False): if self._descriptor_data_is_in_old_format(data):