#NEWLINE# def get_network_details( uid , context ) : #NEWLINE# #INDENT# '\n    Extracts the VMs network adapter information.\n\n    uid -- Id of the VM.\n    context -- The os context.\n    ' #NEWLINE# vm_instance = vm . get_vm ( uid , vm_instance ) #NEWLINE# result = { #NEWLINE# #INDENT# 'public' : [ ] , #NEWLINE# 'admin' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# net_info = NETWORK_API . get_instance_nw_info ( context , vm_instance ) [ 0 ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# LOG . warn ( 'Unable to retrieve network information - this is because of OpenStack!!' ) #NEWLINE# return result #NEWLINE# #UNINDENT# gw = net_info [ 'network' ] [ 'subnets' ] [ 0 ] [ 'gateway' ] [ 'address' ] #NEWLINE# mac = net_info [ 'address' ] #NEWLINE# if ( len ( net_info [ 'network' ] [ 'subnets' ] [ 0 ] [ 'ips' ] ) == 0 ) : #NEWLINE# #INDENT# tmp = { #NEWLINE# #INDENT# 'floating_ips' : [ ] , #NEWLINE# 'address' : '0.0.0.0' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tmp = net_info [ 'network' ] [ 'subnets' ] [ 0 ] [ 'ips' ] [ 0 ] #NEWLINE# #UNINDENT# for item in tmp [ 'floating_ips' ] : #NEWLINE# #INDENT# result [ 'public' ] . append ( { #NEWLINE# #INDENT# 'interface' : 'eth0' , #NEWLINE# 'mac' : 'aa:bb:cc:dd:ee:ff' , #NEWLINE# 'state' : 'active' , #NEWLINE# 'address' : item [ 'address' ] , #NEWLINE# 'gateway' : '0.0.0.0' , #NEWLINE# 'allocation' : 'static' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# result [ 'admin' ] . append ( { #NEWLINE# #INDENT# 'interface' : 'eth0' , #NEWLINE# 'mac' : mac , #NEWLINE# 'state' : 'active' , #NEWLINE# 'address' : tmp [ 'address' ] , #NEWLINE# 'gateway' : gw , #NEWLINE# 'allocation' : 'static' , #NEWLINE# #UNINDENT# } ) #NEWLINE# return result