def _validate_ports_for_firewall_group(self, context, tenant_id,
                                           fwg_ports):
        """Validate firewall group associated ports

        Check if the firewall group associated ports have the same project
        owner and is router interface type or a compute layer 2.
        :param context: neutron context
        :param tenant_id: firewall group project ID
        :param fwg_ports: firewall group associated ports
        """
        # TODO(sridar): elevated context and do we want to use public ?
        for port_id in fwg_ports:
            port = self._core_plugin.get_port(context, port_id)

            if port['tenant_id'] != tenant_id:
                raise f_exc.FirewallGroupPortInvalidProject(
                    port_id=port_id, project_id=port['tenant_id'])
            device_owner = port.get('device_owner', '')
            if (device_owner not in [nl_constants.DEVICE_OWNER_ROUTER_INTF] and
                not device_owner.startswith(
                    nl_constants.DEVICE_OWNER_COMPUTE_PREFIX)):
                raise f_exc.FirewallGroupPortInvalid(port_id=port_id)
            if (device_owner.startswith(
                    nl_constants.DEVICE_OWNER_COMPUTE_PREFIX) and not
                self._is_supported_by_fw_l2_driver(context, port_id)):
                raise exceptions.FirewallGroupPortNotSupported(port_id=port_id)
Example #2
0
 def _validate_ports_for_firewall_group(self, context, tenant_id,
     fwg_ports):
     # TODO(sridar): elevated context and do we want to use public ?
     for port_id in fwg_ports:
         port_db = self._core_plugin._get_port(context, port_id)
         if port_db['device_owner'] != "network:router_interface":
             raise f_exc.FirewallGroupPortInvalid(port_id=port_id)
         if port_db['tenant_id'] != tenant_id:
             raise f_exc.FirewallGroupPortInvalidProject(
                 port_id=port_id, tenant_id=port_db['tenant_id'])
     return
Example #3
0
 def _validate_ports_for_firewall_group(self, context, tenant_id,
                                        fwg_ports):
     # TODO(sridar): elevated context and do we want to use public ?
     for port_id in fwg_ports:
         port_db = self._core_plugin._get_port(context, port_id)
         if port_db['tenant_id'] != tenant_id:
             raise f_exc.FirewallGroupPortInvalidProject(
                 port_id=port_id, project_id=port_db['tenant_id'])
         device_owner = port_db.get('device_owner', '')
         if (device_owner not in [nl_constants.DEVICE_OWNER_ROUTER_INTF]
             and not device_owner.startswith(
                 nl_constants.DEVICE_OWNER_COMPUTE_PREFIX)):
             raise f_exc.FirewallGroupPortInvalid(port_id=port_id)