4 # Copyright 2016 RIFT.IO Inc
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
29 gi
.require_version('RwYang', '1.0')
30 gi
.require_version('RwVnfdYang', '1.0')
31 gi
.require_version('RwNsdYang', '1.0')
33 from gi
.repository
import (
39 import rift
.package
.store
40 import rift
.package
.cloud_init
42 logger
= logging
.getLogger("rift2openmano.py")
45 class VNFNotFoundError(Exception):
49 class RiftNSD(object):
50 model
= RwYang
.Model
.create_libncx()
51 model
.load_module('nsd')
52 model
.load_module('rw-nsd')
54 def __init__(self
, descriptor
):
55 self
._nsd
= descriptor
70 return [c
.vnfd_id_ref
for c
in self
._nsd
.constituent_vnfd
]
73 def constituent_vnfds(self
):
74 return self
._nsd
.constituent_vnfd
82 return self
._nsd
.connection_point
85 def description(self
):
86 return self
._nsd
.description
89 def from_xml_file_hdl(cls
, hdl
):
91 descriptor
= RwNsdYang
.YangData_Nsd_NsdCatalog_Nsd()
92 descriptor
.from_xml_v2(RiftNSD
.model
, hdl
.read())
93 return cls(descriptor
)
96 def from_yaml_file_hdl(cls
, hdl
):
98 descriptor
= RwNsdYang
.YangData_Nsd_NsdCatalog_Nsd()
99 descriptor
.from_yaml(RiftNSD
.model
, hdl
.read())
100 return cls(descriptor
)
103 def from_dict(cls
, nsd_dict
):
104 descriptor
= RwNsdYang
.YangData_Nsd_NsdCatalog_Nsd
.from_dict(nsd_dict
)
105 return cls(descriptor
)
108 class RiftVNFD(object):
109 model
= RwYang
.Model
.create_libncx()
110 model
.load_module('vnfd')
111 model
.load_module('rw-vnfd')
113 def __init__(self
, descriptor
):
114 self
._vnfd
= descriptor
117 return str(self
._vnfd
)
125 return self
._vnfd
.name
128 def description(self
):
129 return self
._vnfd
.description
133 return self
._vnfd
.connection_point
137 return self
._vnfd
.vdu
140 def internal_vlds(self
):
141 return self
._vnfd
.internal_vld
144 def from_xml_file_hdl(cls
, hdl
):
146 descriptor
= RwVnfdYang
.YangData_Vnfd_VnfdCatalog_Vnfd()
147 descriptor
.from_xml_v2(RiftVNFD
.model
, hdl
.read())
148 return cls(descriptor
)
151 def from_yaml_file_hdl(cls
, hdl
):
153 descriptor
= RwVnfdYang
.YangData_Vnfd_VnfdCatalog_Vnfd()
154 descriptor
.from_yaml(RiftVNFD
.model
, hdl
.read())
155 return cls(descriptor
)
158 def from_dict(cls
, vnfd_dict
):
159 descriptor
= RwVnfdYang
.YangData_Vnfd_VnfdCatalog_Vnfd
.from_dict(vnfd_dict
)
160 return cls(descriptor
)
163 def is_writable_directory(dir_path
):
164 """ Returns True if dir_path is writable, False otherwise
167 dir_path - A directory path
169 if not os
.path
.exists(dir_path
):
170 raise ValueError("Directory does not exist: %s", dir_path
)
173 testfile
= tempfile
.TemporaryFile(dir=dir_path
)
181 def create_vnfd_from_files(vnfd_file_hdls
):
182 """ Create a list of RiftVNFD instances from xml/yaml file handles
185 vnfd_file_hdls - Rift VNFD XML/YAML file handles
188 A list of RiftVNFD instances
191 for vnfd_file_hdl
in vnfd_file_hdls
:
192 if vnfd_file_hdl
.name
.endswith("yaml") or vnfd_file_hdl
.name
.endswith("yaml"):
193 vnfd
= RiftVNFD
.from_yaml_file_hdl(vnfd_file_hdl
)
195 vnfd
= RiftVNFD
.from_xml_file_hdl(vnfd_file_hdl
)
196 vnfd_dict
[vnfd
.id] = vnfd
201 def create_nsd_from_file(nsd_file_hdl
):
202 """ Create a list of RiftNSD instances from yaml/xml file handles
205 nsd_file_hdls - Rift NSD XML/yaml file handles
208 A list of RiftNSD instances
210 if nsd_file_hdl
.name
.endswith("yaml") or nsd_file_hdl
.name
.endswith("yaml"):
211 nsd
= RiftNSD
.from_yaml_file_hdl(nsd_file_hdl
)
213 nsd
= RiftNSD
.from_xml_file_hdl(nsd_file_hdl
)
218 return collections
.defaultdict(dict)
220 def convert_vnfd_name(vnfd_name
, member_idx
):
221 return vnfd_name
+ "__" + str(member_idx
)
224 def rift2openmano_nsd(rift_nsd
, rift_vnfds
, openmano_vnfd_ids
, rift_vnfd_id
=None):
225 if rift_vnfd_id
is None:
226 for vnfd_id
in rift_nsd
.vnfd_ids
:
227 if vnfd_id
not in rift_vnfds
:
228 raise VNFNotFoundError("VNF id %s not provided" % vnfd_id
)
231 openmano
["name"] = rift_nsd
.name
232 if rift_vnfd_id
is not None:
233 openmano
["name"] += "scale1"
234 openmano
["description"] = rift_nsd
.description
236 openmano
["topology"] = topology
238 topology
["nodes"] = {}
239 for vnfd
in rift_nsd
.constituent_vnfds
:
240 vnfd_id
= vnfd
.vnfd_id_ref
241 if rift_vnfd_id
is not None and rift_vnfd_id
!= vnfd_id
:
243 rift_vnfd
= rift_vnfds
[vnfd_id
]
244 member_idx
= vnfd
.member_vnf_index
245 openmano_vnfd_id
= openmano_vnfd_ids
.get(vnfd_id
,None)
247 topology
["nodes"][rift_vnfd
.name
+ "__" + str(member_idx
)] = {
249 "vnf_id": openmano_vnfd_id
252 topology
["nodes"][rift_vnfd
.name
+ "__" + str(member_idx
)] = {
254 "VNF model": rift_vnfd
.name
257 for vld
in rift_nsd
.vlds
:
258 # Openmano has both bridge_net and dataplane_net models for network types
259 # For now, since we are using openmano in developer mode lets just hardcode
260 # to bridge_net since it won't matter anyways.
261 # topology["nodes"][vld.name] = {"type": "network", "model": "bridge_net"}
264 topology
["connections"] = {}
265 for vld
in rift_nsd
.vlds
:
267 # Create a connections entry for each external VLD
268 topology
["connections"][vld
.name
] = {}
269 topology
["connections"][vld
.name
]["nodes"] = []
271 #if vld.vim_network_name:
273 if vld
.name
not in topology
["nodes"]:
274 topology
["nodes"][vld
.name
] = {
275 "type": "external_network",
279 # Add the external network to the list of connection points
280 topology
["connections"][vld
.name
]["nodes"].append(
283 elif vld
.provider_network
.has_field("physical_network"):
284 # Add the external datacenter network to the topology
285 # node list if it isn't already added
286 ext_net_name
= vld
.provider_network
.physical_network
287 ext_net_name_with_seg
= ext_net_name
288 if vld
.provider_network
.has_field("segmentation_id"):
289 ext_net_name_with_seg
+= ":{}".format(vld
.provider_network
.segmentation_id
)
291 if ext_net_name
not in topology
["nodes"]:
292 topology
["nodes"][ext_net_name
] = {
293 "type": "external_network",
294 "model": ext_net_name_with_seg
,
297 # Add the external network to the list of connection points
298 topology
["connections"][vld
.name
]["nodes"].append(
303 for vnfd_cp
in vld
.vnfd_connection_point_ref
:
305 # Get the RIFT VNF for this external VLD connection point
306 vnfd
= rift_vnfds
[vnfd_cp
.vnfd_id_ref
]
308 # For each VNF in this connection, use the same interface name
309 topology
["connections"][vld
.name
]["type"] = "link"
310 # Vnf ref is the vnf name with the member_vnf_idx appended
311 member_idx
= vnfd_cp
.member_vnf_index_ref
312 vnf_ref
= vnfd
.name
+ "__" + str(member_idx
)
313 topology
["connections"][vld
.name
]["nodes"].append(
315 vnf_ref
: vnfd_cp
.vnfd_connection_point_ref
320 def rift2openmano_vnfd_nsd(rift_nsd
, rift_vnfds
, rift_vnfd_id
):
322 if rift_vnfd_id
not in rift_vnfds
:
323 print ("IDS", rift_vnfds
)
324 raise VNFNotFoundError("VNF id %s not provided" % rift_vnfd_id
)
326 openmano_vnfd_nsd
= {}
327 openmano_vnfd_nsd
["name"] = rift_vnfd_id
+'-'+'scaling_group'
328 openmano_vnfd_nsd
["description"] = "Scaling Group"
330 openmano_vnfd_nsd
["topology"] = topology
332 topology
["nodes"] = {}
333 openmano_vnfd_nsd
["topology"] = topology
334 topology
["connections"] = {}
335 topology
["nodes"] = {}
336 topology
["nodes"] = {
338 "vnf_id": rift_vnfd_id
341 for vld
in rift_nsd
.vlds
:
343 # Create a connections entry for each external VLD
344 topology
["connections"][vld
.name
] = {}
345 topology
["connections"][vld
.name
]["nodes"] = []
347 for vnfd_cp
in vld
.vnfd_connection_point_ref
:
348 if not rit_vnfd_id
in vnfd_cp
.vnfd_id_ref
:
350 if rift_vnfd_id
in vnfd_cp
.vnfd_id_ref
:
351 # Get the RIFT VNF for this external VLD connection point
352 vnfd
= rift_vnfds
[vnfd_cp
.vnfd_id_ref
]
353 # For each VNF in this connection, use the same interface name
354 topology
["connections"][vld
.name
]["type"] = "link"
355 # Vnf ref is the vnf name with the member_vnf_idx appended
356 member_idx
= vnfd_cp
.member_vnf_index_ref
357 vnf_ref
= rift_vnfd_id
+ "__" + str(member_idx
)
358 topology
["connections"][vld
.name
]["nodes"].append(
360 vnf_ref
: vnfd_cp
.vnfd_connection_point_ref
363 return openmano_vnfd_nsd
365 def cloud_init(rift_vnfd_id
, vdu
):
366 """ Populate cloud_init with script from
367 either the inline contents or from the file provided
369 vnfd_package_store
= rift
.package
.store
.VnfdPackageFilesystemStore(logger
)
371 cloud_init_msg
= None
372 if vdu
.cloud_init
is not None:
373 logger
.debug("cloud_init script provided inline %s", vdu
.cloud_init
)
374 cloud_init_msg
= vdu
.cloud_init
375 elif vdu
.cloud_init_file
is not None:
376 # Get cloud-init script contents from the file provided in the cloud_init_file param
377 logger
.debug("cloud_init script provided in file %s", vdu
.cloud_init_file
)
378 filename
= vdu
.cloud_init_file
379 vnfd_package_store
.refresh()
380 stored_package
= vnfd_package_store
.get_package(rift_vnfd_id
)
381 cloud_init_extractor
= rift
.package
.cloud_init
.PackageCloudInitExtractor(logger
)
383 cloud_init_msg
= cloud_init_extractor
.read_script(stored_package
, filename
)
384 except rift
.package
.cloud_init
.CloudInitExtractionError
as e
:
387 logger
.debug("VDU translation: cloud-init script not provided")
390 logger
.debug("Current cloud init msg is {}".format(cloud_init_msg
))
391 return cloud_init_msg
393 def config_file_init(rift_vnfd_id
, vdu
, cfg_file
):
394 """ Populate config file init with file provided
396 vnfd_package_store
= rift
.package
.store
.VnfdPackageFilesystemStore(logger
)
398 # Get script contents from the file provided in the cloud_init directory
399 logger
.debug("config file script provided in file {}".format(cfg_file
))
401 vnfd_package_store
.refresh()
402 stored_package
= vnfd_package_store
.get_package(rift_vnfd_id
)
403 cloud_init_extractor
= rift
.package
.cloud_init
.PackageCloudInitExtractor(logger
)
405 cfg_file_msg
= cloud_init_extractor
.read_script(stored_package
, filename
)
406 except rift
.package
.cloud_init
.CloudInitExtractionError
as e
:
409 logger
.debug("Current config file msg is {}".format(cfg_file_msg
))
412 def rift2openmano_vnfd(rift_vnfd
, rift_nsd
):
413 openmano_vnf
= {"vnf":{}}
414 vnf
= openmano_vnf
["vnf"]
416 vnf
["name"] = rift_vnfd
.name
417 vnf
["description"] = rift_vnfd
.description
419 vnf
["external-connections"] = []
421 def find_vdu_and_ext_if_by_cp_ref(cp_ref_name
):
422 for vdu
in rift_vnfd
.vdus
:
423 for ext_if
in vdu
.external_interface
:
424 if ext_if
.vnfd_connection_point_ref
== cp_ref_name
:
427 raise ValueError("External connection point reference %s not found" % cp_ref_name
)
429 def find_vdu_and_int_if_by_cp_ref(cp_ref_id
):
430 for vdu
in rift_vnfd
.vdus
:
431 for int_if
in vdu
.internal_interface
:
432 if int_if
.vdu_internal_connection_point_ref
== cp_ref_id
:
435 raise ValueError("Internal connection point reference %s not found" % cp_ref_id
)
437 def rift2openmano_if_type(ext_if
):
439 cp_ref_name
= ext_if
.vnfd_connection_point_ref
440 for vld
in rift_nsd
.vlds
:
442 # if it is an explicit mgmt_network then check if the given
443 # cp_ref is a part of it
444 if not vld
.mgmt_network
:
447 for vld_cp
in vld
.vnfd_connection_point_ref
:
448 if vld_cp
.vnfd_connection_point_ref
== cp_ref_name
:
452 rift_type
= ext_if
.virtual_interface
.type_yang
453 # Retaining it for backward compatibility!
454 if rift_type
== "OM_MGMT":
456 elif rift_type
== "VIRTIO" or rift_type
== "E1000":
461 def rift2openmano_vif(rift_type
):
462 if rift_type
== "VIRTIO":
464 elif rift_type
== "E1000":
467 raise ValueError("VDU Virtual Interface type {} not supported".format(rift_type
))
469 # Add all external connections
470 for cp
in rift_vnfd
.cps
:
471 # Find the VDU and and external interface for this connection point
472 vdu
, ext_if
= find_vdu_and_ext_if_by_cp_ref(cp
.name
)
475 "type": rift2openmano_if_type(ext_if
),
477 "local_iface_name": ext_if
.name
,
478 "description": "%s iface on VDU %s" % (ext_if
.name
, vdu
.name
),
481 vnf
["external-connections"].append(connection
)
483 # Add all internal networks
484 for vld
in rift_vnfd
.internal_vlds
:
487 "description": vld
.description
,
492 # Add the specific VDU connection points
493 for int_cp
in vld
.internal_connection_point
:
494 vdu
, int_if
= find_vdu_and_int_if_by_cp_ref(int_cp
.id_ref
)
495 connection
["elements"].append({
497 "local_iface_name": int_if
.name
,
499 if "internal-connections" not in vnf
:
500 vnf
["internal-connections"] = []
502 vnf
["internal-connections"].append(connection
)
506 for vdu
in rift_vnfd
.vdus
:
509 "description": vdu
.name
,
513 if vdu
.vm_flavor
.has_field("storage_gb") and vdu
.vm_flavor
.storage_gb
:
514 vnfc
["disk"] = vdu
.vm_flavor
.storage_gb
516 if vdu
.has_field("image"):
517 if os
.path
.isabs(vdu
.image
):
518 vnfc
["VNFC image"] = vdu
.image
520 vnfc
["image name"] = vdu
.image
521 if vdu
.has_field("image_checksum"):
522 vnfc
["image checksum"] = vdu
.image_checksum
524 dedicated_int
= False
525 for intf
in list(vdu
.internal_interface
) + list(vdu
.external_interface
):
526 if intf
.virtual_interface
.type_yang
in ["SR_IOV", "PCI_PASSTHROUGH"]:
528 if vdu
.guest_epa
.has_field("numa_node_policy") or dedicated_int
:
530 "memory": max(int(vdu
.vm_flavor
.memory_mb
/1024), 1),
533 numa_node_policy
= vdu
.guest_epa
.numa_node_policy
534 if numa_node_policy
.has_field("node"):
535 numa_node
= numa_node_policy
.node
[0]
537 if numa_node
.has_field("paired_threads"):
538 if numa_node
.paired_threads
.has_field("num_paired_threads"):
539 vnfc
["numas"][0]["paired-threads"] = numa_node
.paired_threads
.num_paired_threads
540 if len(numa_node
.paired_threads
.paired_thread_ids
) > 0:
541 vnfc
["numas"][0]["paired-threads-id"] = []
542 for pair
in numa_node
.paired_threads
.paired_thread_ids
:
543 vnfc
["numas"][0]["paired-threads-id"].append(
544 [pair
.thread_a
, pair
.thread_b
]
548 if vdu
.vm_flavor
.has_field("vcpu_count"):
549 vnfc
["numas"][0]["cores"] = max(vdu
.vm_flavor
.vcpu_count
, 1)
552 if vdu
.vm_flavor
.has_field("vcpu_count") and vdu
.vm_flavor
.vcpu_count
:
553 vnfc
["vcpus"] = vdu
.vm_flavor
.vcpu_count
555 if vdu
.vm_flavor
.has_field("memory_mb") and vdu
.vm_flavor
.memory_mb
:
556 vnfc
["ram"] = vdu
.vm_flavor
.memory_mb
559 if vdu
.has_field("hypervisor_epa"):
560 vnfc
["hypervisor"] = {}
561 if vdu
.hypervisor_epa
.has_field("type"):
562 if vdu
.hypervisor_epa
.type_yang
== "REQUIRE_KVM":
563 vnfc
["hypervisor"]["type"] = "QEMU-kvm"
565 if vdu
.hypervisor_epa
.has_field("version"):
566 vnfc
["hypervisor"]["version"] = vdu
.hypervisor_epa
.version
568 if vdu
.has_field("host_epa"):
569 vnfc
["processor"] = {}
570 if vdu
.host_epa
.has_field("om_cpu_model_string"):
571 vnfc
["processor"]["model"] = vdu
.host_epa
.om_cpu_model_string
572 if vdu
.host_epa
.has_field("om_cpu_feature"):
573 vnfc
["processor"]["features"] = []
574 for feature
in vdu
.host_epa
.om_cpu_feature
:
575 vnfc
["processor"]["features"].append(feature
.feature
)
577 if vdu
.has_field("volumes"):
579 # Sort volumes as device-list is implictly ordered by Openmano
580 newvollist
= sorted(vdu
.volumes
, key
=lambda k
: k
.name
)
581 for iter_num
, volume
in enumerate(newvollist
):
583 # Convert the first volume to vnfc.image
584 if os
.path
.isabs(volume
.image
):
585 vnfc
["VNFC image"] = volume
.image
587 vnfc
["image name"] = volume
.image
588 if volume
.has_field("image_checksum"):
589 vnfc
["image checksum"] = volume
.image_checksum
591 # Add Openmano devices
593 device
["type"] = volume
.device_type
594 device
["image"] = volume
.image
595 vnfc
["devices"].append(device
)
597 vnfc_boot_data_init
= False
598 if vdu
.has_field("cloud_init") or vdu
.has_field("cloud_init_file"):
599 vnfc
['boot-data'] = dict()
600 vnfc_boot_data_init
= True
601 vnfc
['boot-data']['user-data'] = cloud_init(rift_vnfd
.id, vdu
)
603 if vdu
.has_field("supplemental_boot_data"):
604 if vdu
.supplemental_boot_data
.has_field('boot_data_drive'):
605 if vdu
.supplemental_boot_data
.boot_data_drive
is True:
606 if vnfc_boot_data_init
is False:
607 vnfc
['boot-data'] = dict()
608 vnfc_boot_data_init
= True
609 vnfc
['boot-data']['boot-data-drive'] = vdu
.supplemental_boot_data
.boot_data_drive
611 if vdu
.supplemental_boot_data
.has_field('config_file'):
612 om_cfgfile_list
= list()
613 for custom_config_file
in vdu
.supplemental_boot_data
.config_file
:
614 cfg_source
= config_file_init(rift_vnfd
.id, vdu
, custom_config_file
.source
)
615 om_cfgfile_list
.append({"dest":custom_config_file
.dest
, "content": cfg_source
})
616 vnfc
['boot-data']['config-files'] = om_cfgfile_list
619 vnf
["VNFC"].append(vnfc
)
621 for int_if
in list(vdu
.internal_interface
) + list(vdu
.external_interface
):
625 if int_if
.virtual_interface
.has_field("vpci"):
626 intf
["vpci"] = int_if
.virtual_interface
.vpci
628 if int_if
.virtual_interface
.type_yang
in ["VIRTIO", "E1000"]:
629 intf
["model"] = rift2openmano_vif(int_if
.virtual_interface
.type_yang
)
630 vnfc
["bridge-ifaces"].append(intf
)
632 elif int_if
.virtual_interface
.type_yang
in ["OM_MGMT"]:
633 vnfc
["bridge-ifaces"].append(intf
)
635 elif int_if
.virtual_interface
.type_yang
== "SR_IOV":
636 intf
["bandwidth"] = "10 Gbps"
637 intf
["dedicated"] = "no"
638 vnfc
["numas"][0]["interfaces"].append(intf
)
640 elif int_if
.virtual_interface
.type_yang
== "PCI_PASSTHROUGH":
641 intf
["bandwidth"] = "10 Gbps"
642 intf
["dedicated"] = "yes"
643 if "interfaces" not in vnfc
["numas"][0]:
644 vnfc
["numas"][0]["interfaces"] = []
645 vnfc
["numas"][0]["interfaces"].append(intf
)
647 raise ValueError("Interface type %s not supported" % int_if
.virtual_interface
)
649 if int_if
.virtual_interface
.has_field("bandwidth"):
650 if int_if
.virtual_interface
.bandwidth
!= 0:
651 bps
= int_if
.virtual_interface
.bandwidth
653 # Calculate the bits per second conversion
654 for x
in [('M', 1000000), ('G', 1000000000)]:
656 intf
["bandwidth"] = "{} {}bps".format(math
.ceil(bps
/x
[1]), x
[0])
658 # Sort bridge-ifaces-list TODO sort others
659 newlist
= sorted(vnfc
["bridge-ifaces"], key
=lambda k
: k
['name'])
660 vnfc
["bridge-ifaces"] = newlist
665 def parse_args(argv
=sys
.argv
[1:]):
666 """ Parse the command line arguments
669 arv - The list of arguments to parse
672 Argparse Namespace instance
674 parser
= argparse
.ArgumentParser()
678 help="Directory to output converted descriptors. Default is stdout",
682 '-n', '--nsd-file-hdl',
684 type=argparse
.FileType('r'),
685 help="Rift NSD Descriptor File",
689 '-v', '--vnfd-file-hdls',
692 type=argparse
.FileType('r'),
693 help="Rift VNFD Descriptor File",
696 args
= parser
.parse_args(argv
)
698 if not os
.path
.exists(args
.outdir
):
699 os
.makedirs(args
.outdir
)
701 if not is_writable_directory(args
.outdir
):
702 logging
.error("Directory %s is not writable", args
.outdir
)
708 def write_yaml_to_file(name
, outdir
, desc_dict
):
709 file_name
= "%s.yaml" % name
710 yaml_str
= yaml
.dump(desc_dict
)
712 sys
.stdout
.write(yaml_str
)
715 file_path
= os
.path
.join(outdir
, file_name
)
716 dir_path
= os
.path
.dirname(file_path
)
717 if not os
.path
.exists(dir_path
):
718 os
.makedirs(dir_path
)
720 with
open(file_path
, "w") as hdl
:
723 logger
.info("Wrote descriptor to %s", file_path
)
726 def main(argv
=sys
.argv
[1:]):
727 args
= parse_args(argv
)
729 rift_vnfd_id
= 'test_vnfd'
730 openmano_vnfr_ids
= dict()
732 if args
.vnfd_file_hdls
is not None:
733 vnf_dict
= create_vnfd_from_files(args
.vnfd_file_hdls
)
735 for vnfd
in vnf_dict
:
736 openmano_vnfr_ids
[vnfd
] = vnfd
738 if args
.nsd_file_hdl
is not None:
739 nsd
= create_nsd_from_file(args
.nsd_file_hdl
)
741 openmano_nsd
= rift2openmano_nsd(nsd
, vnf_dict
, openmano_vnfr_ids
,rift_vnfd_id
)
742 vnfd_nsd
= rift2openmano_vnfd_nsd(nsd
, vnf_dict
, openmano_vnfr_ids
, rift_vnfd_id
)
743 write_yaml_to_file(openmano_nsd
["name"], args
.outdir
, openmano_nsd
)
744 write_yaml_to_file(vnfd_nsd
["name"], args
.outdir
, vnfd_nsd
)
745 for vnf
in vnf_dict
.values():
746 openmano_vnf
= rift2openmano_vnfd(vnf
, nsd
)
747 write_yaml_to_file(openmano_vnf
["vnf"]["name"], args
.outdir
, openmano_vnf
)
750 if __name__
== "__main__":
751 logging
.basicConfig(level
=logging
.WARNING
)