#NEWLINE# def _get_requested_networks( self , requested_networks ) : #NEWLINE# #INDENT# 'Create a list of requested networks from the networks attribute.' #NEWLINE# networks = [ ] #NEWLINE# network_uuids = [ ] #NEWLINE# for network in requested_networks : #NEWLINE# #INDENT# request = objects . NetworkRequest ( ) #NEWLINE# try : #NEWLINE# #INDENT# request . address = network . get ( 'fixed_ip' , None ) #NEWLINE# request . port_id = network . get ( 'port' , None ) #NEWLINE# if request . port_id : #NEWLINE# #INDENT# request . network_id = None #NEWLINE# if ( not utils . is_neutron ( ) ) : #NEWLINE# #INDENT# msg = _ ( 'Unknown argument: port' ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg ) #NEWLINE# #UNINDENT# if ( request . address is not None ) : #NEWLINE# #INDENT# msg = ( _ ( "Specified Fixed IP '%(addr)s' cannot be used with port '%(port)s': port already has a Fixed IP allocated." ) % { #NEWLINE# #INDENT# 'addr' : request . address , #NEWLINE# 'port' : request . port_id , #NEWLINE# #UNINDENT# } ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# request . network_id = network [ 'uuid' ] #NEWLINE# #UNINDENT# if ( ( not request . port_id ) and ( not uuidutils . is_uuid_like ( request . network_id ) ) ) : #NEWLINE# #INDENT# br_uuid = request . network_id . split ( '-' , 1 ) [ ( - 1 ) ] #NEWLINE# if ( not uuidutils . is_uuid_like ( br_uuid ) ) : #NEWLINE# #INDENT# msg = ( _ ( 'Bad networks format: network uuid is not in proper format (%s)' ) % request . network_id ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = msg ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( not utils . is_neutron ( ) ) and request . network_id and ( request . network_id in network_uuids ) ) : #NEWLINE# #INDENT# expl = ( _ ( 'Duplicate networks (%s) are not allowed' ) % request . network_id ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = expl ) #NEWLINE# #UNINDENT# network_uuids . append ( request . network_id ) #NEWLINE# networks . append ( request ) #NEWLINE# #UNINDENT# except KeyError as key : #NEWLINE# #INDENT# expl = ( _ ( 'Bad network format: missing %s' ) % key ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = expl ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# expl = _ ( 'Bad networks format' ) #NEWLINE# raise exc . HTTPBadRequest ( explanation = expl ) #NEWLINE# #UNINDENT# #UNINDENT# return objects . NetworkRequestList ( objects = networks )