Comment 13 for bug 1284718

Revision history for this message
Aaron Rosen (arosen) wrote :

Hi Salvatore,

I don't think that is the right fix. The reason this is occurring is because we are not calling validate_networks before calling to the nova-compute node. The fix was included in this patch set though was dropped for some reason:

https://review.openstack.org/#/c/57229/8..9/nova/api/openstack/compute/contrib/attach_interfaces.py

In addition we might need to adiff --git a/nova/exception.py b/nova/exception.py
index cce9125..c5caa6d 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -624,6 +624,9 @@ class NetworkRequiresSubnet(Invalid):
     msg_fmt = _("Network %(network_uuid)s requires a subnet in order to boot"
                 " instances on.")

+class NetworkIsExternal(Invalid):
+ msg_fmt = _("Creating ports on router:external network %(network_uuid)s "
+ "is not allowed.")

 class DatastoreNotFound(NotFound):
     msg_fmt = _("Could not find the datastore reference(s) which the VM uses.")
diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py
index 17e3bed..03db13c 100644
--- a/nova/network/neutronv2/api.py
+++ b/nova/network/neutronv2/api.py
@@ -588,6 +588,7 @@ class API(base.Base):

         neutron = neutronv2.get_client(context)
         ports_needed_per_instance = 0

         if not requested_networks:
             nets = self._get_available_networks(context, context.project_id,
@@ -634,10 +635,14 @@ class API(base.Base):
             nets = self._get_available_networks(context,
                                     context.project_id, net_ids,
                                     neutron=neutron)

             for net in nets:
                 if not net.get('subnets'):
                     raise exception.NetworkRequiresSubnet(
                         network_uuid=net['id'])
+ if net.get('router:external'):
+ raise exception.NetworkIsExternal(network_uuid=net['id'])

             if len(nets) != len(net_ids):
                 requsted_netid_set = set(net_ids)
dd these lines as well: