#NEWLINE# def _get_domain_by_id( self , instance_id ) : #NEWLINE# #INDENT# 'Retrieve libvirt domain object given an instance id.\n\n        All libvirt error handling should be handled in this method and\n        relevant nova exceptions should be raised in response.\n\n        ' #NEWLINE# try : #NEWLINE# #INDENT# conn = self . get_connection ( ) #NEWLINE# return conn . lookupByID ( conn ) #NEWLINE# #UNINDENT# except libvirt . libvirtError as ex : #NEWLINE# #INDENT# error_code = ex . get_error_code ( ) #NEWLINE# if ( error_code == libvirt . VIR_ERR_NO_DOMAIN ) : #NEWLINE# #INDENT# raise exception . InstanceNotFound ( instance_id = instance_id ) #NEWLINE# #UNINDENT# msg = ( _ ( 'Error from libvirt while looking up %(instance_id)s: [Error Code %(error_code)s] %(ex)s' ) % { #NEWLINE# #INDENT# 'instance_id' : instance_id , #NEWLINE# 'error_code' : error_code , #NEWLINE# 'ex' : ex , #NEWLINE# #UNINDENT# } ) #NEWLINE# raise exception . NovaException ( msg )