#NEWLINE# def test_NIC_change_offloading_modes( self ) : #NEWLINE# #INDENT# meta = self . env . default_metadata ( ) #NEWLINE# meta [ 'interfaces' ] = [ ] #NEWLINE# node = self . env . create_node ( api = True , meta = meta ) #NEWLINE# new_meta = self . env . default_metadata ( ) #NEWLINE# self . env . set_interfaces_in_meta ( new_meta , [ { #NEWLINE# #INDENT# 'name' : 'new_nic' , #NEWLINE# 'mac' : '00:00:00:00:00:00' , #NEWLINE# 'offloading_modes' : [ { #NEWLINE# #INDENT# 'name' : 'mode_1' , #NEWLINE# 'state' : None , #NEWLINE# 'sub' : [ ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'mode_2' , #NEWLINE# 'state' : None , #NEWLINE# 'sub' : [ ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'mode_3' , #NEWLINE# 'state' : None , #NEWLINE# 'sub' : [ ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# node_data = { #NEWLINE# #INDENT# 'mac' : node [ 'mac' ] , #NEWLINE# 'meta' : new_meta , #NEWLINE# #UNINDENT# } #NEWLINE# resp = self . app . put ( reverse ( 'NodeAgentHandler' ) , jsonutils . dumps ( node_data ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( nic . status_code , 200 ) #NEWLINE# resp = self . app . get ( reverse ( 'NodeNICsHandler' , kwargs = { #NEWLINE# #INDENT# 'node_id' : node [ 'id' ] , #NEWLINE# #UNINDENT# } ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# self . assertEqual ( len ( resp . json_body ) , 1 ) #NEWLINE# resp_nic = resp . json_body [ 0 ] #NEWLINE# nic = new_meta [ 'interfaces' ] [ 0 ] #NEWLINE# self . assertEqual ( resp_nic [ 'offloading_modes' ] , nic [ 'offloading_modes' ] ) #NEWLINE# resp = self . app . get ( reverse ( 'NodeCollectionHandler' , kwargs = { #NEWLINE# #INDENT# 'node_id' : node [ 'id' ] , #NEWLINE# #UNINDENT# } ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# self . assertEqual ( len ( resp . json_body ) , 1 ) #NEWLINE# resp_node = resp . json_body [ 0 ] #NEWLINE# new_nic = { #NEWLINE# #INDENT# 'name' : 'new_nic' , #NEWLINE# 'mac' : '00:00:00:00:00:00' , #NEWLINE# 'offloading_modes' : [ { #NEWLINE# #INDENT# 'name' : 'mode_1' , #NEWLINE# 'state' : True , #NEWLINE# 'sub' : [ ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'mode_2' , #NEWLINE# 'state' : False , #NEWLINE# 'sub' : [ ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'mode_3' , #NEWLINE# 'state' : None , #NEWLINE# 'sub' : [ ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# self . env . set_interfaces_in_meta ( resp_node [ 'meta' ] , [ new_nic ] ) #NEWLINE# resp_node . pop ( 'group_id' ) #NEWLINE# resp = self . app . put ( reverse ( 'NodeCollectionHandler' ) , jsonutils . dumps ( [ resp_node ] ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# resp = self . app . get ( reverse ( 'NodeNICsHandler' , kwargs = { #NEWLINE# #INDENT# 'node_id' : node [ 'id' ] , #NEWLINE# #UNINDENT# } ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# self . assertEqual ( len ( resp . json_body ) , 1 ) #NEWLINE# resp_nic = resp . json_body [ 0 ] #NEWLINE# self . assertEqual ( resp_nic [ 'offloading_modes' ] , new_nic [ 'offloading_modes' ] )