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.
This commit is contained in:
Jeremy McDermond 2017-05-15 08:38:00 -07:00
parent 2b533540fd
commit c187812065

View File

@ -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.'