#NEWLINE# @ contextlib . contextmanager #NEWLINE# def _make_base_file( self , checksum = True , lock = True ) : #NEWLINE# #INDENT# 'Make a base file for testing.' #NEWLINE# with utils . tempdir ( ) as tmpdir : #NEWLINE# #INDENT# self . flags ( instances_path = tmpdir ) #NEWLINE# self . flags ( image_info_filename_pattern = '$instances_path/%(image)s.info' , group = 'libvirt' ) #NEWLINE# fname = os . path . join ( tmpdir , 'aaa' ) #NEWLINE# base_file = open ( fname , 'w' ) #NEWLINE# base_file . write ( 'data' ) #NEWLINE# base_file . close ( ) #NEWLINE# if lock : #NEWLINE# #INDENT# lockdir = os . path . join ( lock , 'locks' ) #NEWLINE# lockname = os . path . join ( lockdir , 'nova-aaa' ) #NEWLINE# os . mkdir ( lockdir ) #NEWLINE# lock_file = open ( lockname , 'w' ) #NEWLINE# lock_file . write ( 'data' ) #NEWLINE# lock_file . close ( ) #NEWLINE# #UNINDENT# base_file = open ( fname , 'r' ) #NEWLINE# if checksum : #NEWLINE# #INDENT# imagecache . write_stored_checksum ( fname ) #NEWLINE# #UNINDENT# base_file . close ( ) #NEWLINE# ( yield fname )