#NEWLINE# def test_nic_adds_by_agent( self ) : #NEWLINE# #INDENT# meta = self . env . default_metadata ( ) #NEWLINE# self . env . set_interfaces_in_meta ( meta , [ { #NEWLINE# #INDENT# 'name' : 'eth0' , #NEWLINE# 'mac' : '00:00:00:00:00:00' , #NEWLINE# 'current_speed' : 1 , #NEWLINE# 'pxe' : True , #NEWLINE# 'state' : 'up' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# node = self . env . create_node ( api = True , meta = meta ) #NEWLINE# meta [ 'interfaces' ] . append ( { #NEWLINE# #INDENT# 'name' : 'new_nic' , #NEWLINE# 'mac' : '00:00:00:00:00:01' , #NEWLINE# #UNINDENT# } ) #NEWLINE# node_data = { #NEWLINE# #INDENT# 'mac' : node [ 'mac' ] , #NEWLINE# 'meta' : meta , #NEWLINE# #UNINDENT# } #NEWLINE# resp = self . app . put ( reverse ( 'NodeAgentHandler' ) , jsonutils . dumps ( node_data ) , 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 ) , len ( meta [ 'interfaces' ] ) ) #NEWLINE# for nic in meta [ 'interfaces' ] : #NEWLINE# #INDENT# filtered_nics = filter ( ( lambda i : ( i [ 'mac' ] == nic [ 'mac' ] ) ) , resp . json_body ) #NEWLINE# resp_nic = filtered_nics [ 0 ] #NEWLINE# self . assertEqual ( resp_nic [ 'mac' ] , nic [ 'mac' ] ) #NEWLINE# self . assertEqual ( resp_nic [ 'current_speed' ] , nic . get ( 'current_speed' ) ) #NEWLINE# self . assertEqual ( resp_nic [ 'max_speed' ] , nic . get ( 'max_speed' ) ) #NEWLINE# self . assertEqual ( resp_nic [ 'state' ] , nic . get ( 'state' ) ) #NEWLINE# for conn in ( 'assigned_networks' , ) : #NEWLINE# #INDENT# self . assertEqual ( resp_nic [ conn ] , [ ] )