Comment 5 for bug 1475792

Revision history for this message
Jay Pipes (jaypipes) wrote : Re: Change Neutron so that it can auto-allocate networks

I would be totally fine just adding a single new Neutron API call that would be called, switched on some Nova CONF.auto_allocate_private_subnet option, that would do something like this:

            # (1) Retrieve non-public network list owned by the tenant.
            search_opts = {'tenant_id': project_id, 'shared': False}
            nets = neutron.list_networks(**search_opts).get('networks', [])
            if CONF.auto_allocate_private_subnet:
                nets += neutron.allocate_subnet_from_available_pools(tenant_id=project_id)
            else:
                # (2) Retrieve public network list.
                search_opts = {'shared': True}
                nets += neutron.list_networks(**search_opts).get('networks', [])

             if not nets:
                 raise exception.NoAvailableNetworks(...)

The Neutron API call could look something like this?

            POST /subnet_pools
            {
                 "tenant_id": project_id,
                 "allocate_first_available": true
            }