#NEWLINE# def neutron_check_network_address_spaces_intersection( self ) : #NEWLINE# #INDENT# 'Check intersection of address spaces of all networks including admin\n\n        (Neutron)\n        ' #NEWLINE# for ( ng1 , ng2 ) in combinations ( self . networks , 2 ) : #NEWLINE# #INDENT# if ( ng1 . get ( 'cidr' ) and ng2 . get ( 'cidr' ) ) : #NEWLINE# #INDENT# if ( ( ng1 [ 'group_id' ] != ng2 [ 'group_id' ] ) and ( ng1 [ 'group_id' ] is not None ) and ( ng2 [ 'group_id' ] is not None ) and ( ng1 [ 'name' ] == ng2 [ 'name' ] ) and ( ng1 [ 'gateway' ] is not None ) and ( ng1 [ 'gateway' ] == ng2 [ 'gateway' ] ) and ( ng1 [ 'cidr' ] == ng2 [ 'cidr' ] ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# cidr1 = netaddr . IPNetwork ( ng1 [ 'cidr' ] ) #NEWLINE# cidr2 = netaddr . IPNetwork ( ng2 [ 'cidr' ] ) #NEWLINE# if self . net_man . is_cidr_intersection ( cidr1 , cidr2 ) : #NEWLINE# #INDENT# self . err_msgs . append ( 'Address space intersection between networks:\n{0}' . format ( ', ' . join ( [ ng1 [ 'name' ] , ng2 [ 'name' ] ] ) ) ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ int ( ng1 [ 'id' ] ) , int ( ng2 [ 'id' ] ) ] , #NEWLINE# 'errors' : [ 'cidr' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . expose_error_messages ( ) #NEWLINE# publics = filter ( ( lambda ng : ( ng [ 'name' ] == consts . NETWORKS . public ) ) , self . networks ) #NEWLINE# public_cidrs = [ netaddr . IPNetwork ( p [ 'cidr' ] ) . cidr for p in publics ] #NEWLINE# floating_ip_ranges = [ netaddr . IPRange ( r1 , r2 ) for ( r1 , r2 ) in self . network_config [ 'floating_ranges' ] ] #NEWLINE# for cidr in publics : #NEWLINE# #INDENT# if all ( ( ( range in cidr ) for range in floating_ip_ranges ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . err_msgs . append ( 'Floating address ranges {0} are not in the same public CIDR.' . format ( ', ' . join ( ( str ( cidr ) for cidr in floating_ip_ranges ) ) ) ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ ] , #NEWLINE# 'errors' : [ 'cidr' , 'ip_ranges' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# self . expose_error_messages ( ) #NEWLINE# for public in publics : #NEWLINE# #INDENT# public_cidr = netaddr . IPNetwork ( public [ 'cidr' ] ) . cidr #NEWLINE# public_gw = netaddr . IPAddress ( public [ 'gateway' ] ) #NEWLINE# ranges = [ netaddr . IPRange ( start , end ) for ( start , end ) in public [ 'ip_ranges' ] ] #NEWLINE# ranges . extend ( ( r for r in floating_ip_ranges if ( r in public_cidr ) ) ) #NEWLINE# for npair in combinations ( ranges , 2 ) : #NEWLINE# #INDENT# if self . net_man . is_range_intersection ( npair [ 0 ] , npair [ 1 ] ) : #NEWLINE# #INDENT# if ( ( npair [ 0 ] in floating_ip_ranges ) or ( npair [ 1 ] in floating_ip_ranges ) ) : #NEWLINE# #INDENT# self . err_msgs . append ( 'Address space intersection between ranges of public and floating network.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . err_msgs . append ( 'Address space intersection between ranges of public network.' ) #NEWLINE# #UNINDENT# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ int ( public [ 'id' ] ) ] , #NEWLINE# 'errors' : [ 'ip_ranges' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# for net in ranges : #NEWLINE# #INDENT# if ( public_gw in net ) : #NEWLINE# #INDENT# self . err_msgs . append ( 'Address intersection between public gateway and IP range of public network.' ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ int ( public [ 'id' ] ) ] , #NEWLINE# 'errors' : [ 'gateway' , 'ip_ranges' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( net not in public_cidr ) : #NEWLINE# #INDENT# self . err_msgs . append ( 'Public gateway and public ranges are not in one CIDR.' ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ int ( public [ 'id' ] ) ] , #NEWLINE# 'errors' : [ 'gateway' , 'ip_ranges' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . expose_error_messages ( ) #NEWLINE# cidr = netaddr . IPNetwork ( self . network_config [ 'internal_cidr' ] ) #NEWLINE# gw = netaddr . IPAddress ( self . network_config [ 'internal_gateway' ] ) #NEWLINE# if ( gw not in cidr ) : #NEWLINE# #INDENT# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ ] , #NEWLINE# 'name' : [ 'internal' ] , #NEWLINE# 'errors' : [ 'gateway' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . err_msgs . append ( 'Internal gateway {0} is not in internal address space {1}.' . format ( str ( gw ) , str ( cidr ) ) ) #NEWLINE# #UNINDENT# for range in floating_ip_ranges : #NEWLINE# #INDENT# if self . net_man . is_range_intersection ( range , cidr ) : #NEWLINE# #INDENT# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ ] , #NEWLINE# 'name' : [ 'internal' , 'external' ] , #NEWLINE# 'errors' : [ 'cidr' , 'ip_ranges' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . err_msgs . append ( 'Intersection between internal CIDR {0} and floating range {1}.' . format ( cidr , range ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . expose_error_messages ( )