Esempio n. 1
0
    def treat_devices_added_or_updated(self, devices, ovs_restarted):
        skipped_devices = []
        need_binding_devices = []
        security_disabled_devices = []
        devices_details_list = (
            self.plugin_rpc.get_devices_details_list_and_failed_devices(
                self.context,
                devices,
                self.agent_id,
                self.conf.host
            )
        )
        failed_devices = set(devices_details_list.get('failed_devices'))

        devices = devices_details_list.get('devices')
        vif_by_id = self.int_br.get_vifs_by_ids(
            [vif['device'] for vif in devices])
        for details in devices:
            device = details['device']
            LOG.debug("Processing port: %s", device)
            port = vif_by_id.get(device)
            if not port:
                # The port disappeared and cannot be processed
                LOG.info(_LI("Port %s was not found on the integration bridge "
                             "and will therefore not be processed"), device)
                skipped_devices.append(device)
                continue

            if 'port_id' in details:
                LOG.info(_LI("Port %(device)s updated. Details: %(details)s"),
                         {'device': device, 'details': details})
                details['vif_port'] = port
                need_binding = self.treat_vif_port(port, details['port_id'],
                                                   details['network_id'],
                                                   details['network_type'],
                                                   details['physical_network'],
                                                   details['segmentation_id'],
                                                   details['admin_state_up'],
                                                   details['fixed_ips'],
                                                   details['device_owner'],
                                                   ovs_restarted)
                if need_binding:
                    need_binding_devices.append(details)

                port_security = details['port_security_enabled']
                has_sgs = 'security_groups' in details
                if not port_security or not has_sgs:
                    security_disabled_devices.append(device)
                self._update_port_network(details['port_id'],
                                          details['network_id'])
                self.ext_manager.handle_port(self.context, details)
                self.sfc_treat_devices_added_updated(details['port_id'])
            else:
                LOG.warning(_LW("Device %s not defined on plugin"), device)
                if (port and port.ofport != -1):
                    self.port_dead(port)
        return (skipped_devices, need_binding_devices,
                security_disabled_devices, failed_devices)
Esempio n. 2
0
 def __init__(self):
     # Registered sfc drivers, keyed by name.
     self.drivers = {}
     # Ordered list of sfc drivers, defining
     # the order in which the drivers are called.
     self.ordered_drivers = []
     LOG.info(_LI("Configured SFC drivers: %s"), cfg.CONF.sfc.drivers)
     super(SfcDriverManager, self).__init__(
         "networking_sfc.sfc.drivers", cfg.CONF.sfc.drivers, invoke_on_load=True, name_order=True
     )
     LOG.info(_LI("Loaded SFC drivers: %s"), self.names())
     self._register_drivers()
Esempio n. 3
0
 def __init__(self):
     # Registered sfc drivers, keyed by name.
     self.drivers = {}
     # Ordered list of sfc drivers, defining
     # the order in which the drivers are called.
     self.ordered_drivers = []
     LOG.info(_LI("Configured SFC drivers: %s"), cfg.CONF.sfc.drivers)
     super(SfcDriverManager, self).__init__('networking_sfc.sfc.drivers',
                                            cfg.CONF.sfc.drivers,
                                            invoke_on_load=True,
                                            name_order=True)
     LOG.info(_LI("Loaded SFC drivers: %s"), self.names())
     self._register_drivers()
Esempio n. 4
0
 def __init__(self,
              namespace='networking_sfc.flowclassifier.drivers',
              names=cfg.CONF.flowclassifier.drivers):
     # Registered flow classifier drivers, keyed by name.
     self.drivers = {}
     # Ordered list of flow classifier drivers, defining
     # the order in which the drivers are called.
     self.ordered_drivers = []
     LOG.info(_LI("Configured Flow Classifier drivers: %s"), names)
     super(FlowClassifierDriverManager, self).__init__(namespace,
                                                       names,
                                                       invoke_on_load=True,
                                                       name_order=True)
     LOG.info(_LI("Loaded Flow Classifier drivers: %s"), self.names())
     self._register_drivers()
Esempio n. 5
0
def main():
    common_config.init(sys.argv[1:])
    common_config.setup_logging()
    q_utils.log_opt_values(LOG)
    bridge_classes = {
        'br_int': br_int.OVSIntegrationBridge,
        'br_phys': br_phys.OVSPhysicalBridge,
        'br_tun': br_tun.OVSTunnelBridge,
    }

    ovs_neutron_agent.prepare_xen_compute()
    ovs_neutron_agent.validate_tunnel_config(
        cfg.CONF.AGENT.tunnel_types,
        cfg.CONF.OVS.local_ip
    )

    try:
        agent = OVSSfcAgent(bridge_classes, cfg.CONF)
    except (RuntimeError, ValueError) as e:
        LOG.exception(e)
        LOG.error(_LE('Agent terminated!'))
        sys.exit(1)

    LOG.info(_LI("Agent initialized successfully, now running... "))
    agent.daemon_loop()
