#NEWLINE# def seed_non_shared_migrate( disks , force = False ) : #NEWLINE# #INDENT# "\n    Non shared migration requires that the disks be present on the migration\n    destination, pass the disks information via this function, to the\n    migration destination before executing the migration.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' virt.seed_non_shared_migrate <disks>\n    " #NEWLINE# for ( _ , data ) in six . iteritems ( disks ) : #NEWLINE# #INDENT# fn_ = data [ 'file' ] #NEWLINE# form = data [ 'file format' ] #NEWLINE# size = data [ 'virtual size' ] . split ( ) [ 1 ] [ 1 : ] #NEWLINE# if ( os . path . isfile ( fn_ ) and ( not force ) ) : #NEWLINE# #INDENT# pre = yaml . safe_load ( subprocess . Popen ( 'qemu-img info arch' , shell = True , stdout = subprocess . PIPE ) . communicate ( ) [ 0 ] ) #NEWLINE# if ( ( pre [ 'file format' ] != data [ 'file format' ] ) and ( pre [ 'virtual size' ] != data [ 'virtual size' ] ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# if ( not os . path . isdir ( os . path . dirname ( fn_ ) ) ) : #NEWLINE# #INDENT# os . makedirs ( os . path . dirname ( fn_ ) ) #NEWLINE# #UNINDENT# if os . path . isfile ( fn_ ) : #NEWLINE# #INDENT# os . remove ( fn_ ) #NEWLINE# #UNINDENT# cmd = ( ( ( ( ( 'qemu-img create -f ' + form ) + ' ' ) + fn_ ) + ' ' ) + size ) #NEWLINE# subprocess . call ( cmd , shell = True ) #NEWLINE# creds = _libvirt_creds ( ) #NEWLINE# cmd = ( ( ( ( ( 'chown ' + creds [ 'user' ] ) + ':' ) + creds [ 'group' ] ) + ' ' ) + fn_ ) #NEWLINE# subprocess . call ( cmd , shell = True ) #NEWLINE# #UNINDENT# return True