🪐
OpenStack 源码分析之 Neutron
  • 前言
  • 整体结构
  • bin
  • doc
  • etc
    • init.d/
    • neutron/
    • api-paste.ini
    • dhcp_agent.ini
    • fwaas_driver.ini
    • l3_agent.ini
    • lbaas_agent.ini
    • metadata_agent.ini
    • metering_agent.ini
    • vpn_agent.ini
    • neutron.conf
    • policy.json
    • rootwrap.conf
    • services.conf
  • neutron
    • agent
      • common/
      • linux/
      • metadata/
      • dhcp_agent.py
      • firewall.py
      • l2population_rpc.py
      • l3_agent.py
      • l3_ha_agent.py
      • netns_cleanup_util.py
      • ovs_cleanup_util.py
      • rpc.py
      • securitygroups_rpc.py
    • api
      • rpc
      • v2
      • views
      • api_common.py
      • extensions.py
      • versions.py
    • cmd
    • common
      • config.py
      • constants.py
      • exceptions.py
      • ipv6_utils.py
      • log.py
      • rpc.py
      • test_lib.py
      • topics.py
      • utils.py
    • db
      • agents_db.py
      • agentschedulers_db.py
      • api.py
      • common_db_mixin.py
      • db_base_plugin_v2.py
      • migration
      • model_base.py
      • models_v2.py
      • securitygroups_rpc_base.py
      • sqlalchemyutils.py
      • 扩展资源和操作类
        • allowedaddresspairs_db.py
        • dvr_mac_db.py
        • external_net_db.py
        • extradhcpopt_db.py
        • extraroute_db.py
        • firewall
        • l3_agentschedulers_db.py
        • l3_attrs_db.py
        • l3_db.py
        • l3_dvr_db.py
        • l3_dvrscheduler_db.py
        • l3_gwmode_db.py
        • l3_hamode_db.py
        • l3_hascheduler_db.py
        • loadbalancer
        • metering
        • portbindings_base.py
        • portbindings_db.py
        • portsecurity_db.py
        • quota_db.py
        • routedserviceinsertion_db.py
        • routerservicetype_db.py
        • securitygroups_db.py
        • servicetype_db.py
        • vpn
    • debug
      • commands.py
      • debug_agent.py
      • shell.py
    • extensions
      • agent.py
      • allowedaddresspairs.py
      • dhcpagentscheduler.py
      • dvr.py
      • external_net.py
      • extraroute.py
      • extra_dhcp_opt.py
      • firewall.py
      • flavor.py
      • l3.py
      • l3agentscheduler.py
      • l3_ext_gw_mode.py
      • l3_ext_ha_mode.py
      • lbaas_agentscheduler.py
      • loadbalancer.py
      • metering.py
      • multiprovidernet.py
      • portbindings.py
      • portsecurity.py
      • providernet.py
      • quotasv2.py
      • routedserviceinsertion.py
      • routerservicetype.py
      • securitygroup.py
      • servicetype.py
      • vpnaas.py
      • init.py
    • hacking
      • checks.py
      • init.py
    • locale
    • notifiers
      • nova.py
      • init.py
    • openstack
      • common
        • cache
        • context.py
        • eventlet_backdoor.py
        • fileutils.py
        • fixture
        • local.py
        • lockutils.py
        • log.py
        • loopingcall.py
        • middleware
        • periodic_task.py
        • policy.py
        • processutils.py
        • service.py
        • systemd.py
        • threadgroup.py
        • uuidutils.py
        • versionutils.py
        • _i18n.py
    • plugins
      • bigswitch
        • agent
        • config.py
        • db
        • extensions
        • l3_router_plugin.py
        • plugin.py
        • routerrule_db.py
        • servermanager.py
        • tests
        • vcsversion.py
        • version.py
        • init.py
      • brocade
        • db
        • NeutronPlugin.py
        • nos
        • tests
        • vlanbm.py
        • init.py
      • cisco
        • cfg_agent
        • common
        • db
        • extensions
        • l2device_plugin_base.py
        • l3
        • models
        • n1kv
        • network_plugin.py
        • service_plugins
        • init.py
      • common
        • constants.py
        • utils.py
        • init.py
      • embrane
        • agent
        • base_plugin.py
        • common
        • l2base
        • plugins
        • init.py
      • hyperv
        • agent
        • agent_notifier_api.py
        • common
        • db.py
        • hyperv_neutron_plugin.py
        • model.py
        • rpc_callbacks.py
        • init.py
      • ibm
        • agent
        • common
        • sdnve_api.py
        • sdnve_api_fake.py
        • sdnve_neutron_plugin.py
      • linuxbridge
        • agent
        • common
        • db
        • init.py
      • metaplugin
        • common
        • meta_db_v2.py
        • meta_models_v2.py
        • meta_neutron_plugin.py
        • proxy_neutron_plugin.py
        • init.py
      • midonet
        • agent
        • common
        • midonet_lib.py
        • plugin.py
        • init.py
      • ml2
        • common
        • config.py
        • db.py
        • drivers
        • driver_api.py
        • driver_context.py
        • managers.py
        • models.py
        • plugin.py
        • rpc.py
      • mlnx
        • agent
        • agent_notify_api.py
        • common
        • db
        • mlnx_plugin.py
        • rpc_callbacks.py
        • init.py
      • nec
        • agent
        • common
        • db
        • drivers
        • extensions
        • nec_plugin.py
        • nec_router.py
        • ofc_driver_base.py
        • ofc_manager.py
        • packet_filter.py
        • router_drivers.py
        • init.py
      • nuage
        • common
        • extensions
        • nuagedb.py
        • nuage_models.py
        • plugin.py
        • syncmanager.py
        • init.py
      • ofagent
        • agent
        • common
      • oneconvergence
        • agent
        • lib
        • plugin.py
        • init.py
      • opencontrail
        • common
        • contrail_plugin.py
        • init.py
      • openvswitch
        • agent
        • common
        • ovs_models_v2.py
        • init.py
      • plumgrid
        • common
        • drivers
        • plumgrid_plugin
        • init.py
      • sriovnicagent
        • common
        • eswitch_manager.py
        • pci_lib.py
        • sriov_nic_agent.py
        • init.py
      • vmware
        • api_client
        • check_nsx_config.py
        • common
        • dbexts
        • dhcpmeta_modes.py
        • dhcp_meta
        • extensions
        • nsxlib
        • nsx_cluster.py
        • plugin.py
        • plugins
        • shell
        • vshield
        • init.py
    • scheduler
      • dhcp_agent_scheduler.py
      • l3_agent_scheduler.py
    • server
    • service.py
    • services
      • firewall
        • agents
        • drivers
        • fwaas_plugin.py
      • l3_router
        • brocade
        • l3_apic.py
        • l3_arista.py
        • l3_router_plugin.py
        • init.py
      • loadbalancer
        • agent
        • agent_scheduler.py
        • constants.py
        • drivers
        • plugin.py
      • metering
        • agents
        • drivers
        • metering_plugin.py
      • provider_configuration.py
      • service_base.py
      • vpn
        • agent.py
        • common
        • device_drivers
        • plugin.py
        • service_drivers
        • init.py
      • init.py
    • tests
      • base.py
      • common
        • agents
        • init.py
      • etc
        • rootwrap.d
      • fake_notifier.py
      • functional
        • agent
        • base.py
        • contrib
        • db
        • sanity
        • init.py
      • post_mortem_debug.py
      • tools.py
      • unit
      • var
      • init.py
    • auth.py
    • context.py
    • hooks.py
    • i18n.py
    • manager.py
    • neutron_plugin_base_v2.py
    • policy.py
    • quota.py
    • service.py
    • version.py
    • wsgi.py
  • rally-jobs
    • extra
      • README.rst
    • plugins
      • README.rst
      • init.py
    • neutron-neutron.yaml
    • README.rst
  • tools
    • check_bash.sh
    • check_i18n.py
    • check_i18n_test_case.txt
    • clean.sh
    • i18n_cfg.py
    • install_venv.py
    • install_venv_common.py
    • pretty_tox.sh
    • with_venv.sh
  • 理解代码
    • 调用逻辑
    • REST API 专题
    • RPC 专题
      • agent RPC
      • plugin RPC
      • neutron-server RPC
    • Plugin 专题
    • Extension 专题
    • Agent 专题
    • Driver 专题
Powered by GitBook
On this page
  • async_process.py
  • daemon.py
  • dhcp.py
  • external_process.py
  • interface.py
  • ip_lib.py
  • iptables_firewall.py
  • iptables_manager.py
  • ovs_lib.py
  • ovsdb_monitor.py
  • polling.py
  • utils.py

Was this helpful?

  1. neutron
  2. agent

linux/

主要包括跟 Linux 环境相关的一些函数实现,为各种 agent 调用系统命令进行包装,例如对 iptables 操作,ovs 操作等等。

async_process.py

实现了AsyncProcess类,对异步进程进行管理。

daemon.py

实现一个通用的Daemon基类。一个daemon意味着一个后台进程,可以通过对应的pid文件对其进行跟踪。

dhcp.py

实现了Dnsmasq类、DhcpBase类、DhcpLocalProcess类、DeviceManager类、DicModel类、NetModel类。

对 Linux 环境下 dhcp 相关的分配和维护实现进行管理。 通过调用 dnsmasq 工具来管理 dhcp 的分配。

external_process.py

定义了ProcessManager类,对neutron孵化出的进程进行管理(可以通过跟踪pid文件进行激活和禁用等)。

interface.py

提供对网桥上的接口进行管理的一系列驱动。

定义了常见的配置信息,包括网桥名称,用户和密码等。

