PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/qemu_img.py |
""" Qemu-img Command Wrapper ======================== The qemu img command is wrapped for specific functions :depends: qemu-img """ import os import salt.utils.path def __virtual__(): """ Only load if qemu-img is installed """ if salt.utils.path.which("qemu-img"): return "qemu_img" return ( False, "The qemu_img execution module cannot be loaded: the qemu-img binary is not in" " the path.", ) def make_image(location, size, fmt): """ Create a blank virtual machine image file of the specified size in megabytes. The image can be created in any format supported by qemu CLI Example: .. code-block:: bash salt '*' qemu_img.make_image /tmp/image.qcow 2048 qcow2 salt '*' qemu_img.make_image /tmp/image.raw 10240 raw """ if not os.path.isabs(location): return "" if not os.path.isdir(os.path.dirname(location)): return "" if not __salt__["cmd.retcode"]( f"qemu-img create -f {fmt} {location} {size}M", python_shell=False, ): return location return "" def convert(orig, dest, fmt): """ Convert an existing disk image to another format using qemu-img CLI Example: .. code-block:: bash salt '*' qemu_img.convert /path/to/original.img /path/to/new.img qcow2 """ cmd = ("qemu-img", "convert", "-O", fmt, orig, dest) ret = __salt__["cmd.run_all"](cmd, python_shell=False) if ret["retcode"] == 0: return True else: return ret["stderr"]