#NEWLINE# def test_admin_nic_and_ip_assignment( self ) : #NEWLINE# #INDENT# cluster = self . env . create_cluster ( api = True ) #NEWLINE# admin_ng = objects . NetworkGroup . get_admin_network_group ( ) #NEWLINE# admin_ip = str ( IPNetwork ( admin_ng . cidr ) [ 0 ] ) #NEWLINE# ( mac1 , mac2 ) = ( self . env . generate_random_mac ( ) , self . env . generate_random_mac ( ) ) #NEWLINE# meta = self . env . default_metadata ( ) #NEWLINE# meta [ 'interfaces' ] = [ { #NEWLINE# #INDENT# 'name' : 'eth1' , #NEWLINE# 'mac' : mac2 , #NEWLINE# 'ip' : admin_ip , #NEWLINE# 'pxe' : True , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'eth0' , #NEWLINE# 'mac' : mac1 , #NEWLINE# #UNINDENT# } ] #NEWLINE# self . env . create_node ( api = True , meta = meta , mac = mac2 , cluster_id = cluster [ 'id' ] ) #NEWLINE# node_db = self . env . nodes [ 0 ] #NEWLINE# self . check_admin_interface ( interface , admin_ng , mac2 , admin_ip , 'eth1' ) #NEWLINE# meta = deepcopy ( node_db . meta ) #NEWLINE# for interface in meta [ 'interfaces' ] : #NEWLINE# #INDENT# if ( interface [ 'mac' ] == mac2 ) : #NEWLINE# #INDENT# interface [ 'ip' ] = None #NEWLINE# interface [ 'pxe' ] = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( interface [ 'mac' ] == mac1 ) : #NEWLINE# #INDENT# interface [ 'ip' ] = admin_ip #NEWLINE# interface [ 'pxe' ] = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# resp = self . app . put ( reverse ( 'NodeAgentHandler' ) , jsonutils . dumps ( { #NEWLINE# #INDENT# 'id' : node_db . id , #NEWLINE# 'mac' : mac1 , #NEWLINE# 'meta' : meta , #NEWLINE# #UNINDENT# } ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# self . db . refresh ( node_db ) #NEWLINE# self . check_admin_interface ( node_db , admin_ng , mac1 , admin_ip , 'eth0' ) #NEWLINE# resp = self . app . put ( reverse ( 'NodeCollectionHandler' ) , jsonutils . dumps ( [ { #NEWLINE# #INDENT# 'id' : node_db . id , #NEWLINE# 'cluster_id' : None , #NEWLINE# #UNINDENT# } ] ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# self . db . refresh ( node_db ) #NEWLINE# self . check_admin_interface ( node_db , admin_ng , mac1 , admin_ip , 'eth0' )