Ejemplo n.º 1
0
    def __init__(self):
        super(OVNPlugin, self).__init__()
        LOG.info(_("Starting OVNPlugin"))
        self.vif_type = portbindings.VIF_TYPE_OVS
        # When set to True, Nova plugs the VIF directly into the ovs bridge
        # instead of using the hybrid mode.
        self.vif_details = {portbindings.CAP_PORT_FILTER: True}

        self._ovn = impl_idl_ovn.OvsdbOvnIdl()

        # Call the synchronization task, this sync neutron DB to OVN-NB DB
        # only in inconsistent states
        self.synchronizer = (
            ovn_nb_sync.OvnNbSynchronizer(self,
                                          self._ovn,
                                          config.get_ovn_neutron_sync_mode()))
        self.base_binding_dict = {
            portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
            portbindings.VIF_DETAILS: {
                # TODO(rkukura): Replace with new VIF security details
                portbindings.CAP_PORT_FILTER:
                'security-group' in self.supported_extension_aliases}}

        self.synchronizer.sync()
        self._setup_rpc()
Ejemplo n.º 2
0
    def __init__(self):
        super(OVNPlugin, self).__init__()
        LOG.info(_("Starting OVNPlugin"))
        self.vif_type = portbindings.VIF_TYPE_OVS
        # When set to True, Nova plugs the VIF directly into the ovs bridge
        # instead of using the hybrid mode.
        self.vif_details = {portbindings.CAP_PORT_FILTER: True}

        self._ovn = impl_idl_ovn.OvsdbOvnIdl()

        # Call the synchronization task, this sync neutron DB to OVN-NB DB
        # only in inconsistent states
        self.synchronizer = (ovn_nb_sync.OvnNbSynchronizer(
            self, self._ovn, config.get_ovn_neutron_sync_mode()))
        self.base_binding_dict = {
            portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
            portbindings.VIF_DETAILS: {
                # TODO(rkukura): Replace with new VIF security details
                portbindings.CAP_PORT_FILTER:
                'security-group' in self.supported_extension_aliases
            }
        }

        self.synchronizer.sync()
        self._setup_rpc()
Ejemplo n.º 3
0
    def post_fork_initialize(self, resource, event, trigger, payload=None):
        # NOTE(rtheis): This will initialize all workers (API, RPC,
        # plugin service and OVN) with OVN IDL connections.
        self._post_fork_event.clear()
        self._ovn_client_inst = None
        self._nb_ovn, self._sb_ovn = impl_idl_ovn.get_ovn_idls(self, trigger)
        # Now IDL connections can be safely used.
        self._post_fork_event.set()

        if trigger.im_class == ovsdb_monitor.OvnWorker:
            # Call the synchronization task if its ovn worker
            # This sync neutron DB to OVN-NB DB only in inconsistent states
            self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
                self._plugin, self._nb_ovn, config.get_ovn_neutron_sync_mode(),
                self)
            self.nb_synchronizer.sync()

            # This sync neutron DB to OVN-SB DB only in inconsistent states
            self.sb_synchronizer = ovn_db_sync.OvnSbSynchronizer(
                self._plugin, self._sb_ovn, self)
            self.sb_synchronizer.sync()

        if trigger.im_class == maintenance.MaintenanceWorker:
            self._maintenance_thread = maintenance.MaintenanceThread()
            self._maintenance_thread.add_periodics(
                maintenance.DBInconsistenciesPeriodics(self._ovn_client))
            self._maintenance_thread.start()
def main():
    """Main method for syncing neutron networks and ports with ovn nb db.

    The utility syncs neutron db with ovn nb db.
    """
    conf = setup_conf()

    # if no config file is passed or no configuration options are passed
    # then load configuration from /etc/neutron/neutron.conf
    try:
        conf(project='neutron')
    except TypeError:
        LOG.error(_LE('Error parsing the configuration values. '
                      'Please verify.'))
        return

    logging.setup(conf, 'neutron_ovn_db_sync_util')
    LOG.info(_LI('Started Neutron OVN db sync'))
    mode = ovn_config.get_ovn_neutron_sync_mode()
    if mode not in [ovn_nb_sync.SYNC_MODE_LOG, ovn_nb_sync.SYNC_MODE_REPAIR]:
        LOG.error(_LE('Invalid sync mode : ["%s"]. Should be "log" or '
                      '"repair"'), mode)
        return

    # we dont want the service plugins to be loaded.
    conf.service_plugins = []
    ovn_plugin = manager.NeutronManager.get_plugin()
    try:
        ovn_plugin._ovn = impl_idl_ovn.OvsdbOvnIdl(ovn_plugin)
    except RuntimeError:
        LOG.error(_LE('Invalid --ovn-ovsdb_connection parameter provided.'))
        return

    synchronizer = ovn_nb_sync.OvnNbSynchronizer(
        ovn_plugin, ovn_plugin._ovn, mode)

    ctx = context.get_admin_context()

    LOG.info(_LI('Syncing the networks and ports with mode : %s'), mode)
    try:
        synchronizer.sync_networks_and_ports(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  the networks and ports. Check the "
                          "--database-connection value again"))
        return
    try:
        synchronizer.sync_acls(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  ACLs for unknown reason "
                          "please try again"))
        return
    try:
        synchronizer.sync_routers_and_rports(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  Routers and Router ports "
                          "please try again"))
        return
    LOG.info(_LI('Sync completed'))
