#NEWLINE# def _disk_profile( profile , hypervisor , **kwargs ) : #NEWLINE# #INDENT# '\n    Gather the disk profile from the config or apply the default based\n    on the active hypervisor\n\n    This is the ``default`` profile for KVM/QEMU, which can be\n    overridden in the configuration:\n\n    .. code-block:: yaml\n\n        virt:\n          disk:\n            default:\n              - system:\n                  size: 8192\n                  format: qcow2\n                  model: virtio\n\n    The ``format`` and ``model`` parameters are optional, and will\n    default to whatever is best suitable for the active hypervisor.\n    ' #NEWLINE# default = [ { #NEWLINE# #INDENT# 'system' : { #NEWLINE# #INDENT# 'size' : '8192' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# if ( hypervisor in [ 'esxi' , 'vmware' ] ) : #NEWLINE# #INDENT# overlay = { #NEWLINE# #INDENT# 'format' : 'vmdk' , #NEWLINE# 'model' : 'scsi' , #NEWLINE# 'pool' : '[{0}] ' . format ( kwargs . get ( 'pool' , '0' ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( hypervisor in [ 'qemu' , 'kvm' ] ) : #NEWLINE# #INDENT# overlay = { #NEWLINE# #INDENT# 'format' : 'qcow2' , #NEWLINE# 'model' : 'virtio' , #NEWLINE# 'pool' : __salt__ [ 'config.option' ] ( 'virt.images' ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# overlay = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# disklist = __salt__ [ 'config.get' ] ( 'virt:disk' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( profile , default ) #NEWLINE# for ( key , val ) in six . iteritems ( overlay ) : #NEWLINE# #INDENT# for ( i , disks ) in enumerate ( disklist ) : #NEWLINE# #INDENT# for disk in disks : #NEWLINE# #INDENT# if ( key not in disks [ disk ] ) : #NEWLINE# #INDENT# disklist [ i ] [ disk ] [ key ] = val #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return disklist