#NEWLINE# @ qc ( 10 ) #NEWLINE# def append_vm_data_remotely( vms = dict_ ( keys = str_ ( of = 'abc123-' , min_length = 36 , max_length = 36 ) , values = tuple_ ( int_ ( min = 1 , max = 3000 ) , list_ ( of = int_ ( min = 1 , max = 3000 ) , min_length = 0 , max_length = 10 ) ) , min_length = 0 , max_length = 5 ) ) : #NEWLINE# #INDENT# db = db_utils . init_db ( 'sqlite:///:memory:' ) #NEWLINE# initial_data = [ ] #NEWLINE# data_to_submit = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# final_data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( uuid , data ) in vms . items ( ) : #NEWLINE# #INDENT# vm_id = db . select_vm_id ( uuid ) #NEWLINE# data_to_submit [ uuid ] = data [ 0 ] #NEWLINE# final_data [ uuid ] = list ( data [ 1 ] ) #NEWLINE# final_data [ uuid ] . append ( data [ 0 ] ) #NEWLINE# for cpu_mhz in data [ 1 ] : #NEWLINE# #INDENT# initial_data . append ( { #NEWLINE# #INDENT# 'vm_id' : cpu_mhz , #NEWLINE# 'cpu_mhz' : cpu_mhz , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# if initial_data : #NEWLINE# #INDENT# db . vm_resource_usage . insert ( ) . execute ( initial_data ) #NEWLINE# #UNINDENT# collector . append_vm_data_remotely ( db , data_to_submit ) #NEWLINE# for ( uuid , data ) in final_data . items ( ) : #NEWLINE# #INDENT# assert ( db . select_cpu_mhz_for_vm ( uuid , 11 ) == data )