Ejemplo n.º 5
0
    def post_fork_initialize(self, resource, event, trigger, **kwargs):
        self._ovn = impl_idl_ovn.OvsdbOvnIdl(self, trigger)

        # Call the synchronization task, this sync neutron DB to OVN-NB DB
        # only in inconsistent states
        self.synchronizer = (
            ovn_nb_sync.OvnNbSynchronizer(self,
                                          self._ovn,
                                          config.get_ovn_neutron_sync_mode()))
        self.synchronizer.sync()
Ejemplo n.º 6
0
    def __reconnect__(self, leader_info=None):
        if leader_info != OvsdbNbOvnIdl.leader_info:
            OvsdbNbOvnIdl.ovsdb_connection.stop()
            self.__init_connect__(leader_info)
            OvsdbNbOvnIdl.leader_info = leader_info

            self.idl = OvsdbNbOvnIdl.ovsdb_connection.idl
            self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
                manager.NeutronManager.get_plugin(), self,
                cfg.get_ovn_neutron_sync_mode(), self.driver)
            self.nb_synchronizer.sync()
Ejemplo n.º 7
0
    def post_fork_initialize(self, resource, event, trigger, **kwargs):
        # NOTE(rtheis): This will initialize all workers (API, RPC,
        # plugin service and OVN) with OVN IDL connections.
        self._nb_ovn, self._sb_ovn = impl_idl_ovn.get_ovn_idls(self, trigger)

        if trigger.im_class == ovsdb_monitor.OvnWorker:
            # Call the synchronization task if its ovn worker
            # This sync neutron DB to OVN-NB DB only in inconsistent states
            self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
                self._plugin, self._nb_ovn, config.get_ovn_neutron_sync_mode(),
                self)
            self.nb_synchronizer.sync()
Ejemplo n.º 8
0
    def post_fork_initialize(self, resource, event, trigger, **kwargs):
        self._ovn = impl_idl_ovn.OvsdbOvnIdl()

        # Call the synchronization task, this sync neutron DB to OVN-NB DB
        # only in inconsistent states
        self.synchronizer = ovn_nb_sync.OvnNbSynchronizer(self, self._ovn, config.get_ovn_neutron_sync_mode())
        self.base_binding_dict = {
            portbindings.VIF_TYPE: portbindings.VIF_TYPE_OVS,
            portbindings.VIF_DETAILS: {
                # TODO(rkukura): Replace with new VIF security details
                portbindings.CAP_PORT_FILTER: "security-group"
                in self.supported_extension_aliases
            },
        }

        self.synchronizer.sync()
Ejemplo n.º 9
0
    def post_fork_initialize(self, resource, event, trigger, **kwargs):
        # NOTE(rtheis): This will initialize all workers (API, RPC,
        # plugin service and OVN) with OVN IDL connections.
        self._nb_ovn, self._sb_ovn = impl_idl_ovn.get_ovn_idls(self,
                                                               trigger)

        if trigger.im_class == ovsdb_monitor.OvnWorker:
            # Call the synchronization task if its ovn worker
            # This sync neutron DB to OVN-NB DB only in inconsistent states
            self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
                self._plugin,
                self._nb_ovn,
                config.get_ovn_neutron_sync_mode(),
                self
            )
            self.nb_synchronizer.sync()
Ejemplo n.º 10
0
    def initialize(self):
        self.vif_type = portbindings.VIF_TYPE_OVS
        # When set to True, Nova plugs the VIF directly into the ovs bridge
        # instead of using the hybrid mode.
        self.vif_details = {portbindings.CAP_PORT_FILTER: True}

        self._ovn = impl_idl_ovn.OvsdbOvnIdl()
        self.security_handler = sec_handler.OvnSecurityGroupsHandler(self._ovn)

        # Call the synchronization task, this sync neutron DB to OVN-NB DB
        # only in inconsistent states
        self.synchronizer = (
            ovn_nb_sync.OvnNbSynchronizer(self,
                                          self._ovn,
                                          cfg.get_ovn_neutron_sync_mode()))
        self.synchronizer.sync()
