#NEWLINE# @ classmethod #NEWLINE# def validate_network_group( cls , ng_data , ng_db , cluster , admin_ranges = None ) : #NEWLINE# #INDENT# "Validate new settings of network group.\n\n        Validate new settings of network group for consistency and check\n        that nodes' IPs will not be out of new IP ranges (for all nodes vs\n        Admin networks and for deployed nodes vs all networks).\n\n        :param ng_data:      new parameters of network group (dict)\n        :param ng_db:        network group instance\n        :param cluster:      cluster instance\n        :param admin_ranges: IP ranges for Admin networks are collected here\n                             if admin_ranges is not None (to use by other code)\n        :return:             ng_data\n        :raises:             errors.InvalidData\n        " #NEWLINE# cidr = ng_data . get ( 'cidr' , ng_db . cidr ) #NEWLINE# ip_ranges = ng_data . get ( 'ip_ranges' , [ ( r . first , r . last ) for r in ng_db . ip_ranges ] ) #NEWLINE# release = ng_data . get ( 'release' , ng_db . get ( 'release' ) ) #NEWLINE# if ( release != ng_db . get ( 'release' ) ) : #NEWLINE# #INDENT# raise errors . InvalidData ( 'Network release could not be changed.' ) #NEWLINE# #UNINDENT# meta = ng_data . get ( 'meta' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# notation = meta . get ( 'notation' , ng_db . meta . get ( 'notation' ) ) #NEWLINE# use_gateway = meta . get ( 'use_gateway' , ng_db . meta . get ( 'use_gateway' , False ) ) #NEWLINE# gateway = ng_data . get ( 'gateway' , ng_db . get ( 'gateway' ) ) #NEWLINE# if ( use_gateway and ( not gateway ) ) : #NEWLINE# #INDENT# raise errors . InvalidData ( "Flag 'use_gateway' cannot be provided without gateway" ) #NEWLINE# #UNINDENT# if ( ( not ip_ranges ) and ( notation == consts . NETWORK_NOTATION . ip_ranges ) ) : #NEWLINE# #INDENT# raise errors . InvalidData ( 'No IP ranges were specified for network {0}' . format ( ng_db . id ) ) #NEWLINE# #UNINDENT# if ( notation in ( consts . NETWORK_NOTATION . cidr , consts . NETWORK_NOTATION . ip_ranges ) ) : #NEWLINE# #INDENT# if ( ( not cidr ) and ( not ng_db . cidr ) ) : #NEWLINE# #INDENT# raise errors . InvalidData ( 'No CIDR was specified for network {0}' . format ( ng_db . id ) ) #NEWLINE# #UNINDENT# #UNINDENT# nm = objects . Cluster . get_network_manager ( cluster ) #NEWLINE# ranges = cls . _get_network_ip_ranges ( ng_data , ng_db , notation , ( gateway is not None ) ) #NEWLINE# is_admin_network = ( ng_db . name == consts . NETWORKS . fuelweb_admin ) #NEWLINE# if is_admin_network : #NEWLINE# #INDENT# if ( admin_ranges is not None ) : #NEWLINE# #INDENT# admin_ranges [ ng_db . id ] = gateway #NEWLINE# #UNINDENT# #UNINDENT# if ( ( is_admin_network or ( cluster . status != consts . CLUSTER_STATUSES . new ) ) and cls . _check_ips_out_of_ip_ranges ( ng_db , nm , ranges ) ) : #NEWLINE# #INDENT# raise errors . InvalidData ( "New IP ranges for network '{0}'({1}) do not cover already allocated IPs." . format ( ng_data [ 'name' ] , ng_data [ 'id' ] ) ) #NEWLINE# #UNINDENT# return ng_data