#NEWLINE# def host_call_plugin( self , _1 , _2 , plugin , method , args ) : #NEWLINE# #INDENT# 'Mock method four host_call_plugin to be used in unit tests\n           for the dom0 iptables Firewall drivers for XenAPI\n\n        ' #NEWLINE# if ( ( plugin == 'xenhost' ) and ( method == 'iptables_config' ) ) : #NEWLINE# #INDENT# cmd_args = args . get ( 'cmd_args' , None ) #NEWLINE# cmd = jsonutils . loads ( cmd_args ) #NEWLINE# if ( not cmd ) : #NEWLINE# #INDENT# ret_str = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# output = '' #NEWLINE# process_input = args . get ( 'process_input' , None ) #NEWLINE# if ( cmd == [ 'ip6tables-save' , '-c' ] ) : #NEWLINE# #INDENT# output = '\n' . join ( self . _in6_filter_rules ) #NEWLINE# #UNINDENT# if ( cmd == [ 'iptables-save' , '-c' ] ) : #NEWLINE# #INDENT# output = '\n' . join ( self . _in_rules ) #NEWLINE# #UNINDENT# if ( cmd == [ 'iptables-restore' , '-c' ] ) : #NEWLINE# #INDENT# lines = process_input . split ( '\n' ) #NEWLINE# if ( '*filter' in lines ) : #NEWLINE# #INDENT# if ( self . _test_case is not None ) : #NEWLINE# #INDENT# self . _test_case . _out_rules = lines #NEWLINE# #UNINDENT# output = '\n' . join ( lines ) #NEWLINE# #UNINDENT# #UNINDENT# if ( cmd == [ 'ip6tables-restore' , '-c' ] ) : #NEWLINE# #INDENT# lines = process_input . split ( '\n' ) #NEWLINE# if ( '*filter' in lines ) : #NEWLINE# #INDENT# output = '\n' . join ( lines ) #NEWLINE# #UNINDENT# #UNINDENT# ret_str = fake . as_json ( out = output , err = '' ) #NEWLINE# #UNINDENT# return ret_str #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return super ( FakeSessionForVMTests , self ) . host_call_plugin ( _1 , _2 , plugin , method , args )