Ejemplo n.º 11
0
    def post_fork_initialize(self, resource, event, trigger, payload=None):
        # NOTE(rtheis): This will initialize all workers (API, RPC,
        # plugin service and OVN) with OVN IDL connections.
        self._post_fork_event.clear()
        self._ovn_client_inst = None

        is_maintenance = (
            utils.get_method_class(trigger) == worker.MaintenanceWorker)
        if not is_maintenance:
            self.node_uuid = db_hash_ring.add_node(self.hash_ring_group)

        self._nb_ovn, self._sb_ovn = impl_idl_ovn.get_ovn_idls(
            self, trigger, binding_events=not is_maintenance)

        # Override agents API methods
        self.patch_plugin_merge("get_agents", get_agents)
        self.patch_plugin_choose("get_agent", get_agent)
        self.patch_plugin_choose("update_agent", update_agent)
        self.patch_plugin_choose("delete_agent", delete_agent)

        # Now IDL connections can be safely used.
        self._post_fork_event.set()

        if is_maintenance:
            # Call the synchronization task if its maintenance worker
            # This sync neutron DB to OVN-NB DB only in inconsistent states
            self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
                self._plugin, self._nb_ovn, self._sb_ovn,
                config.get_ovn_neutron_sync_mode(), self)
            self.nb_synchronizer.sync()

            # This sync neutron DB to OVN-SB DB only in inconsistent states
            self.sb_synchronizer = ovn_db_sync.OvnSbSynchronizer(
                self._plugin, self._sb_ovn, self)
            self.sb_synchronizer.sync()

            self._maintenance_thread = maintenance.MaintenanceThread()
            self._maintenance_thread.add_periodics(
                maintenance.DBInconsistenciesPeriodics(self._ovn_client))
            self._maintenance_thread.add_periodics(
                maintenance.HashRingHealthCheckPeriodics(self.hash_ring_group))
            self._maintenance_thread.start()
Ejemplo n.º 12
0
def main():
    """Main method for syncing neutron networks and ports with ovn nb db.

    The utility syncs neutron db with ovn nb db.
    """
    conf = setup_conf()

    # if no config file is passed or no configuration options are passed
    # then load configuration from /etc/neutron/neutron.conf
    try:
        conf(project='neutron')
    except TypeError:
        LOG.error(
            _LE('Error parsing the configuration values. '
                'Please verify.'))
        return

    logging.setup(conf, 'neutron_ovn_db_sync_util')
    LOG.info(_LI('Started Neutron OVN db sync'))
    mode = ovn_config.get_ovn_neutron_sync_mode()
    if mode not in [ovn_db_sync.SYNC_MODE_LOG, ovn_db_sync.SYNC_MODE_REPAIR]:
        LOG.error(
            _LE('Invalid sync mode : ["%s"]. Should be "log" or '
                '"repair"'), mode)
        return

    # Validate and modify core plugin and ML2 mechanism drivers for syncing.
    if cfg.CONF.core_plugin.endswith('.Ml2Plugin'):
        cfg.CONF.core_plugin = (
            'networking_ovn.cmd.neutron_ovn_db_sync_util.Ml2Plugin')
        if 'ovn' not in cfg.CONF.ml2.mechanism_drivers:
            LOG.error(_LE('No "ovn" mechanism driver found : "%s".'),
                      cfg.CONF.ml2.mechanism_drivers)
            return
        cfg.CONF.set_override('mechanism_drivers', ['ovn-sync'], 'ml2')
        conf.service_plugins = ['networking_ovn.l3.l3_ovn.OVNL3RouterPlugin']
    else:
        LOG.error(_LE('Invalid core plugin : ["%s"].'), cfg.CONF.core_plugin)
        return

    try:
        ovn_api = impl_idl_ovn.OvsdbNbOvnIdl(None)
    except RuntimeError:
        LOG.error(_LE('Invalid --ovn-ovn_nb_connection parameter provided.'))
        return

    core_plugin = manager.NeutronManager.get_plugin()
    ovn_driver = core_plugin.mechanism_manager.mech_drivers['ovn-sync'].obj
    ovn_driver._nb_ovn = ovn_api

    synchronizer = ovn_db_sync.OvnNbSynchronizer(core_plugin, ovn_api, mode,
                                                 ovn_driver)

    ctx = context.get_admin_context()

    LOG.info(_LI('Syncing the networks and ports with mode : %s'), mode)
    try:
        synchronizer.sync_address_sets(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  the Address Sets. Check the "
                "--database-connection value again"))
        return
    try:
        synchronizer.sync_networks_ports_and_dhcp_opts(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  Networks, Ports and DHCP options "
                "for unknown reason please try again"))
        return
    try:
        synchronizer.sync_acls(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  ACLs for unknown "
                "reason please try again"))
        return
    try:
        synchronizer.sync_routers_and_rports(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  Routers and Router ports "
                "please try again"))
        return
    LOG.info(_LI('Sync completed'))
