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
}
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} list_networks( **search_ opts).get( 'networks' , []) allocate_ private_ subnet:
nets += neutron. allocate_ subnet_ from_available_ pools(tenant_ id=project_ id)
search_ opts = {'shared': True}
nets += neutron. list_networks( **search_ opts).get( 'networks' , [])
nets = neutron.
if CONF.auto_
else:
# (2) Retrieve public network list.
if not nets:
raise exception. NoAvailableNetw orks(.. .)
The Neutron API call could look something like this?
POST /subnet_pools
"tenant_ id": project_id,
"allocate_ first_available ": true
{
}