Skip to content

Commit

Permalink
Specify default networks that a compute node assigns has when allocat…
Browse files Browse the repository at this point in the history
…ing instances

Change-Id: I36eb9b6c8164368d8d56868503b2d9ddd40f77bb
  • Loading branch information
sorrison committed Jun 17, 2015
1 parent e2f7d2b commit 1bc2396
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions nova/network/neutronv2/api.py
Expand Up @@ -108,6 +108,10 @@
' extensions',
deprecated_group='DEFAULT',
deprecated_name='neutron_extension_sync_interval'),
cfg.ListOpt('default_networks',
default=[],
help='Default networks to attach to if none given in '
'boot request'),
cfg.StrOpt('ca_certificates_file',
help='Location of CA certificates file to use for '
'neutron client requests.',
Expand Down Expand Up @@ -326,11 +330,17 @@ def allocate_for_instance(self, context, instance, **kwargs):
# bug/1267723 - if no network is requested and more
# than one is available then raise NetworkAmbiguous Exception
if len(nets) > 1:
msg = _("Multiple possible networks found, use a Network "
"ID to be more specific.")
raise exception.NetworkAmbiguous(msg)
ordered_networks.append(
objects.NetworkRequest(network_id=nets[0]['id']))
if CONF.neutron.default_networks:
for network_id in CONF.neutron.default_networks:
ordered_networks.append(
objects.NetworkRequest(network_id=network_id))
else:
msg = _("Multiple possible networks found, use a Network "
"ID to be more specific.")
raise exception.NetworkAmbiguous(msg)
else:
ordered_networks.append(
objects.NetworkRequest(network_id=nets[0]['id']))

# NOTE(melwitt): check external net attach permission after the
# check for ambiguity, there could be another
Expand Down

0 comments on commit 1bc2396

Please sign in to comment.