Ejemplo n.º 13
0
def main():
    """Main method for syncing neutron networks and ports with ovn nb db.

    The utility syncs neutron db with ovn nb db.
    """
    conf = setup_conf()

    # if no config file is passed or no configuration options are passed
    # then load configuration from /etc/neutron/neutron.conf
    try:
        conf(project='neutron')
    except TypeError:
        LOG.error('Error parsing the configuration values. Please verify.')
        return

    logging.setup(conf, 'neutron_ovn_db_sync_util')
    LOG.info('Started Neutron OVN db sync')
    mode = ovn_config.get_ovn_neutron_sync_mode()
    if mode not in [ovn_db_sync.SYNC_MODE_LOG, ovn_db_sync.SYNC_MODE_REPAIR]:
        LOG.error('Invalid sync mode : ["%s"]. Should be "log" or "repair"',
                  mode)
        return

    # Validate and modify core plugin and ML2 mechanism drivers for syncing.
    if (cfg.CONF.core_plugin.endswith('.Ml2Plugin')
            or cfg.CONF.core_plugin == 'ml2'):
        cfg.CONF.core_plugin = (
            'networking_ovn.cmd.neutron_ovn_db_sync_util.Ml2Plugin')
        if not cfg.CONF.ml2.mechanism_drivers:
            LOG.error('please use --config-file to specify '
                      'neutron and ml2 configuration file.')
            return
        if 'ovn' not in cfg.CONF.ml2.mechanism_drivers:
            LOG.error('No "ovn" mechanism driver found : "%s".',
                      cfg.CONF.ml2.mechanism_drivers)
            return
        cfg.CONF.set_override('mechanism_drivers', ['ovn-sync'], 'ml2')
        conf.service_plugins = ['networking_ovn.l3.l3_ovn.OVNL3RouterPlugin']
    else:
        LOG.error('Invalid core plugin : ["%s"].', cfg.CONF.core_plugin)
        return

    try:
        conn = impl_idl_ovn.get_connection(impl_idl_ovn.OvsdbNbOvnIdl)
        ovn_api = impl_idl_ovn.OvsdbNbOvnIdl(conn)
    except RuntimeError:
        LOG.error('Invalid --ovn-ovn_nb_connection parameter provided.')
        return

    try:
        sb_conn = impl_idl_ovn.get_connection(impl_idl_ovn.OvsdbSbOvnIdl)
        ovn_sb_api = impl_idl_ovn.OvsdbSbOvnIdl(sb_conn)
    except RuntimeError:
        LOG.error('Invalid --ovn-ovn_sb_connection parameter provided.')
        return

    manager.init()
    core_plugin = directory.get_plugin()
    ovn_driver = core_plugin.mechanism_manager.mech_drivers['ovn-sync'].obj
    ovn_driver._nb_ovn = ovn_api
    ovn_driver._sb_ovn = ovn_sb_api

    synchronizer = ovn_db_sync.OvnNbSynchronizer(core_plugin, ovn_api,
                                                 ovn_sb_api, mode, ovn_driver)

    LOG.info('Sync for Northbound db started with mode : %s', mode)
    synchronizer.do_sync()
    LOG.info('Sync completed for Northbound db')

    sb_synchronizer = ovn_db_sync.OvnSbSynchronizer(core_plugin, ovn_sb_api,
                                                    ovn_driver)

    LOG.info('Sync for Southbound db started with mode : %s', mode)
    sb_synchronizer.do_sync()
    LOG.info('Sync completed for Southbound db')
