Neutron 一般包含多個 services 和 agents,這些 services 和 agents 跑在一個或多個 nodes 上。這取決於你的 OpenStack 環境如何佈署,devstack 就是 single node,我的環境則由 Control node, Network node, Compute node 組成。
其中有幾個比較重要的 service
services 的 entry point 定義在 setup.cfg 檔案中的 console_scripts 這個片段,這段程式可以在 github 上看到 source code,不過像我用 apt-get -y install neutron-server
來安裝 neutron,系統中並不會留下 setup.cfg
<html>
<style>
pre {
box-shadow: none;
}
table, td {
border: none;
}
</style>
<body>
<script type='text/javascript' src='gistfy-app.herokuapp.com/github/nike1000/neutron/setup.cfg?branch=master&slice=43:67&lang=python'></script>
</body>
</html>
這邊指出了各個 service 的進入點,預設目錄的 prefix 是 /usr/lib/python2.7/dist-packages
以 neutron-db-manage = neutron.db.migration.cli:main
舉例
表示 neutron-db-manage 這個 service 的進入點是在 /usr/lib/python2.7/dist-packages/neutron/db/migration
這個資料夾底下的 cli.py 這個檔案中的 main function
—-
=====0x02 Interacting with Eventlet=====
Neutron 廣泛的使用了 eventlet library 來對 service 提供一個 asynchronous concurrency model
如果一個 service 使用了 eventlet library,則他不應該直接呼叫 eventlet.monkey_patch(),而是在 neutron/cmd/eventlet/… 維護他的 entry point main() function
如此一來,標準 Python library 會自動 patched 在 service 的 entry point import
<html>
<style>
pre {
box-shadow: none;
}
table, td {
border: none;
}
</style>
<body>
<script type='text/javascript' src='gistfy-app.herokuapp.com/github/nike1000/neutron/neutron/cmd/eventlet/init.py?branch=master&slice=13:15&lang=python'></script>
</body>
</html>
只有 neutron-server 會連線到資料庫,因為會影響 rolling upgrades,所以 agents 不會連線至資料庫
除了資料庫存取之外,其他的 configuration options 對於 neutron-server 和 agents 也是分開的
不過 services 和 agents 也都是讀取 /etc/neutron/neutron.conf 這個設定檔
裡面包含了用於 neutron 內部 RPCs 通訊的 oslo.messaging configuration, 像是檔案路徑等 host specific configuration,其他如 database, Keystone, Nova 等相關設定
此外,neutron-server 可能會載入 plugin 特別使用的設定檔,而 agent 不會載入這些 plugin configuration file,不過 agent 可以透過 RPC 對這些 plugin 的設定值做操作
每一個獨立的 agent 也會有自己的設定檔,通常是 /etc/neutron/*_agent.ini,這些設定會在 neutron.conf 之後被載入,所以 agent configuration file 的優先權會高於 neutron.conf
agent config 可能在 Neutron 網路中的不同機器間有不同的配置,例如用於 L3 agent 的 external_network_bridge
如果有任何 agent 需要透過 neutron RPC 存取其他的 external services,則這些 endpoint 必須在 agent 的設定檔中被定義,如 metadata agent 會用到的 nova metadata,我需要加上下列內容於 /etc/neutron/metadata_agent.ini
nova_metadata_ip = controller.mitaka.openstack metadata_proxy_shared_secret = helloOpenStack