From 534a4fdd8259f3bd9868408e5d7846bf66f1afe4 Mon Sep 17 00:00:00 2001 From: Daniel Lintott Date: Wed, 10 Dec 2014 15:43:14 +0000 Subject: [PATCH] Copy instructions to new topology --- gns3converter/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gns3converter/main.py b/gns3converter/main.py index dd9e6df..4362a47 100644 --- a/gns3converter/main.py +++ b/gns3converter/main.py @@ -251,6 +251,10 @@ def save(output_dir, converter, json_topology, snapshot, quiet): config_err = copy_configs(converter.configs, old_topology_dir, topology_files_dir) + # Copy the instructions to the new topology folder + if not snapshot: + copy_instructions(old_topology_dir, output_dir) + # Move the image files to the new topology folder image_err = copy_images(converter.images, topology_files_dir) @@ -332,6 +336,17 @@ def copy_images(images, target): return image_err +def copy_instructions(source_project, dest_project): + old_instructions = os.path.join(source_project, 'instructions') + new_instructions = os.path.join(dest_project, 'instructions') + + if os.path.exists(old_instructions): + try: + shutil.copytree(old_instructions, new_instructions) + except shutil.Error as error: + raise ConvertError('Error copying instructions', error) + + def make_vbox_dirs(max_vbox_id, output_dir, topology_name): """ Create VirtualBox working directories if required