定义了几个不同类型网桥的接口驱动类,包括LinuxInterfaceDriver元类和由它派生出来的MetaInterfaceDriver、BridgeInterfaceDriver、IVSInterfaceDriver、MidonetInterfaceDriver、NullDriver和OVSInterfaceDriver等。

其中LinuxInterfaceDriver元类定义了plug()和unplug()两个抽象方法,需要继承类自己来实现。init_l3()方法则提供对接口进行IP地址的配置。

ip_lib.py

对ip相关的命令进行封装,包括一些操作类。例如IpAddrCommand、IpLinkCommand、IpNetnsCommand、IpNeighCommand、IpRouteCommand、IpRule等。基本上需要对linux上ip相关的命令进行操作都可以通过这个库提供的接口进行。

iptables_firewall.py

利用iptables的规则实现的防火墙驱动,主要包括两个防火墙驱动类。 IptablesFirewallDriver,继承自firewall.FirewallDriver,默认通过iptables规则启用了security group功能,包括添加一条sg-chain链,为每个端口添加两条链(physdev-out和physdev-in)。

OVSHybridIptablesFirewallDriver,继承自IptablesFirewallDriver,基本代码没动,修改了两个获取名字函数的实现:_port_chain_name()和_get_deice_name()。

iptables_manager.py

对iptables规则、表资源进行封装,提供操作接口。

定义了IptablesManager类、IptablesRule类、IptablesTable类。

其中IptablesManager对iptables工具进行包装。首先,创建neutron-filter-top链,加载到FORWARD和OUTPUT两条链开头。默认的INPUT、OUTPUT、FORWARD链会被包装起来,即通过原始的链跳转到一个包装后的链。此外,neutron-filter-top链中有一条规则可以跳转到一条包装后的local链。

ovs_lib.py

提供对OVS网桥的操作支持,包括一个VifPort,BaseOVS类和继承自它的OVSBridge类。提供对网桥、端口等资源的添加、删除,执行ovs-vsctl命令等。

ovsdb_monitor.py

提供对ovsdb的监视器。包括一个OvsdbMonitor类(继承自neutron.agent.linux.async_process.AsyncProcess)和SimpleInterfaceMonitor类(继承自前者)。

polling.py

监视ovsdb来决定何时进行polling。包括一个BasePollingManager和继承自它的InterfacePollingMinimizer类等。

utils.py

一些辅助函数,包括create_process通过创建一个进程来执行命令、get_interface_mac、replace_file等。

Previouscommon/Nextmetadata/

Last updated 5 years ago

Was this helpful?