#NEWLINE# def _to_node( self , element ) : #NEWLINE# #INDENT# attrs = [ 'name' , 'image-id' , 'progress' , 'id' , 'bw-out' , 'bw-in' , 'flavor-id' , 'status' , 'ip-address' , 'root-password' ] #NEWLINE# node_attrs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for attr in attrs : #NEWLINE# #INDENT# node_attrs [ attr ] = element . findtext ( attr ) #NEWLINE# #UNINDENT# primary_ip = element . findtext ( 'ip-address' ) #NEWLINE# public_ip = [ ] #NEWLINE# private_ip = [ ] #NEWLINE# for addr in element . findall ( 'addresses/address' ) : #NEWLINE# #INDENT# ip = addr . text #NEWLINE# try : #NEWLINE# #INDENT# socket . inet_aton ( ip ) #NEWLINE# #UNINDENT# except socket . error : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if is_private_subnet ( ip ) : #NEWLINE# #INDENT# private_ip . append ( ip ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# public_ip . append ( ip ) #NEWLINE# #UNINDENT# #UNINDENT# public_ip . append ( primary_ip ) #NEWLINE# public_ip = list ( set ( public_ip ) ) #NEWLINE# try : #NEWLINE# #INDENT# state = self . NODE_STATE_MAP [ element . findtext ( 'status' ) ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# state = NodeState . UNKNOWN #NEWLINE# #UNINDENT# node_attrs [ 'password' ] = node_attrs [ 'root-password' ] #NEWLINE# extra = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in node_attrs . keys ( ) : #NEWLINE# #INDENT# ek = k . replace ( '-' , '_' ) #NEWLINE# extra [ ek ] = node_attrs [ k ] #NEWLINE# #UNINDENT# n = Node ( id = element . findtext ( 'id' ) , name = element . findtext ( 'name' ) , state = attr , public_ip = public_ip , private_ip = private_ip , driver = self . connection . driver , extra = extra ) #NEWLINE# return n