├── .gitignore
├── README.md
├── SUMMARY.md
├── _images
├── code_logic.dot
├── code_logic.png
├── interface.dot
├── interface.png
├── neutron.api.rpc.agentnotifiers.dot
├── neutron.api.rpc.agentnotifiers.png
├── neutron.db.firewall.firewall_db.dot
├── neutron.db.firewall.firewall_db.png
├── neutron.db.loadbalancer.loadbalancer_db.dot
├── neutron.db.loadbalancer.loadbalancer_db.png
├── neutron.db.model_base.dot
├── neutron.db.model_base.png
├── neutron.plugin.openvswitch.agent.ovs_neutron_agent.OVSNeutronAgent.dot
├── neutron.plugin.openvswitch.agent.ovs_neutron_agent.OVSNeutronAgent.png
├── neutron.plugin.openvswitch.ovs_neutron_plugin.dot
├── neutron.plugin.openvswitch.ovs_neutron_plugin.png
├── neutron.png
├── neutron.services.firewall.dot
├── neutron.services.firewall.png
├── openvswitch_plugin_rpc.dot
├── openvswitch_plugin_rpc.png
├── restapi.dot
└── restapi.png
├── bin
└── README.md
├── doc
└── README.md
├── etc
├── README.md
├── api-pasteini.md
├── dhcp_agentini.md
├── fwaas_driverini.md
├── initd.md
├── l3_agentini.md
├── lbaas_agentini.md
├── metadata_agentini.md
├── metering_agentini.md
├── neutron.md
├── neutronconf.md
├── policyjson.md
├── rootwrapconf.md
├── servicesconf.md
└── vpn_agentini.md
├── neutron
├── README.md
├── agent
│ ├── README.md
│ ├── common.md
│ ├── dhcp_agentpy.md
│ ├── firewallpy.md
│ ├── l2population_rpcpy.md
│ ├── l3_agentpy.md
│ ├── l3_ha_agentpy.md
│ ├── linux.md
│ ├── metadata.md
│ ├── netns_cleanup_utilpy.md
│ ├── ovs_cleanup_utilpy.md
│ ├── rpcpy.md
│ └── securitygroups_rpcpy.md
├── api
│ ├── README.md
│ ├── api_commonpy.md
│ ├── extensionspy.md
│ ├── rpc.md
│ ├── v2.md
│ ├── versionspy.md
│ └── views.md
├── auth.py.md
├── cmd
│ └── README.md
├── common
│ ├── README.md
│ ├── configpy.md
│ ├── constantspy.md
│ ├── exceptionspy.md
│ ├── ipv6_utilspy.md
│ ├── logpy.md
│ ├── rpcpy.md
│ ├── test_libpy.md
│ ├── topicspy.md
│ └── utilspy.md
├── context.py.md
├── db
│ ├── README.md
│ ├── agents_dbpy.md
│ ├── agentschedulers_dbpy.md
│ ├── allowedaddresspairs_dbpy.md
│ ├── apipy.md
│ ├── common_db_mixinpy.md
│ ├── db_base_plugin_v2py.md
│ ├── dvr_mac_dbpy.md
│ ├── extensions.md
│ ├── external_net_dbpy.md
│ ├── extradhcpopt_dbpy.md
│ ├── extraroute_dbpy.md
│ ├── firewall
│ │ └── README.md
│ ├── l3_agentschedulers_dbpy.md
│ ├── l3_attrs_dbpy.md
│ ├── l3_dbpy.md
│ ├── l3_dvr_dbpy.md
│ ├── l3_gwmode_dbpy.md
│ ├── l3_hamode_dbpy.md
│ ├── l3_hascheduler_dbpy.md
│ ├── loadbalancer
│ │ └── README.md
│ ├── metering
│ │ └── README.md
│ ├── migration
│ │ └── README.md
│ ├── model_basepy.md
│ ├── models_v2py.md
│ ├── portbindings_basepy.md
│ ├── portbindings_dbpy.md
│ ├── portsecurity_dbpy.md
│ ├── quota_dbpy.md
│ ├── routedserviceinsertion_dbpy.md
│ ├── routerservicetype_dbpy.md
│ ├── securitygroups_dbpy.md
│ ├── securitygroups_rpc_basepy.md
│ ├── servicetype_dbpy.md
│ ├── sqlalchemyutilspy.md
│ └── vpn
│ │ └── README.md
├── debug
│ ├── README.md
│ ├── commandspy.md
│ ├── debug_agentpy.md
│ └── shellpy.md
├── extensions
│ ├── README.md
│ ├── agentpy.md
│ ├── allowedaddresspairspy.md
│ ├── dhcpagentschedulerpy.md
│ ├── dvrpy.md
│ ├── external_netpy.md
│ ├── extra_dhcp_optpy.md
│ ├── extraroutepy.md
│ ├── firewallpy.md
│ ├── flavorpy.md
│ ├── l3_ext_gw_modepy.md
│ ├── l3_ext_ha_modepy.md
│ ├── l3agentschedulerpy.md
│ ├── l3py.md
│ ├── lbaas_agentschedulerpy.md
│ ├── loadbalancerpy.md
│ ├── meteringpy.md
│ ├── multiprovidernetpy.md
│ ├── portbindingspy.md
│ ├── portsecuritypy.md
│ ├── providernetpy.md
│ ├── quotasv2py.md
│ ├── routedserviceinsertionpy.md
│ ├── routerservicetypepy.md
│ ├── securitygrouppy.md
│ ├── servicetypepy.md
│ └── vpnaaspy.md
├── hacking
│ ├── README.md
│ └── checkspy.md
├── hooks.py.md
├── i18n.py.md
├── locale
│ └── README.md
├── manager.py.md
├── neutron_plugin_base_v2.py.md
├── notifiers
│ ├── README.md
│ └── novapy.md
├── openstack
│ ├── README.md
│ └── common
│ │ ├── README.md
│ │ ├── _i18npy.md
│ │ ├── cache.md
│ │ ├── cache
│ │ └── README.md
│ │ ├── contextpy.md
│ │ ├── eventlet_backdoorpy.md
│ │ ├── fileutilspy.md
│ │ ├── fixture.md
│ │ ├── fixture
│ │ └── README.md
│ │ ├── localpy.md
│ │ ├── lockutilspy.md
│ │ ├── logpy.md
│ │ ├── loopingcallpy.md
│ │ ├── middleware.md
│ │ ├── periodic_taskpy.md
│ │ ├── policypy.md
│ │ ├── processutilspy.md
│ │ ├── servicepy.md
│ │ ├── systemdpy.md
│ │ ├── threadgrouppy.md
│ │ ├── uuidutilspy.md
│ │ └── versionutilspy.md
├── plugins
│ ├── README.md
│ ├── bigswitch
│ │ └── README.md
│ ├── hyperv
│ │ ├── agent.md
│ │ └── common.md
│ ├── ibm
│ │ ├── README.md
│ │ ├── agent.md
│ │ ├── common.md
│ │ ├── sdnve_api_fakepy.md
│ │ ├── sdnve_apipy.md
│ │ └── sdnve_neutron_pluginpy.md
│ ├── ml2
│ │ ├── README.md
│ │ ├── common.md
│ │ ├── configpy.md
│ │ ├── dbpy.md
│ │ ├── driver_apipy.md
│ │ ├── driver_contextpy.md
│ │ ├── drivers.md
│ │ ├── managerspy.md
│ │ ├── modelspy.md
│ │ ├── pluginpy.md
│ │ └── rpcpy.md
│ ├── ofagent
│ │ ├── README.md
│ │ ├── agent.md
│ │ └── common.md
│ └── openvswitch
│ │ ├── README.md
│ │ ├── agent.md
│ │ ├── common.md
│ │ └── ovs_models_v2py.md
├── policy.py.md
├── quota.py.md
├── scheduler
│ ├── README.md
│ ├── dhcp_agent_schedulerpy.md
│ └── l3_agent_schedulerpy.md
├── server
│ └── README.md
├── service.py.md
├── services
│ ├── README.md
│ ├── firewall
│ │ ├── README.md
│ │ ├── agents.md
│ │ ├── drivers.md
│ │ └── fwaas_pluginpy.md
│ ├── l3_router
│ │ ├── README.md
│ │ ├── l3_apicpy.md
│ │ └── l3_router_pluginpy.md
│ ├── loadbalancer
│ │ ├── README.md
│ │ ├── agent.md
│ │ ├── agent_schedulerpy.md
│ │ ├── constantspy.md
│ │ ├── drivers.md
│ │ └── pluginpy.md
│ ├── metering
│ │ ├── README.md
│ │ ├── agents.md
│ │ ├── drivers.md
│ │ └── metering_pluginpy.md
│ ├── provider_configurationpy.md
│ ├── service_basepy.md
│ └── vpn
│ │ ├── README.md
│ │ └── agentpy.md
├── tests
│ └── README.md
├── version.py.md
└── wsgi.py.md
├── overview
└── README.md
├── rally-jobs
├── README.md
├── README.rst.md
├── extra
│ ├── README.md
│ └── README.rst.md
├── neutron-neutron.yaml.md
└── plugins
│ ├── README.md
│ ├── README.rst.md
│ └── __init__.py.md
├── tools
├── README.md
├── check_bash.sh.md
├── check_i18n.py.md
├── check_i18n_test_case.txt.md
├── clean.sh.md
├── i18n_cfg.py.md
├── install_venv.py.md
├── install_venv_common.py.md
├── pretty_tox.sh.md
└── with_venv.sh.md
└── understanding
├── README.md
├── agent.md
├── call_logic.md
├── extension.md
├── plugin.md
├── rest_api.md
└── rpc
├── README.md
├── agent_rpc.md
├── neutron_server_rpc.md
└── plugin_rpc.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Node rules:
2 | ## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
3 | .grunt
4 |
5 | ## Dependency directory
6 | ## Commenting this out is preferred by some people, see
7 | ## https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
8 | node_modules
9 |
10 | # Book build output
11 | _book
12 |
13 | # eBook build output
14 | *.epub
15 | *.mobi
16 | *.pdf
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | OpenStack Neutron 源码分析
2 | ============
3 | [Neutron](https://wiki.openstack.org/wiki/Neutron) 是 OpenStack 项目中负责提供网络服务的组件,它基于软件定义网络的思想,实现了网络虚拟化下的资源管理。
4 |
5 | 本书将剖析 Neutron 组件的代码。
6 |
7 | 最新版本在线阅读:[GitBook](https://www.gitbook.io/book/yeasy/openstack_code_Neutron)。
8 |
9 | 本书源码在 Github 上维护,欢迎参与: [https://github.com/yeasy/openstack_code_Neutron](https://github.com/yeasy/openstack_code_Neutron)。
10 |
11 | 感谢所有的 [贡献者](https://github.com/yeasy/openstack_code_Neutron/graphs/contributors)。
12 |
13 | ## 更新历史:
14 | * V0.8: 2015-02-03
15 | * 按照最新版本进行更新
16 | * 添加更多服务的实现分析。
17 | * V0.71: 2014-08-07
18 | * 添加更多细节分析,添加对ML2的分析。
19 | * V0.7: 2014-07-18
20 | * 完成对cmd、common和db部分的分析;
21 | * 整体代码框架分析完毕。
22 | * V0.6: 2014-07-11
23 | * 完成对api部分的分析;
24 | * 增加目录;
25 | * 增加新的一章,集中从专题角度剖析代码。
26 | * V0.5: 2014-07-07
27 | * 完成对agent部分的补充修订。
28 | * V0.4: 2014-05-19
29 | * 完成对OpenvSwitch plugin的分析。
30 | * V0.3: 2014-05-12
31 | * 完成对IBM 的SDN-VE plugin的分析。
32 | *V0.2: 2014-05-06
33 | * 完成配置文件(etc/)相关分析。
34 | * V0.1: 2014-04-14
35 | * 完成代码基本结构。
36 |
37 |
38 | ## 参加步骤
39 | * 在 GitHub 上 `fork` 到自己的仓库,如 `user/openstack_code_Neutron`,然后 `clone` 到本地,并设置用户信息。
40 | ```
41 | $ git clone git@github.com:user/openstack_code_Neutron.git
42 | $ cd openstack_code_Neutron
43 | $ git config user.name "User"
44 | $ git config user.email user@email.com
45 | ```
46 |
47 | * 修改代码后提交,并推送到自己的仓库。
48 | ```
49 | $ #do some change on the content
50 | $ git commit -am "Fix issue #1: change helo to hello"
51 | $ git push
52 | ```
53 |
54 | * 在 GitHub 网站上提交 pull request。
55 | * 定期使用项目仓库内容更新自己仓库内容。
56 | ```
57 | $ git remote add upstream https://github.com/yeasy/openstack_code_Neutron
58 | $ git fetch upstream
59 | $ git checkout master
60 | $ git rebase upstream/master
61 | $ git push -f origin master
62 | ```
63 |
--------------------------------------------------------------------------------
/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 | * [前言](README.md)
4 | * [整体结构](overview/README.md)
5 | * [bin](bin/README.md)
6 | * [doc](doc/README.md)
7 | * [etc](etc/README.md)
8 | * [init.d/](etc/initd.md)
9 | * [neutron/](etc/neutron.md)
10 | * [api-paste.ini](etc/api-pasteini.md)
11 | * [dhcp_agent.ini](etc/dhcp_agentini.md)
12 | * [fwaas_driver.ini](etc/fwaas_driverini.md)
13 | * [l3_agent.ini](etc/l3_agentini.md)
14 | * [lbaas_agent.ini](etc/lbaas_agentini.md)
15 | * [metadata_agent.ini](etc/metadata_agentini.md)
16 | * [metering_agent.ini](etc/metering_agentini.md)
17 | * [vpn_agent.ini](etc/vpn_agentini.md)
18 | * [neutron.conf](etc/neutronconf.md)
19 | * [policy.json](etc/policyjson.md)
20 | * [rootwrap.conf](etc/rootwrapconf.md)
21 | * [services.conf](etc/servicesconf.md)
22 | * [neutron](neutron/README.md)
23 | * [agent](neutron/agent/README.md)
24 | * [common/](neutron/agent/common.md)
25 | * [linux/](neutron/agent/linux.md)
26 | * [metadata/](neutron/agent/metadata.md)
27 | * [dhcp_agent.py](neutron/agent/dhcp_agentpy.md)
28 | * [firewall.py](neutron/agent/firewallpy.md)
29 | * [l2population_rpc.py](neutron/agent/l2population_rpcpy.md)
30 | * [l3_agent.py](neutron/agent/l3_agentpy.md)
31 | * [l3_ha_agent.py](neutron/agent/l3_ha_agentpy.md)
32 | * [netns_cleanup_util.py](neutron/agent/netns_cleanup_utilpy.md)
33 | * [ovs_cleanup_util.py](neutron/agent/ovs_cleanup_utilpy.md)
34 | * [rpc.py](neutron/agent/rpcpy.md)
35 | * [securitygroups_rpc.py](neutron/agent/securitygroups_rpcpy.md)
36 | * [api](neutron/api/README.md)
37 | * [rpc](neutron/api/rpc.md)
38 | * [v2](neutron/api/v2.md)
39 | * [views](neutron/api/views.md)
40 | * [api_common.py](neutron/api/api_commonpy.md)
41 | * [extensions.py](neutron/api/extensionspy.md)
42 | * [versions.py](neutron/api/versionspy.md)
43 | * [cmd](neutron/cmd/README.md)
44 | * [common](neutron/common/README.md)
45 | * [config.py](neutron/common/configpy.md)
46 | * [constants.py](neutron/common/constantspy.md)
47 | * [exceptions.py](neutron/common/exceptionspy.md)
48 | * [ipv6_utils.py](neutron/common/ipv6_utilspy.md)
49 | * [log.py](neutron/common/logpy.md)
50 | * [rpc.py](neutron/common/rpcpy.md)
51 | * [test_lib.py](neutron/common/test_libpy.md)
52 | * [topics.py](neutron/common/topicspy.md)
53 | * [utils.py](neutron/common/utilspy.md)
54 | * [db](neutron/db/README.md)
55 | * [agents_db.py](neutron/db/agents_dbpy.md)
56 | * [agentschedulers_db.py](neutron/db/agentschedulers_dbpy.md)
57 | * [api.py](neutron/db/apipy.md)
58 | * [common_db_mixin.py](neutron/db/common_db_mixinpy.md)
59 | * [db_base_plugin_v2.py](neutron/db/db_base_plugin_v2py.md)
60 | * [migration](neutron/db/migration/README.md)
61 | * [model_base.py](neutron/db/model_basepy.md)
62 | * [models_v2.py](neutron/db/models_v2py.md)
63 | * [securitygroups_rpc_base.py](neutron/db/securitygroups_rpc_basepy.md)
64 | * [sqlalchemyutils.py](neutron/db/sqlalchemyutilspy.md)
65 | * [扩展资源和操作类](neutron/db/extensions.md)
66 | * [allowedaddresspairs_db.py](neutron/db/allowedaddresspairs_dbpy.md)
67 | * [dvr_mac_db.py](neutron/db/dvr_mac_dbpy.md)
68 | * [external_net_db.py](neutron/db/external_net_dbpy.md)
69 | * [extradhcpopt_db.py](neutron/db/extradhcpopt_dbpy.md)
70 | * [extraroute_db.py](neutron/db/extraroute_dbpy.md)
71 | * [firewall](neutron/db/firewall/README.md)
72 | * [l3_agentschedulers_db.py](neutron/db/l3_agentschedulers_dbpy.md)
73 | * [l3_attrs_db.py](neutron/db/l3_attrs_dbpy.md)
74 | * [l3_db.py](neutron/db/l3_dbpy.md)
75 | * [l3_dvr_db.py](neutron/db/l3_dvr_dbpy.md)
76 | * [l3_dvrscheduler_db.py](neutron/db/l3_dvrscheduler_dbpy.md)
77 | * [l3_gwmode_db.py](neutron/db/l3_gwmode_dbpy.md)
78 | * [l3_hamode_db.py](neutron/db/l3_hamode_dbpy.md)
79 | * [l3_hascheduler_db.py](neutron/db/l3_hascheduler_dbpy.md)
80 | * [loadbalancer](neutron/db/loadbalancer/README.md)
81 | * [metering](neutron/db/metering/README.md)
82 | * [portbindings_base.py](neutron/db/portbindings_basepy.md)
83 | * [portbindings_db.py](neutron/db/portbindings_dbpy.md)
84 | * [portsecurity_db.py](neutron/db/portsecurity_dbpy.md)
85 | * [quota_db.py](neutron/db/quota_dbpy.md)
86 | * [routedserviceinsertion_db.py](neutron/db/routedserviceinsertion_dbpy.md)
87 | * [routerservicetype_db.py](neutron/db/routerservicetype_dbpy.md)
88 | * [securitygroups_db.py](neutron/db/securitygroups_dbpy.md)
89 | * [servicetype_db.py](neutron/db/servicetype_dbpy.md)
90 | * [vpn](neutron/db/vpn/README.md)
91 | * [debug](neutron/debug/README.md)
92 | * [commands.py](neutron/debug/commandspy.md)
93 | * [debug_agent.py](neutron/debug/debug_agentpy.md)
94 | * [shell.py](neutron/debug/shellpy.md)
95 | * [extensions](neutron/extensions/README.md)
96 | * [agent.py](neutron/extensions/agentpy.md)
97 | * [allowedaddresspairs.py](neutron/extensions/allowedaddresspairspy.md)
98 | * [dhcpagentscheduler.py](neutron/extensions/dhcpagentschedulerpy.md)
99 | * [dvr.py](neutron/extensions/dvrpy.md)
100 | * [external_net.py](neutron/extensions/external_netpy.md)
101 | * [extraroute.py](neutron/extensions/extraroutepy.md)
102 | * [extra_dhcp_opt.py](neutron/extensions/extra_dhcp_optpy.md)
103 | * [firewall.py](neutron/extensions/firewallpy.md)
104 | * [flavor.py](neutron/extensions/flavorpy.md)
105 | * [l3.py](neutron/extensions/l3py.md)
106 | * [l3agentscheduler.py](neutron/extensions/l3agentschedulerpy.md)
107 | * [l3_ext_gw_mode.py](neutron/extensions/l3_ext_gw_modepy.md)
108 | * [l3_ext_ha_mode.py](neutron/extensions/l3_ext_ha_modepy.md)
109 | * [lbaas_agentscheduler.py](neutron/extensions/lbaas_agentschedulerpy.md)
110 | * [loadbalancer.py](neutron/extensions/loadbalancerpy.md)
111 | * [metering.py](neutron/extensions/meteringpy.md)
112 | * [multiprovidernet.py](neutron/extensions/multiprovidernetpy.md)
113 | * [portbindings.py](neutron/extensions/portbindingspy.md)
114 | * [portsecurity.py](neutron/extensions/portsecuritypy.md)
115 | * [providernet.py](neutron/extensions/providernetpy.md)
116 | * [quotasv2.py](neutron/extensions/quotasv2py.md)
117 | * [routedserviceinsertion.py](neutron/extensions/routedserviceinsertionpy.md)
118 | * [routerservicetype.py](neutron/extensions/routerservicetypepy.md)
119 | * [securitygroup.py](neutron/extensions/securitygrouppy.md)
120 | * [servicetype.py](neutron/extensions/servicetypepy.md)
121 | * [vpnaas.py](neutron/extensions/vpnaaspy.md)
122 | * [__init__.py](neutron/extensions/__init__py.md)
123 | * [hacking](neutron/hacking/README.md)
124 | * [checks.py](neutron/hacking/checkspy.md)
125 | * [__init__.py](neutron/hacking/__init__py.md)
126 | * [locale](neutron/locale/README.md)
127 | * [notifiers](neutron/notifiers/README.md)
128 | * [nova.py](neutron/notifiers/novapy.md)
129 | * [__init__.py](neutron/notifiers/__init__py.md)
130 | * [openstack](neutron/openstack/README.md)
131 | * [common](neutron/openstack/common/README.md)
132 | * [cache](neutron/openstack/common/cache.md)
133 | * [context.py](neutron/openstack/common/contextpy.md)
134 | * [eventlet_backdoor.py](neutron/openstack/common/eventlet_backdoorpy.md)
135 | * [fileutils.py](neutron/openstack/common/fileutilspy.md)
136 | * [fixture](neutron/openstack/common/fixture.md)
137 | * [local.py](neutron/openstack/common/localpy.md)
138 | * [lockutils.py](neutron/openstack/common/lockutilspy.md)
139 | * [log.py](neutron/openstack/common/logpy.md)
140 | * [loopingcall.py](neutron/openstack/common/loopingcallpy.md)
141 | * [middleware](neutron/openstack/common/middleware.md)
142 | * [periodic_task.py](neutron/openstack/common/periodic_taskpy.md)
143 | * [policy.py](neutron/openstack/common/policypy.md)
144 | * [processutils.py](neutron/openstack/common/processutilspy.md)
145 | * [service.py](neutron/openstack/common/servicepy.md)
146 | * [systemd.py](neutron/openstack/common/systemdpy.md)
147 | * [threadgroup.py](neutron/openstack/common/threadgrouppy.md)
148 | * [uuidutils.py](neutron/openstack/common/uuidutilspy.md)
149 | * [versionutils.py](neutron/openstack/common/versionutilspy.md)
150 | * [_i18n.py](neutron/openstack/common/_i18npy.md)
151 | * [plugins](neutron/plugins/README.md)
152 | * [bigswitch](neutron/plugins/bigswitch/README.md)
153 | * [agent](neutron/plugins/bigswitch/agent.md)
154 | * [config.py](neutron/plugins/bigswitch/configpy.md)
155 | * [db](neutron/plugins/bigswitch/db.md)
156 | * [extensions](neutron/plugins/bigswitch/extensions.md)
157 | * [l3_router_plugin.py](neutron/plugins/bigswitch/l3_router_pluginpy.md)
158 | * [plugin.py](neutron/plugins/bigswitch/pluginpy.md)
159 | * [routerrule_db.py](neutron/plugins/bigswitch/routerrule_dbpy.md)
160 | * [servermanager.py](neutron/plugins/bigswitch/servermanagerpy.md)
161 | * [tests](neutron/plugins/bigswitch/tests.md)
162 | * [vcsversion.py](neutron/plugins/bigswitch/vcsversionpy.md)
163 | * [version.py](neutron/plugins/bigswitch/versionpy.md)
164 | * [__init__.py](neutron/plugins/bigswitch/__init__py.md)
165 | * [brocade](neutron/plugins/brocade/README.md)
166 | * [db](neutron/plugins/brocade/db.md)
167 | * [NeutronPlugin.py](neutron/plugins/brocade/NeutronPluginpy.md)
168 | * [nos](neutron/plugins/brocade/nos.md)
169 | * [tests](neutron/plugins/brocade/tests.md)
170 | * [vlanbm.py](neutron/plugins/brocade/vlanbmpy.md)
171 | * [__init__.py](neutron/plugins/brocade/__init__py.md)
172 | * [cisco](neutron/plugins/cisco/README.md)
173 | * [cfg_agent](neutron/plugins/cisco/cfg_agent.md)
174 | * [common](neutron/plugins/cisco/common.md)
175 | * [db](neutron/plugins/cisco/db.md)
176 | * [extensions](neutron/plugins/cisco/extensions.md)
177 | * [l2device_plugin_base.py](neutron/plugins/cisco/l2device_plugin_basepy.md)
178 | * [l3](neutron/plugins/cisco/l3.md)
179 | * [models](neutron/plugins/cisco/models.md)
180 | * [n1kv](neutron/plugins/cisco/n1kv.md)
181 | * [network_plugin.py](neutron/plugins/cisco/network_pluginpy.md)
182 | * [service_plugins](neutron/plugins/cisco/service_plugins.md)
183 | * [__init__.py](neutron/plugins/cisco/__init__py.md)
184 | * [common](neutron/plugins/common/README.md)
185 | * [constants.py](neutron/plugins/common/constantspy.md)
186 | * [utils.py](neutron/plugins/common/utilspy.md)
187 | * [__init__.py](neutron/plugins/common/__init__py.md)
188 | * [embrane](neutron/plugins/embrane/README.md)
189 | * [agent](neutron/plugins/embrane/agent.md)
190 | * [base_plugin.py](neutron/plugins/embrane/base_pluginpy.md)
191 | * [common](neutron/plugins/embrane/common.md)
192 | * [l2base](neutron/plugins/embrane/l2base.md)
193 | * [plugins](neutron/plugins/embrane/plugins.md)
194 | * [__init__.py](neutron/plugins/embrane/__init__py.md)
195 | * [hyperv](neutron/plugins/hyperv/README.md)
196 | * [agent](neutron/plugins/hyperv/agent.md)
197 | * [agent_notifier_api.py](neutron/plugins/hyperv/agent_notifier_apipy.md)
198 | * [common](neutron/plugins/hyperv/common.md)
199 | * [db.py](neutron/plugins/hyperv/dbpy.md)
200 | * [hyperv_neutron_plugin.py](neutron/plugins/hyperv/hyperv_neutron_pluginpy.md)
201 | * [model.py](neutron/plugins/hyperv/modelpy.md)
202 | * [rpc_callbacks.py](neutron/plugins/hyperv/rpc_callbackspy.md)
203 | * [__init__.py](neutron/plugins/hyperv/__init__py.md)
204 | * [ibm](neutron/plugins/ibm/README.md)
205 | * [agent](neutron/plugins/ibm/agent.md)
206 | * [common](neutron/plugins/ibm/common.md)
207 | * [sdnve_api.py](neutron/plugins/ibm/sdnve_apipy.md)
208 | * [sdnve_api_fake.py](neutron/plugins/ibm/sdnve_api_fakepy.md)
209 | * [sdnve_neutron_plugin.py](neutron/plugins/ibm/sdnve_neutron_pluginpy.md)
210 | * [linuxbridge](neutron/plugins/linuxbridge/README.md)
211 | * [agent](neutron/plugins/linuxbridge/agent.md)
212 | * [common](neutron/plugins/linuxbridge/common.md)
213 | * [db](neutron/plugins/linuxbridge/db.md)
214 | * [__init__.py](neutron/plugins/linuxbridge/__init__py.md)
215 | * [metaplugin](neutron/plugins/metaplugin/README.md)
216 | * [common](neutron/plugins/metaplugin/common.md)
217 | * [meta_db_v2.py](neutron/plugins/metaplugin/meta_db_v2py.md)
218 | * [meta_models_v2.py](neutron/plugins/metaplugin/meta_models_v2py.md)
219 | * [meta_neutron_plugin.py](neutron/plugins/metaplugin/meta_neutron_pluginpy.md)
220 | * [proxy_neutron_plugin.py](neutron/plugins/metaplugin/proxy_neutron_pluginpy.md)
221 | * [__init__.py](neutron/plugins/metaplugin/__init__py.md)
222 | * [midonet](neutron/plugins/midonet/README.md)
223 | * [agent](neutron/plugins/midonet/agent.md)
224 | * [common](neutron/plugins/midonet/common.md)
225 | * [midonet_lib.py](neutron/plugins/midonet/midonet_libpy.md)
226 | * [plugin.py](neutron/plugins/midonet/pluginpy.md)
227 | * [__init__.py](neutron/plugins/midonet/__init__py.md)
228 | * [ml2](neutron/plugins/ml2/README.md)
229 | * [common](neutron/plugins/ml2/common.md)
230 | * [config.py](neutron/plugins/ml2/configpy.md)
231 | * [db.py](neutron/plugins/ml2/dbpy.md)
232 | * [drivers](neutron/plugins/ml2/drivers.md)
233 | * [driver_api.py](neutron/plugins/ml2/driver_apipy.md)
234 | * [driver_context.py](neutron/plugins/ml2/driver_contextpy.md)
235 | * [managers.py](neutron/plugins/ml2/managerspy.md)
236 | * [models.py](neutron/plugins/ml2/modelspy.md)
237 | * [plugin.py](neutron/plugins/ml2/pluginpy.md)
238 | * [rpc.py](neutron/plugins/ml2/rpcpy.md)
239 | * [mlnx](neutron/plugins/mlnx/README.md)
240 | * [agent](neutron/plugins/mlnx/agent.md)
241 | * [agent_notify_api.py](neutron/plugins/mlnx/agent_notify_apipy.md)
242 | * [common](neutron/plugins/mlnx/common.md)
243 | * [db](neutron/plugins/mlnx/db.md)
244 | * [mlnx_plugin.py](neutron/plugins/mlnx/mlnx_pluginpy.md)
245 | * [rpc_callbacks.py](neutron/plugins/mlnx/rpc_callbackspy.md)
246 | * [__init__.py](neutron/plugins/mlnx/__init__py.md)
247 | * [nec](neutron/plugins/nec/README.md)
248 | * [agent](neutron/plugins/nec/agent.md)
249 | * [common](neutron/plugins/nec/common.md)
250 | * [db](neutron/plugins/nec/db.md)
251 | * [drivers](neutron/plugins/nec/drivers.md)
252 | * [extensions](neutron/plugins/nec/extensions.md)
253 | * [nec_plugin.py](neutron/plugins/nec/nec_pluginpy.md)
254 | * [nec_router.py](neutron/plugins/nec/nec_routerpy.md)
255 | * [ofc_driver_base.py](neutron/plugins/nec/ofc_driver_basepy.md)
256 | * [ofc_manager.py](neutron/plugins/nec/ofc_managerpy.md)
257 | * [packet_filter.py](neutron/plugins/nec/packet_filterpy.md)
258 | * [router_drivers.py](neutron/plugins/nec/router_driverspy.md)
259 | * [__init__.py](neutron/plugins/nec/__init__py.md)
260 | * [nuage](neutron/plugins/nuage/README.md)
261 | * [common](neutron/plugins/nuage/common.md)
262 | * [extensions](neutron/plugins/nuage/extensions.md)
263 | * [nuagedb.py](neutron/plugins/nuage/nuagedbpy.md)
264 | * [nuage_models.py](neutron/plugins/nuage/nuage_modelspy.md)
265 | * [plugin.py](neutron/plugins/nuage/pluginpy.md)
266 | * [syncmanager.py](neutron/plugins/nuage/syncmanagerpy.md)
267 | * [__init__.py](neutron/plugins/nuage/__init__py.md)
268 | * [ofagent](neutron/plugins/ofagent/README.md)
269 | * [agent](neutron/plugins/ofagent/agent.md)
270 | * [common](neutron/plugins/ofagent/common.md)
271 | * [oneconvergence](neutron/plugins/oneconvergence/README.md)
272 | * [agent](neutron/plugins/oneconvergence/agent.md)
273 | * [lib](neutron/plugins/oneconvergence/lib.md)
274 | * [plugin.py](neutron/plugins/oneconvergence/pluginpy.md)
275 | * [__init__.py](neutron/plugins/oneconvergence/__init__py.md)
276 | * [opencontrail](neutron/plugins/opencontrail/README.md)
277 | * [common](neutron/plugins/opencontrail/common.md)
278 | * [contrail_plugin.py](neutron/plugins/opencontrail/contrail_pluginpy.md)
279 | * [__init__.py](neutron/plugins/opencontrail/__init__py.md)
280 | * [openvswitch](neutron/plugins/openvswitch/README.md)
281 | * [agent](neutron/plugins/openvswitch/agent.md)
282 | * [common](neutron/plugins/openvswitch/common.md)
283 | * [ovs_models_v2.py](neutron/plugins/openvswitch/ovs_models_v2py.md)
284 | * [__init__.py](neutron/plugins/openvswitch/__init__py.md)
285 | * [plumgrid](neutron/plugins/plumgrid/README.md)
286 | * [common](neutron/plugins/plumgrid/common.md)
287 | * [drivers](neutron/plugins/plumgrid/drivers.md)
288 | * [plumgrid_plugin](neutron/plugins/plumgrid/plumgrid_plugin.md)
289 | * [__init__.py](neutron/plugins/plumgrid/__init__py.md)
290 | * [sriovnicagent](neutron/plugins/sriovnicagent/README.md)
291 | * [common](neutron/plugins/sriovnicagent/common.md)
292 | * [eswitch_manager.py](neutron/plugins/sriovnicagent/eswitch_managerpy.md)
293 | * [pci_lib.py](neutron/plugins/sriovnicagent/pci_libpy.md)
294 | * [sriov_nic_agent.py](neutron/plugins/sriovnicagent/sriov_nic_agentpy.md)
295 | * [__init__.py](neutron/plugins/sriovnicagent/__init__py.md)
296 | * [vmware](neutron/plugins/vmware/README.md)
297 | * [api_client](neutron/plugins/vmware/api_client.md)
298 | * [check_nsx_config.py](neutron/plugins/vmware/check_nsx_configpy.md)
299 | * [common](neutron/plugins/vmware/common.md)
300 | * [dbexts](neutron/plugins/vmware/dbexts.md)
301 | * [dhcpmeta_modes.py](neutron/plugins/vmware/dhcpmeta_modespy.md)
302 | * [dhcp_meta](neutron/plugins/vmware/dhcp_meta.md)
303 | * [extensions](neutron/plugins/vmware/extensions.md)
304 | * [nsxlib](neutron/plugins/vmware/nsxlib.md)
305 | * [nsx_cluster.py](neutron/plugins/vmware/nsx_clusterpy.md)
306 | * [plugin.py](neutron/plugins/vmware/pluginpy.md)
307 | * [plugins](neutron/plugins/vmware/plugins.md)
308 | * [shell](neutron/plugins/vmware/shell.md)
309 | * [vshield](neutron/plugins/vmware/vshield.md)
310 | * [__init__.py](neutron/plugins/vmware/__init__py.md)
311 | * [scheduler](neutron/scheduler/README.md)
312 | * [dhcp_agent_scheduler.py](neutron/scheduler/dhcp_agent_schedulerpy.md)
313 | * [l3_agent_scheduler.py](neutron/scheduler/l3_agent_schedulerpy.md)
314 | * [server](neutron/server/README.md)
315 | * [service.py](neutron/servicepy.md)
316 | * [services](neutron/services/README.md)
317 | * [firewall](neutron/services/firewall/README.md)
318 | * [agents](neutron/services/firewall/agents.md)
319 | * [drivers](neutron/services/firewall/drivers.md)
320 | * [fwaas_plugin.py](neutron/services/firewall/fwaas_pluginpy.md)
321 | * [l3_router](neutron/services/l3_router/README.md)
322 | * [brocade](neutron/services/l3_router/brocade.md)
323 | * [l3_apic.py](neutron/services/l3_router/l3_apicpy.md)
324 | * [l3_arista.py](neutron/services/l3_router/l3_aristapy.md)
325 | * [l3_router_plugin.py](neutron/services/l3_router/l3_router_pluginpy.md)
326 | * [__init__.py](neutron/services/l3_router/__init__py.md)
327 | * [loadbalancer](neutron/services/loadbalancer/README.md)
328 | * [agent](neutron/services/loadbalancer/agent.md)
329 | * [agent_scheduler.py](neutron/services/loadbalancer/agent_schedulerpy.md)
330 | * [constants.py](neutron/services/loadbalancer/constantspy.md)
331 | * [drivers](neutron/services/loadbalancer/drivers.md)
332 | * [plugin.py](neutron/services/loadbalancer/pluginpy.md)
333 | * [metering](neutron/services/metering/README.md)
334 | * [agents](neutron/services/metering/agents.md)
335 | * [drivers](neutron/services/metering/drivers.md)
336 | * [metering_plugin.py](neutron/services/metering/metering_pluginpy.md)
337 | * [provider_configuration.py](neutron/services/provider_configurationpy.md)
338 | * [service_base.py](neutron/services/service_basepy.md)
339 | * [vpn](neutron/services/vpn/README.md)
340 | * [agent.py](neutron/services/vpn/agentpy.md)
341 | * [common](neutron/services/vpn/common.md)
342 | * [device_drivers](neutron/services/vpn/device_drivers.md)
343 | * [plugin.py](neutron/services/vpn/pluginpy.md)
344 | * [service_drivers](neutron/services/vpn/service_drivers.md)
345 | * [__init__.py](neutron/services/vpn/__init__py.md)
346 | * [__init__.py](neutron/services/__init__py.md)
347 | * [tests](neutron/tests/README.md)
348 | * [base.py](neutron/tests/basepy.md)
349 | * [common](neutron/tests/common/README.md)
350 | * [agents](neutron/tests/common/agents.md)
351 | * [__init__.py](neutron/tests/common/__init__py.md)
352 | * [etc](neutron/tests/etc/README.md)
353 | * [rootwrap.d](neutron/tests/etc/rootwrap.d.md)
354 | * [fake_notifier.py](neutron/tests/fake_notifierpy.md)
355 | * [functional](neutron/tests/functional/README.md)
356 | * [agent](neutron/tests/functional/agent.md)
357 | * [base.py](neutron/tests/functional/basepy.md)
358 | * [contrib](neutron/tests/functional/contrib.md)
359 | * [db](neutron/tests/functional/db.md)
360 | * [sanity](neutron/tests/functional/sanity.md)
361 | * [__init__.py](neutron/tests/functional/__init__py.md)
362 | * [post_mortem_debug.py](neutron/tests/post_mortem_debugpy.md)
363 | * [tools.py](neutron/tests/toolspy.md)
364 | * [unit](neutron/tests/unit/README.md)
365 | * [var](neutron/tests/var/README.md)
366 | * [__init__.py](neutron/tests/__init__py.md)
367 | * [auth.py](neutron/auth.py.md)
368 | * [context.py](neutron/context.py.md)
369 | * [hooks.py](neutron/hooks.py.md)
370 | * [i18n.py](neutron/i18n.py.md)
371 | * [manager.py](neutron/manager.py.md)
372 | * [neutron_plugin_base_v2.py](neutron/neutron_plugin_base_v2.py.md)
373 | * [policy.py](neutron/policy.py.md)
374 | * [quota.py](neutron/quota.py.md)
375 | * [service.py](neutron/service.py.md)
376 | * [version.py](neutron/version.py.md)
377 | * [wsgi.py](neutron/wsgi.py.md)
378 | * [rally-jobs](rally-jobs/README.md)
379 | * [extra](rally-jobs/extra/README.md)
380 | * [README.rst](rally-jobs/extra/README.rst.md)
381 | * [plugins](rally-jobs/plugins/README.md)
382 | * [README.rst](rally-jobs/plugins/README.rst.md)
383 | * [__init__.py](rally-jobs/plugins/__init__.py.md)
384 | * [neutron-neutron.yaml](rally-jobs/neutron-neutron.yaml.md)
385 | * [README.rst](rally-jobs/README.rst.md)
386 | * [tools](tools/README.md)
387 | * [check_bash.sh](tools/check_bash.sh.md)
388 | * [check_i18n.py](tools/check_i18n.py.md)
389 | * [check_i18n_test_case.txt](tools/check_i18n_test_case.txt.md)
390 | * [clean.sh](tools/clean.sh.md)
391 | * [i18n_cfg.py](tools/i18n_cfg.py.md)
392 | * [install_venv.py](tools/install_venv.py.md)
393 | * [install_venv_common.py](tools/install_venv_common.py.md)
394 | * [pretty_tox.sh](tools/pretty_tox.sh.md)
395 | * [with_venv.sh](tools/with_venv.sh.md)
396 | * [理解代码](understanding/README.md)
397 | * [调用逻辑](understanding/call_logic.md)
398 | * [REST API 专题](understanding/rest_api.md)
399 | * [RPC 专题](understanding/rpc/README.md)
400 | * [agent RPC](understanding/rpc/agent_rpc.md)
401 | * [plugin RPC](understanding/rpc/plugin_rpc.md)
402 | * [neutron-server RPC](understanding/rpc/neutron_server_rpc.md)
403 | * [Plugin 专题](understanding/plugin.md)
404 | * [Extension 专题](understanding/extension.md)
405 | * [Agent 专题](understanding/agent.md)
406 | * [Driver 专题](understanding/driver.md)
--------------------------------------------------------------------------------
/_images/code_logic.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | "Web or Client" -> "Neutron Server" [label="REST API Call"];
5 | "Neutron Server" -> Plugin [label="WSGI Resource Call"];
6 | Plugin -> Agent [dir=both,label="RPC API Call"];
7 | Agent -> Driver [label="Local Method Call"]
8 |
9 | }
--------------------------------------------------------------------------------
/_images/code_logic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/code_logic.png
--------------------------------------------------------------------------------
/_images/interface.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | LinuxInterfaceDriver -> BridgeInterfaceDriver;
5 | LinuxInterfaceDriver -> IVSInterfaceDriver;
6 | LinuxInterfaceDriver -> MetaInterfaceDriver;
7 | LinuxInterfaceDriver -> MidonetInterfaceDriver;
8 | LinuxInterfaceDriver -> NullDriver;
9 | LinuxInterfaceDriver -> OVSInterfaceDriver;
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/_images/interface.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/interface.png
--------------------------------------------------------------------------------
/_images/neutron.api.rpc.agentnotifiers.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | "Notify()" -> "_notify_agents()";
5 | "_notify_agents()" -> "_schedule_network()";
6 | "_notify_agents()" -> "_get_enabled_agents()";
7 | "_notify_agents()" -> "_cast_message()";
8 | "network_removed_from_agent()" -> "_cast_message()";
9 | "network_added_to_agent()" -> "_cast_message()";
10 | "agent_updated()" -> "_cast_message()";
11 | }
--------------------------------------------------------------------------------
/_images/neutron.api.rpc.agentnotifiers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.api.rpc.agentnotifiers.png
--------------------------------------------------------------------------------
/_images/neutron.db.firewall.firewall_db.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | "FirewallRule"[color=blue]
5 | "Firewall"[color=blue]
6 | "FirewallPolicy"[color=blue]
7 | "model_base.BASEV2\nmodels_v2.HasId\nmodels_v2.HasTenant" -> "FirewallRule";
8 | "model_base.BASEV2\nmodels_v2.HasId\nmodels_v2.HasTenant" -> "Firewall";
9 | "model_base.BASEV2\nmodels_v2.HasId\nmodels_v2.HasTenant" -> "FirewallPolicy";
10 |
11 | "Firewall_db_mixin"[color=blue]
12 | "neutron.api.extensions.PluginInterface" -> "neutron.services.service_base.ServicePluginBase" -> "neutron.extension.firewall.FirewallPluginBase" -> "Firewall_db_mixin"
13 | "neutron.db.common_db_mixin.CommonDbMixin" -> "Firewall_db_mixin"
14 |
15 | {rank=same; "FirewallPolicy" "Firewall_db_mixin"}
16 |
17 | }
--------------------------------------------------------------------------------
/_images/neutron.db.firewall.firewall_db.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.db.firewall.firewall_db.png
--------------------------------------------------------------------------------
/_images/neutron.db.loadbalancer.loadbalancer_db.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | "SessionPersistence"[color=blue]
5 | "PoolStatistics"[color=blue]
6 | "Vip"[color=blue]
7 | "Member"[color=blue]
8 | "Pool"[color=blue]
9 | "HealthMonitor"[color=blue]
10 | "PoolMonitorAssociation"[color=blue]
11 | "model_base.BASEV2\n..." -> "SessionPersistence";
12 | "model_base.BASEV2\n..." -> "PoolStatistics";
13 | "model_base.BASEV2\n..." -> "Vip";
14 | "model_base.BASEV2\n..." -> "Member";
15 | "model_base.BASEV2\n..." -> "Pool";
16 | "model_base.BASEV2\n..." -> "HealthMonitor";
17 | "model_base.BASEV2\n..." -> "PoolMonitorAssociation";
18 |
19 | "LoadBalancerPluginDb"[color=blue]
20 | "neutron.api.extensions.PluginInterface" -> "neutron.services.service_base.ServicePluginBase" -> "neutron.extension.loadbalancer.LoadBalancePluginBase" -> "LoadBalancerPluginDb"
21 | "neutron.db.common_db_mixin.CommonDbMixin" -> "LoadBalancerPluginDb"
22 |
23 | {rank=same; "SessionPersistence" "LoadBalancerPluginDb"}
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/_images/neutron.db.loadbalancer.loadbalancer_db.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.db.loadbalancer.loadbalancer_db.png
--------------------------------------------------------------------------------
/_images/neutron.db.model_base.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | "oslo.db.sqlalchemy.models.ModelBase" -> "NeutronBase";
5 | "NeutronBase" -> "NeutronBaseV2";
6 |
7 | }
--------------------------------------------------------------------------------
/_images/neutron.db.model_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.db.model_base.png
--------------------------------------------------------------------------------
/_images/neutron.plugin.openvswitch.agent.ovs_neutron_agent.OVSNeutronAgent.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 |
5 | rpcproxy[label=<neutron.common.rpc.RpcProxy>];
6 |
7 | pluginapi[label=<neutron.agent.rpc.PluginApi:
get_device_details()
get_devices_details_list()
update_device_down()
update_device_up()
tunnel_sync>];
8 | rpcapimixin[label=<neutron.agent.rpc.SecurityGroupServerRpcApiMixin:
security_group_rules_for_devices()>];
9 | stateapi[label=<neutron.agent.rpc.PluginReportStateAPI:
report_state()>];
10 |
11 | pluginrpc[label="self.plugin_rpc = OVSPluginApi(topics.PLUGIN)",color=blue];
12 | staterpc[label="self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)",color=blue];
13 |
14 | rpcproxy->pluginapi-> pluginrpc;
15 | rpcapimixin -> pluginrpc;
16 | rpcproxy ->stateapi->staterpc;
17 |
18 | createconnection[label=<neutron.common.rpc..create_connection()>];
19 | createconsumer[label=<neutron.agent.rpc.create_consumers()>];
20 | connection[label="self.connection = agent_rpc.create_consumers(self.endpoints,self.topic,consumers)",color=blue];
21 |
22 | createconnection->createconsumer->connection;
23 |
24 | {rank=same; pluginrpc staterpc connection}
25 | }
26 |
--------------------------------------------------------------------------------
/_images/neutron.plugin.openvswitch.agent.ovs_neutron_agent.OVSNeutronAgent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.plugin.openvswitch.agent.ovs_neutron_agent.OVSNeutronAgent.png
--------------------------------------------------------------------------------
/_images/neutron.plugin.openvswitch.ovs_neutron_plugin.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 |
5 | plugin[label="OVS Plugin",color=blue];
6 | agent[label="OVS Agent",color=blue];
7 |
8 | agent -> plugin [shape=box,label=<OVSPluginApi:
get_device_details
get_devices_details_list
update_device_down
update_device_up
tunnel_sync
security_group_rules_for_devices>]
9 | //agent -> plugin [shape=box,label="{OVSPluginApi|get_device_details\lget_devices_details_list\lupdate_device_down\lupdate_device_up\ltunnel_sync\lsecurity_group_rules_for_devices}"]
10 | agent->plugin[label=<report_state>]
11 | plugin->agent[label=<notify:
network_delete
port_update
tunnel_update>]
12 |
13 | //{rank=same; pluginrpc staterpc connection}
14 | }
15 |
--------------------------------------------------------------------------------
/_images/neutron.plugin.openvswitch.ovs_neutron_plugin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.plugin.openvswitch.ovs_neutron_plugin.png
--------------------------------------------------------------------------------
/_images/neutron.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.png
--------------------------------------------------------------------------------
/_images/neutron.services.firewall.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | rpccallback[label="rpc.RpcCallback",color=blue];
5 | rpcproxy[label="rpc.RpcProxy",color=red];
6 |
7 | subgraph cluster_plugin{
8 | label="Firewall Plugin";
9 | callback[label="FirewallCallbacks",color=blue];
10 | agentapi[label="FirewallAgentApi",color=red];
11 | };
12 |
13 | subgraph cluster_agent{
14 | label="Firewall Agent";
15 | apimixin[label="FWaaSPluginApiMixin",color=red];
16 | callbackmixin[label="FWaaSAgentRpcCallbackMixin"];
17 | };
18 |
19 | apimixin->callback[label="set_firewall_status\nfirewall_deleted"];
20 | agentapi->callbackmixin[label="create_firewall\nupdate_firewall\ndelete_firewall"];
21 |
22 | //{rank=same; rpccallback callback}
23 | //{rank=same; rpcproxy apimixin}
24 | }
25 |
--------------------------------------------------------------------------------
/_images/neutron.services.firewall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/neutron.services.firewall.png
--------------------------------------------------------------------------------
/_images/openvswitch_plugin_rpc.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 | plugin[label="OVS Plugin",color=blue];
5 | agent[label="OVS Agent",color=red];
6 | dhcpagent[label="DHCP Agent",color=red];
7 | l3agent[label="L3 Agent",color=red];
8 | consumer[label="{Topics|topics.PLUGIN\ltopics.L3PLUGIN}",color=red];
9 |
10 | notifyrpc[label="{AgentNotifierApi|network_delete\lport_update\ltunnel_update\l}",color=blue];
11 | dhcpnotifyrpc[label="{DhcpAgentNotifierApi|agent_updated\lnetwork_added_to_agent\lnetwork_removed_from_agent\lnetwork.(CUD).end\lsubnet.(CUD).end\lport.(CUD).end}\l}",color=blue];
12 | l3notifyrpc[label="{L3AgentNotifierApi|add_arp_entry\ldel_arp_entry\lagent_updated\lrouter_added_to_agent\lrouter_removed_from_agent\lrouter_deleted\lrouter_updated\l}",color=blue];
13 |
14 | ovspluginapi[label="{OVSPluginApi|get_device_details\lget_devices_details_list\lupdate_device_down\lupdate_device_up\ltunnel_sync\lsecurity_group_rules_for_devices}",color=red];
15 | staterpc[label="report_state",color=red];
16 |
17 | plugin->notifyrpc->agent[color=blue,style=dotted];
18 | plugin->dhcpnotifyrpc->dhcpagent[color=blue,style=dotted];
19 | plugin->l3notifyrpc->l3agent[color=blue,style=dotted];
20 |
21 | agent->ovspluginapi->plugin[color=red,style=dotted];
22 | agent->staterpc->plugin[color=red,style=dotted];
23 | consumer->plugin[color=red,style=dotted];
24 |
25 | {rank=same; notifyrpc dhcpnotifyrpc l3notifyrpc ovspluginapi staterpc};
26 | //{rank=same; rpcproxy apimixin}
27 | }
28 |
--------------------------------------------------------------------------------
/_images/openvswitch_plugin_rpc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/openvswitch_plugin_rpc.png
--------------------------------------------------------------------------------
/_images/restapi.dot:
--------------------------------------------------------------------------------
1 | //dot -Tpng xx.dot -o xx.png
2 | digraph G {
3 | node [shape = record];
4 |
5 | server[label="neutron-server",color=blue];
6 | apiservice[label="service.NeutronApiService",color=blue];
7 | wsgiservice[label="service.WsgiService",color=blue];
8 | _run_wsgi[
9 | label="{service._run_wsgi()|app=common.config.load_paste_app(api-paste.ini)\lwsgi.Server.start(app)}"
10 | ];
11 | apirouter[
12 | label="{api.router.APIRouter}|
13 | plugin=manager.NeutronManager.get_plugin()\l
14 | ext_mgr = extensions.PluginAwareExtensionManager.get_instance()\l
15 | mapper.collection()
16 | "
17 | ]
18 |
19 | //apimixin->callback[label="set_firewall_status\nfirewall_deleted"];
20 | //agentapi->callbackmixin[label="create_firewall\nupdate_firewall\ndelete_firewall"];
21 |
22 |
23 | server->apiservice;
24 | apiservice->wsgiservice[style=dotted];
25 | wsgiservice->_run_wsgi->apirouter;
26 |
27 | //{rank=same; rpccallback callback}
28 | //{rank=same; rpcproxy apimixin}
29 | }
30 |
--------------------------------------------------------------------------------
/_images/restapi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/_images/restapi.png
--------------------------------------------------------------------------------
/bin/README.md:
--------------------------------------------------------------------------------
1 | # bin
2 | * neutron-rootwrap文件,python可执行文件
3 | * neutron-rootwrap-xen-dom0文件,python可执行文件。
4 | 提供利用root权限执行命令时候的操作接口,通过检查,可以配置不同用户利用管理员身份执行命令的权限。其主要实现是利用了oslo.rootwrap 包中的cmd模块。
5 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # doc
2 | 可以利用 sphinx 工具来生成文档。用户在该目录下通过执行 make html 可以生成 html 格式的说明文档。
3 |
4 | * source 子目录:文档相关的代码。
5 | * Makefile:用户执行 make 命令的模板文件。
6 | * pom.xml:maven项目管理文件。
7 |
--------------------------------------------------------------------------------
/etc/README.md:
--------------------------------------------------------------------------------
1 | # etc
2 | 存放 Neutron 服务运行相关的配置文件。
3 |
--------------------------------------------------------------------------------
/etc/api-pasteini.md:
--------------------------------------------------------------------------------
1 | ## api-paste.ini
2 | 定义了WSGI应用和路由信息。利用Paste来实例化Neutron的APIRouter类,将资源(端口、网络、子网)映射到URL上,以及各个资源的控制器。
3 | 在neutron-server启动的时候,一般会指定参数--config-file neutron.conf --config-file xxx.ini。看neutron/server/__init__.py的代码: main()主程序中会调用config.parse(sys.argv[1:])来读取这些配置文件中的信息。而api-paste.ini信息中定义了neutron、neutronapi_v2_0、若干filter和两个app。
4 | ```
5 | [composite:neutron]
6 | use = egg:Paste#urlmap
7 | /: neutronversions
8 | /v2.0: neutronapi_v2_0
9 |
10 | [composite:neutronapi_v2_0]
11 | use = call:neutron.auth:pipeline_factory
12 | noauth = request_id catch_errors extensions neutronapiapp_v2_0
13 | keystone = request_id catch_errors authtoken keystonecontext extensions neutronapiapp_v2_0
14 |
15 | [filter:request_id]
16 | paste.filter_factory = oslo.middleware:RequestId.factory
17 |
18 | [filter:catch_errors]
19 | paste.filter_factory = oslo.middleware:CatchErrors.factory
20 |
21 | [filter:keystonecontext]
22 | paste.filter_factory = neutron.auth:NeutronKeystoneContext.factory
23 |
24 | [filter:authtoken]
25 | paste.filter_factory = keystonemiddleware.auth_token:filter_factory
26 |
27 | [filter:extensions]
28 | paste.filter_factory = neutron.api.extensions:plugin_aware_extension_middleware_factory
29 |
30 | [app:neutronversions]
31 | paste.app_factory = neutron.api.versions:Versions.factory
32 |
33 | [app:neutronapiapp_v2_0]
34 | paste.app_factory = neutron.api.v2.router:APIRouter.factory
35 | ```
36 |
37 | neutron-server在读取完配置信息后,会执行neutron/common/config.py:load_paste_app(“neutron”),即将neutron应用load进来。从api-paste.ini中可以看到,neutron实际上是一个composite,分别将URL“/”和“/v2.0”映射到neutronversions应用和neutronapi_v2_0(也是一个composite)。
38 |
39 | 前者实际上调用了 neutron.api.versions 模块中的 Versions.factory 来处理传入的请求。
40 |
41 | 后者则要复杂一些,首先调用 neutron.auth 模块中的pipeline_factory 处理。如果是 noauth,则传入参数为 request_id,catch_errors,extensions 这些 filter和 neutronapiapp_v2_0 应用;如果是 keystone,则多传入一个 authtoken filter,最后一个参数仍然是 neutronapiapp_v2_0 应用。来看 neutron.auth 模块中的 pipeline_factory 处理代码。
42 |
43 | ```
44 | def pipeline_factory(loader, global_conf, **local_conf):
45 | """Create a paste pipeline based on the 'auth_strategy' config option."""
46 | pipeline = local_conf[cfg.CONF.auth_strategy]
47 | pipeline = pipeline.split()
48 | filters = [loader.get_filter(n) for n in pipeline[:-1]]
49 | app = loader.get_app(pipeline[-1])
50 | filters.reverse()
51 | for filter in filters:
52 | app = filter(app)
53 | return app
54 | ```
55 |
56 | 最终的代码入口是neutron.api.v2.router:APIRouter.factory。该方法主要代码为
57 | ```
58 | class APIRouter(wsgi.Router):
59 |
60 | @classmethod
61 | def factory(cls, global_config, **local_config):
62 | return cls(**local_config)
63 |
64 | def __init__(self, **local_config):
65 | mapper = routes_mapper.Mapper()
66 | plugin = manager.NeutronManager.get_plugin()
67 | ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
68 | ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)
69 |
70 | col_kwargs = dict(collection_actions=COLLECTION_ACTIONS,
71 | member_actions=MEMBER_ACTIONS)
72 |
73 | def _map_resource(collection, resource, params, parent=None):
74 | allow_bulk = cfg.CONF.allow_bulk
75 | allow_pagination = cfg.CONF.allow_pagination
76 | allow_sorting = cfg.CONF.allow_sorting
77 | controller = base.create_resource(
78 | collection, resource, plugin, params, allow_bulk=allow_bulk,
79 | parent=parent, allow_pagination=allow_pagination,
80 | allow_sorting=allow_sorting)
81 | path_prefix = None
82 | if parent:
83 | path_prefix = "/%s/{%s_id}/%s" % (parent['collection_name'],
84 | parent['member_name'],
85 | collection)
86 | mapper_kwargs = dict(controller=controller,
87 | requirements=REQUIREMENTS,
88 | path_prefix=path_prefix,
89 | **col_kwargs)
90 | return mapper.collection(collection, resource,
91 | **mapper_kwargs)
92 |
93 | mapper.connect('index', '/', controller=Index(RESOURCES))
94 | for resource in RESOURCES:
95 | _map_resource(RESOURCES[resource], resource,
96 | attributes.RESOURCE_ATTRIBUTE_MAP.get(
97 | RESOURCES[resource], dict()))
98 |
99 | for resource in SUB_RESOURCES:
100 | _map_resource(SUB_RESOURCES[resource]['collection_name'], resource,
101 | attributes.RESOURCE_ATTRIBUTE_MAP.get(
102 | SUB_RESOURCES[resource]['collection_name'],
103 | dict()),
104 | SUB_RESOURCES[resource]['parent'])
105 | ```
106 |
107 | neutron server启动后,根据配置文件动态加载对应的core plugin 和 service plugin。neturon server 中会对收到的 rest api 请求进行解析,并最终转换成对该 plugin(core or service) 中相应方法的调用。
108 |
109 |
--------------------------------------------------------------------------------
/etc/dhcp_agentini.md:
--------------------------------------------------------------------------------
1 | ## dhcp_agent.ini
2 | dhcp agent 相关的配置信息。包括与 neutron 的同步状态的频率、超时、驱动信息等。
3 |
4 | 需要注意的是,这些 ini 文件内容多为注释掉的默认值的情况,是自动从代码中提取的。
5 |
6 | ```
7 | hcp.Dnsmasq
8 |
9 | # Allow overlapping IP (Must have kernel build with CONFIG_NET_NS=y and
10 | # iproute2 package that supports namespaces).
11 | # use_namespaces = True
12 |
13 | # The DHCP server can assist with providing metadata support on isolated
14 | # networks. Setting this value to True will cause the DHCP server to append
15 | # specific host routes to the DHCP request. The metadata service will only
16 | # be activated when the subnet does not contain any router port. The guest
17 | # instance must be configured to request host routes via DHCP (Option 121).
18 | # enable_isolated_metadata = False
19 |
20 | # Allows for serving metadata requests coming from a dedicated metadata
21 | # access network whose cidr is 169.254.169.254/16 (or larger prefix), and
22 | # is connected to a Neutron router from which the VMs send metadata
23 | # request. In this case DHCP Option 121 will not be injected in VMs, as
24 | # they will be able to reach 169.254.169.254 through a router.
25 | # This option requires enable_isolated_metadata = True
26 | # enable_metadata_network = False
27 |
28 | # Number of threads to use during sync process. Should not exceed connection
29 | # pool size configured on server.
30 | # num_sync_threads = 4
31 |
32 | # Location to store DHCP server config files
33 | # dhcp_confs = $state_path/dhcp
34 |
35 | # Domain to use for building the hostnames
36 | # dhcp_domain = openstacklocal
37 |
38 | # Override the default dnsmasq settings with this file
39 | # dnsmasq_config_file =
40 |
41 | # Comma-separated list of DNS servers which will be used by dnsmasq
42 | # as forwarders.
43 | # dnsmasq_dns_servers =
44 |
45 | # Limit number of leases to prevent a denial-of-service.
46 | # dnsmasq_lease_max = 16777216
47 |
48 | # Location to DHCP lease relay UNIX domain socket
49 | # dhcp_lease_relay_socket = $state_path/dhcp/lease_relay
50 |
51 | # Use broadcast in DHCP replies
52 | # dhcp_broadcast_reply = False
53 |
54 | # Location of Metadata Proxy UNIX domain socket
55 | # metadata_proxy_socket = $state_path/metadata_proxy
56 |
57 | # dhcp_delete_namespaces, which is false by default, can be set to True if
58 | # namespaces can be deleted cleanly on the host running the dhcp agent.
59 | # Do not enable this until you understand the problem with the Linux iproute
60 | # utility mentioned in https://bugs.launchpad.net/neutron/+bug/1052535 and
61 | # you are sure that your version of iproute does not suffer from the problem.
62 | # If True, namespaces will be deleted when a dhcp server is disabled.
63 | # dhcp_delete_namespaces = False
64 |
65 | # Timeout for ovs-vsctl commands.
66 | # If the timeout expires, ovs commands will fail with ALARMCLOCK error.
67 | # ovs_vsctl_timeout = 10
68 | ```
69 |
--------------------------------------------------------------------------------
/etc/fwaas_driverini.md:
--------------------------------------------------------------------------------
1 | ## fwaas_driver.ini
2 | 配置 fwaas 的 driver 信息,默认为
3 | ```
4 | [fwaas]
5 | #driver = neutron.services.firewall.drivers.linux.iptables_fwaas.IptablesFwaasDriver
6 | #enabled = True
7 | ```
8 |
--------------------------------------------------------------------------------
/etc/initd.md:
--------------------------------------------------------------------------------
1 | ## init.d/
2 | neutron-server 是 Upstart 支持的系统服务脚本,核心部分为
3 | ```
4 | case "$1" in
5 | start)
6 | test "$ENABLED" = "true" || exit 0
7 | log_daemon_msg "Starting neutron server" "neutron-server"
8 | start-stop-daemon -Sbmv --pidfile $PIDFILE --chdir $DAEMON_DIR --exec $DAEMON -- $DAEMON_ARGS
9 | log_end_msg $?
10 | ;;
11 | stop)
12 | test "$ENABLED" = "true" || exit 0
13 | log_daemon_msg "Stopping neutron server" "neutron-server"
14 | start-stop-daemon --stop --oknodo --pidfile ${PIDFILE}
15 | log_end_msg $?
16 | ;;
17 | restart|force-reload)
18 | test "$ENABLED" = "true" || exit 1
19 | $0 stop
20 | sleep 1
21 | $0 start
22 | ;;
23 | status)
24 | test "$ENABLED" = "true" || exit 0
25 | status_of_proc -p $PIDFILE $DAEMON neutron-server && exit 0 || exit $?
26 | ;;
27 | *)
28 | log_action_msg "Usage: /etc/init.d/neutron-server {start|stop|restart|force-reload|status}"
29 | exit 1
30 | ;;
31 | esac
32 | ```
33 |
--------------------------------------------------------------------------------
/etc/l3_agentini.md:
--------------------------------------------------------------------------------
1 | ## l3_agent.ini
2 | L3 agent 相关的配置信息。
3 | 当存在外部网桥的时候,每个 agent 最多只能关联到一个外部网络。
4 |
5 | ```
6 | [DEFAULT]
7 | # Show debugging output in log (sets DEBUG log level output)
8 | # debug = False
9 |
10 | # L3 requires that an interface driver be set. Choose the one that best
11 | # matches your plugin.
12 | # interface_driver =
13 |
14 | # Example of interface_driver option for OVS based plugins (OVS, Ryu, NEC)
15 | # that supports L3 agent
16 | # interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
17 |
18 | # Use veth for an OVS interface or not.
19 | # Support kernels with limited namespace support
20 | # (e.g. RHEL 6.5) so long as ovs_use_veth is set to True.
21 | # ovs_use_veth = False
22 |
23 | # Example of interface_driver option for LinuxBridge
24 | # interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
25 |
26 | # Allow overlapping IP (Must have kernel build with CONFIG_NET_NS=y and
27 | # iproute2 package that supports namespaces).
28 | # use_namespaces = True
29 |
30 | # If use_namespaces is set as False then the agent can only configure one router.
31 |
32 | # This is done by setting the specific router_id.
33 | # router_id =
34 |
35 | # When external_network_bridge is set, each L3 agent can be associated
36 | # with no more than one external network. This value should be set to the UUID
37 | # of that external network. To allow L3 agent support multiple external
38 | # networks, both the external_network_bridge and gateway_external_network_id
39 | # must be left empty.
40 | # gateway_external_network_id =
41 |
42 | # Indicates that this L3 agent should also handle routers that do not have
43 | # an external network gateway configured. This option should be True only
44 | # for a single agent in a Neutron deployment, and may be False for all agents
45 | # if all routers must have an external network gateway
46 | # handle_internal_only_routers = True
47 |
48 | # Name of bridge used for external network traffic. This should be set to
49 | # empty value for the linux bridge. when this parameter is set, each L3 agent
50 | # can be associated with no more than one external network.
51 | # external_network_bridge = br-ex
52 |
53 | # TCP Port used by Neutron metadata server
54 | # metadata_port = 9697
55 |
56 | # Send this many gratuitous ARPs for HA setup. Set it below or equal to 0
57 | # to disable this feature.
58 | # send_arp_for_ha = 3
59 |
60 | # seconds between re-sync routers' data if needed
61 | # periodic_interval = 40
62 |
63 | # seconds to start to sync routers' data after
64 | # starting agent
65 | # periodic_fuzzy_delay = 5
66 |
67 | # enable_metadata_proxy, which is true by default, can be set to False
68 | # if the Nova metadata server is not available
69 | # enable_metadata_proxy = True
70 |
71 | # Location of Metadata Proxy UNIX domain socket
72 | # metadata_proxy_socket = $state_path/metadata_proxy
73 |
74 | # router_delete_namespaces, which is false by default, can be set to True if
75 | # namespaces can be deleted cleanly on the host running the L3 agent.
76 | # Do not enable this until you understand the problem with the Linux iproute
77 | # utility mentioned in https://bugs.launchpad.net/neutron/+bug/1052535 and
78 | # you are sure that your version of iproute does not suffer from the problem.
79 | # If True, namespaces will be deleted when a router is destroyed.
80 | # router_delete_namespaces = False
81 |
82 | # Timeout for ovs-vsctl commands.
83 | # If the timeout expires, ovs commands will fail with ALARMCLOCK error.
84 | # ovs_vsctl_timeout = 10
85 |
86 | # The working mode for the agent. Allowed values are:
87 | # - legacy: this preserves the existing behavior where the L3 agent is
88 | # deployed on a centralized networking node to provide L3 services
89 | # like DNAT, and SNAT. Use this mode if you do not want to adopt DVR.
90 | # - dvr: this mode enables DVR functionality, and must be used for an L3
91 | # agent that runs on a compute host.
92 | # - dvr_snat: this enables centralized SNAT support in conjunction with
93 | # DVR. This mode must be used for an L3 agent running on a centralized
94 | # node (or in single-host deployments, e.g. devstack).
95 | # agent_mode = legacy
96 |
97 | # Location to store keepalived and all HA configurations
98 | # ha_confs_path = $state_path/ha_confs
99 |
100 | # VRRP authentication type AH/PASS
101 | # ha_vrrp_auth_type = PASS
102 |
103 | # VRRP authentication password
104 | # ha_vrrp_auth_password =
105 |
106 | # The advertisement interval in seconds
107 | # ha_vrrp_advert_int = 2
108 | ```
109 |
--------------------------------------------------------------------------------
/etc/lbaas_agentini.md:
--------------------------------------------------------------------------------
1 | ## lbaas_agent.ini
2 | 配置 LBaaS agent 的相关信息,包括跟 Neutron 定期同步状态的频率等。
3 | ```
4 | [DEFAULT]
5 | # Show debugging output in log (sets DEBUG log level output).
6 | # debug = False
7 |
8 | # The LBaaS agent will resync its state with Neutron to recover from any
9 | # transient notification or rpc errors. The interval is number of
10 | # seconds between attempts.
11 | # periodic_interval = 10
12 |
13 | # LBaas requires an interface driver be set. Choose the one that best
14 | # matches your plugin.
15 | # interface_driver =
16 |
17 | # Example of interface_driver option for OVS based plugins (OVS, Ryu, NEC, NVP,
18 | # BigSwitch/Floodlight)
19 | # interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
20 |
21 | # Use veth for an OVS interface or not.
22 | # Support kernels with limited namespace support
23 | # (e.g. RHEL 6.5) so long as ovs_use_veth is set to True.
24 | # ovs_use_veth = False
25 |
26 | # Example of interface_driver option for LinuxBridge
27 | # interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
28 |
29 | # The agent requires drivers to manage the loadbalancer. HAProxy is the opensource version.
30 | # Multiple device drivers reflecting different service providers could be specified:
31 | # device_driver = path.to.provider1.driver.Driver
32 | # device_driver = path.to.provider2.driver.Driver
33 | # Default is:
34 | # device_driver = neutron.services.loadbalancer.drivers.haproxy.namespace_driver.HaproxyNSDriver
35 |
36 | [haproxy]
37 | # Location to store config and state files
38 | # loadbalancer_state_path = $state_path/lbaas
39 |
40 | # The user group
41 | # user_group = nogroup
42 |
43 | # When delete and re-add the same vip, send this many gratuitous ARPs to flush
44 | # the ARP cache in the Router. Set it below or equal to 0 to disable this feature.
45 | # send_gratuitous_arp = 3
46 | ```
47 |
--------------------------------------------------------------------------------
/etc/metadata_agentini.md:
--------------------------------------------------------------------------------
1 | ## metadata_agent.ini
2 | metadata agent 的配置信息,包括访问 Neutron API 的用户信息等。
3 |
4 | ```
5 | [DEFAULT]
6 | # Show debugging output in log (sets DEBUG log level output)
7 | # debug = True
8 |
9 | # The Neutron user information for accessing the Neutron API.
10 | auth_url = http://localhost:5000/v2.0
11 | auth_region = RegionOne
12 | # Turn off verification of the certificate for ssl
13 | # auth_insecure = False
14 | # Certificate Authority public key (CA cert) file for ssl
15 | # auth_ca_cert =
16 | admin_tenant_name = %SERVICE_TENANT_NAME%
17 | admin_user = %SERVICE_USER%
18 | admin_password = %SERVICE_PASSWORD%
19 |
20 | # Network service endpoint type to pull from the keystone catalog
21 | # endpoint_type = adminURL
22 |
23 | # IP address used by Nova metadata server
24 | # nova_metadata_ip = 127.0.0.1
25 |
26 | # TCP Port used by Nova metadata server
27 | # nova_metadata_port = 8775
28 |
29 | # Which protocol to use for requests to Nova metadata server, http or https
30 | # nova_metadata_protocol = http
31 |
32 | # Whether insecure SSL connection should be accepted for Nova metadata server
33 | # requests
34 | # nova_metadata_insecure = False
35 |
36 | # Client certificate for nova api, needed when nova api requires client
37 | # certificates
38 | # nova_client_cert =
39 |
40 | # Private key for nova client certificate
41 | # nova_client_priv_key =
42 |
43 | # When proxying metadata requests, Neutron signs the Instance-ID header with a
44 | # shared secret to prevent spoofing. You may select any string for a secret,
45 | # but it must match here and in the configuration used by the Nova Metadata
46 | # Server. NOTE: Nova uses a different key: neutron_metadata_proxy_shared_secret
47 | # metadata_proxy_shared_secret =
48 |
49 | # Location of Metadata Proxy UNIX domain socket
50 | # metadata_proxy_socket = $state_path/metadata_proxy
51 |
52 | # Number of separate worker processes for metadata server. Defaults to
53 | # half the number of CPU cores
54 | # metadata_workers =
55 |
56 | # Number of backlog requests to configure the metadata server socket with
57 | # metadata_backlog = 4096
58 |
59 | # URL to connect to the cache backend.
60 | # default_ttl=0 parameter will cause cache entries to never expire.
61 | # Otherwise default_ttl specifies time in seconds a cache entry is valid for.
62 | # No cache is used in case no value is passed.
63 | # cache_url = memory://?default_ttl=5
64 | ```
65 |
--------------------------------------------------------------------------------
/etc/metering_agentini.md:
--------------------------------------------------------------------------------
1 | ## metering_agent.ini
2 | metering agent 的配置信息,包括 metering 的频率、driver 等。
3 |
4 | ```
5 | [DEFAULT]
6 | # Show debugging output in log (sets DEBUG log level output)
7 | # debug = True
8 |
9 | # Default driver:
10 | # driver = neutron.services.metering.drivers.noop.noop_driver.NoopMeteringDriver
11 | # Example of non-default driver
12 | # driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver
13 |
14 | # Interval between two metering measures
15 | # measure_interval = 30
16 |
17 | # Interval between two metering reports
18 | # report_interval = 300
19 |
20 | # interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
21 |
22 | # use_namespaces = True
23 |
24 | ```
25 |
--------------------------------------------------------------------------------
/etc/neutron.md:
--------------------------------------------------------------------------------
1 | ## neutron/
2 |
3 | ### plugins/
4 | 包括bigswitch、brocade、cisco、……等多种插件的配置文件(ini文件)。
5 |
6 | ### rootwrap.d
7 | 包括一系列的filter文件。包括debug.filters
8 | rootwrap是实现让非特权用户以root权限去运行某些命令。这些命令就在filter中指定。
9 | 以neutron用户为例,在/etc/sudoers.d/neutron文件中有
10 | ```
11 | neutron ALL = (root) NOPASSWD: SETENV: /usr/bin/neutron-rootwrap
12 | ```
13 | 使得neutron可以以root权限运行neutron-rootwrap。
14 |
15 | 而在/etc/neutron/rootwarp.conf中定义了
16 | ```
17 | filters_path=/etc/neutron/rootwrap.d,/usr/share/neutron/rootwrap,/etc/quantum/rootwrap.d,/usr/share/quantum/rootwrap
18 | ```
19 |
20 | 这些目录中定义了命令的filter,也就是说匹配这些filter中定义的命令就可以用root权限执行了。这些filter中命令的典型格式为
21 | ```
22 | cmd-name: filter-name, raw-command, user, args
23 | ```
24 |
25 | 例如/usr/share/neutron/rootwrap/dhcp.filters文件中的如下命令允许以root身份执行ovs-vsctl命令。
26 | ```
27 | ovs-vsctl: CommandFilter, ovs-vsctl, root
28 | ```
29 |
30 | 需要注意/etc/neutron/rootwrap.d,/usr/neutron/nova/rootwrap必须是root权限才能修改。
31 |
32 |
--------------------------------------------------------------------------------
/etc/neutronconf.md:
--------------------------------------------------------------------------------
1 | ## neutron.conf
2 | neutron-server 启动后读取的配置信息。
3 |
4 | ```
5 | [DEFAULT]
6 | # Print more verbose output (set logging level to INFO instead of default WARNING level).
7 | # verbose = False
8 |
9 | # =========Start Global Config Option for Distributed L3 Router===============
10 | # Setting the "router_distributed" flag to "True" will default to the creation
11 | # of distributed tenant routers. The admin can override this flag by specifying
12 | # the type of the router on the create request (admin-only attribute). Default
13 | # value is "False" to support legacy mode (centralized) routers.
14 | #
15 | # router_distributed = False
16 | #
17 | # ===========End Global Config Option for Distributed L3 Router===============
18 |
19 | # Print debugging output (set logging level to DEBUG instead of default WARNING level).
20 | # debug = False
21 |
22 | # Where to store Neutron state files. This directory must be writable by the
23 | # user executing the agent.
24 | # state_path = /var/lib/neutron
25 |
26 | # Where to store lock files
27 | lock_path = $state_path/lock
28 |
29 | # log_format = %(asctime)s %(levelname)8s [%(name)s] %(message)s
30 | # log_date_format = %Y-%m-%d %H:%M:%S
31 |
32 | # use_syslog -> syslog
33 | # log_file and log_dir -> log_dir/log_file
34 | # (not log_file) and log_dir -> log_dir/{binary_name}.log
35 | # use_stderr -> stderr
36 | # (not user_stderr) and (not log_file) -> stdout
37 | # publish_errors -> notification system
38 |
39 | # use_syslog = False
40 | # syslog_log_facility = LOG_USER
41 |
42 | # use_stderr = True
43 | # log_file =
44 | # log_dir =
45 |
46 | # publish_errors = False
47 |
48 | # Address to bind the API server to
49 | # bind_host = 0.0.0.0
50 |
51 | # Port the bind the API server to
52 | # bind_port = 9696
53 |
54 | # Path to the extensions. Note that this can be a colon-separated list of
55 | # paths. For example:
56 | # api_extensions_path = extensions:/path/to/more/extensions:/even/more/extensions
57 | # The __path__ of neutron.extensions is appended to this, so if your
58 | # extensions are in there you don't need to specify them here
59 | # api_extensions_path =
60 |
61 | # (StrOpt) Neutron core plugin entrypoint to be loaded from the
62 | # neutron.core_plugins namespace. See setup.cfg for the entrypoint names of the
63 | # plugins included in the neutron source distribution. For compatibility with
64 | # previous versions, the class name of a plugin can be specified instead of its
65 | # entrypoint name.
66 | #
67 | # core_plugin =
68 | # Example: core_plugin = ml2
69 |
70 | # (ListOpt) List of service plugin entrypoints to be loaded from the
71 | # neutron.service_plugins namespace. See setup.cfg for the entrypoint names of
72 | # the plugins included in the neutron source distribution. For compatibility
73 | # with previous versions, the class name of a plugin can be specified instead
74 | # of its entrypoint name.
75 | #
76 | # service_plugins =
77 | # Example: service_plugins = router,firewall,lbaas,vpnaas,metering
78 |
79 | # Paste configuration file
80 | # api_paste_config = api-paste.ini
81 |
82 | # The strategy to be used for auth.
83 | # Supported values are 'keystone'(default), 'noauth'.
84 | # auth_strategy = keystone
85 |
86 | # Base MAC address. The first 3 octets will remain unchanged. If the
87 | # 4h octet is not 00, it will also be used. The others will be
88 | # randomly generated.
89 | # 3 octet
90 | # base_mac = fa:16:3e:00:00:00
91 | # 4 octet
92 | # base_mac = fa:16:3e:4f:00:00
93 |
94 | # DVR Base MAC address. The first 3 octets will remain unchanged. If the
95 | # 4th octet is not 00, it will also be used. The others will be randomly
96 | # generated. The 'dvr_base_mac' *must* be different from 'base_mac' to
97 | # avoid mixing them up with MAC's allocated for tenant ports.
98 | # A 4 octet example would be dvr_base_mac = fa:16:3f:4f:00:00
99 | # The default is 3 octet
100 | # dvr_base_mac = fa:16:3f:00:00:00
101 |
102 | # Maximum amount of retries to generate a unique MAC address
103 | # mac_generation_retries = 16
104 |
105 | # DHCP Lease duration (in seconds). Use -1 to
106 | # tell dnsmasq to use infinite lease times.
107 | # dhcp_lease_duration = 86400
108 |
109 | # Allow sending resource operation notification to DHCP agent
110 | # dhcp_agent_notification = True
111 |
112 | # Enable or disable bulk create/update/delete operations
113 | # allow_bulk = True
114 | # Enable or disable pagination
115 | # allow_pagination = False
116 | # Enable or disable sorting
117 | # allow_sorting = False
118 | # Enable or disable overlapping IPs for subnets
119 | # Attention: the following parameter MUST be set to False if Neutron is
120 | # being used in conjunction with nova security groups
121 | # allow_overlapping_ips = False
122 | # Ensure that configured gateway is on subnet. For IPv6, validate only if
123 | # gateway is not a link local address. Deprecated, to be removed during the
124 | # K release, at which point the check will be mandatory.
125 | # force_gateway_on_subnet = True
126 |
127 | # Default maximum number of items returned in a single response,
128 | # value == infinite and value < 0 means no max limit, and value must
129 | # be greater than 0. If the number of items requested is greater than
130 | # pagination_max_limit, server will just return pagination_max_limit
131 | # of number of items.
132 | # pagination_max_limit = -1
133 |
134 | # Maximum number of DNS nameservers per subnet
135 | # max_dns_nameservers = 5
136 |
137 | # Maximum number of host routes per subnet
138 | # max_subnet_host_routes = 20
139 |
140 | # Maximum number of fixed ips per port
141 | # max_fixed_ips_per_port = 5
142 |
143 | # Maximum number of routes per router
144 | # max_routes = 30
145 |
146 | # =========== items for agent management extension =============
147 | # Seconds to regard the agent as down; should be at least twice
148 | # report_interval, to be sure the agent is down for good
149 | # agent_down_time = 75
150 | # =========== end of items for agent management extension =====
151 |
152 | # =========== items for agent scheduler extension =============
153 | # Driver to use for scheduling network to DHCP agent
154 | # network_scheduler_driver = neutron.scheduler.dhcp_agent_scheduler.ChanceScheduler
155 | # Driver to use for scheduling router to a default L3 agent
156 | # router_scheduler_driver = neutron.scheduler.l3_agent_scheduler.ChanceScheduler
157 | # Driver to use for scheduling a loadbalancer pool to an lbaas agent
158 | # loadbalancer_pool_scheduler_driver = neutron.services.loadbalancer.agent_scheduler.ChanceScheduler
159 |
160 | # Allow auto scheduling networks to DHCP agent. It will schedule non-hosted
161 | # networks to first DHCP agent which sends get_active_networks message to
162 | # neutron server
163 | # network_auto_schedule = True
164 |
165 | # Allow auto scheduling routers to L3 agent. It will schedule non-hosted
166 | # routers to first L3 agent which sends sync_routers message to neutron server
167 | # router_auto_schedule = True
168 |
169 | # Allow automatic rescheduling of routers from dead L3 agents with
170 | # admin_state_up set to True to alive agents.
171 | # allow_automatic_l3agent_failover = False
172 |
173 | # Number of DHCP agents scheduled to host a network. This enables redundant
174 | # DHCP agents for configured networks.
175 | # dhcp_agents_per_network = 1
176 |
177 | # =========== end of items for agent scheduler extension =====
178 |
179 | # =========== items for l3 extension ==============
180 | # Enable high availability for virtual routers.
181 | # l3_ha = False
182 | #
183 | # Maximum number of l3 agents which a HA router will be scheduled on. If it
184 | # is set to 0 the router will be scheduled on every agent.
185 | # max_l3_agents_per_router = 3
186 | #
187 | # Minimum number of l3 agents which a HA router will be scheduled on. The
188 | # default value is 2.
189 | # min_l3_agents_per_router = 2
190 | #
191 | # CIDR of the administrative network if HA mode is enabled
192 | # l3_ha_net_cidr = 169.254.192.0/18
193 | # =========== end of items for l3 extension =======
194 |
195 | # =========== WSGI parameters related to the API server ==============
196 | # Number of separate worker processes to spawn. The default, 0, runs the
197 | # worker thread in the current process. Greater than 0 launches that number of
198 | # child processes as workers. The parent process manages them.
199 | # api_workers = 0
200 |
201 | # Number of separate RPC worker processes to spawn. The default, 0, runs the
202 | # worker thread in the current process. Greater than 0 launches that number of
203 | # child processes as RPC workers. The parent process manages them.
204 | # This feature is experimental until issues are addressed and testing has been
205 | # enabled for various plugins for compatibility.
206 | # rpc_workers = 0
207 |
208 | # Sets the value of TCP_KEEPIDLE in seconds to use for each server socket when
209 | # starting API server. Not supported on OS X.
210 | # tcp_keepidle = 600
211 |
212 | # Number of seconds to keep retrying to listen
213 | # retry_until_window = 30
214 |
215 | # Number of backlog requests to configure the socket with.
216 | # backlog = 4096
217 |
218 | # Max header line to accommodate large tokens
219 | # max_header_line = 16384
220 |
221 | # Enable SSL on the API server
222 | # use_ssl = False
223 |
224 | # Certificate file to use when starting API server securely
225 | # ssl_cert_file = /path/to/certfile
226 |
227 | # Private key file to use when starting API server securely
228 | # ssl_key_file = /path/to/keyfile
229 |
230 | # CA certificate file to use when starting API server securely to
231 | # verify connecting clients. This is an optional parameter only required if
232 | # API clients need to authenticate to the API server using SSL certificates
233 | # signed by a trusted CA
234 | # ssl_ca_file = /path/to/cafile
235 | # ======== end of WSGI parameters related to the API server ==========
236 |
237 |
238 | # ======== neutron nova interactions ==========
239 | # Send notification to nova when port status is active.
240 | # notify_nova_on_port_status_changes = True
241 |
242 | # Send notifications to nova when port data (fixed_ips/floatingips) change
243 | # so nova can update it's cache.
244 | # notify_nova_on_port_data_changes = True
245 |
246 | # URL for connection to nova (Only supports one nova region currently).
247 | # nova_url = http://127.0.0.1:8774/v2
248 |
249 | # Name of nova region to use. Useful if keystone manages more than one region
250 | # nova_region_name =
251 |
252 | # Username for connection to nova in admin context
253 | # nova_admin_username =
254 |
255 | # The uuid of the admin nova tenant
256 | # nova_admin_tenant_id =
257 |
258 | # The name of the admin nova tenant. If the uuid of the admin nova tenant
259 | # is set, this is optional. Useful for cases where the uuid of the admin
260 | # nova tenant is not available when configuration is being done.
261 | # nova_admin_tenant_name =
262 |
263 | # Password for connection to nova in admin context.
264 | # nova_admin_password =
265 |
266 | # Authorization URL for connection to nova in admin context.
267 | # nova_admin_auth_url =
268 |
269 | # CA file for novaclient to verify server certificates
270 | # nova_ca_certificates_file =
271 |
272 | # Boolean to control ignoring SSL errors on the nova url
273 | # nova_api_insecure = False
274 |
275 | # Number of seconds between sending events to nova if there are any events to send
276 | # send_events_interval = 2
277 |
278 | # ======== end of neutron nova interactions ==========
279 |
280 | #
281 | # Options defined in oslo.messaging
282 | #
283 |
284 | # Use durable queues in amqp. (boolean value)
285 | # Deprecated group/name - [DEFAULT]/rabbit_durable_queues
286 | #amqp_durable_queues=false
287 |
288 | # Auto-delete queues in amqp. (boolean value)
289 | #amqp_auto_delete=false
290 |
291 | # Size of RPC connection pool. (integer value)
292 | #rpc_conn_pool_size=30
293 |
294 | # Qpid broker hostname. (string value)
295 | #qpid_hostname=localhost
296 |
297 | # Qpid broker port. (integer value)
298 | #qpid_port=5672
299 |
300 | # Qpid HA cluster host:port pairs. (list value)
301 | #qpid_hosts=$qpid_hostname:$qpid_port
302 |
303 | # Username for Qpid connection. (string value)
304 | #qpid_username=
305 |
306 | # Password for Qpid connection. (string value)
307 | #qpid_password=
308 |
309 | # Space separated list of SASL mechanisms to use for auth.
310 | # (string value)
311 | #qpid_sasl_mechanisms=
312 |
313 | # Seconds between connection keepalive heartbeats. (integer
314 | # value)
315 | #qpid_heartbeat=60
316 |
317 | # Transport to use, either 'tcp' or 'ssl'. (string value)
318 | #qpid_protocol=tcp
319 |
320 | # Whether to disable the Nagle algorithm. (boolean value)
321 | #qpid_tcp_nodelay=true
322 |
323 | # The qpid topology version to use. Version 1 is what was
324 | # originally used by impl_qpid. Version 2 includes some
325 | # backwards-incompatible changes that allow broker federation
326 | # to work. Users should update to version 2 when they are
327 | # able to take everything down, as it requires a clean break.
328 | # (integer value)
329 | #qpid_topology_version=1
330 |
331 | # SSL version to use (valid only if SSL enabled). valid values
332 | # are TLSv1, SSLv23 and SSLv3. SSLv2 may be available on some
333 | # distributions. (string value)
334 | #kombu_ssl_version=
335 |
336 | # SSL key file (valid only if SSL enabled). (string value)
337 | #kombu_ssl_keyfile=
338 |
339 | # SSL cert file (valid only if SSL enabled). (string value)
340 | #kombu_ssl_certfile=
341 |
342 | # SSL certification authority file (valid only if SSL
343 | # enabled). (string value)
344 | #kombu_ssl_ca_certs=
345 |
346 | # How long to wait before reconnecting in response to an AMQP
347 | # consumer cancel notification. (floating point value)
348 | #kombu_reconnect_delay=1.0
349 |
350 | # The RabbitMQ broker address where a single node is used.
351 | # (string value)
352 | #rabbit_host=localhost
353 |
354 | # The RabbitMQ broker port where a single node is used.
355 | # (integer value)
356 | #rabbit_port=5672
357 |
358 | # RabbitMQ HA cluster host:port pairs. (list value)
359 | #rabbit_hosts=$rabbit_host:$rabbit_port
360 |
361 | # Connect over SSL for RabbitMQ. (boolean value)
362 | #rabbit_use_ssl=false
363 |
364 | # The RabbitMQ userid. (string value)
365 | #rabbit_userid=guest
366 |
367 | # The RabbitMQ password. (string value)
368 | #rabbit_password=guest
369 |
370 | # the RabbitMQ login method (string value)
371 | #rabbit_login_method=AMQPLAIN
372 |
373 | # The RabbitMQ virtual host. (string value)
374 | #rabbit_virtual_host=/
375 |
376 | # How frequently to retry connecting with RabbitMQ. (integer
377 | # value)
378 | #rabbit_retry_interval=1
379 |
380 | # How long to backoff for between retries when connecting to
381 | # RabbitMQ. (integer value)
382 | #rabbit_retry_backoff=2
383 |
384 | # Maximum number of RabbitMQ connection retries. Default is 0
385 | # (infinite retry count). (integer value)
386 | #rabbit_max_retries=0
387 |
388 | # Use HA queues in RabbitMQ (x-ha-policy: all). If you change
389 | # this option, you must wipe the RabbitMQ database. (boolean
390 | # value)
391 | #rabbit_ha_queues=false
392 |
393 | # If passed, use a fake RabbitMQ provider. (boolean value)
394 | #fake_rabbit=false
395 |
396 | # ZeroMQ bind address. Should be a wildcard (*), an ethernet
397 | # interface, or IP. The "host" option should point or resolve
398 | # to this address. (string value)
399 | #rpc_zmq_bind_address=*
400 |
401 | # MatchMaker driver. (string value)
402 | #rpc_zmq_matchmaker=oslo.messaging._drivers.matchmaker.MatchMakerLocalhost
403 |
404 | # ZeroMQ receiver listening port. (integer value)
405 | #rpc_zmq_port=9501
406 |
407 | # Number of ZeroMQ contexts, defaults to 1. (integer value)
408 | #rpc_zmq_contexts=1
409 |
410 | # Maximum number of ingress messages to locally buffer per
411 | # topic. Default is unlimited. (integer value)
412 | #rpc_zmq_topic_backlog=
413 |
414 | # Directory for holding IPC sockets. (string value)
415 | #rpc_zmq_ipc_dir=/var/run/openstack
416 |
417 | # Name of this node. Must be a valid hostname, FQDN, or IP
418 | # address. Must match "host" option, if running Nova. (string
419 | # value)
420 | #rpc_zmq_host=oslo
421 |
422 | # Seconds to wait before a cast expires (TTL). Only supported
423 | # by impl_zmq. (integer value)
424 | #rpc_cast_timeout=30
425 |
426 | # Heartbeat frequency. (integer value)
427 | #matchmaker_heartbeat_freq=300
428 |
429 | # Heartbeat time-to-live. (integer value)
430 | #matchmaker_heartbeat_ttl=600
431 |
432 | # Size of RPC greenthread pool. (integer value)
433 | #rpc_thread_pool_size=64
434 |
435 | # Driver or drivers to handle sending notifications. (multi
436 | # valued)
437 | #notification_driver=
438 |
439 | # AMQP topic used for OpenStack notifications. (list value)
440 | # Deprecated group/name - [rpc_notifier2]/topics
441 | #notification_topics=notifications
442 |
443 | # Seconds to wait for a response from a call. (integer value)
444 | #rpc_response_timeout=60
445 |
446 | # A URL representing the messaging driver to use and its full
447 | # configuration. If not set, we fall back to the rpc_backend
448 | # option and driver specific configuration. (string value)
449 | #transport_url=
450 |
451 | # The messaging driver to use, defaults to rabbit. Other
452 | # drivers include qpid and zmq. (string value)
453 | #rpc_backend=rabbit
454 |
455 | # The default exchange under which topics are scoped. May be
456 | # overridden by an exchange name specified in the
457 | # transport_url option. (string value)
458 | #control_exchange=openstack
459 |
460 |
461 | [matchmaker_redis]
462 |
463 | #
464 | # Options defined in oslo.messaging
465 | #
466 |
467 | # Host to locate redis. (string value)
468 | #host=127.0.0.1
469 |
470 | # Use this port to connect to redis host. (integer value)
471 | #port=6379
472 |
473 | # Password for Redis server (optional). (string value)
474 | #password=
475 |
476 |
477 | [matchmaker_ring]
478 |
479 | #
480 | # Options defined in oslo.messaging
481 | #
482 |
483 | # Matchmaker ring file (JSON). (string value)
484 | # Deprecated group/name - [DEFAULT]/matchmaker_ringfile
485 | #ringfile=/etc/oslo/matchmaker_ring.json
486 |
487 | [quotas]
488 | # Default driver to use for quota checks
489 | # quota_driver = neutron.db.quota_db.DbQuotaDriver
490 |
491 | # Resource name(s) that are supported in quota features
492 | # quota_items = network,subnet,port
493 |
494 | # Default number of resource allowed per tenant. A negative value means
495 | # unlimited.
496 | # default_quota = -1
497 |
498 | # Number of networks allowed per tenant. A negative value means unlimited.
499 | # quota_network = 10
500 |
501 | # Number of subnets allowed per tenant. A negative value means unlimited.
502 | # quota_subnet = 10
503 |
504 | # Number of ports allowed per tenant. A negative value means unlimited.
505 | # quota_port = 50
506 |
507 | # Number of security groups allowed per tenant. A negative value means
508 | # unlimited.
509 | # quota_security_group = 10
510 |
511 | # Number of security group rules allowed per tenant. A negative value means
512 | # unlimited.
513 | # quota_security_group_rule = 100
514 |
515 | # Number of vips allowed per tenant. A negative value means unlimited.
516 | # quota_vip = 10
517 |
518 | # Number of pools allowed per tenant. A negative value means unlimited.
519 | # quota_pool = 10
520 |
521 | # Number of pool members allowed per tenant. A negative value means unlimited.
522 | # The default is unlimited because a member is not a real resource consumer
523 | # on Openstack. However, on back-end, a member is a resource consumer
524 | # and that is the reason why quota is possible.
525 | # quota_member = -1
526 |
527 | # Number of health monitors allowed per tenant. A negative value means
528 | # unlimited.
529 | # The default is unlimited because a health monitor is not a real resource
530 | # consumer on Openstack. However, on back-end, a member is a resource consumer
531 | # and that is the reason why quota is possible.
532 | # quota_health_monitor = -1
533 |
534 | # Number of routers allowed per tenant. A negative value means unlimited.
535 | # quota_router = 10
536 |
537 | # Number of floating IPs allowed per tenant. A negative value means unlimited.
538 | # quota_floatingip = 50
539 |
540 | # Number of firewalls allowed per tenant. A negative value means unlimited.
541 | # quota_firewall = 1
542 |
543 | # Number of firewall policies allowed per tenant. A negative value means
544 | # unlimited.
545 | # quota_firewall_policy = 1
546 |
547 | # Number of firewall rules allowed per tenant. A negative value means
548 | # unlimited.
549 | # quota_firewall_rule = 100
550 |
551 | [agent]
552 | # Use "sudo neutron-rootwrap /etc/neutron/rootwrap.conf" to use the real
553 | # root filter facility.
554 | # Change to "sudo" to skip the filtering and just run the comand directly
555 | # root_helper = sudo
556 |
557 | # Set to true to add comments to generated iptables rules that describe
558 | # each rule's purpose. (System must support the iptables comments module.)
559 | # comment_iptables_rules = True
560 |
561 | # =========== items for agent management extension =============
562 | # seconds between nodes reporting state to server; should be less than
563 | # agent_down_time, best if it is half or less than agent_down_time
564 | # report_interval = 30
565 |
566 | # =========== end of items for agent management extension =====
567 |
568 | [keystone_authtoken]
569 | auth_host = 127.0.0.1
570 | auth_port = 35357
571 | auth_protocol = http
572 | admin_tenant_name = %SERVICE_TENANT_NAME%
573 | admin_user = %SERVICE_USER%
574 | admin_password = %SERVICE_PASSWORD%
575 |
576 | [database]
577 | # This line MUST be changed to actually run the plugin.
578 | # Example:
579 | # connection = mysql://root:pass@127.0.0.1:3306/neutron
580 | # Replace 127.0.0.1 above with the IP address of the database used by the
581 | # main neutron server. (Leave it as is if the database runs on this host.)
582 | # connection = sqlite://
583 | # NOTE: In deployment the [database] section and its connection attribute may
584 | # be set in the corresponding core plugin '.ini' file. However, it is suggested
585 | # to put the [database] section and its connection attribute in this
586 | # configuration file.
587 |
588 | # Database engine for which script will be generated when using offline
589 | # migration
590 | # engine =
591 |
592 | # The SQLAlchemy connection string used to connect to the slave database
593 | # slave_connection =
594 |
595 | # Database reconnection retry times - in event connectivity is lost
596 | # set to -1 implies an infinite retry count
597 | # max_retries = 10
598 |
599 | # Database reconnection interval in seconds - if the initial connection to the
600 | # database fails
601 | # retry_interval = 10
602 |
603 | # Minimum number of SQL connections to keep open in a pool
604 | # min_pool_size = 1
605 |
606 | # Maximum number of SQL connections to keep open in a pool
607 | # max_pool_size = 10
608 |
609 | # Timeout in seconds before idle sql connections are reaped
610 | # idle_timeout = 3600
611 |
612 | # If set, use this value for max_overflow with sqlalchemy
613 | # max_overflow = 20
614 |
615 | # Verbosity of SQL debugging information. 0=None, 100=Everything
616 | # connection_debug = 0
617 |
618 | # Add python stack traces to SQL as comment strings
619 | # connection_trace = False
620 |
621 | # If set, use this value for pool_timeout with sqlalchemy
622 | # pool_timeout = 10
623 |
624 | [service_providers]
625 | # Specify service providers (drivers) for advanced services like loadbalancer, VPN, Firewall.
626 | # Must be in form:
627 | # service_provider=::[:default]
628 | # List of allowed service types includes LOADBALANCER, FIREWALL, VPN
629 | # Combination of and must be unique; must also be unique
630 | # This is multiline option, example for default provider:
631 | # service_provider=LOADBALANCER:name:lbaas_plugin_driver_path:default
632 | # example of non-default provider:
633 | # service_provider=FIREWALL:name2:firewall_driver_path
634 | # --- Reference implementations ---
635 | service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
636 | service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
637 | # In order to activate Radware's lbaas driver you need to uncomment the next line.
638 | # If you want to keep the HA Proxy as the default lbaas driver, remove the attribute default from the line below.
639 | # Otherwise comment the HA Proxy line
640 | # service_provider = LOADBALANCER:Radware:neutron.services.loadbalancer.drivers.radware.driver.LoadBalancerDriver:default
641 | # uncomment the following line to make the 'netscaler' LBaaS provider available.
642 | # service_provider=LOADBALANCER:NetScaler:neutron.services.loadbalancer.drivers.netscaler.netscaler_driver.NetScalerPluginDriver
643 | # Uncomment the following line (and comment out the OpenSwan VPN line) to enable Cisco's VPN driver.
644 | # service_provider=VPN:cisco:neutron.services.vpn.service_drivers.cisco_ipsec.CiscoCsrIPsecVPNDriver:default
645 | # Uncomment the line below to use Embrane heleos as Load Balancer service provider.
646 | # service_provider=LOADBALANCER:Embrane:neutron.services.loadbalancer.drivers.embrane.driver.EmbraneLbaas:default
647 | # Uncomment the line below to use the A10 Networks LBaaS driver. Requires 'pip install a10-neutron-lbaas'.
648 | #service_provider = LOADBALANCER:A10Networks:neutron.services.loadbalancer.drivers.a10networks.driver_v1.ThunderDriver:default
649 | # Uncomment the following line to test the LBaaS v2 API _WITHOUT_ a real backend
650 | # service_provider = LOADBALANCER:LoggingNoop:neutron.services.loadbalancer.drivers.logging_noop.driver.LoggingNoopLoadBalancerDriver:default
651 | ```
652 |
--------------------------------------------------------------------------------
/etc/policyjson.md:
--------------------------------------------------------------------------------
1 | ## policy.json
2 | 配置策略。每次进行API调用时,会采取对应的检查,policy.json文件发生更新后会立即生效。
3 |
4 | 目前支持的策略有三种:rule、role或者generic。
5 |
6 | 其中rule后面会跟一个文件名,例如
7 | ```
8 | "get_floatingip": "rule:admin_or_owner",
9 | ```
10 |
11 | 其策略为rule:admin_or_owner,表明要从文件中读取具体策略内容。
12 | role策略后面会跟一个role名称,表明只有指定role才可以执行。
13 | generic策略则根据参数来进行比较。
14 |
15 | ```
16 | {
17 | "context_is_admin": "role:admin",
18 | "admin_or_owner": "rule:context_is_admin or tenant_id:%(tenant_id)s",
19 | "context_is_advsvc": "role:advsvc",
20 | "admin_or_network_owner": "rule:context_is_admin or tenant_id:%(network:tenant_id)s",
21 | "admin_only": "rule:context_is_admin",
22 | "regular_user": "",
23 | "shared": "field:networks:shared=True",
24 | "shared_firewalls": "field:firewalls:shared=True",
25 | "external": "field:networks:router:external=True",
26 | "default": "rule:admin_or_owner",
27 |
28 | "create_subnet": "rule:admin_or_network_owner",
29 | "get_subnet": "rule:admin_or_owner or rule:shared",
30 | "update_subnet": "rule:admin_or_network_owner",
31 | "delete_subnet": "rule:admin_or_network_owner",
32 |
33 | "create_network": "",
34 | "get_network": "rule:admin_or_owner or rule:shared or rule:external or rule:context_is_advsvc",
35 | "get_network:router:external": "rule:regular_user",
36 | "get_network:segments": "rule:admin_only",
37 | "get_network:provider:network_type": "rule:admin_only",
38 | "get_network:provider:physical_network": "rule:admin_only",
39 | "get_network:provider:segmentation_id": "rule:admin_only",
40 | "get_network:queue_id": "rule:admin_only",
41 | "create_network:shared": "rule:admin_only",
42 | "create_network:router:external": "rule:admin_only",
43 | "create_network:segments": "rule:admin_only",
44 | "create_network:provider:network_type": "rule:admin_only",
45 | "create_network:provider:physical_network": "rule:admin_only",
46 | "create_network:provider:segmentation_id": "rule:admin_only",
47 | "update_network": "rule:admin_or_owner",
48 | "update_network:segments": "rule:admin_only",
49 | "update_network:shared": "rule:admin_only",
50 | "update_network:provider:network_type": "rule:admin_only",
51 | "update_network:provider:physical_network": "rule:admin_only",
52 | "update_network:provider:segmentation_id": "rule:admin_only",
53 | "update_network:router:external": "rule:admin_only",
54 | "delete_network": "rule:admin_or_owner",
55 |
56 | "create_port": "",
57 | "create_port:mac_address": "rule:admin_or_network_owner or rule:context_is_advsvc",
58 | "create_port:fixed_ips": "rule:admin_or_network_owner or rule:context_is_advsvc",
59 | "create_port:port_security_enabled": "rule:admin_or_network_owner or rule:context_is_advsvc",
60 | "create_port:binding:host_id": "rule:admin_only",
61 | "create_port:binding:profile": "rule:admin_only",
62 | "create_port:mac_learning_enabled": "rule:admin_or_network_owner or rule:context_is_advsvc",
63 | "get_port": "rule:admin_or_owner or rule:context_is_advsvc",
64 | "get_port:queue_id": "rule:admin_only",
65 | "get_port:binding:vif_type": "rule:admin_only",
66 | "get_port:binding:vif_details": "rule:admin_only",
67 | "get_port:binding:host_id": "rule:admin_only",
68 | "get_port:binding:profile": "rule:admin_only",
69 | "update_port": "rule:admin_or_owner or rule:context_is_advsvc",
70 | "update_port:fixed_ips": "rule:admin_or_network_owner or rule:context_is_advsvc",
71 | "update_port:port_security_enabled": "rule:admin_or_network_owner or rule:context_is_advsvc",
72 | "update_port:binding:host_id": "rule:admin_only",
73 | "update_port:binding:profile": "rule:admin_only",
74 | "update_port:mac_learning_enabled": "rule:admin_or_network_owner or rule:context_is_advsvc",
75 | "delete_port": "rule:admin_or_owner or rule:context_is_advsvc",
76 |
77 | "get_router:ha": "rule:admin_only",
78 | "create_router": "rule:regular_user",
79 | "create_router:external_gateway_info:enable_snat": "rule:admin_only",
80 | "create_router:distributed": "rule:admin_only",
81 | "create_router:ha": "rule:admin_only",
82 | "get_router": "rule:admin_or_owner",
83 | "get_router:distributed": "rule:admin_only",
84 | "update_router:external_gateway_info:enable_snat": "rule:admin_only",
85 | "update_router:distributed": "rule:admin_only",
86 | "update_router:ha": "rule:admin_only",
87 | "delete_router": "rule:admin_or_owner",
88 |
89 | "add_router_interface": "rule:admin_or_owner",
90 | "remove_router_interface": "rule:admin_or_owner",
91 |
92 | "create_firewall": "",
93 | "get_firewall": "rule:admin_or_owner",
94 | "create_firewall:shared": "rule:admin_only",
95 | "get_firewall:shared": "rule:admin_only",
96 | "update_firewall": "rule:admin_or_owner",
97 | "update_firewall:shared": "rule:admin_only",
98 | "delete_firewall": "rule:admin_or_owner",
99 |
100 | "create_firewall_policy": "",
101 | "get_firewall_policy": "rule:admin_or_owner or rule:shared_firewalls",
102 | "create_firewall_policy:shared": "rule:admin_or_owner",
103 | "update_firewall_policy": "rule:admin_or_owner",
104 | "delete_firewall_policy": "rule:admin_or_owner",
105 |
106 | "create_firewall_rule": "",
107 | "get_firewall_rule": "rule:admin_or_owner or rule:shared_firewalls",
108 | "update_firewall_rule": "rule:admin_or_owner",
109 | "delete_firewall_rule": "rule:admin_or_owner",
110 |
111 | "create_qos_queue": "rule:admin_only",
112 | "get_qos_queue": "rule:admin_only",
113 |
114 | "update_agent": "rule:admin_only",
115 | "delete_agent": "rule:admin_only",
116 | "get_agent": "rule:admin_only",
117 |
118 | "create_dhcp-network": "rule:admin_only",
119 | "delete_dhcp-network": "rule:admin_only",
120 | "get_dhcp-networks": "rule:admin_only",
121 | "create_l3-router": "rule:admin_only",
122 | "delete_l3-router": "rule:admin_only",
123 | "get_l3-routers": "rule:admin_only",
124 | "get_dhcp-agents": "rule:admin_only",
125 | "get_l3-agents": "rule:admin_only",
126 | "get_loadbalancer-agent": "rule:admin_only",
127 | "get_loadbalancer-pools": "rule:admin_only",
128 |
129 | "create_floatingip": "rule:regular_user",
130 | "update_floatingip": "rule:admin_or_owner",
131 | "delete_floatingip": "rule:admin_or_owner",
132 | "get_floatingip": "rule:admin_or_owner",
133 |
134 | "create_network_profile": "rule:admin_only",
135 | "update_network_profile": "rule:admin_only",
136 | "delete_network_profile": "rule:admin_only",
137 | "get_network_profiles": "",
138 | "get_network_profile": "",
139 | "update_policy_profiles": "rule:admin_only",
140 | "get_policy_profiles": "",
141 | "get_policy_profile": "",
142 |
143 | "create_metering_label": "rule:admin_only",
144 | "delete_metering_label": "rule:admin_only",
145 | "get_metering_label": "rule:admin_only",
146 |
147 | "create_metering_label_rule": "rule:admin_only",
148 | "delete_metering_label_rule": "rule:admin_only",
149 | "get_metering_label_rule": "rule:admin_only",
150 |
151 | "get_service_provider": "rule:regular_user",
152 | "get_lsn": "rule:admin_only",
153 | "create_lsn": "rule:admin_only"
154 | }
155 | ```
156 |
--------------------------------------------------------------------------------
/etc/rootwrapconf.md:
--------------------------------------------------------------------------------
1 | ## rootwrap.conf
2 | neutron-rootwrap的配置文件。
3 | 给定了一系列的filter文件路径和可执行文件路径,以及log信息。
4 |
5 | ```
6 | # Configuration for neutron-rootwrap
7 | # This file should be owned by (and only-writeable by) the root user
8 |
9 | [DEFAULT]
10 | # List of directories to load filter definitions from (separated by ',').
11 | # These directories MUST all be only writeable by root !
12 | filters_path=/etc/neutron/rootwrap.d,/usr/share/neutron/rootwrap
13 |
14 | # List of directories to search executables in, in case filters do not
15 | # explicitely specify a full path (separated by ',')
16 | # If not specified, defaults to system PATH environment variable.
17 | # These directories MUST all be only writeable by root !
18 | exec_dirs=/sbin,/usr/sbin,/bin,/usr/bin
19 |
20 | # Enable logging to syslog
21 | # Default value is False
22 | use_syslog=False
23 |
24 | # Which syslog facility to use.
25 | # Valid values include auth, authpriv, syslog, local0, local1...
26 | # Default value is 'syslog'
27 | syslog_log_facility=syslog
28 |
29 | # Which messages to log.
30 | # INFO means log all usage
31 | # ERROR means only log unsuccessful attempts
32 | syslog_log_level=ERROR
33 |
34 | [xenapi]
35 | # XenAPI configuration is only required by the L2 agent if it is to
36 | # target a XenServer/XCP compute host's dom0.
37 | xenapi_connection_url=
38 | xenapi_connection_username=root
39 | xenapi_connection_password=
40 | ```
41 |
--------------------------------------------------------------------------------
/etc/servicesconf.md:
--------------------------------------------------------------------------------
1 | ## services.conf
2 | 配置一些特殊的 service 信息。
3 |
4 | ```
5 | [radware]
6 | #vdirect_address = 0.0.0.0
7 | #ha_secondary_address=
8 | #vdirect_user = vDirect
9 | #vdirect_password = radware
10 | #service_ha_pair = False
11 | #service_throughput = 1000
12 | #service_ssl_throughput = 200
13 | #service_compression_throughput = 100
14 | #service_cache = 20
15 | #service_adc_type = VA
16 | #service_adc_version=
17 | #service_session_mirroring_enabled = False
18 | #service_isl_vlan = -1
19 | #service_resource_pool_ids = []
20 | #actions_to_skip = 'setup_l2_l3'
21 | #l4_action_name = 'BaseCreate'
22 | #l2_l3_workflow_name = openstack_l2_l3
23 | #l4_workflow_name = openstack_l4
24 | #l2_l3_ctor_params = service: _REPLACE_, ha_network_name: HA-Network, ha_ip_pool_name: default, allocate_ha_vrrp: True, allocate_ha_ips: True
25 | #l2_l3_setup_params = data_port: 1, data_ip_address: 192.168.200.99, data_ip_mask: 255.255.255.0, gateway: 192.168.200.1, ha_port: 2
26 |
27 | [netscaler_driver]
28 | #netscaler_ncc_uri = https://ncc_server.acme.org/ncc/v1/api
29 | #netscaler_ncc_username = admin
30 | #netscaler_ncc_password = secret
31 |
32 | [heleoslb]
33 | #esm_mgmt =
34 | #admin_username =
35 | #admin_password =
36 | #lb_image =
37 | #inband_id =
38 | #oob_id =
39 | #mgmt_id =
40 | #dummy_utif_id =
41 | #resource_pool_id =
42 | #async_requests =
43 | #lb_flavor = small
44 | #sync_interval = 60
45 | ```
46 |
--------------------------------------------------------------------------------
/etc/vpn_agentini.md:
--------------------------------------------------------------------------------
1 | ## vpn_agent.ini
2 | 配置 vpn agent 的参数,vpn agent 是从 L3 agent 继承来的,也可以在 L3 agent 中对相应参数进行配置。
3 | ```
4 | [DEFAULT]
5 | # VPN-Agent configuration file
6 | # Note vpn-agent inherits l3-agent, so you can use configs on l3-agent also
7 |
8 | [vpnagent]
9 | # vpn device drivers which vpn agent will use
10 | # If we want to use multiple drivers, we need to define this option multiple times.
11 | # vpn_device_driver=neutron.services.vpn.device_drivers.ipsec.OpenSwanDriver
12 | # vpn_device_driver=neutron.services.vpn.device_drivers.cisco_ipsec.CiscoCsrIPsecDriver
13 | # vpn_device_driver=another_driver
14 |
15 | [ipsec]
16 | # Status check interval
17 | # ipsec_status_check_interval=60
18 |
19 | ```
20 |
--------------------------------------------------------------------------------
/neutron/README.md:
--------------------------------------------------------------------------------
1 | # neutron
2 | 该目录下包含了neutron实现的主要代码。
3 | neutron从设计理念上来看,可以分为neutron-server相关(含各种plugin)和neutron-agent相关两大部分。
4 | 其中neutron-server维护high-level的抽象网络管理,并通过不同产品的plugin(这些plugin需要实现neutron定义的一系列操作网络的API)转化为各自agent能理解的指令,agent具体执行指令。简单的说,neutron-server是做决策的,各种neutron-agent是实际干活的,plugin是上下沟通的。如图表 1 所示。在这种结构中,同一时间只能有一套 plugin--agent 机制发生作用。
5 |
6 | 
7 |
8 | 目前,ML2子项目希望统一plugin对上接口,通过提供不同的驱动,来沟通不同产品的实现机制。
9 |
--------------------------------------------------------------------------------
/neutron/agent/README.md:
--------------------------------------------------------------------------------
1 | ## agent
2 | 在 neutron 的架构中,各种 agent 运行在计算节点和网络节点上,接收来自 neutron-server 的 plugin 的指令,对所管理的网桥进行实际的操作,属于“直接干活”的部分。plugin 和 agent 之间进行双向交互,一般的,每个 plugin 会创建一个 RPC server 来监听 agent 的请求。
3 |
4 | agent 可以大致分为 core agent、dhcp、l3 和其它(metadata等)。
5 | 本部分代码实现各种 agent 所需要的操作接口和库函数。
6 |
--------------------------------------------------------------------------------
/neutron/agent/common.md:
--------------------------------------------------------------------------------
1 | ### common/
2 | 主要包括 config.py,其中定义了 agent 的一些配置的关键字和默认值,和一些注册配置的函数。
3 |
4 | #### 一些配置常量
5 | 包括:
6 | ```
7 | ROOT_HELPER_OPTS = [
8 | cfg.StrOpt('root_helper', default='sudo',
9 | help=_('Root helper application.')),
10 | ]
11 |
12 | AGENT_STATE_OPTS = [
13 | cfg.FloatOpt('report_interval', default=30,
14 | help=_('Seconds between nodes reporting state to server; '
15 | 'should be less than agent_down_time, best if it '
16 | 'is half or less than agent_down_time.')),
17 | ]
18 |
19 | INTERFACE_DRIVER_OPTS = [
20 | cfg.StrOpt('interface_driver',
21 | help=_("The driver used to manage the virtual interface.")),
22 | ]
23 |
24 | USE_NAMESPACES_OPTS = [
25 | cfg.BoolOpt('use_namespaces', default=True,
26 | help=_("Allow overlapping IP.")),
27 | ]
28 | ```
29 |
30 | #### 注册函数
31 | 往全局的 conf 中注册各个常量
32 |
--------------------------------------------------------------------------------
/neutron/agent/dhcp_agentpy.md:
--------------------------------------------------------------------------------
1 | ### dhcp_agent.py
2 | dhcp 服务的 agent 端,负责实现 dhcp 的分配等。
3 |
4 | 主要包括 DhcpAgent()类、继承自它的 DhcpAgentWithStateReport 类和继承自 RpcProxy 的 DhcpPluginApi 类。
5 |
6 | 主函数为
7 | ```
8 | def main():
9 | register_options()
10 | common_config.init(sys.argv[1:])
11 | config.setup_logging(cfg.CONF)
12 | server = neutron_service.Service.create(
13 | binary='neutron-dhcp-agent',
14 | topic=topics.DHCP_AGENT,
15 | report_interval=cfg.CONF.AGENT.report_interval,
16 | manager='neutron.agent.dhcp_agent.DhcpAgentWithStateReport')
17 | service.launch(server).wait()
18 | ```
19 | 读取和注册相关配置(包括dhcpagent、interface_driver、use_namespace等)。
20 | 然后创建一个neutron_service。绑定的主题是DHCP_AGENT,默认驱动是Dnsmasq,默认的管理器是DhcpAgentWithStateReport类
21 | 然后启动这个service。
22 |
23 | dhcp agent的任务包括:汇报状态、处理来自plugin的RPC调用 API、管理dhcp信息。
24 |
25 | plugin端的rpc调用方法(一般由neutron.api.v2.base.py发出通知)在neutron.api.rpc.agentnoftifiers.DhcpAgentNotifyAPI()类中实现,其中发出notification消息,会调用agent中对应的方法,包括(其中点符号替换为下划线符号)
26 | ```
27 | VALID_RESOURCES = ['network', 'subnet', 'port']
28 | VALID_METHOD_NAMES = ['network.create.end',
29 | 'network.update.end',
30 | 'network.delete.end',
31 | 'subnet.create.end',
32 | 'subnet.update.end',
33 | 'subnet.delete.end',
34 | 'port.create.end',
35 | 'port.update.end',
36 | 'port.delete.end']
37 | ```
38 |
39 | #### DhcpAgent类
40 | 继承自manager.Manager类。
41 |
42 | manager.Manager类继承自n_rpc.RpcCallback类和periodic_task.PeriodicTasks类,提供周期性运行任务的方法。
43 |
44 | 初始化方法会首先从配置中导入driver类信息,然后获取admin的上下文。之后创建一个DhcpPluginApi类作为向plugin发出rpc消息的handler。
45 |
46 | after_start()方法会调用run()方法,执行将neutron中状态同步到本地和孵化一个新的协程来周期性同步状态。
47 |
48 | ```
49 | def after_start(self):
50 | self.run()
51 | LOG.info(_("DHCP agent started"))
52 |
53 | def run(self):
54 | """Activate the DHCP agent."""
55 | self.sync_state()
56 | self.periodic_resync()
57 | ```
58 |
59 | 其中sync_state()会发出rpc消息给plugin,获取最新的网络状态,然后更新本地信息,调用dnsmasq进程使之生效。该方法在启动后运行一次。
60 | periodic_resync()方法则孵化一个协程来运行_periodic_resync_helper()方法,该函数是一个无限循环,它周期性的调用sync_state()。
61 |
62 |
63 | #### DhcpPluginApi类
64 | 提供从agent往plugin一侧进行rpc调用的api。
65 |
66 | #### DhcpAgentWithStateReport类
67 | 该类继承自DhcpAgent,主要添加了状态汇报。
68 | 汇报状态主要是DhcpAgentWithStateReport初始化中指定了一个agent_rpc.PluginReportStateAPI(topics.PLUGIN)类作为状态汇报rpc消息的处理handler。
69 |
70 | ```
71 | if report_interval:
72 | self.heartbeat = loopingcall.FixedIntervalLoopingCall(self._report_state)
73 | self.heartbeat.start(interval=report_interval)
74 | ```
75 |
76 | 这些代码会让_report_state()定期执行来汇报自身状态。
77 | 其中_report_state()方法主要代码为:
78 |
79 | ```
80 | self.agent_state.get('configurations').update(
81 | self.cache.get_state())
82 | ctx = context.get_admin_context_without_session()
83 | self.state_rpc.report_state(ctx, self.agent_state, self.use_call)
84 | ```
85 |
--------------------------------------------------------------------------------
/neutron/agent/firewallpy.md:
--------------------------------------------------------------------------------
1 | ### firewall.py
2 | 提供 FirewallDriver 元类和继承自它的简单的防火墙驱动类 NoopFirewallDriver。
3 |
--------------------------------------------------------------------------------
/neutron/agent/l2population_rpcpy.md:
--------------------------------------------------------------------------------
1 | ### l2population_rpc.py
2 | 主要定义了 L2populationRpcCallBackMixin 元类和 L2populationRpcCallBackTunnelMixin 类。
3 |
4 | 前者作为通用类,处理跟 L2populationRpc 相关的回调。
5 |
6 | 后者为隧道处理 L2population 的 Rpc 回调。
7 |
--------------------------------------------------------------------------------
/neutron/agent/l3_agentpy.md:
--------------------------------------------------------------------------------
1 | ### l3_agent.py
2 | 提供 L3 层服务的 agent,包括 L3NATAgent 类、继承自它的 L3NATAgentWithStateReport 类(作为manager)、继承自 n_rpc.RpcProxy 类的 L3PluginApi 类(作为 agent 调用 plugin 一侧的 api)和 RouterInfo 类。
3 |
4 | 主过程为
5 | ```
6 | def main(manager='neutron.agent.l3_agent.L3NATAgentWithStateReport'):
7 | _register_opts(cfg.CONF)
8 | common_config.init(sys.argv[1:])
9 | config.setup_logging()
10 | server = neutron_service.Service.create(
11 | binary='neutron-l3-agent',
12 | topic=topics.L3_AGENT,
13 | report_interval=cfg.CONF.AGENT.report_interval,
14 | manager=manager)
15 | service.launch(server).wait()
16 | ```
17 |
18 | 也是标准的 service 流程。
19 |
20 | 从 conf.CONF 中注册各个系统常量,包括 L3 相关 agent 的参数、接口驱动、命名空间等等。
21 |
22 | 启动一个管理 neutron-l3-agent 执行程序的服务,该服务将监听 topic 为 topics.L3_AGENT 的 RPC 消息队列,管理类为 L3NATAgentWithStateReport。
23 |
24 | #### L3NATAgent 类
25 | 继承自 firewall_l3_agent.FWaaSL3AgentRpcCallback、l3_ha_agent.AgentMixin 和 manager.Manager。
26 |
27 | 前者是由于现在的 FWaaS 设计都是挂载到 router 上的,因此,在创建router 的时候,需要把对应的 firewall 添加上。
28 |
29 | 而 Manager 作为一个进行rpc调用管理和执行周期性任务的基础类。
30 | 初始化中根据配置信息,导入 driver,获取 admin 的上下文,获取 L3PluginApi,然后定期执行 self._rpc_loop() 方法。该方法根据数据库中的信息来同步本地的 router。
31 |
32 | 调用 self._process_routers() 方法和 self._process_router_delete() 方法,这两个方法会进一步对本地的 iptables 进行操作,完成 router 的添加或删除。
33 |
34 | #### L3NATAgentWithStateReport类
35 | 该类是 L3 agent 资源 service 的 manager,其继承自 L3NATAgent,并添加了 rpc.PluginReportStateAPI 类来进行周期性状态汇报。
36 |
37 | 主要添加了两个方法。
38 | * `_report_state()`:定期的汇报自己的状态,以 `topic.PLUGIN` 作为主题向 rpc 队列中写入 agent 的状态信息消息。这些消息会被各个 plugin 收到。
39 | * `agent_updated()`:收到 agent_updated 消息的处理。
40 |
41 | #### L3PluginApi 类
42 | 继承自 `neutron.common.rpc.RpcProxy` 类,是一个进行 rpc 调用的代理。
43 |
44 | 被 L3NATAgent 类来调用,负责向 L3 的 Plugin 发出 rpc 消息(主题为 `topics.L3PLUGIN`),这些消息到达 plugin,最终被 plugin 的父类 neutron.db.l3_rpc_base.L3RpcCallbackMixin 类中的对应方法来处理,这些方法进一步调用父类 `neutron.db.l3_db.L3_NAT_db_mixin` 类中的对应方法跟数据库进行交互。
45 |
46 | 目前定义了下面几个方法:
47 | * `get_routers()` 通过 rpc 调用 L3 Plugin 的 sync_routers() 方法来来获取外部网络的id。
48 | * `get_external_network_id()` 通过 rpc 调用 external_network_id() 来获取外部网络的id。
49 | * `update_floatingip_statuses()` 通过 rpc 调用 update_floatingip_statuses() 来更新 floating ip 的状态。
50 | * `get_ports_by_subnet()` 通过 rpc 调用 get_ports_by_subnet() 来获取对应 subnet 中的端口信息。
51 | * `get_service_plugin_list()` 通过 rpc 调用 get_service_plugin_list() 来获取 L3 Plugin 中激活服务的列表。
52 |
53 |
--------------------------------------------------------------------------------
/neutron/agent/l3_ha_agentpy.md:
--------------------------------------------------------------------------------
1 | ### l3_ha_agent.py
2 | L3 的 HA 主要是通过 VRRP 来实现的,这里定义了两个类。
3 | * AgentMixin
4 | * RouterMixin
5 |
6 | 这两个类中都实现了跟 HA 相关的一些方法,供 L3 Agent 使用。
7 |
--------------------------------------------------------------------------------
/neutron/agent/linux.md:
--------------------------------------------------------------------------------
1 | ### linux/
2 | 主要包括跟 Linux 环境相关的一些函数实现,为各种 agent 调用系统命令进行包装,例如对 iptables 操作,ovs 操作等等。
3 |
4 | #### async_process.py
5 | 实现了AsyncProcess类,对异步进程进行管理。
6 |
7 | #### daemon.py
8 | 实现一个通用的Daemon基类。一个daemon意味着一个后台进程,可以通过对应的pid文件对其进行跟踪。
9 |
10 | #### dhcp.py
11 | 实现了Dnsmasq类、DhcpBase类、DhcpLocalProcess类、DeviceManager类、DicModel类、NetModel类。
12 |
13 | 对 Linux 环境下 dhcp 相关的分配和维护实现进行管理。
14 | 通过调用 dnsmasq 工具来管理 dhcp 的分配。
15 |
16 | #### external_process.py
17 | 定义了ProcessManager类,对neutron孵化出的进程进行管理(可以通过跟踪pid文件进行激活和禁用等)。
18 |
19 | #### interface.py
20 | 提供对网桥上的接口进行管理的一系列驱动。
21 |
22 | 定义了常见的配置信息,包括网桥名称,用户和密码等。
23 |
24 | 定义了几个不同类型网桥的接口驱动类,包括LinuxInterfaceDriver元类和由它派生出来的MetaInterfaceDriver、BridgeInterfaceDriver、IVSInterfaceDriver、MidonetInterfaceDriver、NullDriver和OVSInterfaceDriver等。
25 |
26 | 其中LinuxInterfaceDriver元类定义了plug()和unplug()两个抽象方法,需要继承类自己来实现。init_l3()方法则提供对接口进行IP地址的配置。
27 |
28 | #### ip_lib.py
29 | 对ip相关的命令进行封装,包括一些操作类。例如IpAddrCommand、IpLinkCommand、IpNetnsCommand、IpNeighCommand、IpRouteCommand、IpRule等。基本上需要对linux上ip相关的命令进行操作都可以通过这个库提供的接口进行。
30 |
31 | #### iptables_firewall.py
32 | 利用iptables的规则实现的防火墙驱动,主要包括两个防火墙驱动类。
33 | IptablesFirewallDriver,继承自firewall.FirewallDriver,默认通过iptables规则启用了security group功能,包括添加一条sg-chain链,为每个端口添加两条链(physdev-out和physdev-in)。
34 |
35 | OVSHybridIptablesFirewallDriver,继承自IptablesFirewallDriver,基本代码没动,修改了两个获取名字函数的实现:_port_chain_name()和_get_deice_name()。
36 |
37 | #### iptables_manager.py
38 | 对iptables规则、表资源进行封装,提供操作接口。
39 |
40 | 定义了IptablesManager类、IptablesRule类、IptablesTable类。
41 |
42 | 其中IptablesManager对iptables工具进行包装。首先,创建neutron-filter-top链,加载到FORWARD和OUTPUT两条链开头。默认的INPUT、OUTPUT、FORWARD链会被包装起来,即通过原始的链跳转到一个包装后的链。此外,neutron-filter-top链中有一条规则可以跳转到一条包装后的local链。
43 |
44 | #### ovs_lib.py
45 | 提供对OVS网桥的操作支持,包括一个VifPort,BaseOVS类和继承自它的OVSBridge类。提供对网桥、端口等资源的添加、删除,执行ovs-vsctl命令等。
46 |
47 | #### ovsdb_monitor.py
48 | 提供对ovsdb的监视器。包括一个OvsdbMonitor类(继承自neutron.agent.linux.async_process.AsyncProcess)和SimpleInterfaceMonitor类(继承自前者)。
49 |
50 | #### polling.py
51 | 监视ovsdb来决定何时进行polling。包括一个BasePollingManager和继承自它的InterfacePollingMinimizer类等。
52 |
53 | #### utils.py
54 | 一些辅助函数,包括create_process通过创建一个进程来执行命令、get_interface_mac、replace_file等。
55 |
--------------------------------------------------------------------------------
/neutron/agent/metadata.md:
--------------------------------------------------------------------------------
1 | ### metadata/
2 |
3 | #### agent.py
4 | 主要包括MetadataProxyHandler、UnixDomainHttpProtocol、WorkerService、UnixDomainWSGIServer、UnixDomainMetadataProxy几个类和一个main函数。
5 | 该文件的主逻辑代码为:
6 | ```
7 | cfg.CONF.register_opts(UnixDomainMetadataProxy.OPTS)
8 | cfg.CONF.register_opts(MetadataProxyHandler.OPTS)
9 | cache.register_oslo_configs(cfg.CONF)
10 | cfg.CONF.set_default(name='cache_url', default='memory://?default_ttl=5')
11 | agent_conf.register_agent_state_opts_helper(cfg.CONF)
12 | config.init(sys.argv[1:])
13 | config.setup_logging(cfg.CONF)
14 | utils.log_opt_values(LOG)
15 | proxy = UnixDomainMetadataProxy(cfg.CONF)
16 | proxy.run()
17 | ```
18 |
19 | 在读取相关配置完成后,则实例化一个UnixDomainMetadataProxy,并调用其run函数。run函数则进一步创建一个`server = UnixDomainWSGIServer('neutron-metadata-agent')` 对象,并调用其start()和wait()函数。
20 |
21 | run函数会将应用绑定到MetadataProxyHandler()类,该类包括一个`__call__`函数,调用_proxy_request()对传入的HTTP请求进行处理。
22 |
23 | #### namespace_proxy.py
24 | 定义了UnixDomainHTTPConnection、NetworkMetadataProxyHandler、ProxyDaemon三个类和主函数。主函数代码为
25 |
26 | ```
27 | eventlet.monkey_patch()
28 | opts = [
29 | cfg.StrOpt('network_id',
30 | help=_('Network that will have instance metadata '
31 | 'proxied.')),
32 | cfg.StrOpt('router_id',
33 | help=_('Router that will have connected instances\' '
34 | 'metadata proxied.')),
35 | cfg.StrOpt('pid_file',
36 | help=_('Location of pid file of this process.')),
37 | cfg.BoolOpt('daemonize',
38 | default=True,
39 | help=_('Run as daemon.')),
40 | cfg.IntOpt('metadata_port',
41 | default=9697,
42 | help=_("TCP Port to listen for metadata server "
43 | "requests.")),
44 | cfg.StrOpt('metadata_proxy_socket',
45 | default='$state_path/metadata_proxy',
46 | help=_('Location of Metadata Proxy UNIX domain '
47 | 'socket'))
48 | ]
49 |
50 | cfg.CONF.register_cli_opts(opts)
51 | # Don't get the default configuration file
52 | cfg.CONF(project='neutron', default_config_files=[])
53 | config.setup_logging(cfg.CONF)
54 | utils.log_opt_values(LOG)
55 | proxy = ProxyDaemon(cfg.CONF.pid_file,
56 | cfg.CONF.metadata_port,
57 | network_id=cfg.CONF.network_id,
58 | router_id=cfg.CONF.router_id)
59 |
60 | if cfg.CONF.daemonize:
61 | proxy.start()
62 | else:
63 | proxy.run()
64 | ```
65 |
66 | 其基本过程也是读取完成相关的配置信息,然后启动一个ProxyDaemon实例,以daemon或run方法来运行。run方法则创建一个wsgi服务器,然后运行。最终绑定的应用为NetworkMetadataProxyHandler。
67 |
68 | ```
69 | proxy = wsgi.Server('neutron-network-metadata-proxy')
70 | proxy.start(handler, self.port)
71 | proxy.wait()
72 | ```
73 |
--------------------------------------------------------------------------------
/neutron/agent/netns_cleanup_utilpy.md:
--------------------------------------------------------------------------------
1 | ### netns_cleanup_util.py
2 | 清理无用的网络名字空间。当neutron的agent非正常退出时可以通过该工具来清理环境。
3 |
4 | 主过程十分简单,第一步是获取可能的无用名字空间,第二步是sleep后清除这些名字空间。
5 |
6 | ```python
7 | def main():
8 | """Main method for cleaning up network namespaces.
9 |
10 | This method will make two passes checking for namespaces to delete. The
11 | process will identify candidates, sleep, and call garbage collect. The
12 | garbage collection will re-verify that the namespace meets the criteria for
13 | deletion (ie it is empty). The period of sleep and the 2nd pass allow
14 | time for the namespace state to settle, so that the check prior deletion
15 | will re-confirm the namespace is empty.
16 |
17 | The utility is designed to clean-up after the forced or unexpected
18 | termination of Neutron agents.
19 |
20 | The --force flag should only be used as part of the cleanup of a devstack
21 | installation as it will blindly purge namespaces and their devices. This
22 | option also kills any lingering DHCP instances.
23 | """
24 | conf = setup_conf()
25 | conf()
26 | config.setup_logging()
27 |
28 | root_helper = agent_config.get_root_helper(conf)
29 | # Identify namespaces that are candidates for deletion.
30 | candidates = [ns for ns in
31 | ip_lib.IPWrapper.get_namespaces(root_helper)
32 | if eligible_for_deletion(conf, ns, conf.force)]
33 |
34 | if candidates:
35 | eventlet.sleep(2)
36 |
37 | for namespace in candidates:
38 | destroy_namespace(conf, namespace, conf.force)
39 | ```
40 |
--------------------------------------------------------------------------------
/neutron/agent/ovs_cleanup_utilpy.md:
--------------------------------------------------------------------------------
1 | ### ovs_cleanup_util.py
2 | 清理无用的ovs网桥和端口。
3 |
--------------------------------------------------------------------------------
/neutron/agent/rpcpy.md:
--------------------------------------------------------------------------------
1 | ### rpc.py
2 | 定义了create_consumer()方法,设置agent 进行RPC时候的消费者。
3 |
4 | 定义了PluginApi类和PluginReportStateAPI类。两者都是继承自rpc.RpcProxy类。
5 | 前者代表rpc API在agent一侧部分,用于agent调用plugin的方法。后者是agent汇报自身状态,用于向plugin汇报状态信息。
6 |
7 | PluginApi类包括四个方法:get_device_details()、tunnel_sync()、update_device_down()和update_device_up()。
8 |
9 | PluginReportStateAPI类只提供一个方法:report_state,将agent获取的本地的状态信息以rpc消息的方式发出去。
10 |
--------------------------------------------------------------------------------
/neutron/agent/securitygroups_rpcpy.md:
--------------------------------------------------------------------------------
1 | ### securitygroups_rpc.py
2 | 定义了SecurityGroupAgentRpcApiMixin类、SecurityGroupAgentRpcCallbackMixin类、SecurityGroupAgentRpcMixin和SecurityGroupServerRpcApiMixin。
3 |
4 | 其中 *RpcApi 类提供了在agent端的对RPC的支持。
5 |
--------------------------------------------------------------------------------
/neutron/api/README.md:
--------------------------------------------------------------------------------
1 | ## api
2 | 提供RestAPI访问。
3 |
--------------------------------------------------------------------------------
/neutron/api/api_commonpy.md:
--------------------------------------------------------------------------------
1 | ### api_common.py
2 | 一些实现api通用的类和方法,包括。
3 | 类:PaginationHelper、PaginationEmulatedHelper、PaginationNativeHelper、NoPaginationHelper、SortingHelper、SortingEmulatedHelper、SortingNativeHelper、NoSortingHelper、NeutronController。
4 | 方法:get_filters、get_previous_link、get_next_link、get_limit_and_marker、list_args、get_sorts、get_page_reverse、get_pagination_links。
5 |
--------------------------------------------------------------------------------
/neutron/api/extensionspy.md:
--------------------------------------------------------------------------------
1 | ### extensions.py
2 | 定义了实现extension的几个类。
3 | ExtensionDescriptor类定义了作为extension描述的基础类。
4 |
5 | ActionExtensionController类继承自wsgi.Controller,负责对扩展行动的管理。
6 |
7 | RequestExtensionController类继承自wsgi.Controller,负责对扩展request的管理。
8 |
9 | ExtensionController类继承自wsgi.Controller,定义了index、show、delete、create等方法,对扩展进行管理。
10 |
11 | ExtensionMiddleware继承自wsgi.Middleware,负责处理扩展的中间件。
12 |
13 | ExtensionManager类负责从配置文件中加载扩展。
14 |
15 | PluginAwareExtensionManager类继承自ExtensionManager,增加对plugin对extension支持情况的检查。
16 |
--------------------------------------------------------------------------------
/neutron/api/rpc.md:
--------------------------------------------------------------------------------
1 | ### rpc
2 | #### agentnotifiers
3 | 主要负责发出一些rpc的通知给agent,包括三个文件:dhcp_rpc_agent_api.py、l3_rpc_agent_api.py、metering_rpc_agent_api.py。
4 | 分别实现向dhcp、l3或者metering的agent发出通知消息。
5 |
6 | 以dhcp_rpc_agent_api.py为例,定义了DhcpAgentNotifyAPI类,该类继承自neutron.common.rpc.RpcProxy。
7 |
8 | 首先定义允许对agent操作的资源和方法。
9 | ```python
10 | VALID_RESOURCES = ['network', 'subnet', 'port']
11 | VALID_METHOD_NAMES = ['network.create.end',
12 | 'network.update.end',
13 | 'network.delete.end',
14 | 'subnet.create.end',
15 | 'subnet.update.end',
16 | 'subnet.delete.end',
17 | 'port.create.end',
18 | 'port.update.end',
19 | 'port.delete.end']
20 | ```
21 | 实现的方法包括agent_updated()、network_added_to_agent()、network_removed_from_agent(),分别cast一条rpc消息到dhcp agent,调用对应方法。
22 | ```python
23 | def _cast_message(self, context, method, payload, host,
24 | topic=topics.DHCP_AGENT):
25 | """Cast the payload to the dhcp agent running on the host."""
26 | self.cast(
27 | context, self.make_msg(method, payload=payload),topic='%s.%s' % (topic, host))
28 |
29 | def network_removed_from_agent(self, context, network_id, host):
30 | self._cast_message(context, 'network_delete_end',
31 | {'network_id': network_id}, host)
32 |
33 | def network_added_to_agent(self, context, network_id, host):
34 | self._cast_message(context, 'network_create_end',
35 | {'network': {'id': network_id}}, host)
36 |
37 | def agent_updated(self, context, admin_state_up, host):
38 | self._cast_message(context, 'agent_updated',
39 | {'admin_state_up': admin_state_up}, host)
40 | ```
41 |
42 | 另外,实现notify()方法,可以调用所允许的方法。
43 | neutron的api中会直接调用notify()方法。
44 | ```python
45 | def notify(self, context, data, method_name):
46 | # data is {'key' : 'value'} with only one key
47 | if method_name not in self.VALID_METHOD_NAMES:
48 | return
49 | obj_type = data.keys()[0]
50 | if obj_type not in self.VALID_RESOURCES:
51 | return
52 | obj_value = data[obj_type]
53 | network_id = None
54 | if obj_type == 'network' and 'id' in obj_value:
55 | network_id = obj_value['id']
56 | elif obj_type in ['port', 'subnet'] and 'network_id' in obj_value:
57 | network_id = obj_value['network_id']
58 | if not network_id:
59 | return
60 | method_name = method_name.replace(".", "_")
61 | if method_name.endswith("_delete_end"):
62 | if 'id' in obj_value:
63 | self._notify_agents(context, method_name,
64 | {obj_type + '_id': obj_value['id']},
65 | network_id)
66 | else:
67 | self._notify_agents(context, method_name, data, network_id)
68 | ```
69 |
70 | 整体API的agent 通知调用的主要调用结构如下图所示。
71 |
72 | 
73 |
74 | #### handler
75 | 包括dvr_rpc.py文件。
76 | 其中定义了对dvr服务两端的rpc的api和callback类,包括DVRServerRpcApiMixin、DVRServerRpcCallbackMixin、DVRAgentRpcApiMixin、DVRAgentRpcCallbackMixin。
77 |
--------------------------------------------------------------------------------
/neutron/api/v2.md:
--------------------------------------------------------------------------------
1 | ### v2
2 | 实现neutron api第2个版本的定义。
3 | 主要方法包括index、update、create、show和delete。
4 |
5 | #### attributes.py
6 | 这里面定义了一系列的_validate_xxx方法,包括_validate_mac_address、_validate_ip_address、_validate_boolean等,对传入的参数进行格式检查。
7 |
8 | #### base.py
9 | 定义了Controller类和create_resource方法。
10 | 后者根据传入参数声明一个Controller并用它初始化一个wsgi的资源。
11 | ```python
12 | def create_resource(collection, resource, plugin, params, allow_bulk=False,
13 | member_actions=None, parent=None, allow_pagination=False,
14 | allow_sorting=False):
15 | controller = Controller(plugin, collection, resource, params, allow_bulk,
16 | member_actions=member_actions, parent=parent,
17 | allow_pagination=allow_pagination,
18 | allow_sorting=allow_sorting)
19 |
20 | return wsgi_resource.Resource(controller, FAULT_MAP)
21 | ```
22 |
23 | Controller类负责对rest API调用的资源进行处理,将对资源的请求转化为对应的plugin中方法的调用。
24 | 成员包括一个对dhcp agent的notifier。
25 |
26 | #### resource.py
27 | 主要定义了Request类和Resource方法。
28 | Request类继承自wsgi.Request,代表一个资源请求。
29 | Resource方法会根据传入的Controller构造一个resource对象。
30 |
31 | #### resource_helper.py
32 | 包括build_plural_mappings和build_resource_info两个方法。
33 | 前者对所有的资源创建从其复数到单数形式的映射;后者为advanced services扩展创建API资源对象。
34 |
35 | #### router.py
36 | 此处的router意味着是在wsgi框架下对请求的rest api进行调度的router,并非网络中的router。从外面api-paste.ini文件中,可以看到最终app指向的是
37 | ```
38 | [app:neutronapiapp_v2_0]
39 | paste.app_factory = neutron.api.v2.router:APIRouter.factory
40 | ```
41 | 该文件主要包括了APIRouter类,继承自wsgi.Router类,定义了factory方法。
42 | 其中factory()方法返回一个该类的实体。
43 | 分析其初始化方法:
44 | ```python
45 | def __init__(self, **local_config):
46 | mapper = routes_mapper.Mapper()
47 | plugin = manager.NeutronManager.get_plugin()
48 | ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
49 | ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)
50 |
51 | col_kwargs = dict(collection_actions=COLLECTION_ACTIONS,
52 | member_actions=MEMBER_ACTIONS)
53 |
54 | def _map_resource(collection, resource, params, parent=None):
55 | allow_bulk = cfg.CONF.allow_bulk
56 | allow_pagination = cfg.CONF.allow_pagination
57 | allow_sorting = cfg.CONF.allow_sorting
58 | controller = base.create_resource(
59 | collection, resource, plugin, params, allow_bulk=allow_bulk,
60 | parent=parent, allow_pagination=allow_pagination,
61 | allow_sorting=allow_sorting)
62 | path_prefix = None
63 | if parent:
64 | path_prefix = "/%s/{%s_id}/%s" % (parent['collection_name'],
65 | parent['member_name'],
66 | collection)
67 | mapper_kwargs = dict(controller=controller,
68 | requirements=REQUIREMENTS,
69 | path_prefix=path_prefix,
70 | **col_kwargs)
71 | return mapper.collection(collection, resource,
72 | **mapper_kwargs)
73 |
74 | mapper.connect('index', '/', controller=Index(RESOURCES))
75 | for resource in RESOURCES:
76 | _map_resource(RESOURCES[resource], resource,
77 | attributes.RESOURCE_ATTRIBUTE_MAP.get(
78 | RESOURCES[resource], dict()))
79 |
80 | for resource in SUB_RESOURCES:
81 | _map_resource(SUB_RESOURCES[resource]['collection_name'], resource,
82 | attributes.RESOURCE_ATTRIBUTE_MAP.get(
83 | SUB_RESOURCES[resource]['collection_name'],
84 | dict()),
85 | SUB_RESOURCES[resource]['parent'])
86 |
87 | super(APIRouter, self).__init__(mapper)
88 | ```
89 |
90 | 首先初始化一个router的mapper;之后获取plugin,通过调用NeutronManger类(负责解析配置文件并读取其中的plugin信息);然后获取支持的扩展的资源管理者,并把默认的对网络、子网和端口的资源的操作添加到扩展的资源管理者类中。
91 |
92 | 接下来,绑定资源的请求到各个资源上。_map_resource方法中创建了对应的控制器和映射关系。控制器在base.py文件中,其中定义了index、show、create、delete和update方法。这些方法中会获取plugin的对应方法对请求进行处理。例如,在create方法中有
93 | ```python
94 | obj_creator = getattr(self._plugin, action)
95 | ...
96 | obj = obj_creator(request.context, **kwargs)
97 | ```
98 |
99 |
--------------------------------------------------------------------------------
/neutron/api/versionspy.md:
--------------------------------------------------------------------------------
1 | ### versions.py
2 | 当rest api请求是版本号时候,调用该模块中的类Versions进行处理。
3 | 绑定也是在api-paste.ini文件中。
4 | ```
5 | /: neutronversions
6 | [app:neutronversions]
7 | paste.app_factory = neutron.api.versions:Versions.factory
8 | ```
9 |
10 | 调用的是Versions类中的factory()方法,该方法返回一个类的实体。该类是一个callable对象,主要函数就是`__call__()`方法。
11 | ```python
12 | @webob.dec.wsgify(RequestClass=wsgi.Request)
13 | def __call__(self, req):
14 | """Respond to a request for all Neutron API versions."""
15 | version_objs = [
16 | {
17 | "id": "v2.0",
18 | "status": "CURRENT",
19 | },
20 | ]
21 |
22 | if req.path != '/':
23 | language = req.best_match_language()
24 | msg = _('Unknown API version specified')
25 | msg = gettextutils.translate(msg, language)
26 | return webob.exc.HTTPNotFound(explanation=msg)
27 |
28 | builder = versions_view.get_view_builder(req)
29 | versions = [builder.build(version) for version in version_objs]
30 | response = dict(versions=versions)
31 | metadata = {
32 | "application/xml": {
33 | "attributes": {
34 | "version": ["status", "id"],
35 | "link": ["rel", "href"],
36 | }
37 | }
38 | }
39 |
40 | content_type = req.best_match_content_type()
41 | body = (wsgi.Serializer(metadata=metadata).
42 | serialize(response, content_type))
43 |
44 | response = webob.Response()
45 | response.content_type = content_type
46 | response.body = body
47 |
48 | return response
49 | ```
50 |
--------------------------------------------------------------------------------
/neutron/api/views.md:
--------------------------------------------------------------------------------
1 | ### views
2 | 主要包括versions.py,其中定义了ViewBuilder类和全局的get_view_builder()方法,该方法返回一个ViewBuilder类的实例。
3 |
--------------------------------------------------------------------------------
/neutron/auth.py.md:
--------------------------------------------------------------------------------
1 | ## auth.py
2 | 定义了类NeutronKeystoneContext,可以利用keystone的头部信息来生成一次请求的上下文。
3 | 定义了方法pipeline_factory,是一个流水线处理,对给定的auth_strategy(例如filter1 filter2 filter3 ... app),逆序调用各个过滤器对app进行处理,并返回最终结果。
4 |
--------------------------------------------------------------------------------
/neutron/cmd/README.md:
--------------------------------------------------------------------------------
1 | ## cmd
2 | * usage_audit.py,检测存在哪些网络资源(包括网络、子网、端口、路由器和浮动IP),显示它们的信息。
3 | * sanity_check.py,进行一些简单的检查,包括是否支持vxlan,是否支持patch端口,是否支持nova的notify等。
4 |
--------------------------------------------------------------------------------
/neutron/common/README.md:
--------------------------------------------------------------------------------
1 | ## common
2 | 这个包里面定义的都是一些模块通用的功能,包括对配置的操作,日志管理、rpc调用,以及一些常量等。
3 |
--------------------------------------------------------------------------------
/neutron/common/configpy.md:
--------------------------------------------------------------------------------
1 | ### config.py
2 | 对配置进行管理。
3 | 定义了core_opts的属性和默认值,包括绑定的主机地址、端口、配置文件默认位置、策略文件位置、VIF的起始Mac地址、DNS数量、子网的主机路由限制、DHCP释放时间、nova的配置信息等。
4 |
5 | 定义了core_cli_opts的属性和默认值,包括状态文件的路径。
6 | 注册上面定义的配置项。
7 |
8 | 主要包括
9 | load_paste_app(app_name)方法,从默认的paste config文件来读取配置,生成并返回WSGI应用。最关键的逻辑实现是
10 | ```
11 | app = deploy.loadapp("config:%s" % config_path, name=app_name)
12 | ```
13 |
14 | init(args)方法,读入配置文件,调用rpc的初始化函数,并检查base_mac参数是否合法。
15 | setup_logging(conf)方法,配置logging模块,导入配置信息。
16 |
--------------------------------------------------------------------------------
/neutron/common/constantspy.md:
--------------------------------------------------------------------------------
1 | ### constants.py
2 | 定义一些常量,例如各种资源的ACTIVE、BUILD、DOWN、ERROR状态,DHCP等网络协议端口号,VLAN TAG范围等。
3 |
--------------------------------------------------------------------------------
/neutron/common/exceptionspy.md:
--------------------------------------------------------------------------------
1 | ### exceptions.py
2 | 定义了各种情况下的异常类,包括NetworkInUse、PolicyFileNotFound等等。
3 |
--------------------------------------------------------------------------------
/neutron/common/ipv6_utilspy.md:
--------------------------------------------------------------------------------
1 | ### ipv6_utils.py
2 | 目前主要定义了get_ipv6_addr_by_EUI64(prefix, mac)方法,通过给定的v4地址前缀和mac来获取v6地址。
3 |
--------------------------------------------------------------------------------
/neutron/common/logpy.md:
--------------------------------------------------------------------------------
1 | ### log.py
2 | 基于neutron.openstack.common中的log模块。
3 |
4 | 主要是定义了log修饰,在执行方法时会一条debug日志,包括类名,方法名,参数等信息。
5 |
--------------------------------------------------------------------------------
/neutron/common/rpcpy.md:
--------------------------------------------------------------------------------
1 | ### rpc.py
2 | 定义了类RequestContextSerializer,RpcProxy,RpcCallback,Service,Connection。
3 |
4 | 其中RequestContextSerializer类中定义了对实体和上下文的序列化/反序列化,将RPC的通用上下文转化到Neutron上下文。
5 | RpcProxy类提供rpc层的操作,基本上所有需要进行rpc调用的应用都会用到这个类。其中分别定义了call,cast和fanout_cast方法来发出rpc调用请求。
6 |
7 | Service类代表运行在主机上的应用程序所代表的的服务,继承自service.Service,重载了start方法和stop方法。start方法中会创建三个消费连接来监听rpc请求。第一个是监听发送到某个topic上的所有主机上,第二个是监听发送到某个topic的特定主机上,最后一个是所有的广播请求。
8 |
9 | Connection类代表了rpc请求的相关连接。
10 |
--------------------------------------------------------------------------------
/neutron/common/test_libpy.md:
--------------------------------------------------------------------------------
1 | ### test_lib.py
2 | 定义了test_config={},用于各个plugin进行测试。
3 |
--------------------------------------------------------------------------------
/neutron/common/topicspy.md:
--------------------------------------------------------------------------------
1 | ### topics.py
2 | 管理rpc调用过程中的topic信息。
3 | ```python
4 | NETWORK = 'network'
5 | SUBNET = 'subnet'
6 | PORT = 'port'
7 | SECURITY_GROUP = 'security_group'
8 | L2POPULATION = 'l2population'
9 |
10 | CREATE = 'create'
11 | DELETE = 'delete'
12 | UPDATE = 'update'
13 |
14 | AGENT = 'q-agent-notifier'
15 | PLUGIN = 'q-plugin'
16 | L3PLUGIN = 'q-l3-plugin'
17 | DHCP = 'q-dhcp-notifer'
18 | FIREWALL_PLUGIN = 'q-firewall-plugin'
19 | METERING_PLUGIN = 'q-metering-plugin'
20 | LOADBALANCER_PLUGIN = 'n-lbaas-plugin'
21 |
22 | L3_AGENT = 'l3_agent'
23 | DHCP_AGENT = 'dhcp_agent'
24 | METERING_AGENT = 'metering_agent'
25 | LOADBALANCER_AGENT = 'n-lbaas_agent'
26 | ```
27 |
--------------------------------------------------------------------------------
/neutron/common/utilspy.md:
--------------------------------------------------------------------------------
1 | ### utils.py
2 | 一些辅助函数,包括查找配置文件,封装subprocess.Popen的subprocess_open,解析映射关系、获取主机名、字典和字符串格式的转化、检查对扩展的支持等等。
3 |
--------------------------------------------------------------------------------
/neutron/context.py.md:
--------------------------------------------------------------------------------
1 | ## context.py
2 | 定义继承自neutron.openstack.common.context.RequestContext的基础类ContextBase。以及继承自它的Context。表示安全上下文和请求信息,用于代表执行给定操作的用户。
3 |
--------------------------------------------------------------------------------
/neutron/db/README.md:
--------------------------------------------------------------------------------
1 | ## db
2 | 跟数据库相关的操作。因为各项服务根本上的操作都需要跟数据库打交道,因此这部分定义了大量的数据库资源类和相关接口,可以被进一步继承实现。
3 | 包括对核心plugin api的实现基础类,其次是一些扩展的资源和方法的支持。
4 | 其中model_base.py和models_v2.py中定义了最基础的几个模型类。
5 |
--------------------------------------------------------------------------------
/neutron/db/agents_dbpy.md:
--------------------------------------------------------------------------------
1 | ### agents_db.py
2 | 包括三个类,继承自model_base.BASEV2和models_v2.HasId的Agent类,继承自neutron.extensions.agent.AgentPluginBase的AgentDbMixin类,继承自rpc.RpcCallback的AgentExtRpcCallback。
3 |
4 | Agent类表示数据库中对一个agent的相关信息的记录。
5 |
6 | AgentDbMixin类用于添加对agent扩展的支持到db_base_plugin_v2,提供了获取配置、对agent进行curd操作等方法。
7 |
8 | AgentExtRpcCallback类在plugin的实现中用于处理rpc汇报,其中定义了report_state()方法用于向plugin汇报状态。
9 |
--------------------------------------------------------------------------------
/neutron/db/agentschedulers_dbpy.md:
--------------------------------------------------------------------------------
1 | ### agentschedulers_db.py
2 | 跟agent schedululer相关的一些数据库资源和操作类。
3 |
4 | 继承自model_base.BASEV2的NetworkDhcpAgentBinding类表示数据库中网络和dhcpagent的一条绑定关系。
5 |
6 | 继承自agents_db.AgentDbMixin的AgentSchedulerDbMixin类。
7 |
8 | 继承自AgentSchedulerDbMixin类的DhcpAgentSchedulerDbMixin类用于添加dhcp agent扩展的支持到db_base_plugin_v2。
9 |
--------------------------------------------------------------------------------
/neutron/db/allowedaddresspairs_dbpy.md:
--------------------------------------------------------------------------------
1 | #### allowedaddresspairs_db.py
2 | 定义了数据库资源类AllowedAddressPair,和操作类AllowedAddressPairsMixin。
3 |
--------------------------------------------------------------------------------
/neutron/db/apipy.md:
--------------------------------------------------------------------------------
1 | ### api.py
2 | 定义了一些数据库的配置方法,包括
3 | configure_db()启动一个数据库,创建一个引擎然后注册模型。
4 | get_engine()方法获取引擎。
5 | get_sessions()方法获取会话信息。
6 |
--------------------------------------------------------------------------------
/neutron/db/common_db_mixinpy.md:
--------------------------------------------------------------------------------
1 | ### common_db_mixin.py
2 | 定义了在核心plugin和服务plugin中的常见的数据库方法。
3 | 实现了扩展的插件类则需要通过register_model_query_hook来注册它的hook。
4 |
--------------------------------------------------------------------------------
/neutron/db/db_base_plugin_v2py.md:
--------------------------------------------------------------------------------
1 | ### db_base_plugin_v2.py
2 | 其中定义了NeutronDbPluginV2,是各个plugin的基础类。
3 | 继承自neutron.neutron_plugin_base_v2.NeutronPluginBaseV2类和neutron.common_db_mixin.CommonDbMixin类。
4 |
5 | 该类利用SQLAlchemy的模型实现了neutron plugin 的接口,主要包括对网络、子网、端口等资源的 CRUD 操作。
6 |
--------------------------------------------------------------------------------
/neutron/db/dvr_mac_dbpy.md:
--------------------------------------------------------------------------------
1 | #### dvr_mac_db.py
2 | 数据库资源类DistributedVirtualRouterMacAddress,和操作类DVRDbMixin。
3 |
4 | 后者继承自neutron.extensions.dvr.DVRMacAddressPluginBase类。
5 |
--------------------------------------------------------------------------------
/neutron/db/extensions.md:
--------------------------------------------------------------------------------
1 | ### 扩展资源和操作类
2 | 包括一系列资源在数据库中对应的记录和操作,这些模块的格式都很相似,一般包括若干个静态资源类和一个操作的mixin实现类。这个mixin类一般都是扩展核心plugin的资源、方法等支持,即提供扩展资源操作,一般继承自extension包中对应的基础类。
3 |
--------------------------------------------------------------------------------
/neutron/db/external_net_dbpy.md:
--------------------------------------------------------------------------------
1 | #### external_net_db.py
2 | 定义了继承自model_base.BASEV2的数据库资源类ExternalNetwork,以及操作类External_net_db_mixin。
3 |
4 | 后者为db_base_plugin_v2添加了对外部网络方法的支持。
5 |
--------------------------------------------------------------------------------
/neutron/db/extradhcpopt_dbpy.md:
--------------------------------------------------------------------------------
1 | #### extradhcpopt_db.py
2 | 代表绑定到某个端口上的额外的属性。
3 |
4 | 定义了继承自model_base.BASEV2类和models_v2.HasId类的数据库资源类ExtraDhcpOpt,以及操作类ExtraDhcpOptMixin。
5 |
--------------------------------------------------------------------------------
/neutron/db/extraroute_dbpy.md:
--------------------------------------------------------------------------------
1 | #### extraroute_db.py
2 | 定义了继承自model_base.BASEV2类、models_v2.Route类的数据库资源类RouterRoute和资源操作类ExtraRoute_db_mixin。
3 |
--------------------------------------------------------------------------------
/neutron/db/firewall/README.md:
--------------------------------------------------------------------------------
1 | #### firewall
2 | firewall_db.py中定义了跟防火墙数据库相关的几个类,包括FirewallRule、Firewall、FirewallPolicy和Firewall_db_mixin。
3 | * FirewallRule表示数据库中一条防火墙规则记录;
4 | * Firewall表示数据库中一个防火墙资源记录;
5 | * FirewallPolicy表示数据库中一条防火墙策略记录;
6 | * Firewall_db_mixin表示数据库中防火墙相关操作的实现类,包括创建、删除、更新和获取各种防火墙资源等操作;
7 |
8 | 
9 |
--------------------------------------------------------------------------------
/neutron/db/l3_agentschedulers_dbpy.md:
--------------------------------------------------------------------------------
1 | #### l3_agentschedulers_db.py
2 | 定义类L3AgentSchedulerDbMixin 和 RouterL3AgentBinding。
3 |
--------------------------------------------------------------------------------
/neutron/db/l3_attrs_dbpy.md:
--------------------------------------------------------------------------------
1 | #### l3_attrs_db.py
2 | 定义了RouterExtraAttributes类(继承自model_base.BASE类),代表一个路由器的附加属性。
3 |
4 | 定义了ExtraAttributesMixin类,用来对这些虚拟属性进行支持。
5 |
--------------------------------------------------------------------------------
/neutron/db/l3_dbpy.md:
--------------------------------------------------------------------------------
1 | #### l3_db.py
2 | 代表了路由器、浮动IP资源和对应操作实现。
3 |
4 | 定义了继承自model_base.BASEV2类、models_v2.HasId类和models_v2.HasTenant类的数据库资源类Router和FloatingIP,以及继承自neutron.extensions.l3.RouterPluginBase类的资源操作类L3_NAT_db_mixin。L3_NAT_db_mixin实际上为核心plugin添加了L3/NAT的扩展资源方法。
5 |
--------------------------------------------------------------------------------
/neutron/db/l3_dvr_dbpy.md:
--------------------------------------------------------------------------------
1 | #### l3_dvr_db.py
2 | 定义了类L3_NAT_with_dvr_db_mixin,对DVR进行支持。
3 |
--------------------------------------------------------------------------------
/neutron/db/l3_gwmode_dbpy.md:
--------------------------------------------------------------------------------
1 | #### l3_gwmode_db.py
2 | 定义了继承自l3_db.L3_NAT_db_mixin类的L3_NAT_db_mixin,添加对可配置网关路由器的支持。
3 |
--------------------------------------------------------------------------------
/neutron/db/l3_hamode_dbpy.md:
--------------------------------------------------------------------------------
1 | # l3_hamode_db.py
2 |
--------------------------------------------------------------------------------
/neutron/db/l3_hascheduler_dbpy.md:
--------------------------------------------------------------------------------
1 | # l3_hascheduler_db.py
2 |
--------------------------------------------------------------------------------
/neutron/db/loadbalancer/README.md:
--------------------------------------------------------------------------------
1 | #### loadbalancer
2 | loadbalancer_db.py中定义了跟负载均衡服务相关的几个数据库资源和操作类。
3 | 资源类都继承自model_base.BASE2类,此外还根据需求继承了其他几个类增添属性。
4 | * SessionPersistence类表示数据库中一条session的持久化类型;
5 | * PoolStatistics类表示数据库中一个pool的一些统计信息;
6 | * Vip类表示数据库中一个VIP记录;
7 | * Member类表示一个负载均衡的成员;
8 | * Pool类表示一个负载均衡池资源;
9 | * HealthMonitor类表示一个负载均衡的健康状态监视器资源;
10 | * PoolMonitorAssociation类表示Pool到HealthMonitor的关联关系。
11 | * LoadBalancerPluginDb则继承自loadbalancer.LoadBalancerPluginBase和base_db.CommonDbMixin,代表对负载均衡相关的数据资源进行操作实现。
12 |
13 | 
14 |
--------------------------------------------------------------------------------
/neutron/db/metering/README.md:
--------------------------------------------------------------------------------
1 | #### metering
2 | 包括metering_db.py和metering_rpc.py。
3 |
4 | 前者跟firewall_db.py类似,定义了metering的资源和操作实现类。
5 |
6 | 后者主要定义了MeteringRpcCallbacks类。
7 |
--------------------------------------------------------------------------------
/neutron/db/migration/README.md:
--------------------------------------------------------------------------------
1 | ### migration
2 | 负责将原先的ovs或linux bridge的数据库迁移到ml2支持的数据库格式。
3 | 包括cli.py,migrate_to_ml2.py等。
4 |
--------------------------------------------------------------------------------
/neutron/db/model_basepy.md:
--------------------------------------------------------------------------------
1 | ### model_base.py
2 | 定义了继承自 oslo.db.sqlalchemy.models.ModelBase的NeutronBase 和继承自其的 NeutronBaseV2 类。
3 |
4 | 
5 |
6 | 实际上,oslo.db.sqlalchemy.models.ModelBase是sqlalchemy的模型基础类,因此继承自其的类自动完成映射,可以对数据库进行操作。
7 |
8 | 最后,还定义了BASEV2作为其他地方可以继承的模型类。
9 | ```
10 | BASEV2 = declarative.declarative_base(cls=NeutronBaseV2)
11 | ```
12 |
--------------------------------------------------------------------------------
/neutron/db/models_v2py.md:
--------------------------------------------------------------------------------
1 | ### models_v2.py
2 | 通过继承model_base.BASE2,定义了几个数据模型,包括IPAllocationPool,IPAllocation,Route,SubnetRoute,Port,DNSNameServer,Subnet,Network。
3 |
--------------------------------------------------------------------------------
/neutron/db/portbindings_basepy.md:
--------------------------------------------------------------------------------
1 | # portbindings_base.py
2 |
--------------------------------------------------------------------------------
/neutron/db/portbindings_dbpy.md:
--------------------------------------------------------------------------------
1 | #### portbindings_db.py
2 | 定义了端口绑定的基础类PortBindingBaseMixin。
3 |
--------------------------------------------------------------------------------
/neutron/db/portsecurity_dbpy.md:
--------------------------------------------------------------------------------
1 | #### portsecurity_db.py
2 | 定义了继承自model_base.BASEV2类的PortSecurityBinding资源类和NetworkSecurityBinding资源类,以及资源操作类PortSecurityDbMixin。
3 |
--------------------------------------------------------------------------------
/neutron/db/quota_dbpy.md:
--------------------------------------------------------------------------------
1 | #### quota_db.py
2 | 定义了继承自model_base.BASEV2类、models_v2.HasId类的数据库资源类Quota和资源操作类DbQuotaDriver。
3 |
--------------------------------------------------------------------------------
/neutron/db/routedserviceinsertion_dbpy.md:
--------------------------------------------------------------------------------
1 | #### routedserviceinsertion_db.py
2 | 定义了继承自model_base.BASEV2类的数据库资源类ServiceRouterBinding和资源操作类RoutedServiceInsertionDbMixin。
3 |
--------------------------------------------------------------------------------
/neutron/db/routerservicetype_dbpy.md:
--------------------------------------------------------------------------------
1 | #### routerservicetype_db.py
2 | 实现对router服务类型的支持。
3 | 定义了继承自model_base.BASEV2类的数据库资源类RouterServiceTypeBinding和资源操作类RouterServiceTypeDbMixin。
4 |
--------------------------------------------------------------------------------
/neutron/db/securitygroups_dbpy.md:
--------------------------------------------------------------------------------
1 | #### securitygroups_db.py
2 | 实现对安全组资源的支持。
3 |
4 | 包括三个资源类:SecurityGroup、SecurityGroupPortBinding、SecurityGroupRule,以及一个资源操作类SecurityGroupDbMixin。
5 |
--------------------------------------------------------------------------------
/neutron/db/securitygroups_rpc_basepy.md:
--------------------------------------------------------------------------------
1 | ### securitygroups_rpc_base.py
2 | 实现对安全组的扩展rpc的基础支持。
3 |
4 | 继承自neutron.db.securitygroups_rpc_base.SecurityGroupDbMixin类的SecurityGroupServerRpcMixin,以及SecurityGroupServerRpcCallbackMixin类。
5 |
6 | 后者为plugin提供了securitygroup的agent的支持。
7 |
--------------------------------------------------------------------------------
/neutron/db/servicetype_dbpy.md:
--------------------------------------------------------------------------------
1 | #### servicetype_db.py
2 | 定义了继承自model_base.BASEV2类的数据库资源类ProviderResourceAssociation和资源操作类ServiceTypeManager。
3 |
--------------------------------------------------------------------------------
/neutron/db/sqlalchemyutilspy.md:
--------------------------------------------------------------------------------
1 | ### sqlalchemyutils.py
2 | 定义了sqlalchemyutils.py方法,根据指定的排序和标记条件来返回一个查询。
3 |
--------------------------------------------------------------------------------
/neutron/db/vpn/README.md:
--------------------------------------------------------------------------------
1 | #### vpn
2 | vpn_db.py文件跟firewall_db.py类似,定义了VPN的资源和操作实现类,以及一个VPNPluginRpcDbMixin类。
3 |
4 | vpn_validator.py文件定义了VpnReferenceValidator类,对vpn资源进行校验。
5 |
--------------------------------------------------------------------------------
/neutron/debug/README.md:
--------------------------------------------------------------------------------
1 | ## debug
2 | 提供简单的辅助debug功能。
3 |
--------------------------------------------------------------------------------
/neutron/debug/commandspy.md:
--------------------------------------------------------------------------------
1 | ### commands.py
2 | 包括若干命令的实现类:ProbeCommand基类和继承自它的CreateProbe,DeleteProbe,ListProbe,ClearProbe,ExecProbe,PingAll。
3 |
--------------------------------------------------------------------------------
/neutron/debug/debug_agentpy.md:
--------------------------------------------------------------------------------
1 | ### debug_agent.py
2 | 通过调用client来执行各项查询操作和debug命令。
3 |
--------------------------------------------------------------------------------
/neutron/debug/shellpy.md:
--------------------------------------------------------------------------------
1 | ### shell.py
2 | 提供一个shell环境来完成debug。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/README.md:
--------------------------------------------------------------------------------
1 | ## extensions
2 | 对现有neutron API的扩展。某些plugin可能还支持额外的资源或操作,可以以extension的方式实现。包括firewall、vpnaas、l3、lbaas等。
3 |
4 | 这些扩展资源类,大部分都继承自neutron.api.extensions.ExtensionDescriptor类,一般都实现了如下的类方法。
5 | get_name、get_alias、get_description、get_namespace、get_updated、get_extended_resources。
6 |
--------------------------------------------------------------------------------
/neutron/extensions/agentpy.md:
--------------------------------------------------------------------------------
1 | ### agent.py
2 | 主要定义了两个类:Agent和AgentPluginBase。
3 |
4 | 前者提供对agent管理扩展;后者提供对agent进行操作的rest API,包括对agent的CRUD操作,在agent_db.py中被AgentDbMixin类继承。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/allowedaddresspairspy.md:
--------------------------------------------------------------------------------
1 | ### allowedaddresspairs.py
2 | 主要定义了Allowedaddresspairs类,表示支持允许地址对的扩展类。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/dhcpagentschedulerpy.md:
--------------------------------------------------------------------------------
1 | ### dhcpagentscheduler.py
2 | NetworkSchedulerController类,继承自wsgi.Controller,对网络调度器进行创建、删除和索引。
3 |
4 | DhcpAgentsHostingNetworkController类,继承自wsgi.Controller,对dhcp_agent_hosting_network进行索引操作。
5 |
6 | Dhcpagentscheduler类,继承自extensions.ExtensionDescriptor,对dhcp agent的调度进行支持。
7 |
8 | DhcpAgentSchedulerPluginBase类,提供对dhcp agent的调度器进行操作的REST API,包括添加、删除和列出网络到dhcp agent等。
9 |
--------------------------------------------------------------------------------
/neutron/extensions/dvrpy.md:
--------------------------------------------------------------------------------
1 | ### dvr.py
2 | 定义了Dvr类,代表分布式虚拟路由器的扩展类。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/external_netpy.md:
--------------------------------------------------------------------------------
1 | ### external_net.py
2 | External_net扩展类,继承自extensions.ExtensionDescriptor,为dhcp增加配置选项。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/extra_dhcp_optpy.md:
--------------------------------------------------------------------------------
1 | ### extra_dhcp_opt.py
2 | Extra_dhcp_opt扩展类,继承自extensions.ExtensionDescriptor,为网络增加external network属性。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/extraroutepy.md:
--------------------------------------------------------------------------------
1 | ### extraroute.py
2 | Extraroute类,提供附加的路由支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/firewallpy.md:
--------------------------------------------------------------------------------
1 | ### firewall.py
2 | Firewall扩展类,继承自extensions.ExtensionDescriptor,提供防火墙扩展支持。
3 |
4 | FirewallPluginBase抽象基础类,继承自service_base.ServicePluginBase,定义了防火墙plugin的基础接口。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/flavorpy.md:
--------------------------------------------------------------------------------
1 | ### flavor.py
2 | Flavor扩展类,继承自extensions.ExtensionDescriptor,为网络和路由器提供flavor支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/l3_ext_gw_modepy.md:
--------------------------------------------------------------------------------
1 | ### l3_ext_gw_mode.py
2 | L3_ext_gw_mode扩展类,继承自extensions.ExtensionDescriptor,为路由器提供外部网关支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/l3_ext_ha_modepy.md:
--------------------------------------------------------------------------------
1 | ### l3_ext_ha_mode.py
2 |
--------------------------------------------------------------------------------
/neutron/extensions/l3agentschedulerpy.md:
--------------------------------------------------------------------------------
1 | ### l3agentscheduler.py
2 | RouterSchedulerController类和L3AgentsHostingRouterController类,都继承自wsgi.Controller。
3 |
4 | L3agentscheduler扩展类,继承自extensions.ExtensionDescriptor,支持l3 agent的调度器。
5 | L3AgentSchedulerPluginBase,为管理l3 agent调度器提供REST API支持。
6 |
--------------------------------------------------------------------------------
/neutron/extensions/l3py.md:
--------------------------------------------------------------------------------
1 | ### l3.py
2 | L3扩展类,继承自extensions.ExtensionDescriptor,提供路由器支持。
3 |
4 | RouterPluginBase,抽象基础类,提供对路由器的操作,被l3_db.py中的L3_NAT_db_mixin类继承。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/lbaas_agentschedulerpy.md:
--------------------------------------------------------------------------------
1 | ### lbaas_agentscheduler.py
2 | PoolSchedulerController类和LbaasAgentHostingPoolController类,都继承自wsgi.Controller。
3 |
4 | Lbaas_agentscheduler扩展类,继承自extensions.ExtensionDescriptor,支持lbaas agent调度器的支持。
5 |
6 | LbaasAgentSchedulerPluginBase,为管理l3 agent调度器提供REST API支持。
7 |
--------------------------------------------------------------------------------
/neutron/extensions/loadbalancerpy.md:
--------------------------------------------------------------------------------
1 | ### loadbalancer.py
2 | Loadbalancer扩展类,继承自extensions.ExtensionDescriptor,支持lbaas agent调度器的支持。
3 |
4 | LoadBalancerPluginBase抽象基础类,继承自service_base.ServicePluginBase。被loadbalancer_db.py中的LoadBalancerPluginDb类继承。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/meteringpy.md:
--------------------------------------------------------------------------------
1 | ### metering.py
2 | Metering扩展类,继承自extensions.ExtensionDescriptor,提供metering扩展支持。
3 |
4 | MeteringPluginBase抽象基础类,继承自service_base.ServicePluginBase。被metering_db.py中的MeteringDbMixin类继承。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/multiprovidernetpy.md:
--------------------------------------------------------------------------------
1 | ### multiprovidernet.py
2 | Multiprovidernet扩展类,继承自extensions.ExtensionDescriptor,提供多provider网络的扩展支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/portbindingspy.md:
--------------------------------------------------------------------------------
1 | ### portbindings.py
2 | Portbindings扩展类,继承自extensions.ExtensionDescriptor,提供端口绑定扩展支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/portsecuritypy.md:
--------------------------------------------------------------------------------
1 | ### portsecurity.py
2 | Portsecurity扩展类,提供端口安全支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/providernetpy.md:
--------------------------------------------------------------------------------
1 | ### providernet.py
2 | Providernet扩展类,继承自extensions.ExtensionDescriptor,提供provider网络扩展支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/quotasv2py.md:
--------------------------------------------------------------------------------
1 | ### quotasv2.py
2 | QuotaSetsController类,继承自wsgi.Controller。
3 |
4 | Quotasv2扩展类,继承自extensions.ExtensionDescriptor,提供quotas管理支持。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/routedserviceinsertionpy.md:
--------------------------------------------------------------------------------
1 | ### routedserviceinsertion.py
2 | Routedserviceinsertion扩展类,提供路由服务类型支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/routerservicetypepy.md:
--------------------------------------------------------------------------------
1 | ### routerservicetype.py
2 | Routerservicetype扩展类,提供路由服务类型支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/securitygrouppy.md:
--------------------------------------------------------------------------------
1 | ### securitygroup.py
2 | Securitygroup扩展类,继承自extensions.ExtensionDescriptor,提供安全组扩展支持。
3 |
4 | SecurityGroupPluginBase抽象基础类,定义对安全组进行管理操作的接口。
5 |
--------------------------------------------------------------------------------
/neutron/extensions/servicetypepy.md:
--------------------------------------------------------------------------------
1 | ### servicetype.py
2 | Servicetype扩展类,继承自extensions.ExtensionDescriptor,提供服务类型的扩展支持。
3 |
--------------------------------------------------------------------------------
/neutron/extensions/vpnaaspy.md:
--------------------------------------------------------------------------------
1 | ### vpnaas.py
2 | Vpnaas扩展类,继承自extensions.ExtensionDescriptor,提供安全组扩展支持。
3 |
4 | VPNPluginBase抽象基础类,继承自service_base.ServicePluginBase,定义对vpn服务进行管理操作的接口。这个类被vpn_db.py中的VPNPluginDb类继承。
5 |
--------------------------------------------------------------------------------
/neutron/hacking/README.md:
--------------------------------------------------------------------------------
1 | ## hacking
2 | 定义一些修改代码中需要的辅助函数,主要包括 check.py 模块。
3 |
--------------------------------------------------------------------------------
/neutron/hacking/checkspy.md:
--------------------------------------------------------------------------------
1 | ### checks.py
2 | 定义了一些辅助函数。包括检查作者标签,日志格式等。
3 |
--------------------------------------------------------------------------------
/neutron/hooks.py.md:
--------------------------------------------------------------------------------
1 | ## hooks.py
2 | 定义方法setup_hook,对给定的配置进行处理,检查平台添加必要的信息。
3 |
--------------------------------------------------------------------------------
/neutron/i18n.py.md:
--------------------------------------------------------------------------------
1 | ## i18n.py
2 |
--------------------------------------------------------------------------------
/neutron/locale/README.md:
--------------------------------------------------------------------------------
1 | ## locale
2 | 多语言支持。包括语言de,en_AU,en_GB,en_US,es,fr,it,ja,ko_KR,pt_BR,sr,zh_CN,zh_TW。
3 | 在各子目录下包括各个语言对应的字符串。
4 |
--------------------------------------------------------------------------------
/neutron/manager.py.md:
--------------------------------------------------------------------------------
1 | ## manager.py
2 | 定义了类Manager和类NeutronManager。
3 |
4 | 前者继承自neutron.common.rpc.RpcCallback类和neutron.openstack.common.periodic_task.PeriodicTasks类。该类会定义运行任务。
5 |
6 | 后者负责解析配置文件并初始化neutron的plugin。
7 |
--------------------------------------------------------------------------------
/neutron/neutron_plugin_base_v2.py.md:
--------------------------------------------------------------------------------
1 | ## neutron_plugin_base_v2.py
2 | Neutron plugin的抽象基础类,是实现plugin的参考和基础,它定义了实现一个neutron plugin所需的基本接口。
3 | 包括下面的方法:
4 |
5 | 属性 | Create | Delete | Read | Update
6 | --- | --- | --- | --- | ---
7 | port | Y | Y | Y | Y
8 | ports | | | Y |
9 | ports_count | | | Y |
10 | network | Y | Y | Y | Y
11 | networks | | | Y |
12 | networks_count | | | Y |
13 | subnet | Y | Y | Y | Y
14 | subnets | | | Y |
15 | subnet_count | | | Y |
16 |
--------------------------------------------------------------------------------
/neutron/notifiers/README.md:
--------------------------------------------------------------------------------
1 | ## notifiers
2 |
--------------------------------------------------------------------------------
/neutron/notifiers/novapy.md:
--------------------------------------------------------------------------------
1 | ### nova.py
2 | 定义 Notifier类,发送nova可能关心的一些事件消息。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/README.md:
--------------------------------------------------------------------------------
1 | # openstack
2 |
--------------------------------------------------------------------------------
/neutron/openstack/common/README.md:
--------------------------------------------------------------------------------
1 | ### common
2 | 公共模块。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/_i18npy.md:
--------------------------------------------------------------------------------
1 | #### _i18n.py
2 |
--------------------------------------------------------------------------------
/neutron/openstack/common/cache.md:
--------------------------------------------------------------------------------
1 | #### cache
2 | * _backends
3 | * backends.py
4 | * cache.py
5 |
--------------------------------------------------------------------------------
/neutron/openstack/common/cache/README.md:
--------------------------------------------------------------------------------
1 | #### cache
2 | _backends
3 | backends.py
4 | cache.py
5 |
--------------------------------------------------------------------------------
/neutron/openstack/common/contextpy.md:
--------------------------------------------------------------------------------
1 | #### context.py
2 | 定义类RequestContext,代表在request上下文中的有用信息,包括用户名、租户、认证信息等等。
3 |
4 | 还定义了两个全局方法get_admin_context()和get_context_from_function_and_args()。
5 |
6 |
7 |
--------------------------------------------------------------------------------
/neutron/openstack/common/eventlet_backdoorpy.md:
--------------------------------------------------------------------------------
1 | #### eventlet_backdoor.py
2 |
--------------------------------------------------------------------------------
/neutron/openstack/common/fileutilspy.md:
--------------------------------------------------------------------------------
1 | #### fileutils.py
2 | 定义了跟文件操作相关的一些方法,比如创建目录,读取修改的文件和安全删除等。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/fixture.md:
--------------------------------------------------------------------------------
1 | #### fixture
2 | * config.py
3 | * lockutils.py
4 | * mockpatch.py
5 | * moxstubout.py
6 |
--------------------------------------------------------------------------------
/neutron/openstack/common/fixture/README.md:
--------------------------------------------------------------------------------
1 | # fixture
2 |
--------------------------------------------------------------------------------
/neutron/openstack/common/localpy.md:
--------------------------------------------------------------------------------
1 | #### local.py
2 | 管理对线程局部的变量。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/lockutilspy.md:
--------------------------------------------------------------------------------
1 | #### lockutils.py
2 | 跟锁相关的方法,包括锁和同步等。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/logpy.md:
--------------------------------------------------------------------------------
1 | #### log.py
2 | 日志相关的类和方法。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/loopingcallpy.md:
--------------------------------------------------------------------------------
1 | #### loopingcall.py
2 | 一些需要循环调用的类。
3 |
4 | 基础类LoopingCallBase,和继承自其的FixedIntervalLoopingCall类和DynamicLoopingCall类。
5 |
--------------------------------------------------------------------------------
/neutron/openstack/common/middleware.md:
--------------------------------------------------------------------------------
1 | #### middleware
2 | * base.py
3 | * catch_errors.py
4 | * correlation_id.py
5 | * debug.py
6 | * request_id.py
7 | * sizelimit.py
8 |
--------------------------------------------------------------------------------
/neutron/openstack/common/periodic_taskpy.md:
--------------------------------------------------------------------------------
1 | #### periodic_task.py
2 | 定义了类PeriodicTasks,表示定期的任务。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/policypy.md:
--------------------------------------------------------------------------------
1 | #### policy.py
2 | 对访问策略的管理,处理policy.json文件。
3 |
4 | 类Rules,代表一条规则。
5 |
6 | 一系列的继承自BaseCheck的类,代表各种对规则格式进行的检查,例如是否为真,与或非逻辑等。
7 |
--------------------------------------------------------------------------------
/neutron/openstack/common/processutilspy.md:
--------------------------------------------------------------------------------
1 | #### processutils.py
2 | 封装了一些进程操作,提供高层方法,包括:
3 | * _subprocess_setup()方法
4 | * execute()方法,在shell中通过subprocess来执行一条命令。
5 | * trycmd()方法,对execute()方法的封装,处理警告和错误信息。
6 | * ssh_execute
7 |
--------------------------------------------------------------------------------
/neutron/openstack/common/servicepy.md:
--------------------------------------------------------------------------------
1 | #### service.py
2 | 定义了基础类service和services,前者被rpc.Service类继承。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/systemdpy.md:
--------------------------------------------------------------------------------
1 | #### systemd.py
2 | 跟systemd打交道的若干方法,包括notify()方法,发送通知给systemd系统服务等
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/threadgrouppy.md:
--------------------------------------------------------------------------------
1 | #### threadgroup.py
2 | 定义了类Thread和ThreadGroup。
3 |
4 | 前者是对greenthread的封装,拥有一个到threadgroup的引用,当线程结束时候通知threadgroup将自身移除。
5 |
6 | 后者对greenthread进行管理,可以为greenthread添加一个计时器。
7 |
--------------------------------------------------------------------------------
/neutron/openstack/common/uuidutilspy.md:
--------------------------------------------------------------------------------
1 | #### uuidutils.py
2 | 对uuid进行检查和生成。
3 |
--------------------------------------------------------------------------------
/neutron/openstack/common/versionutilspy.md:
--------------------------------------------------------------------------------
1 | #### versionutils.py
2 | 检查版本号的兼容性。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/README.md:
--------------------------------------------------------------------------------
1 | ## plugins
2 | 包括实现网络功能的各个插件。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/bigswitch/README.md:
--------------------------------------------------------------------------------
1 | ### bigswitch
2 |
--------------------------------------------------------------------------------
/neutron/plugins/hyperv/agent.md:
--------------------------------------------------------------------------------
1 | # agent
2 |
--------------------------------------------------------------------------------
/neutron/plugins/hyperv/common.md:
--------------------------------------------------------------------------------
1 | #### common
2 | 这里面的文件主要是定义一些常量。
3 |
4 | config.py定义了配置选项(关键词)和默认值等,包括sdnve_opts和sdnve_agent_opts两个配置组,并且将这些配置项导入到全局的cfg.CONF中。只要导入该模块,相应的配置组和配置选项就会被认可合法,从而可以通过解析配置文件中这些关键词,而为这些配置选项赋值;
5 |
6 | constants.py则分别定义了一些固定的常量;
7 | exceptions.py中定义了一些异常类型。
8 |
--------------------------------------------------------------------------------
/neutron/plugins/ibm/README.md:
--------------------------------------------------------------------------------
1 | ### ibm
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ibm/agent.md:
--------------------------------------------------------------------------------
1 | #### agent
2 | sdnve_neutron_agent.py,该文件主要实现一个在计算节点和网络节点上的daemon,对本地的网桥进行实际操作。其主要过程代码为
3 | ```python
4 | def main():
5 | eventlet.monkey_patch()
6 | cfg.CONF.register_opts(ip_lib.OPTS)
7 | cfg.CONF(project='neutron')
8 | logging_config.setup_logging(cfg.CONF)
9 |
10 | try:
11 | agent_config = create_agent_config_map(cfg.CONF)
12 | except ValueError as e:
13 | LOG.exception(_("%s Agent terminated!"), e)
14 | raise SystemExit(1)
15 |
16 | plugin = SdnveNeutronAgent(**agent_config)
17 |
18 | # Start everything.
19 | LOG.info(_("Agent initialized successfully, now running... "))
20 | plugin.daemon_loop()
21 | ```
22 |
23 | 其中,eventlet.monkey_patch()是使用eventlet的patch,将本地的一些python库进行绿化,使之支持协程。
24 | ```python
25 | cfg.CONF.register_opts(ip_lib.OPTS)
26 | cfg.CONF(project='neutron')
27 | logging_config.setup_logging(cfg.CONF)
28 | ```
29 |
30 | 这三行则初始化配置信息。register_opts是注册感兴趣的关键字并设置它们的默认值,只有感兴趣的关键字才会被后面的步骤进行配置更新。
31 |
32 | 最关键的cfg.CONF(project='neutron'),这其实是个函数调用,实际上调用了cfg.ConfigOpts类的__call__方法,来解析project参数所指定的相关配置文件,并从中读取配置信息。需要注意的是,外部的sys.argv参数会传递给所import的cfg模块进行解析。因此,如果在启动agent的时候通过命令行给出了参数,则cfg.ConfigOpts类会解析这些命令行参数。否则,将默认去~/.${project}/、~/、/etc/${project}/、/etc/等地方搜索配置文件(默认为os.path.basename(sys.argv[0]))。如果不进行这一步,那么所有的关键字只带有默认的信息,配置文件中信息就不起作用了。
33 | ```python
34 | try:
35 | agent_config = create_agent_config_map(cfg.CONF)
36 | except ValueError as e:
37 | LOG.exception(_("%s Agent terminated!"), e)
38 | raise SystemExit(1)
39 | ```
40 |
41 | 这部分则试图从全局配置库中读取agent相关的一些配置项。包括网桥、接口mapping、控制器IP等等。
42 |
43 | 后面部分是实例化一个SdnveNeutronAgent类,并调用它的daemon_loop()方法。
44 |
--------------------------------------------------------------------------------
/neutron/plugins/ibm/common.md:
--------------------------------------------------------------------------------
1 | # common
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ibm/sdnve_api_fakepy.md:
--------------------------------------------------------------------------------
1 | #### sdnve_api_fake.py
2 | 伪造响应 API 调用请求,可用于测试。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/ibm/sdnve_apipy.md:
--------------------------------------------------------------------------------
1 | #### sdnve_api.py
2 | 封装sdnve控制器所支持的操作为一些API。
3 | RequestHandler类,处理与sdnve控制器的请求和响应消息的基本类。提供get、post、put、delete等请求。对HTTP消息处理的实现通过其内部的httplib2.Http成员来进行。
4 | Client类,继承自RequestHandler类。提供对sdnve中各种网络资源(网络,子网,端口,租户,路由器,浮动IP)的CRUD操作的API和对应实现。
5 | KeystongClient类,主要是获取系统中的租户信息。
6 |
--------------------------------------------------------------------------------
/neutron/plugins/ibm/sdnve_neutron_pluginpy.md:
--------------------------------------------------------------------------------
1 | #### sdnve_neutron_plugin.py
2 | 主要定义了 SdnvePluginV2 类,继承自如下几个基础类:
3 | * db_base_plugin_v2.NeutronDbPluginV2:提供在数据库中对网络、子网、端口的CRUD操作API;
4 | * external_net_db.External_net_db_mixin:为db_base_plugin_v2添加对外部网络的操作方法;
5 | * portbindings_db.PortBindingMixin:端口绑定相关的操作;
6 | * l3_gwmode_db.L3_NAT_db_mixin:添加可配置的网关模式,为端口和网络提供字典风格的扩展函数。
7 | * agents_db.AgentDbMixin:为db_base_plugin_v2添加agent扩展,对agent的创建、删除、获取等。
8 |
9 | SdnvePluginV2类实现了neutron中定义的API,实现基于SDN-VE对上提供网络抽象的支持。包括对网络、子网、端口、路由器等资源的CRUD操作。
10 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/README.md:
--------------------------------------------------------------------------------
1 | ### ml2
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/common.md:
--------------------------------------------------------------------------------
1 | # common
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/configpy.md:
--------------------------------------------------------------------------------
1 | # config.py
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/dbpy.md:
--------------------------------------------------------------------------------
1 | # db.py
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/driver_apipy.md:
--------------------------------------------------------------------------------
1 | # driver_api.py
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/driver_contextpy.md:
--------------------------------------------------------------------------------
1 | # driver_context.py
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/drivers.md:
--------------------------------------------------------------------------------
1 | # drivers
2 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/managerspy.md:
--------------------------------------------------------------------------------
1 | #### managers.py
2 | 两个manager类:MechanismManager和TypeManager。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/modelspy.md:
--------------------------------------------------------------------------------
1 | #### models.py
2 | 数据库模型,包括DVRPortBinding、NetworkSegment、PortBinding三种类型,都继承自neutron.db.model_base.NeutronBaseV2。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/pluginpy.md:
--------------------------------------------------------------------------------
1 | #### plugin.py
2 | 主要实现类Ml2Plugin,是ML2的Plugin端的主类。继承自多个父类。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/ml2/rpcpy.md:
--------------------------------------------------------------------------------
1 | #### rpc.py
2 |
3 | 包括两个类:RpcCallbacks和AgentNotifierApi。
4 |
5 | 前者负责当agent往plugin发出rpc请求时候,plugin实现请求的相关动作,除了继承自父类(dhcp rpc、dvr rpc、sg_db rpc和tunnel rpc)中的方法,还包括get_port_from_device、get_device_details、get_devices_details_list、update_device_down、update_device_up、get_dvr_mac_address_by_host、get_compute_ports_on_host_by_subnet、get_subnet_for_dvr等方法。
6 |
7 | 后者负责当plugin往agent发出rpc请求(plugin通知agent)的时候,plugin端的方法。继承自dvr、sg、tunnel等父类。此外还实现了network_delete、port_update两个方法。
8 |
9 |
--------------------------------------------------------------------------------
/neutron/plugins/ofagent/README.md:
--------------------------------------------------------------------------------
1 | ### ofagent
2 | openflow agent机制的驱动应用。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/ofagent/agent.md:
--------------------------------------------------------------------------------
1 | #### agent
2 |
3 | ##### ofa_neutron_agent.py
4 | ##### ports.py
5 | 定义了一个Port类,表示一个OF端口。
6 |
--------------------------------------------------------------------------------
/neutron/plugins/ofagent/common.md:
--------------------------------------------------------------------------------
1 | #### common
2 | 主要包括config.py,定义了agent的配置项,并注册ovs的相关配置和agent的配置项。
3 |
--------------------------------------------------------------------------------
/neutron/plugins/openvswitch/README.md:
--------------------------------------------------------------------------------
1 | ### openvswitch
2 |
--------------------------------------------------------------------------------
/neutron/plugins/openvswitch/agent.md:
--------------------------------------------------------------------------------
1 | #### agent
2 | 主要包括xenapi目录(xen相关)、ovs_neutron_agent.py和ovs_dvr_neutron_agent.py文件(运行在各个节点上的对网桥进行操作的代理)。
3 | ovs_neutron_agent.py文件main函数主要过程如下:
4 | ```python
5 | def main():
6 | cfg.CONF.register_opts(ip_lib.OPTS)
7 | common_config.init(sys.argv[1:])
8 | common_config.setup_logging(cfg.CONF)
9 | logging_config.setup_logging(cfg.CONF)
10 | q_utils.log_opt_values(LOG)
11 |
12 | try:
13 | agent_config = create_agent_config_map(cfg.CONF)
14 | except ValueError as e:
15 | LOG.error(_('%s Agent terminated!'), e)
16 | sys.exit(1)
17 |
18 | is_xen_compute_host = 'rootwrap-xen-dom0' in agent_config['root_helper']
19 | if is_xen_compute_host:
20 | # Force ip_lib to always use the root helper to ensure that ip
21 | # commands target xen dom0 rather than domU.
22 | cfg.CONF.set_default('ip_lib_force_root', True)
23 |
24 | agent = OVSNeutronAgent(**agent_config)
25 | signal.signal(signal.SIGTERM, handle_sigterm)
26 |
27 | # Start everything.
28 | LOG.info(_("Agent initialized successfully, now running... "))
29 | agent.daemon_loop()
30 | sys.exit(0)
31 | ```
32 |
33 | 首先是读取各种配置信息,然后提取agent相关的属性。
34 |
35 | 然后生成一个agent实例(OVSNeutronAgent类),并调用其daemon_loop()函数,该函数进一步执行rpc_loop()。
36 |
37 | OVSNeutronAgent类初始化的时候,会依次调用setup_rpc()、setup_integration_br()和setup_physical_bridges()。
38 |
39 | ovs_dvr_neutron_agent.py文件是neutron实现分布式路由器设计时的agent。
40 |
41 | ##### setup_rpc()
42 | setup_rpc()首先创建了两个rpc句柄,分别是
43 | ```python
44 | self.plugin_rpc = OVSPluginApi(topics.PLUGIN)
45 | self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
46 | ```
47 |
48 | 其中,前者是与neutron-server(准确的说是ovs plugin)进行通信,通过rpc消息调用plugin的方法。这些消息在neutron.agent.rpc.PluginApi类中定义,包括get_device_details、get_devices_details_list、update_device_down、update_device_up、tunnel_sync、security_group_rules_for_devices等。
49 |
50 | 后者是agent定期将自身的状态上报给neutron-server。
51 |
52 | 之后,创建dispatcher和所关注的消息主题:
53 | ```python
54 | self.dispatcher = self.create_rpc_dispatcher()
55 | # Define the listening consumers for the agent
56 | consumers = [[topics.PORT, topics.UPDATE],
57 | [topics.NETWORK, topics.DELETE],
58 | [constants.TUNNEL, topics.UPDATE],
59 | [topics.SECURITY_GROUP, topics.UPDATE]]
60 | ```
61 | 这样,neutron-server发到这四个主题的消息,会被agent接收到。agent会检查端口是否在本地,如果在本地则进行对应动作。
62 | 创建消费者rpc连接来接收rpc消息:
63 | ```python
64 | self.connection = agent_rpc.create_consumers(self.dispatcher,
65 | self.topic,
66 | consumers)
67 | ```
68 | 最后,创建heartbeat,定期的调用self._report_state(),通过state_rpc来汇报本地状态。
69 | 图表 3展示了这一过程,是一个很好的理解agent端的rpc实现的例子。
70 |
71 | 
72 |
73 | ##### setup_integration_br()
74 | 清除integration网桥上的int_peer_patch_port端口和流表,添加一条normal流。
75 |
76 | ##### setup_physical_bridges()
77 | 创建准备挂载物理网卡的网桥,添加一条normal流,然后创建veth对,连接到integration网桥,添加drop流规则,禁止未经转换的流量经过veth对。
78 |
--------------------------------------------------------------------------------
/neutron/plugins/openvswitch/common.md:
--------------------------------------------------------------------------------
1 | #### common
2 | 包括config.py和constants.py两个文件。
3 |
4 | 其中config.py文件中定义了所关注的配置项和默认值,并注册了OVS和AGENT两个配置组到全局的配置项中。
5 |
6 | 而constants.py中则定义了一些常量,包括ovs版本号等。
7 |
--------------------------------------------------------------------------------
/neutron/plugins/openvswitch/ovs_models_v2py.md:
--------------------------------------------------------------------------------
1 | #### ovs_models_v2.py
2 | 定义了继承自model_base.BASEV2的四个类。
3 |
4 | * NetworkBinding代表虚拟网和物理网的绑定。
5 | * TunnelAllocation代表隧道id的分配状态。
6 | * TunnelEndpoint代表隧道的一个端点。
7 | * VlanAllocation代表物理网上的vlan id的分配状态。
8 |
9 | 这些模型类供ovs_db_v2.py进行使用。
10 |
--------------------------------------------------------------------------------
/neutron/policy.py.md:
--------------------------------------------------------------------------------
1 | ## policy.py
2 |
--------------------------------------------------------------------------------
/neutron/quota.py.md:
--------------------------------------------------------------------------------
1 | ## quota.py
2 |
--------------------------------------------------------------------------------
/neutron/scheduler/README.md:
--------------------------------------------------------------------------------
1 | ## scheduler
2 | 实现调度、负载均衡的算法。
3 |
--------------------------------------------------------------------------------
/neutron/scheduler/dhcp_agent_schedulerpy.md:
--------------------------------------------------------------------------------
1 | ### dhcp_agent_scheduler.py
2 | 定义了ChanceScheduler类,用于实现随机为一个网络分配一个dhcp agent。
3 |
4 | 该类主要定义对外的两个方法,schedule()实现对一个网络返回调度给它的若干agents,auto_schedule_networks()方法将还没有分配agent的所有网络安排到指定主机的agent上。
5 |
--------------------------------------------------------------------------------
/neutron/scheduler/l3_agent_schedulerpy.md:
--------------------------------------------------------------------------------
1 | ### l3_agent_scheduler.py
2 | 定义了抽象基础类L3Scheduler,和继承自它的ChanceScheduler、LeastRoutersScheduler两种分配机制。
3 |
--------------------------------------------------------------------------------
/neutron/server/README.md:
--------------------------------------------------------------------------------
1 | # server
2 | 实现neutron-server的主进程。
3 |
4 | __init__.py文件中包括一个main()函数,是WSGI服务器开始的模块,并且通过调用serve_wsgi来创建一个NeutronApiService的实例。然后通过eventlet的greenpool来运行WSGI的应用程序,响应来自客户端的请求。
5 | 主要过程为:
6 | ```python
7 | eventlet.monkey_patch()
8 | ```
9 | 绿化各个模块为支持协程(通过打补丁的方式让本地导入的库都支持协程)。
10 | ```python
11 | config.parse(sys.argv[1:])
12 | if not cfg.CONF.config_file:
13 | sys.exit(_("ERROR: Unable to find configuration file via the default"
14 | " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
15 | " the '--config-file' option!"))
16 | ```
17 | 通过解析命令行传入的参数,获取配置文件所在。
18 | ```python
19 | pool = eventlet.GreenPool()
20 | ```
21 | 创建基于协程的线程池。
22 | ```python
23 | neutron_api = service.serve_wsgi(service.NeutronApiService)
24 | api_thread = pool.spawn(neutron_api.wait)
25 | ```
26 | serve_wsgi方法创建NeutronApiService实例(作为一个WsgiService),并调用其的start()来启动socket服务器端。
27 | ```python
28 | #neutron.service
29 | def serve_wsgi(cls):
30 | try:
31 | service = cls.create()
32 | service.start()
33 | except Exception:
34 | with excutils.save_and_reraise_exception():
35 | LOG.exception(_('Unrecoverable error: please check log '
36 | 'for details.'))
37 | return service
38 | ```
39 | neutron.service.NeutronApiService类继承自neutron.service.WsgiService,其create方法返回一个appname默认为“neutron”的WsgiService对象;start方法则调用_run_wsgi方法。
40 | ```python
41 | def start(self):
42 | self.wsgi_app = _run_wsgi(self.app_name)
43 | ```
44 |
45 | _run_wsgi方法主要是从api-paste.ini文件中读取应用(最后是利用neutron.api.v2.router:APIRouter.factory来构造应用),然后为应用创建一个wsgi的服务端,并启动应用,主要代码为。
46 | ```python
47 | def _run_wsgi(app_name):
48 | app = config.load_paste_app(app_name)
49 | if not app:
50 | LOG.error(_('No known API applications configured.'))
51 | return
52 | server = wsgi.Server("Neutron")
53 | server.start(app, cfg.CONF.bind_port, cfg.CONF.bind_host,
54 | workers=cfg.CONF.api_workers)
55 | # Dump all option values here after all options are parsed
56 | cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
57 | LOG.info(_("Neutron service started, listening on %(host)s:%(port)s"),
58 | {'host': cfg.CONF.bind_host,
59 | 'port': cfg.CONF.bind_port})
60 | return server
61 | ```
62 |
63 | 至此,neutron server启动完成,之后,需要创建rpc服务端。
64 | ```python
65 | try:
66 | neutron_rpc = service.serve_rpc()
67 | except NotImplementedError:
68 | LOG.info(_("RPC was already started in parent process by plugin."))
69 | else:
70 | rpc_thread = pool.spawn(neutron_rpc.wait)
71 | rpc_thread.link(lambda gt: api_thread.kill())
72 | api_thread.link(lambda gt: rpc_thread.kill())
73 | ```
74 |
75 | 这些代码创建plugin的rpc服务端,并将api和rpc的生存绑定到一起,一个死掉,则另外一个也死掉。
76 | ```python
77 | pool.waitall()
78 | ```
79 | 最后是后台不断等待。
80 |
81 | 下面的图表总结了neutron-server的核心启动过程。
82 |
83 | neutron.server|neutron.service#serve_wsgi() | neutron.service.NeutronApiService|neutron.service.WsgiService |neutron.service#_run_wsgi()
84 | --- | --- | --- | ---
85 | neutron_api = service.serve_wsgi(service.NeutronApiService) |service = cls.create(); service.start()|service = cls(app_name=’neutron’) |self.wsgi_app = _run_wsgi(self.app_name)| app = config.load_paste_app(app_name); server = wsgi.Server("Neutron"); server.start(app, cfg.CONF.bind_port, cfg.CONF.bind_host, workers=cfg.CONF.api_workers)
86 |
--------------------------------------------------------------------------------
/neutron/service.py.md:
--------------------------------------------------------------------------------
1 | ## service.py
2 | 定义了相关的配置信息,包括periodic_interval,api_workers,rcp_workers,periodic_fuzzy_delay。
3 |
4 | 实现neutron中跟服务相关的类。
5 |
6 | 包括NeutronApiService,RpcWorker,继承自n_rpc.Service的Service和WsgiService。
7 |
8 | Service是各个服务的基类。
9 |
10 | WsgiService是实现基于WSGI的服务的基础类。
11 |
12 | NeutronApiService继承自WsgiService,添加了create()方法,配置log相关的选项,并返回类实体。
13 |
14 | #### Service类
15 | Service是很重要的一个概念,各个服务的组件都以Service类的方式来进行交互。此处Service类继承自rpc中的Service,整体的继承关系为
16 | neutron.openstack.common.service.Service类-->neutron.common.rpc.Service类-->neutron.service.Service类。
17 |
18 | 其中neutron.openstack.common.service.Service类定义了简单的reset()、start()、stop()和wait()方法。该类初始化后会维护一个线程组。
19 |
20 | neutron.common.rpc.Service类中进一步丰富了start()和stop()方法,并在初始化中引入了host、topic、manager和serializer参数。
21 |
22 | start()增加创建了Connection对象,之后创建了三个consumer,分别监听主题为参数传入的topic(fanout分别为True和False),以及主题为topic.host。然后调用manager的初始化。最后作为server启动所有的consumer。
23 |
24 | neutron.service.Service类的初始化中更进一步的增加了binary、report_interval、periodic_interval、periodic_fuzzy_delay等参数。除丰富了start()、stop()和wait()方法外,还增加了create()类方法、kill()、periodic_tasks()和report_state()。
25 |
26 | start()增加了周期性执行report_state()和periodic_tasks(),并且调用manager的init_host()和after_start()方法。
27 |
28 | create()方法是类方法,它根据传入的参数binary参数获取真实的程序名,并在未给定参数的情况下尝试从配置文件中解析manager和report_interval、periodic_interval、periodic_fuzzy_delay等参数。最后是返回生成的Service类对象。
29 |
30 | report_state()方法仅定义了接口。
31 |
32 | periodic_tasks()则首先获取admin的上下文,然后调用manager的periodic_tasks()方法执行。
33 |
34 | 总结一下,neutron.service.Service类,初始化会处理传入参数,并解析配置文件。start()方法则创建并启动三个consumer,监听传入的topic和topic.host。初始化manager并周期性运行它的periodic_tasks()和report_state()方法。
35 |
--------------------------------------------------------------------------------
/neutron/services/README.md:
--------------------------------------------------------------------------------
1 | # services
2 |
--------------------------------------------------------------------------------
/neutron/services/firewall/README.md:
--------------------------------------------------------------------------------
1 | ### firewall
2 | 防火墙服务。
3 |
--------------------------------------------------------------------------------
/neutron/services/firewall/agents.md:
--------------------------------------------------------------------------------
1 | # agents
2 | firewall_agent_api.py中定义了FWaaSPluginApiMixin类和FWaaSAgentRpcCallbackMixin类。
3 |
4 | 前者继承自rpc.RpcProxy,是agent往plugin发出rpc消息时候,为agent一端使用的方法。包括set_firewall_status()方法和firewall_deleted()方法。
5 |
6 | 后者为agent的实现提供mixin,分别声明了create_firewall、update_firewall、delete_firewall三个接口,这三个接口用于处理plugin发出的对应rpc调用请求。
7 |
--------------------------------------------------------------------------------
/neutron/services/firewall/drivers.md:
--------------------------------------------------------------------------------
1 | # drivers
2 | 包括对linux防火墙和varmour防火墙进行操作的驱动类。
3 |
--------------------------------------------------------------------------------
/neutron/services/firewall/fwaas_pluginpy.md:
--------------------------------------------------------------------------------
1 | #### fwaas_plugin.py
2 | FirewallCallbacks类,继承自rpc.RpcCallback,agent利用rpc来调用该类的方法实现设置防火墙的状态、通知防火墙被删除、获取tenant所拥有的防火墙和规则、获取防火墙所属的租户们的信息。
3 |
4 | FirewallAgentApi类,继承自rpc.RpcProxy类,是plugin向agent端发送rpc调用时候,为plugin端使用的方法,包括对防火墙的创建、更新和删除。
5 |
6 | FirewallPlugin类,继承自firewall_db.Firewall_db_mixin类,是防火墙这个服务plugin的实现类,其中定义了一系列对防火墙进行操作的方法,包括create_firewall、update_firewall、delete_db_firewall_object、delete_firewall、update_firewall_policy、update_firewall_rule、insert_rule、remove_rule等。
7 | plugin和agent之间的调用关系如下面图表所示。
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/neutron/services/l3_router/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/neutron/services/l3_router/README.md
--------------------------------------------------------------------------------
/neutron/services/l3_router/l3_apicpy.md:
--------------------------------------------------------------------------------
1 | #### l3_apic.py
2 | 定义类ApicL3ServicePlugin,是Cisco APIC (Application Policy Infrastructure Controller) l3路由器的服务插件主类。
3 |
--------------------------------------------------------------------------------
/neutron/services/l3_router/l3_router_pluginpy.md:
--------------------------------------------------------------------------------
1 | #### l3_router_plugin.py
2 | L3RouterPlugin类,是Neutron L3路由器服务插件的实现主类。
3 |
--------------------------------------------------------------------------------
/neutron/services/loadbalancer/README.md:
--------------------------------------------------------------------------------
1 | ### loadbalancer
2 | 与其他服务实现类似,多了 agent 的 scheduler。
3 |
--------------------------------------------------------------------------------
/neutron/services/loadbalancer/agent.md:
--------------------------------------------------------------------------------
1 | #### agent
2 | 包括 agent.py、agent_api.py、agent_device_driver.py
3 | agent_manager.py 等模块,实现 LBaaS 服务的 agent 部分。
4 |
5 | ##### agent.py
6 | 按照标准流程,启动了一个 LbaasAgentService 服务,主代码如下。
7 | ```python
8 | def main():
9 | cfg.CONF.register_opts(OPTS)
10 | cfg.CONF.register_opts(manager.OPTS)
11 | # import interface options just in case the driver uses namespaces
12 | cfg.CONF.register_opts(interface.OPTS)
13 | config.register_interface_driver_opts_helper(cfg.CONF)
14 | config.register_agent_state_opts_helper(cfg.CONF)
15 | config.register_root_helper(cfg.CONF)
16 |
17 | common_config.init(sys.argv[1:])
18 | config.setup_logging()
19 |
20 | mgr = manager.LbaasAgentManager(cfg.CONF)
21 | svc = LbaasAgentService(
22 | host=cfg.CONF.host,
23 | topic=topics.LOADBALANCER_AGENT,
24 | manager=mgr
25 | )
26 | service.launch(svc).wait()
27 | ```
28 | 其中,管理服务类为 agent_manager 中的 LbaasAgentManager 类。
29 |
30 | LbaasAgentService 类是一个 rpc 服务类,定期执行管理服务类中的周期性任务。
31 | ```python
32 | class LbaasAgentService(n_rpc.Service):
33 | def start(self):
34 | super(LbaasAgentService, self).start()
35 | self.tg.add_timer(
36 | cfg.CONF.periodic_interval,
37 | self.manager.run_periodic_tasks,
38 | None,
39 | None
40 | )
41 | ```
42 |
43 | ##### agent_manager.py
44 | 主要就是定义了 LbaasAgentManager 类,继承自 n_rpc.RpcCallback 和 periodic_task.PeriodicTasks。
45 |
46 | 作为 agent 中的管理类。它实现了 LBaaS 中定义的各种操作 API,包括:
47 | * agent_updated
48 | * collect_stats
49 | * create_member
50 | * create_pool
51 | * create_pool_health_monitor
52 | * create_vip
53 | * delete_member
54 | * delete_pool
55 | * delete_pool_health_monitor
56 | * delete_vip
57 | * initialize_service_hook
58 | * periodic_resync
59 | * remove_orphans
60 | * sync_state
61 | * update_member
62 | * update_pool
63 | * update_pool_health_monitor
64 | * update_vip
65 | 这些操作又是通过调用更下一层的 driver 来实现。
66 |
67 | 同时,它定义了一个 rpc api 调用成员,向 topics.LOADBALANCER_PLUGIN 主题发送消息。
68 | ```python
69 | self.plugin_rpc = agent_api.LbaasAgentApi(
70 | topics.LOADBALANCER_PLUGIN,
71 | self.context,
72 | self.conf.host
73 | )
74 | ```
75 |
76 | ##### agent_api.py
77 | 主要定义了 LbaasAgentApi 类,继承自 n_rpc.RpcProxy,也是一个典型的 RPC 代理类。
78 |
79 | 这个类在 LbaasAgentManager 类中使用,用来负责替 agent 向指定的主题发送消息,调用监听者的对应方法。主要包括:
80 | * get_logical_device
81 | * get_ready_devices
82 | * plug_vip_port
83 | * pool_deployed
84 | * pool_destroyed
85 | * unplug_vip_port
86 | * update_pool_stats
87 | * update_status
88 |
89 | ##### agent_device_driver.py
90 | 主要定义了 AgentDeviceDriver 类,是一个抽象类,抽象出来支持 LBaaS agent 所需要 API 的一个驱动类。这些 API 包括对 pool、member 等资源的 CRUD 等。
91 |
92 |
--------------------------------------------------------------------------------
/neutron/services/loadbalancer/agent_schedulerpy.md:
--------------------------------------------------------------------------------
1 | #### agent_scheduler.py
2 | loadbalancer池和agent之间的绑定和调度维护。
3 |
--------------------------------------------------------------------------------
/neutron/services/loadbalancer/constantspy.md:
--------------------------------------------------------------------------------
1 | #### constants.py
2 | 常量定义。
3 |
--------------------------------------------------------------------------------
/neutron/services/loadbalancer/drivers.md:
--------------------------------------------------------------------------------
1 | #### drivers
2 | 包括支持 LBaaS agent 中需要的 API 的一些驱动,包括 a10networks、embrane、haproxy、logging_noop、netscaler、radware 等等。
3 |
4 |
5 | ##### driver_base.py
6 | 定义了一系列的实现 driver 所需要的基础类,
7 | 包括 BaseHealthMonitorManager、BaseListenerManager、BaseLoadBalancerManager
8 | BaseMemberManager、BasePoolManager、LoadBalancerBaseDriver。
9 |
10 |
11 | ##### driver_mixins.py
12 |
--------------------------------------------------------------------------------
/neutron/services/loadbalancer/pluginpy.md:
--------------------------------------------------------------------------------
1 | #### plugin.py
2 | 定义了该服务plugin的实现主类LoadBalancerPlugin。
3 |
--------------------------------------------------------------------------------
/neutron/services/metering/README.md:
--------------------------------------------------------------------------------
1 | ### metering
2 |
--------------------------------------------------------------------------------
/neutron/services/metering/agents.md:
--------------------------------------------------------------------------------
1 | #### agents
2 |
--------------------------------------------------------------------------------
/neutron/services/metering/drivers.md:
--------------------------------------------------------------------------------
1 | #### drivers
2 |
--------------------------------------------------------------------------------
/neutron/services/metering/metering_pluginpy.md:
--------------------------------------------------------------------------------
1 | #### metering_plugin.py
2 | 定义了metering服务plugin的实现主类MeteringPlugin。
3 |
--------------------------------------------------------------------------------
/neutron/services/provider_configurationpy.md:
--------------------------------------------------------------------------------
1 | ### provider_configuration.py
2 | 主要定义了类ProviderConfiguration。代表一个service的实际提供者的配置信息。
3 |
--------------------------------------------------------------------------------
/neutron/services/service_basepy.md:
--------------------------------------------------------------------------------
1 | ### service_base.py
2 |
3 | 定义了抽象基础类ServicePluginBase,继承自extensions.PluginInterface类。为所有的service plugin定义基础的接口,包括get_plugin_type、get_plugin_name、get_plugin_description。
4 |
5 | 定义了方法load_drivers,该方法为指定的service加载驱动。
6 |
--------------------------------------------------------------------------------
/neutron/services/vpn/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/neutron/services/vpn/README.md
--------------------------------------------------------------------------------
/neutron/services/vpn/agentpy.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yeasy/openstack_code_Neutron/f46dcf5e6238c1e730845060ea2d3e4103007e88/neutron/services/vpn/agentpy.md
--------------------------------------------------------------------------------
/neutron/tests/README.md:
--------------------------------------------------------------------------------
1 | ## tests
2 |
--------------------------------------------------------------------------------
/neutron/version.py.md:
--------------------------------------------------------------------------------
1 | ## version.py
2 | 从prb中获取version信息。
3 | ```python
4 | version_info = pbr.version.VersionInfo('neutron')
5 | ```
6 |
--------------------------------------------------------------------------------
/neutron/wsgi.py.md:
--------------------------------------------------------------------------------
1 | ## wsgi.py
2 | WorkerService类,封装被ProcessLauncher处理的一个工作者。
3 | * Server 类,管理多个WSGI socket和应用。
4 | * Middleware 类,封装基本的WSGI中间件。
5 | * Request 类,继承自webob.Request类,代表请求信息。
6 | * ActionDispatcher 类,通过行动名将方法名映射到本地方法。
7 | * Application 类,是WSGI应用的封装基础类。
8 | * Debug 类,用于进行debug的中间件。
9 | * Router 类,WSGI中间件,将到达的请求发送给应用。
10 | * Resource类,继承自Application类,是wsgi应用,用于处理序列化和控制器分发。
11 | * Controller类,是一个WSGI的应用,根据请求,调用响应的方法。
12 |
--------------------------------------------------------------------------------
/overview/README.md:
--------------------------------------------------------------------------------
1 | # 整体结构
2 |
3 | 源代码主要分为5个目录和若干文件:
4 | bin,doc,etc,neutron和tools。
5 | 除了这 5 个目录外,还包括一些说明文档、安装需求说明文件等。
6 |
7 | ## bin
8 | 主要包括 neutron-rootwrap、neutron-rootwrap-xen-dom0 两个文件。
9 | 提供一些可执行命令。
10 |
11 | ## doc
12 | 包括文档生成的相关源码。
13 |
14 | ## etc
15 | 跟服务和配置相关的文件,基本上该目录中内容在安装时会被复制到系统的/etc/ 目录下。
16 | * init.d/neutron-server:neutron-server 系统服务脚本,支持 start、stop、restart 和 status 操作。
17 | * neutron/: 核心的库代码。
18 | * plugins/: 各种厂商的 plugin 相关的配置文件(*.ini),其中被注释掉的行表明了默认值。
19 | * rootwrap.d/: 一些 filters 文件,用来限定各个模块执行命令的权限。
20 | 各种 ini 和 conf 文件,包括 api-paste.ini、dhcp_agent.ini、l3_agent.ini、fwaas_driver.ini、lbaas_agent.ini、metadata_agent.ini、metering_agent.ini,以及 neutron.conf、policy.json、rootwrap.conf、services.conf 等。
21 | 基本上 neutron 相关的各个组件的配置信息都在这里了。
22 |
23 | ## neutron
24 | 核心的代码实现都在这个目录下。
25 | 可以通过下面的命令来统计主要实现的核心代码量。
26 | ```
27 | find neutron -name "*.py" | xargs cat | wc -l
28 | ```
29 | 目前版本,约为226k行。
30 |
31 | ## tools
32 | 一些相关的代码格式化检测、环境安装的脚本。
33 |
34 | ## 其它文档
35 | * README.rst:介绍了项目的情况和连接。
36 | * TESTING.rst:介绍如何进行开发后的测试。官方配置的 jenkins 当 gerrit 上有代码提交 review 的时候会触发 tox 测试。实际上,OpenStack 中的项目使用 [tox](http://tox.readthedocs.org/en/latest/) 来管理测试的虚拟环境,使用 [testr](https://wiki.openstack.org/wiki/Testr) 来管理运行测试案例的顺序。
37 | * run_tests.sh:自动创建一个虚拟环境并进行测试。命令为 `./run_tests -V`。
38 |
--------------------------------------------------------------------------------
/rally-jobs/README.md:
--------------------------------------------------------------------------------
1 | # rally-jobs
2 |
--------------------------------------------------------------------------------
/rally-jobs/README.rst.md:
--------------------------------------------------------------------------------
1 | ## README.rst
2 |
--------------------------------------------------------------------------------
/rally-jobs/extra/README.md:
--------------------------------------------------------------------------------
1 | ## extra
2 |
--------------------------------------------------------------------------------
/rally-jobs/extra/README.rst.md:
--------------------------------------------------------------------------------
1 | ### README.rst
2 |
--------------------------------------------------------------------------------
/rally-jobs/neutron-neutron.yaml.md:
--------------------------------------------------------------------------------
1 | ## neutron-neutron.yaml
2 |
--------------------------------------------------------------------------------
/rally-jobs/plugins/README.md:
--------------------------------------------------------------------------------
1 | ## plugins
2 |
--------------------------------------------------------------------------------
/rally-jobs/plugins/README.rst.md:
--------------------------------------------------------------------------------
1 | ### README.rst
2 |
--------------------------------------------------------------------------------
/rally-jobs/plugins/__init__.py.md:
--------------------------------------------------------------------------------
1 | ### __init__.py
2 |
--------------------------------------------------------------------------------
/tools/README.md:
--------------------------------------------------------------------------------
1 | # tools
2 | 包括跟安装和格式检查相关的一些工具。
3 |
--------------------------------------------------------------------------------
/tools/check_bash.sh.md:
--------------------------------------------------------------------------------
1 | ## check_bash.sh
2 |
--------------------------------------------------------------------------------
/tools/check_i18n.py.md:
--------------------------------------------------------------------------------
1 | ## check_i18n.py
2 | 检查国际化。
3 |
--------------------------------------------------------------------------------
/tools/check_i18n_test_case.txt.md:
--------------------------------------------------------------------------------
1 | ## check_i18n_test_case.txt
2 | 是check_i18n.py进行国际化格式检查的用例
3 |
--------------------------------------------------------------------------------
/tools/clean.sh.md:
--------------------------------------------------------------------------------
1 | ## clean.sh
2 | 清除代码编译中间结果。
3 |
--------------------------------------------------------------------------------
/tools/i18n_cfg.py.md:
--------------------------------------------------------------------------------
1 | ## i18n_cfg.py
2 |
--------------------------------------------------------------------------------
/tools/install_venv.py.md:
--------------------------------------------------------------------------------
1 | ## install_venv.py
2 | neutron开发的时候,可能需要一套虚环境,该脚本可以安装一个python虚环境。
3 |
--------------------------------------------------------------------------------
/tools/install_venv_common.py.md:
--------------------------------------------------------------------------------
1 | ## install_venv_common.py
2 | 为install_venv.py提供必要的方法。
3 |
--------------------------------------------------------------------------------
/tools/pretty_tox.sh.md:
--------------------------------------------------------------------------------
1 | ## pretty_tox.sh
2 |
--------------------------------------------------------------------------------
/tools/with_venv.sh.md:
--------------------------------------------------------------------------------
1 | ## with_venv.sh
2 | 启用虚环境。
3 |
--------------------------------------------------------------------------------
/understanding/README.md:
--------------------------------------------------------------------------------
1 | # 理解代码
2 | 本部分试图从专题和业务流程的角度来剖析 Neutron 代码,以便理解如此设计的内涵。
3 |
--------------------------------------------------------------------------------
/understanding/agent.md:
--------------------------------------------------------------------------------
1 | ## Agent专题
2 | agent 一般作为 plugin 的后端,接收远端 plugin 的命令来具体实施对本地网络资源的操作,并同时反馈信息给远端的 plugin。
3 |
4 | agent 可以分为四种:核心 agent、dhcp agent、l3 agent、其它 agent。
5 | 核心 agent 用于服务核心plugin,提供 L2 功能,所以又被称为 L2 agent。该 agent 在所有的计算和网络节点均存在。
6 |
7 | dhcp agent 用于提供对虚机的 dhcp 管理和分配。核心 plugin 在实现上通过继承 DhcpAgentSchedulerDbMixin 来实现对 dhcp agent 的操作。dhcp agent 可以安装在任何节点上,并支持可以配置多个实例,还支持配置的的调度策略。
8 |
9 | l3 agent 用于提供对路由器的管理(配置 iptables规则)。l3 agent 也可以安装在任何节点上,并支持可以配置多个实例,还支持配置的的调度策略。
10 |
11 | 其它 agent,用于实现其它的网络服务等,包括 metadata、metering 等。
12 | 从 agent 的结构上来看,主要包括两部分:跟 plugin 之间的 rpc 消息处理,以及本地的操作。前者主要用于跟 plugin 进行交互,接收 plugin 命令、调用 plugin 方法、汇报状态等;后者用于对本地资源进行实际的操作,包括配置 iptables 表项,配置 dhcp 服务等。
13 |
--------------------------------------------------------------------------------
/understanding/call_logic.md:
--------------------------------------------------------------------------------
1 | ## 调用逻辑
2 |
--------------------------------------------------------------------------------
/understanding/extension.md:
--------------------------------------------------------------------------------
1 | ## Extension专题
2 | Neutron中的扩展,主要用于实现原先标准API中并不支持的扩展的网络服务,包括路由器、防火墙、vpn等等。
3 |
4 | 扩展包括三种类型:资源扩展、行动扩展和请求扩展。
5 |
6 | 资源扩展意味着在网络中引入新的资源和相应的属性;行动扩展是为标准的API控制器添加行动支持;请求扩展是为API控制器提供额外的请求和响应支持。
7 |
--------------------------------------------------------------------------------
/understanding/plugin.md:
--------------------------------------------------------------------------------
1 | ## Plugin专题
2 | plugin实现对REST API请求的后端支持。前端的rest框架会调用plugin的相应方法来实现rest api规定的语义。
3 |
4 | plugin包括两种类型:核心plugin和服务plugin。
5 |
6 | 核心Plugin实现了对标准API的支持(对网络、端口和子网资源的相应操作),此外还可以选择性的支持一些扩展的API(_supported_extension_aliases属性中会指出)。
7 | 以neutron的openvswitch plugin为例,支持的扩展API包括
8 | ```python
9 | _supported_extension_aliases = ["provider", "external-net", "router",
10 | "ext-gw-mode", "binding", "quotas",
11 | "security-group", "agent", "extraroute",
12 | "l3_agent_scheduler",
13 | "dhcp_agent_scheduler",
14 | "extra_dhcp_opt",
15 | "allowed-address-pairs"]
16 | ```
17 | 服务plugin则专门用于实现扩展API。目前,路由器、防火墙、vpn等都有相应的service plugin来专门实现。
18 |
19 | neturon server启动时候,根据配置文件动态加载相应的核心plugin及服务plugins。
20 | 目前,neutron-server只能配置一个核心Plugin,但可以配置多个服务plugin(但每个extension的实现plugin不能超过一个)。
21 |
22 | ML2 core plugin允许同时加载多个mechanism driver,可以达到同时使用不同的L2实现技术的效果。
23 |
--------------------------------------------------------------------------------
/understanding/rest_api.md:
--------------------------------------------------------------------------------
1 | ## REST API 专题
2 | neutron-server(相当于REST API Server)的核心作用之一就是要实现REST API。
3 |
4 | 在Neutron中,neutron-server(相当于REST API Server)负责将收到的REST API请求交由Plugin来进行相关处理。可以看出,这其实就是一个web服务器要完成的事情,将http请求转化为对资源的操作(通过plugin的方法调用),并返回响应。
5 | REST API可以分为两类:标准API和扩展API。
6 |
7 | 前者主要是由原先的 nova-network项目沿用而来,实现对网络二层的支持,核心资源只有网络、端口和子网;后者则通过进行扩展,提供更多的网络服务。目前已有的扩展有L3(router),L4(TPC/udp firewall)及L7(http/https load balancer)。随着neutron项目的不断成熟,扩展API会演化为标准API。
8 |
9 | 这个过程的主要涉及的模块包括
10 | neutron.server、service模块,以及定义了neutron API的neutron.api包。
11 |
12 | 
13 |
14 | 以neutron.api.v2包为例,其中base.py中定义了Controller类,是实现URL到plugin的api进行mapping的核心。
15 |
16 | 其主要方法包括create、delete、index、show、update。
17 |
18 | 顾名思义,create用于创建资源,delete用于删除资源,show是获取资源、update是更新资源,index是返回请求资源的列表。
19 |
20 | 以create方法为例来看主要过程。
21 |
22 | 向network的notifier发送一个资源create.start的通知;然后进行policy的检查;之后调用plugin中相应的方法进行处理,最后向network的notifier发出一个资源create.end的通知。
23 |
--------------------------------------------------------------------------------
/understanding/rpc/README.md:
--------------------------------------------------------------------------------
1 | ## RPC 专题
2 | RPC是neutron中跨模块进行方法调用的很重要的一种方式,主要包括client端和server端。client端用于发出rpc消息,server端用于监听消息并进行相应处理。
3 |
--------------------------------------------------------------------------------
/understanding/rpc/agent_rpc.md:
--------------------------------------------------------------------------------
1 | ### agent端的rpc
2 | 在dhcp agent、l3 agent、firewall agent以及metering agent的main函数中都能找到类似的创建一个rpc 服务端的代码,以dhcp agent为例。
3 | ```python
4 | def main():
5 | register_options()
6 | common_config.init(sys.argv[1:])
7 | config.setup_logging(cfg.CONF)
8 | server = neutron_service.Service.create(
9 | binary='neutron-dhcp-agent',
10 | topic=topics.DHCP_AGENT,
11 | report_interval=cfg.CONF.AGENT.report_interval,
12 | manager='neutron.agent.dhcp_agent.DhcpAgentWithStateReport')
13 | service.launch(server).wait()
14 | ```
15 | 最核心的,也是跟rpc相关的部分包括两部分,首先是创建rpc服务端。
16 | ```python
17 | server = neutron_service.Service.create(
18 | binary='neutron-dhcp-agent',
19 | topic=topics.DHCP_AGENT,
20 | report_interval=cfg.CONF.AGENT.report_interval,
21 | manager='neutron.agent.dhcp_agent.DhcpAgentWithStateReport')
22 | ```
23 | 该代码实际上创建了一个rpc服务端,监听指定的topic并定期的运行manager上的定期任务。
24 |
25 | create()方法返回一个neutron.service.Service对象,neutron.service.Service继承自neutron.common.rpc.Service类。
26 |
27 | 首先看neutron.common.rpc.Service类,该类定义了start方法,该方法主要完成两件事情:一件事情是将manager添加到endpoints中;一件是创建了三个rpc的consumer,分别监听topic、topic.host和fanout的队列消息。
28 |
29 | 而在neutron.service.Service类中,初始化中生成了一个manager实例(即neutron.agent.dhcp_agent.DhcpAgentWithStateReport);并为start方法添加了周期性执行report_state方法和periodic_tasks方法。report_state方法实际上什么都没做,periodic_tasks方法则调用manager的periodic_tasks方法。
30 |
31 | manager实例(即neutron.agent.dhcp_agent.DhcpAgentWithStateReport)在初始化的时候首先创建一个rpc的client端,通过代码
32 | ```python
33 | self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
34 | ```
35 | 该client端实际上定义了report_state方法,可以状态以rpc消息的方式发送给plugin。
36 |
37 | manager在初始化后,还会指定周期性运行_report_state方法,实际上就是调用client端的report_state方法。
38 |
39 | 至此,对rpc服务端的创建算是完成了,之后执行代码。
40 | ```python
41 | service.launch(server).wait()
42 | ```
43 |
44 | service.launch(server)方法首先会将server放到协程组中,并调用server的start方法来启动server。
45 |
--------------------------------------------------------------------------------
/understanding/rpc/neutron_server_rpc.md:
--------------------------------------------------------------------------------
1 | ### neutron-server的rpc
2 | 这个rpc服务端主要通过neutron.server中主函数中代码执行
3 | ```python
4 | neutron_rpc = service.serve_rpc()
5 | ```
6 | 方法的实现代码如下
7 | ```python
8 | def serve_rpc():
9 | plugin = manager.NeutronManager.get_plugin()
10 |
11 | # If 0 < rpc_workers then start_rpc_listeners would be called in a
12 | # subprocess and we cannot simply catch the NotImplementedError. It is
13 | # simpler to check this up front by testing whether the plugin supports
14 | # multiple RPC workers.
15 | if not plugin.rpc_workers_supported():
16 | LOG.debug(_("Active plugin doesn't implement start_rpc_listeners"))
17 | if 0 < cfg.CONF.rpc_workers:
18 | msg = _("'rpc_workers = %d' ignored because start_rpc_listeners "
19 | "is not implemented.")
20 | LOG.error(msg, cfg.CONF.rpc_workers)
21 | raise NotImplementedError
22 |
23 | try:
24 | rpc = RpcWorker(plugin)
25 |
26 | if cfg.CONF.rpc_workers < 1:
27 | rpc.start()
28 | return rpc
29 | else:
30 | launcher = common_service.ProcessLauncher(wait_interval=1.0)
31 | launcher.launch_service(rpc, workers=cfg.CONF.rpc_workers)
32 | return launcher
33 | except Exception:
34 | with excutils.save_and_reraise_exception():
35 | LOG.exception(_('Unrecoverable error: please check log '
36 | 'for details.'))
37 | ```
38 | 其中,RpcWorker(plugin)主要通过调用plugin的方法来创建rpc服务端。
39 | ```python
40 | self._servers = self._plugin.start_rpc_listeners()
41 | ```
42 |
43 | 该方法在大多数plugin中并未被实现,目前ml2支持该方法。
44 |
45 | 在neutron.plugin.ml2.plugin.ML2Plugin类中,该方法创建了一个topic为topics.PLUGIN的消费rpc。
46 |
47 | ```python
48 | def start_rpc_listeners(self):
49 | self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager),
50 | agents_db.AgentExtRpcCallback()]
51 | self.topic = topics.PLUGIN
52 | self.conn = n_rpc.create_connection(new=True)
53 | self.conn.create_consumer(self.topic, self.endpoints,
54 | fanout=False)
55 | return self.conn.consume_in_threads()
56 | ```
57 |
--------------------------------------------------------------------------------
/understanding/rpc/plugin_rpc.md:
--------------------------------------------------------------------------------
1 | ### plugin端的rpc
2 | 以openvswitch的plugin为例进行分析。
3 |
4 | neutron.plugin.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2类在初始化的时候调用了self.setup_rpc方法。
5 |
6 | 其代码为
7 | ```python
8 | def setup_rpc(self):
9 | # RPC support
10 | self.service_topics = {svc_constants.CORE: topics.PLUGIN,
11 | svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
12 | self.conn = n_rpc.create_connection(new=True)
13 | self.notifier = AgentNotifierApi(topics.AGENT)
14 | self.agent_notifiers[q_const.AGENT_TYPE_DHCP] = (
15 | dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
16 | )
17 | self.agent_notifiers[q_const.AGENT_TYPE_L3] = (
18 | l3_rpc_agent_api.L3AgentNotifyAPI()
19 | )
20 | self.endpoints = [OVSRpcCallbacks(self.notifier, self.tunnel_type),
21 | agents_db.AgentExtRpcCallback()]
22 | for svc_topic in self.service_topics.values():
23 | self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
24 | # Consume from all consumers in threads
25 | self.conn.consume_in_threads()
26 | ```
27 |
28 | 创建一个通知rpc的客户端,用于向l2的agent发出通知。所有plugin都需要有这样一个发出通知消息的客户端。
29 |
30 | 分别创建了一个dhcp agent和l3 agent的通知rpc客户端。
31 |
32 | 之后,创建两个跟service agent相关的consumer,分别监听topics.PLUGIN和topics.L3PLUGIN两个主题。
33 |
34 | 
35 |
--------------------------------------------------------------------------------