#NEWLINE# @ auth #NEWLINE# def _POST( self , * param , **params ) : #NEWLINE# #INDENT# ( host_id , guest_id ) = self . chk_guestby1 ( param ) #NEWLINE# if ( guest_id is None ) : #NEWLINE# #INDENT# return web . notfound ( ) #NEWLINE# #UNINDENT# if ( not validates_snapshot ( self ) ) : #NEWLINE# #INDENT# return web . badrequest ( self . view . alert ) #NEWLINE# #UNINDENT# guest = findbyguest1 ( self . orm , guest_id ) #NEWLINE# kvs = KaresansuiVirtSnapshot ( readonly = False ) #NEWLINE# try : #NEWLINE# #INDENT# domname = kvs . kvc . uuid_to_domname ( guest . uniq_key ) #NEWLINE# if ( not domname ) : #NEWLINE# #INDENT# return web . conflict ( web . ctx . path ) #NEWLINE# #UNINDENT# virt = kvs . kvc . search_kvg_guests ( domname ) [ 0 ] #NEWLINE# if ( virt . is_active ( ) is True ) : #NEWLINE# #INDENT# return web . badrequest ( _ ( ( 'Guest is running. Please stop and try again. name=%s' % domname ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# kvs . finish ( ) #NEWLINE# #UNINDENT# id = int ( time . time ( ) ) #NEWLINE# notebook = new_notebook ( self . input . title , self . input . value ) #NEWLINE# snapshot = new_snapshot ( guest , id , self . me , self . me , notebook ) #NEWLINE# save_snapshot ( self . orm , snapshot ) #NEWLINE# options = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# options [ 'name' ] = domname #NEWLINE# options [ 'id' ] = id #NEWLINE# _cmd = dict2command ( ( '%s/%s' % ( karesansui . config [ 'application.bin.dir' ] , VIRT_COMMAND_TAKE_SNAPSHOT ) ) , options ) #NEWLINE# cmdname = 'Take Snapshot' #NEWLINE# _jobgroup = JobGroup ( cmdname , karesansui . sheconf [ 'env.uniqkey' ] ) #NEWLINE# _jobgroup . jobs . append ( Job ( ( '%s command' % cmdname ) , 0 , _cmd ) ) #NEWLINE# _machine2jobgroup = m2j_new ( machine = guest , jobgroup_id = ( - 1 ) , uniq_key = karesansui . sheconf [ 'env.uniqkey' ] , created_user = options . me , modified_user = self . me ) #NEWLINE# save_job_collaboration ( self . orm , self . pysilhouette . orm , _machine2jobgroup , _jobgroup ) #NEWLINE# return web . accepted ( )