Esempio n. 6
0
 def __init__(self):
     # Registered flow classifier drivers, keyed by name.
     self.drivers = {}
     # Ordered list of flow classifier drivers, defining
     # the order in which the drivers are called.
     self.ordered_drivers = []
     LOG.info(_LI("Configured Flow Classifier drivers: %s"),
              cfg.CONF.flowclassifier.drivers)
     super(FlowClassifierDriverManager, self).__init__(
         'networking_sfc.flowclassifier.drivers',
         cfg.CONF.flowclassifier.drivers,
         invoke_on_load=True,
         name_order=True)
     LOG.info(_LI("Loaded Flow Classifier drivers: %s"),
              self.names())
     self._register_drivers()
Esempio n. 7
0
def main():
    common_config.init(sys.argv[1:])
    common_config.setup_logging()
    q_utils.log_opt_values(LOG)
    bridge_classes = {
        'br_int': br_int.OVSIntegrationBridge,
        'br_phys': br_phys.OVSPhysicalBridge,
        'br_tun': br_tun.OVSTunnelBridge,
    }

    ovs_neutron_agent.prepare_xen_compute()
    ovs_neutron_agent.validate_tunnel_config(
        cfg.CONF.AGENT.tunnel_types,
        cfg.CONF.OVS.local_ip
    )

    try:
        agent = OVSSfcAgent(bridge_classes, cfg.CONF)
    except (RuntimeError, ValueError) as e:
        LOG.exception(e)
        LOG.error(_LE('Agent terminated!'))
        sys.exit(1)

    LOG.info(_LI("Agent initialized successfully, now running... "))
    agent.daemon_loop()
Esempio n. 8
0
 def initialize(self):
     # ServiceChain bulk operations requires each driver to support them
     self.native_bulk_support = True
     for driver in self.ordered_drivers:
         LOG.info(_LI("Initializing SFC driver '%s'"), driver.name)
         driver.obj.initialize()
         self.native_bulk_support &= getattr(driver.obj, "native_bulk_support", True)
