#NEWLINE# def _create_subnet( self , request , data , network = None , tenant_id = None , no_redirect = False ) : #NEWLINE# #INDENT# if network : #NEWLINE# #INDENT# network_id = network . id #NEWLINE# network_name = network . name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# network_id = self . context . get ( 'network_id' ) #NEWLINE# network_name = self . context . get ( 'network_name' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# params = { #NEWLINE# #INDENT# 'network_id' : network_id , #NEWLINE# 'name' : data [ 'subnet_name' ] , #NEWLINE# 'cidr' : data [ 'cidr' ] , #NEWLINE# 'ip_version' : int ( data [ 'ip_version' ] ) , #NEWLINE# #UNINDENT# } #NEWLINE# if tenant_id : #NEWLINE# #INDENT# params [ 'tenant_id' ] = tenant_id #NEWLINE# #UNINDENT# if data [ 'no_gateway' ] : #NEWLINE# #INDENT# params [ 'gateway_ip' ] = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if data [ 'gateway_ip' ] : #NEWLINE# #INDENT# params [ 'gateway_ip' ] = data [ 'gateway_ip' ] #NEWLINE# #UNINDENT# #UNINDENT# self . _setup_subnet_parameters ( params , data ) #NEWLINE# subnet = api . neutron . subnet_create ( request , ** params ) #NEWLINE# self . context [ 'subnet_id' ] = subnet . id #NEWLINE# msg = ( _ ( 'Subnet "%s" was successfully created.' ) % data [ 'cidr' ] ) #NEWLINE# LOG . debug ( msg ) #NEWLINE# return subnet #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# msg = _ ( 'Failed to create subnet "%(sub)s" for network "%(net)s":  %(reason)s' ) #NEWLINE# if no_redirect : #NEWLINE# #INDENT# redirect = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# redirect = self . get_failure_url ( ) #NEWLINE# #UNINDENT# exceptions . handle ( request , ( network_name % { #NEWLINE# #INDENT# 'sub' : data [ 'cidr' ] , #NEWLINE# 'net' : network_name , #NEWLINE# 'reason' : e , #NEWLINE# #UNINDENT# } ) , redirect = redirect ) #NEWLINE# return False