#NEWLINE# def _shelve_offload( self , clean_shutdown = True ) : #NEWLINE# #INDENT# host = 'fake-mini' #NEWLINE# instance = self . _create_fake_instance_obj ( params = { #NEWLINE# #INDENT# 'host' : host , #NEWLINE# #UNINDENT# } ) #NEWLINE# instance . task_state = task_states . SHELVING #NEWLINE# instance . save ( ) #NEWLINE# self . useFixture ( utils_fixture . TimeFixture ( ) ) #NEWLINE# self . mox . StubOutWithMock ( self . compute , '_notify_about_instance_usage' ) #NEWLINE# self . mox . StubOutWithMock ( self . compute . driver , 'power_off' ) #NEWLINE# self . mox . StubOutWithMock ( self . compute , '_get_power_state' ) #NEWLINE# self . mox . StubOutWithMock ( self . compute . network_api , 'cleanup_instance_network_on_host' ) #NEWLINE# self . mox . StubOutWithMock ( self . compute , '_update_resource_tracker' ) #NEWLINE# self . compute . _notify_about_instance_usage ( self . context , instance , 'shelve_offload.start' ) #NEWLINE# if clean_shutdown : #NEWLINE# #INDENT# self . compute . driver . power_off ( instance , CONF . shutdown_timeout , self . compute . SHUTDOWN_RETRY_INTERVAL ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . compute . driver . power_off ( instance , 0 , 0 ) #NEWLINE# #UNINDENT# self . compute . network_api . cleanup_instance_network_on_host ( self . context , instance , instance . host ) #NEWLINE# self . compute . _get_power_state ( self . context , instance ) . AndReturn ( 123 ) #NEWLINE# self . compute . _update_resource_tracker ( self . context , instance ) #NEWLINE# self . compute . _notify_about_instance_usage ( self . context , instance , 'shelve_offload.end' ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# with mock . patch . object ( instance , 'save' ) : #NEWLINE# #INDENT# self . compute . shelve_offload_instance ( self . context , instance , clean_shutdown = clean_shutdown ) #NEWLINE# #UNINDENT# self . assertEqual ( vm_states . SHELVED_OFFLOADED , host . vm_state ) #NEWLINE# self . assertIsNone ( instance . task_state )