From c187812065c3415678882b5f272bf54a2bf792ce Mon Sep 17 00:00:00 2001 From: Jeremy McDermond Date: Mon, 15 May 2017 08:38:00 -0700 Subject: [PATCH] JunOS: Change os_install to use get_file instead of get_template In the JunOS modules os_install is designed to install operating system images to the device. The current code uses get_template to upload the OS image file to the device. This does not work because get_template attempts to load the entire file into memory so that it can process any template directives inside the file. The typical JunOS files are so large that they cause a MemoryError exception in Python. I can think of no circumstances where it would be useful to template an OS image file. Any changes you make to it will break the internal checksums and cause upgrades to break. Therefore, I have changed the code to use get_file which does not have the problem with large files. This code has been tested in my lab with JunOS 15.1X53-D55.5 version upgrades on EX2300 switches. --- salt/modules/junos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/junos.py b/salt/modules/junos.py index b58529613d..9e41482bb5 100644 --- a/salt/modules/junos.py +++ b/salt/modules/junos.py @@ -1005,7 +1005,7 @@ def install_os(path=None, **kwargs): return ret image_cached_path = files.mkstemp() - __salt__['cp.get_template'](path, image_cached_path) + __salt__['cp.get_file'](path, image_cached_path) if not os.path.isfile(image_cached_path): ret['message'] = 'Invalid image path.'