Esempio n. 9
0
 def delete_port_chain(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             pc = self._get_port_chain(context, id)
             context.session.delete(pc)
     except ext_sfc.PortChainNotFound:
         LOG.info(_LI("Deleting a non-existing port chain."))
Esempio n. 10
0
 def delete_port_chain(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             pc = self._get_port_chain(context, id)
             context.session.delete(pc)
     except ext_sfc.PortChainNotFound:
         LOG.info(_LI("Deleting a non-existing port chain."))
Esempio n. 11
0
 def initialize(self):
     # ServiceChain bulk operations requires each driver to support them
     self.native_bulk_support = True
     for driver in self.ordered_drivers:
         LOG.info(_LI("Initializing SFC driver '%s'"), driver.name)
         driver.obj.initialize()
         self.native_bulk_support &= getattr(driver.obj,
                                             'native_bulk_support', True)
Esempio n. 12
0
 def delete_flow_classifier(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             fc = self._get_flow_classifier(context, id)
             context.session.delete(fc)
     except AssertionError:
         raise fc_ext.FlowClassifierInUse(id=id)
     except fc_ext.FlowClassifierNotFound:
         LOG.info(_LI("Deleting a non-existing flow classifier."))
Esempio n. 13
0
 def delete_port_pair_group(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             pg = self._get_port_pair_group(context, id)
             if pg.chain_group_associations:
                 raise ext_sfc.PortPairGroupInUse(id=id)
             context.session.delete(pg)
     except ext_sfc.PortPairGroupNotFound:
         LOG.info(_LI("Deleting a non-existing port pair group."))
Esempio n. 14
0
 def delete_port_pair(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             pp = self._get_port_pair(context, id)
             if pp.portpairgroup_id:
                 raise ext_sfc.PortPairInUse(id=id)
             context.session.delete(pp)
     except ext_sfc.PortPairNotFound:
         LOG.info(_LI("Deleting a non-existing port pair."))
Esempio n. 15
0
 def delete_flow_classifier(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             fc = self._get_flow_classifier(context, id)
             context.session.delete(fc)
     except AssertionError:
         raise fc_ext.FlowClassifierInUse(id=id)
     except fc_ext.FlowClassifierNotFound:
         LOG.info(_LI("Deleting a non-existing flow classifier."))
Esempio n. 16
0
 def delete_port_pair_group(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             pg = self._get_port_pair_group(context, id)
             if pg.chain_group_associations:
                 raise ext_sfc.PortPairGroupInUse(id=id)
             context.session.delete(pg)
     except ext_sfc.PortPairGroupNotFound:
         LOG.info(_LI("Deleting a non-existing port pair group."))
Esempio n. 17
0
 def delete_port_pair(self, context, id):
     try:
         with context.session.begin(subtransactions=True):
             pp = self._get_port_pair(context, id)
             if pp.portpairgroup_id:
                 raise ext_sfc.PortPairInUse(id=id)
             context.session.delete(pp)
     except ext_sfc.PortPairNotFound:
         LOG.info(_LI("Deleting a non-existing port pair."))
Esempio n. 18
0
    def _register_drivers(self):
        """Register all SFC drivers.

        This method should only be called once in the SfcDriverManager
        constructor.
        """
        for ext in self:
            self.drivers[ext.name] = ext
            self.ordered_drivers.append(ext)
        LOG.info(_LI("Registered SFC drivers: %s"), [driver.name for driver in self.ordered_drivers])
Esempio n. 19
0
    def _register_drivers(self):
        """Register all Flow Classifier drivers.

        This method should only be called once in the
        FlowClassifierDriverManager constructor.
        """
        for ext in self:
            self.drivers[ext.name] = ext
            self.ordered_drivers.append(ext)
        LOG.info(_LI("Registered Flow Classifier drivers: %s"),
                 [driver.name for driver in self.ordered_drivers])
Esempio n. 20
0
    def sfc_treat_devices_removed(self, port_ids):
        resync = False
        for port_id in port_ids:
            LOG.info(_LI("a device %s is removed"), port_id)
            try:
                self._delete_ports_flowrules_by_id(port_id)
            except Exception as e:
                LOG.exception(e)
                LOG.error(_LE("delete port flow rule failed for %(port_id)s"),
                          {'port_id': port_id})
                resync = True

        return resync
Esempio n. 21
0
    def delete_port(self, context, port):
        """Handle agent SFC extension port delete."""
        port_id = port['port_id']
        resync = False
        LOG.info(_LI("a device %s is removed"), port_id)
        try:
            self._delete_ports_flowrules_by_id(context, port_id)
        except Exception as e:
            LOG.exception(e)
            LOG.error(_LE("delete port flow rule failed for %(port_id)s"),
                      {'port_id': port_id})
            resync = True

        return resync
Esempio n. 22
0
    def sfc_treat_devices_removed(self, port_ids):
        resync = False
        for port_id in port_ids:
            LOG.info(_LI("a device %s is removed"), port_id)
            try:
                self._delete_ports_flowrules_by_id(port_id)
            except Exception as e:
                LOG.exception(e)
                LOG.error(
                    _LE("delete port flow rule failed for %(port_id)s"),
                    {'port_id': port_id}
                )
                resync = True

        return resync
Esempio n. 23
0
    def delete_port(self, context, port):
        """Handle agent SFC extension port delete."""
        port_id = port['port_id']
        resync = False
        LOG.info(_LI("a device %s is removed"), port_id)
        try:
            self._delete_ports_flowrules_by_id(context, port_id)
        except Exception as e:
            LOG.exception(e)
            LOG.error(
                _LE("delete port flow rule failed for %(port_id)s"),
                {'port_id': port_id}
            )
            resync = True

        return resync
Esempio n. 24
0
 def update_flowrules_status(self, context, **kwargs):
     flowrules_status = kwargs.get('flowrules_status')
     LOG.info(_LI('update_flowrules_status: %s'), flowrules_status)
     for flowrule_dict in flowrules_status:
         self.driver.update_flowrule_status(
             context, flowrule_dict['id'], flowrule_dict['status'])
Esempio n. 25
0
 def _ovn(self):
     if self._ovn_property is None:
         LOG.info(_LI("Getting OvsdbOvnIdl"))
         self._ovn_property = impl_idl_ovn.OvsdbNbOvnIdl(self)
     return self._ovn_property
Esempio n. 26
0
 def _ovn(self):
     if self._ovn_property is None:
         LOG.info(_LI("Getting OvsdbOvnIdl"))
         self._ovn_property = impl_idl_ovn.OvsdbNbOvnIdl(self)
     return self._ovn_property
Esempio n. 27
0
 def update_flowrules_status(self, context, **kwargs):
     flowrules_status = kwargs.get('flowrules_status')
     LOG.info(_LI('update_flowrules_status: %s'), flowrules_status)
     for flowrule_dict in flowrules_status:
         self.driver.update_flowrule_status(context, flowrule_dict['id'],
                                            flowrule_dict['status'])