#NEWLINE# def create_cow_image( backing_file , path , size = None ) : #NEWLINE# #INDENT# 'Create COW image\n\n    Creates a COW image with the given backing file\n\n    :param backing_file: Existing image on which to base the COW image\n    :param path: Desired location of the COW image\n    ' #NEWLINE# base_cmd = [ 'qemu-img' , 'create' , '-f' , 'qcow2' ] #NEWLINE# cow_opts = [ ] #NEWLINE# if backing_file : #NEWLINE# #INDENT# cow_opts += [ ( 'backing_file=%s' % backing_file ) ] #NEWLINE# base_details = images . qemu_img_info ( backing_file ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# base_details = None #NEWLINE# #UNINDENT# if ( base_details and ( base_details . cluster_size is not None ) ) : #NEWLINE# #INDENT# cow_opts += [ ( 'cluster_size=%s' % base_details . cluster_size ) ] #NEWLINE# #UNINDENT# if ( size is not None ) : #NEWLINE# #INDENT# cow_opts += [ ( 'size=%s' % csv_opts ) ] #NEWLINE# #UNINDENT# if cow_opts : #NEWLINE# #INDENT# csv_opts = ',' . join ( cow_opts ) #NEWLINE# cow_opts = [ '-o' , csv_opts ] #NEWLINE# #UNINDENT# cmd = ( ( base_cmd + cow_opts ) + [ path ] ) #NEWLINE# execute ( * cmd )