Ejemplo n.º 14
0
def main():
    """Main method for syncing neutron networks and ports with ovn nb db.

    The utility syncs neutron db with ovn nb db.
    """
    conf = setup_conf()

    # if no config file is passed or no configuration options are passed
    # then load configuration from /etc/neutron/neutron.conf
    try:
        conf(project='neutron')
    except TypeError:
        LOG.error(
            _LE('Error parsing the configuration values. '
                'Please verify.'))
        return

    logging.setup(conf, 'neutron_ovn_db_sync_util')
    LOG.info(_LI('Started Neutron OVN db sync'))
    mode = ovn_config.get_ovn_neutron_sync_mode()
    if mode not in [ovn_nb_sync.SYNC_MODE_LOG, ovn_nb_sync.SYNC_MODE_REPAIR]:
        LOG.error(
            _LE('Invalid sync mode : ["%s"]. Should be "log" or '
                '"repair"'), mode)
        return

    # we dont want the service plugins to be loaded.
    conf.service_plugins = []
    ovn_plugin = manager.NeutronManager.get_plugin()
    try:
        ovn_plugin._ovn = impl_idl_ovn.OvsdbOvnIdl(ovn_plugin)
    except RuntimeError:
        LOG.error(_LE('Invalid --ovn-ovsdb_connection parameter provided.'))
        return

    synchronizer = ovn_nb_sync.OvnNbSynchronizer(ovn_plugin, ovn_plugin._ovn,
                                                 mode)

    ctx = context.get_admin_context()

    LOG.info(_LI('Syncing the networks and ports with mode : %s'), mode)
    try:
        synchronizer.sync_networks_and_ports(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  the networks and ports. Check the "
                "--database-connection value again"))
        return
    try:
        synchronizer.sync_acls(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  ACLs for unknown reason "
                "please try again"))
        return
    try:
        synchronizer.sync_routers_and_rports(ctx)
    except Exception:
        LOG.exception(
            _LE("Error syncing  Routers and Router ports "
                "please try again"))
        return
    LOG.info(_LI('Sync completed'))
def main():
    """Main method for syncing neutron networks and ports with ovn nb db.

    The utility syncs neutron db with ovn nb db.
    """
    conf = setup_conf()

    # if no config file is passed or no configuration options are passed
    # then load configuration from /etc/neutron/neutron.conf
    try:
        conf(project='neutron')
    except TypeError:
        LOG.error(_LE('Error parsing the configuration values. '
                      'Please verify.'))
        return

    logging.setup(conf, 'neutron_ovn_db_sync_util')
    LOG.info(_LI('Started Neutron OVN db sync'))
    mode = ovn_config.get_ovn_neutron_sync_mode()
    if mode not in [ovn_db_sync.SYNC_MODE_LOG, ovn_db_sync.SYNC_MODE_REPAIR]:
        LOG.error(_LE('Invalid sync mode : ["%s"]. Should be "log" or '
                      '"repair"'), mode)
        return

    # Validate and modify core plugin and ML2 mechanism drivers for syncing.
    if cfg.CONF.core_plugin.endswith('.Ml2Plugin'):
        cfg.CONF.core_plugin = (
            'networking_ovn.cmd.neutron_ovn_db_sync_util.Ml2Plugin')
        if 'ovn' not in cfg.CONF.ml2.mechanism_drivers:
            LOG.error(_LE('No "ovn" mechanism driver found : "%s".'),
                      cfg.CONF.ml2.mechanism_drivers)
            return
        cfg.CONF.set_override('mechanism_drivers', ['ovn-sync'], 'ml2')
        conf.service_plugins = ['networking_ovn.l3.l3_ovn.OVNL3RouterPlugin']
    else:
        LOG.error(_LE('Invalid core plugin : ["%s"].'), cfg.CONF.core_plugin)
        return

    try:
        ovn_api = impl_idl_ovn.OvsdbNbOvnIdl(None)
    except RuntimeError:
        LOG.error(_LE('Invalid --ovn-ovn_nb_connection parameter provided.'))
        return

    core_plugin = manager.NeutronManager.get_plugin()
    ovn_driver = core_plugin.mechanism_manager.mech_drivers['ovn-sync'].obj
    ovn_driver._nb_ovn = ovn_api

    synchronizer = ovn_db_sync.OvnNbSynchronizer(
        core_plugin, ovn_api, mode, ovn_driver)

    ctx = context.get_admin_context()

    LOG.info(_LI('Syncing the networks and ports with mode : %s'), mode)
    try:
        synchronizer.sync_address_sets(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  the Address Sets. Check the "
                          "--database-connection value again"))
        return
    try:
        synchronizer.sync_networks_ports_and_dhcp_opts(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  Networks, Ports and DHCP options "
                          "for unknown reason please try again"))
        return
    try:
        synchronizer.sync_acls(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  ACLs for unknown "
                          "reason please try again"))
        return
    try:
        synchronizer.sync_routers_and_rports(ctx)
    except Exception:
        LOG.exception(_LE("Error syncing  Routers and Router ports "
                          "please try again"))
        return
    LOG.info(_LI('Sync completed'))