#NEWLINE# @ staticmethod #NEWLINE# def validate_subnet_prefix_length( ip_version , new_prefix_length , ip_pool = None ) : #NEWLINE# #INDENT# if ( ( new_prefix_length < 2 ) or ( ( ip_version == 4 ) and ( new_prefix_length > MAX_IPV4_SUBNET_PREFIX_LENGTH ) ) or ( ( ip_version == 6 ) and ( new_prefix_length > MAX_IPV6_SUBNET_PREFIX_LENGTH ) ) ) : #NEWLINE# #INDENT# raise gpolicy . InvalidDefaultSubnetPrefixLength ( length = new_prefix_length , protocol = ip_version ) #NEWLINE# #UNINDENT# if ( ip_version is not None ) : #NEWLINE# #INDENT# ip_pool_prefix_length = netaddr . IPNetwork ( ip_pool ) . prefixlen #NEWLINE# if ( ip_pool_prefix_length > new_prefix_length ) : #NEWLINE# #INDENT# raise gpolicy . SubnetPrefixLengthExceedsIpPool ( ip_pool = ip_pool , subnet_size = new_prefix_length )