#NEWLINE# def setup( self , mount = True ) : #NEWLINE# #INDENT# LOG . debug ( 'Setting up appliance for %(image)s' , { #NEWLINE# #INDENT# 'image' : self . image , #NEWLINE# #UNINDENT# } ) #NEWLINE# try : #NEWLINE# #INDENT# self . handle = tpool . Proxy ( guestfs . GuestFS ( python_return_dict = False , close_on_exit = False ) ) #NEWLINE# #UNINDENT# except TypeError as e : #NEWLINE# #INDENT# if ( ( 'close_on_exit' in six . text_type ( e ) ) or ( 'python_return_dict' in six . text_type ( self ) ) ) : #NEWLINE# #INDENT# self . handle = tpool . Proxy ( guestfs . GuestFS ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# if CONF . guestfs . debug : #NEWLINE# #INDENT# self . configure_debug ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if forceTCG : #NEWLINE# #INDENT# self . handle . set_backend_settings ( 'force_tcg' ) #NEWLINE# #UNINDENT# #UNINDENT# except AttributeError as ex : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Unable to force TCG mode, libguestfs too old? %s' ) , ex ) #NEWLINE# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if isinstance ( self . image , imgmodel . LocalImage ) : #NEWLINE# #INDENT# self . handle . add_drive_opts ( self . image . path , format = self . image . format ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( self . image , imgmodel . RBDImage ) : #NEWLINE# #INDENT# self . handle . add_drive_opts ( ( '%s/%s' % ( self . image . pool , self . image . name ) ) , protocol = 'rbd' , format = imgmodel . FORMAT_RAW , server = self . image . servers , username = self . image . user , secret = self . image . password ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise exception . UnsupportedImageModel ( self . image . __class__ . __name__ ) #NEWLINE# #UNINDENT# #UNINDENT# self . handle . launch ( ) #NEWLINE# if mount : #NEWLINE# #INDENT# self . setup_os ( ) #NEWLINE# self . handle . aug_init ( '/' , 0 ) #NEWLINE# self . mount = True #NEWLINE# #UNINDENT# #UNINDENT# except RuntimeError as e : #NEWLINE# #INDENT# self . teardown ( ) #NEWLINE# raise exception . NovaException ( ( _ ( 'Error mounting %(image)s with libguestfs (%(e)s)' ) % { #NEWLINE# #INDENT# 'image' : self . image , #NEWLINE# 'e' : e , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . teardown ( ) #NEWLINE# raise