#NEWLINE# def neutron_check_gateways( self ) : #NEWLINE# #INDENT# 'Check that gateways are set if non-default node groups are used.' #NEWLINE# if ( objects . NodeGroupCollection . get_by_cluster_id ( self . cluster . id ) . count ( ) < 2 ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# for net in net . networks : #NEWLINE# #INDENT# if ( net [ 'meta' ] [ 'notation' ] in ( consts . NETWORK_NOTATION . cidr , consts . NETWORK_NOTATION . ip_ranges ) ) : #NEWLINE# #INDENT# cidr = netaddr . IPNetwork ( net [ 'cidr' ] ) #NEWLINE# if ( net [ 'gateway' ] is not None ) : #NEWLINE# #INDENT# gw = netaddr . IPAddress ( net [ 'gateway' ] ) #NEWLINE# if ( gw in cidr ) : #NEWLINE# #INDENT# ip_range = self . _get_net_range_for_ip ( gw , net ) #NEWLINE# if ( ip_range is not None ) : #NEWLINE# #INDENT# self . err_msgs . append ( "Gateway address belongs to the network's IP range [{0}]." . format ( ip_range ) ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ net [ 'id' ] ] , #NEWLINE# 'errors' : [ 'gateway' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . err_msgs . append ( 'Gateway address does not belong to the network.' ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ net [ 'id' ] ] , #NEWLINE# 'errors' : [ 'gateway' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . err_msgs . append ( 'Gateway is not set for network.' ) #NEWLINE# self . result . append ( { #NEWLINE# #INDENT# 'ids' : [ net [ 'id' ] ] , #NEWLINE# 'errors' : [ 'gateway' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . expose_error_messages ( )