X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=common%2Fpython%2Frift%2Fmano%2Fyang_translator%2Frwmano%2Ftranslate_descriptors.py;h=707ab7fbc4e98bee96969e570a07235e450b4951;hb=93f10aabdba5a1c745d002654c0bb6345a682a47;hp=f0a68665a969a297da8b70e543dfe7ad6587d8af;hpb=a32315535a0d3ed57f671de78d2df0b5de11db68;p=osm%2FSO.git diff --git a/common/python/rift/mano/yang_translator/rwmano/translate_descriptors.py b/common/python/rift/mano/yang_translator/rwmano/translate_descriptors.py index f0a68665..707ab7fb 100644 --- a/common/python/rift/mano/yang_translator/rwmano/translate_descriptors.py +++ b/common/python/rift/mano/yang_translator/rwmano/translate_descriptors.py @@ -104,10 +104,11 @@ class TranslateDescriptors(object): return types_map - def __init__(self, log, yangs, tosca_template): + def __init__(self, log, yangs, tosca_template, vnfd_files=None): self.log = log self.yangs = yangs self.tosca_template = tosca_template + self.vnfd_files = vnfd_files # list of all TOSCA resources generated self.tosca_resources = [] self.metadata = {} @@ -143,27 +144,30 @@ class TranslateDescriptors(object): def _translate_yang(self): self.log.debug(_('Translating the descriptors.')) - for nsd in self.yangs[self.NSD]: - self.log.debug(_("Translate descriptor of type nsd: {}"). - format(nsd)) - tosca_node = TranslateDescriptors. \ - YANG_TO_TOSCA_TYPE[self.NSD]( - self.log, - nsd.pop(ToscaResource.NAME), - self.NSD, - nsd) - self.tosca_resources.append(tosca_node) - - for vnfd in self.yangs[self.VNFD]: - self.log.debug(_("Translate descriptor of type vnfd: {}"). - format(vnfd)) - tosca_node = TranslateDescriptors. \ - YANG_TO_TOSCA_TYPE[self.VNFD]( - self.log, - vnfd.pop(ToscaResource.NAME), - self.VNFD, - vnfd) - self.tosca_resources.append(tosca_node) + if self.NSD in self.yangs: + for nsd in self.yangs[self.NSD]: + self.log.debug(_("Translate descriptor of type nsd: {}"). + format(nsd)) + tosca_node = TranslateDescriptors. \ + YANG_TO_TOSCA_TYPE[self.NSD]( + self.log, + nsd.pop(ToscaResource.NAME), + self.NSD, + nsd, + self.vnfd_files) + self.tosca_resources.append(tosca_node) + + if self.VNFD in self.yangs: + for vnfd in self.yangs[self.VNFD]: + self.log.debug(_("Translate descriptor of type vnfd: {}"). + format(vnfd)) + tosca_node = TranslateDescriptors. \ + YANG_TO_TOSCA_TYPE[self.VNFD]( + self.log, + vnfd.pop(ToscaResource.NAME), + self.VNFD, + vnfd) + self.tosca_resources.append(tosca_node) # First translate VNFDs for node in self.tosca_resources: