[tony@tony-controller ~]$ yum_repo_package_list centos-openstack-rocky | grep nova
openstack-nova-api.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-common.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-compute.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-conductor.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-console.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-novncproxy.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-placement-api.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
openstack-nova-scheduler.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
python-nova.noarch 1:18.2.0-1.el7 @centos-openstack-rocky
python2-novaclient.noarch 1:11.0.0-1.el7 @centos-openstack-rocky
openstack-nova.noarch 1:18.2.0-1.el7 centos-openstack-rocky
openstack-nova-cells.noarch 1:18.2.0-1.el7 centos-openstack-rocky
openstack-nova-migration.noarch 1:18.2.0-1.el7 centos-openstack-rocky
openstack-nova-network.noarch 1:18.2.0-1.el7 centos-openstack-rocky
openstack-nova-serialproxy.noarch 1:18.2.0-1.el7 centos-openstack-rocky
openstack-nova-spicehtml5proxy.noarch 1:18.2.0-1.el7 centos-openstack-rocky
puppet-nova.noarch 13.3.1-1.el7 centos-openstack-rocky
python-nova-tests.noarch 1:18.2.0-1.el7 centos-openstack-rocky
python-novaclient-doc.noarch 1:11.0.0-1.el7 centos-openstack-rocky
python-novajoin.noarch 1.1.1-2.el7 centos-openstack-rocky
python-novajoin-doc.noarch 1.1.1-2.el7 centos-openstack-rocky
python-novajoin-tests-tempest-doc.noarch
python-novajoin-tests-unit.noarch 1.1.1-2.el7 centos-openstack-rocky
python2-novajoin-tests-tempest.noarch 0.0.1-0.2.f657712git.el7
这个包中包含了重要的配置文件,命令行接口以及被其他的nova服务依赖的公共库等。
[tony@tony-controller ~]$ yum_info openstack-nova-common
sudo yum info openstack-nova-common
...
Description :
: ...
: This package contains scripts, config and dependencies shared
: between all the OpenStack nova services.
sudo rpm -ql openstack-nova-common
/etc/logrotate.d/openstack-nova
/etc/nova
/etc/nova/api-paste.ini
/etc/nova/nova.conf
/etc/nova/policy.json
/etc/nova/release
/etc/nova/rootwrap.conf
/etc/sudoers.d/nova
/usr/bin/nova-manage
/usr/bin/nova-policy
/usr/bin/nova-rootwrap
/usr/bin/nova-rootwrap-daemon
/usr/bin/nova-status
/usr/share/doc/openstack-nova-common-18.2.0
/usr/share/doc/openstack-nova-common-18.2.0/policy.yaml.sample
/usr/share/licenses/openstack-nova-common-18.2.0
/usr/share/licenses/openstack-nova-common-18.2.0/LICENSE
/usr/share/locale/cs/LC_MESSAGES/nova.mo
...
/usr/share/locale/zh_TW/LC_MESSAGES/nova.mo
/usr/share/nova
/usr/share/nova/interfaces.template
/usr/share/nova/nova-dist.conf
/usr/share/nova/rootwrap/network.filters
/var/lib/nova
/var/lib/nova/buckets
/var/lib/nova/instances
/var/lib/nova/keys
/var/lib/nova/networks
/var/lib/nova/tmp
/var/log/nova
/var/run/nova
这个包里包含了nova-api服务的配置文件,以及可执行文件。
在Rocky的最简安装配置中,只启用的nova-api服务。另外两个nova-metadata-api服务与nova-os-compute-api服务没有启用。
[tony@tony-controller ~]$ yum_info openstack-nova-api
sudo yum info openstack-nova-api
Name : openstack-nova-api
Description :
: ...
: This package contains the Nova services providing programmatic access.
sudo rpm -ql openstack-nova-api
/usr/bin/nova-api
/usr/bin/nova-api-metadata
/usr/bin/nova-api-os-compute
/usr/bin/nova-api-wsgi
/usr/bin/nova-metadata-wsgi
/usr/lib/systemd/system/openstack-nova-api.service
/usr/lib/systemd/system/openstack-nova-metadata-api.service
/usr/lib/systemd/system/openstack-nova-os-compute-api.service
/usr/share/nova/rootwrap/api-metadata.filters
这个包为compute服务提供数据库访问。conductor并不是一个服务。
[tony@tony-controller ~]$ yum_info openstack-nova-conductor
sudo yum info openstack-nova-conductor
Name : openstack-nova-conductor
Description :
: ...
: This package contains the Nova services providing database access for
: the compute service
sudo rpm -ql openstack-nova-conductor
/usr/bin/nova-conductor
/usr/lib/systemd/system/openstack-nova-conductor.service
这个包为虚拟机提供了console服务。
[tony@tony-controller ~]$ yum_info openstack-nova-console
sudo yum info openstack-nova-console
Name : openstack-nova-console
Description :
: ...
: This package contains the Nova services providing
: console access services to Virtual Machines.
sudo rpm -ql openstack-nova-console
/usr/bin/nova-console
/usr/bin/nova-consoleauth
/usr/bin/nova-xvpvncproxy
/usr/lib/systemd/system/openstack-nova-console.service
/usr/lib/systemd/system/openstack-nova-consoleauth.service
/usr/lib/systemd/system/openstack-nova-xvpvncproxy.service
这个包包含了Nova noVNC Proxy服务,使用浏览器webstockets连接来代理VNC访问。
[tony@tony-controller ~]$ yum_info openstack-nova-novncproxy
sudo yum info openstack-nova-novncproxy
Name : openstack-nova-novncproxy
Description :
: ...
: This package contains the Nova noVNC Proxy service that can proxy
: VNC traffic over browser websockets connections.
sudo rpm -ql openstack-nova-novncproxy
/etc/sysconfig/openstack-nova-novncproxy
/usr/bin/nova-novncproxy
/usr/lib/systemd/system/openstack-nova-novncproxy.service
这个包包含了调度服务,用于调度虚拟机在云中的运行。
[tony@tony-controller ~]$ yum_info openstack-nova-scheduler
sudo yum info openstack-nova-scheduler
Name : openstack-nova-scheduler
Description : ...
: This package contains the service for scheduling where
: to run Virtual Machines in the cloud.
sudo rpm -ql openstack-nova-scheduler
/usr/bin/nova-scheduler
/usr/lib/systemd/system/openstack-nova-scheduler.service
这个包包含了Nova placement服务,这个服务最初允许对资源提供者的管理。
[tony@tony-controller ~]$ yum_info openstack-nova-placement-api
sudo yum info openstack-nova-placement-api
Name : openstack-nova-placement-api
Description : ...
: This package contains the Nova placement service, which will initially
: allow for the management of resource providers.
sudo rpm -ql openstack-nova-placement-api
/etc/httpd/conf.d/00-nova-placement-api.conf
/usr/bin/nova-placement-api
这个包包含了控制虚拟机的服务
[tony@tony-controller ~]$ yum_info openstack-nova-compute
sudo yum info openstack-nova-compute
Name : openstack-nova-compute
Description :...
: This package contains the Nova service for controlling Virtual Machines.
sudo rpm -ql openstack-nova-compute
/usr/bin/nova-compute
/usr/lib/systemd/system/openstack-nova-compute.service
/usr/share/nova/rootwrap/compute.filters
这个包包括了nova的python库。
[tony@tony-controller ~]$ yum_info python-nova
sudo yum info python-nova
Name : python-nova
Description : ...
: This package contains the nova Python library.
nova的库所在的主要目录
[tony@tony-controller ~]$ sudo rpm -ql python-nova | grep -v "\.py"
/usr/lib/python2.7/site-packages/nova
/usr/lib/python2.7/site-packages/nova-18.2.0-py2.7.egg-info
…
/usr/lib/python2.7/site-packages/nova/api
/usr/lib/python2.7/site-packages/nova/api/ec2
/usr/lib/python2.7/site-packages/nova/api/metadata
/usr/lib/python2.7/site-packages/nova/api/openstack
/usr/lib/python2.7/site-packages/nova/api/openstack/compute
/usr/lib/python2.7/site-packages/nova/api/openstack/compute/rest_api_version_history.rst
/usr/lib/python2.7/site-packages/nova/api/openstack/compute/schemas
/usr/lib/python2.7/site-packages/nova/api/openstack/compute/views
/usr/lib/python2.7/site-packages/nova/api/openstack/placement
/usr/lib/python2.7/site-packages/nova/api/openstack/placement/handlers
/usr/lib/python2.7/site-packages/nova/api/openstack/placement/objects
/usr/lib/python2.7/site-packages/nova/api/openstack/placement/policies
/usr/lib/python2.7/site-packages/nova/api/openstack/placement/rest_api_version_history.rst
/usr/lib/python2.7/site-packages/nova/api/openstack/placement/schemas
/usr/lib/python2.7/site-packages/nova/api/validation
/usr/lib/python2.7/site-packages/nova/cells
/usr/lib/python2.7/site-packages/nova/cells/filters
/usr/lib/python2.7/site-packages/nova/cells/weights
/usr/lib/python2.7/site-packages/nova/cmd
/usr/lib/python2.7/site-packages/nova/common
/usr/lib/python2.7/site-packages/nova/compute
/usr/lib/python2.7/site-packages/nova/compute/monitors
/usr/lib/python2.7/site-packages/nova/compute/monitors/cpu
/usr/lib/python2.7/site-packages/nova/conductor
/usr/lib/python2.7/site-packages/nova/conductor/tasks
/usr/lib/python2.7/site-packages/nova/conf
/usr/lib/python2.7/site-packages/nova/console
/usr/lib/python2.7/site-packages/nova/console/rfb
/usr/lib/python2.7/site-packages/nova/console/securityproxy
/usr/lib/python2.7/site-packages/nova/console/xvp.conf.template
/usr/lib/python2.7/site-packages/nova/consoleauth
/usr/lib/python2.7/site-packages/nova/db
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api_migrations
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api_migrations/migrate_repo
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api_migrations/migrate_repo/README
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api_migrations/migrate_repo/migrate.cfg
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/api_migrations/migrate_repo/versions
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/migrate_repo
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/migrate_repo/README
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/migrate_repo/migrate.cfg
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/migrate_repo/versions
/usr/lib/python2.7/site-packages/nova/db/sqlalchemy/migrate_repo/versions/246_sqlite_upgrade.sql
/usr/lib/python2.7/site-packages/nova/hacking
/usr/lib/python2.7/site-packages/nova/image
/usr/lib/python2.7/site-packages/nova/image/download
/usr/lib/python2.7/site-packages/nova/ipv6
/usr/lib/python2.7/site-packages/nova/keymgr
/usr/lib/python2.7/site-packages/nova/network
/usr/lib/python2.7/site-packages/nova/network/neutronv2
/usr/lib/python2.7/site-packages/nova/network/security_group
/usr/lib/python2.7/site-packages/nova/notifications
/usr/lib/python2.7/site-packages/nova/notifications/objects
/usr/lib/python2.7/site-packages/nova/objects
/usr/lib/python2.7/site-packages/nova/pci
/usr/lib/python2.7/site-packages/nova/policies
/usr/lib/python2.7/site-packages/nova/privsep
/usr/lib/python2.7/site-packages/nova/scheduler
/usr/lib/python2.7/site-packages/nova/scheduler/client
/usr/lib/python2.7/site-packages/nova/scheduler/filters
/usr/lib/python2.7/site-packages/nova/scheduler/weights
/usr/lib/python2.7/site-packages/nova/servicegroup
/usr/lib/python2.7/site-packages/nova/servicegroup/drivers
/usr/lib/python2.7/site-packages/nova/virt
/usr/lib/python2.7/site-packages/nova/virt/disk
/usr/lib/python2.7/site-packages/nova/virt/disk/mount
/usr/lib/python2.7/site-packages/nova/virt/disk/vfs
/usr/lib/python2.7/site-packages/nova/virt/hyperv
/usr/lib/python2.7/site-packages/nova/virt/hyperv/README.rst
/usr/lib/python2.7/site-packages/nova/virt/image
/usr/lib/python2.7/site-packages/nova/virt/interfaces.template
/usr/lib/python2.7/site-packages/nova/virt/ironic
/usr/lib/python2.7/site-packages/nova/virt/libvirt
/usr/lib/python2.7/site-packages/nova/virt/libvirt/storage
/usr/lib/python2.7/site-packages/nova/virt/libvirt/volume
/usr/lib/python2.7/site-packages/nova/virt/powervm
/usr/lib/python2.7/site-packages/nova/virt/powervm/disk
/usr/lib/python2.7/site-packages/nova/virt/powervm/tasks
/usr/lib/python2.7/site-packages/nova/virt/powervm/volume
/usr/lib/python2.7/site-packages/nova/virt/vmwareapi
/usr/lib/python2.7/site-packages/nova/virt/xenapi
/usr/lib/python2.7/site-packages/nova/virt/xenapi/image
/usr/lib/python2.7/site-packages/nova/virt/zvm
/usr/lib/python2.7/site-packages/nova/vnc
/usr/lib/python2.7/site-packages/nova/volume
…
这个包包括nova命令行接口/usr/bin/nova,以及nova client相应的库。
[tony@tony-controller ~]$ yum_info python2-novaclient
sudo yum info python2-novaclient
Name : python2-novaclient
Description :
: This is a client for the OpenStack Nova API. There's a Python API (the
: novaclient module), and a command-line script (nova). Each implements 100% of
: the OpenStack Nova API.
sudo rpm -ql python2-novaclient
/etc/bash_completion.d
/etc/bash_completion.d/nova
/usr/bin/nova
/usr/bin/nova-2
/usr/bin/nova-2.7
/usr/lib/python2.7/site-packages/novaclient
/usr/lib/python2.7/site-packages/novaclient/__init__.py
/usr/lib/python2.7/site-packages/novaclient/__init__.pyc
/usr/lib/python2.7/site-packages/novaclient/__init__.pyo
...
[tony@tony-controller ~]$ sudo systemctl | grep openstack-nova
Service Name | Description | Entry Executable |
---|---|---|
openstack-nova-api.service | OpenStack Nova API Server | /usr/bin/nova-api |
openstack-nova-compute.service | OpenStack Nova Compute Server | /usr/bin/nova-compute |
openstack-nova-conductor.service | OpenStack Nova Conductor Server | /usr/bin/nova-conductor |
openstack-nova-consoleauth.service | OpenStack Nova VNC console auth Server | /usr/bin/nova-consoleauth |
openstack-nova-novncproxy.service | OpenStack Nova NoVNC Proxy Server | /usr/bin/nova-novncproxy --web /usr/share/novnc/ $OPTIONS |
openstack-nova-scheduler.service | OpenStack Nova Scheduler Server | /usr/bin/nova-scheduler |
nova-api服务的入口程序是/usr/bin/nova-api,这是一个python程序。
[tony@tony-controller ~]$ systemctl_status openstack-nova-api.service
● openstack-nova-api.service - OpenStack Nova API Server
Loaded: loaded (/usr/lib/systemd/system/openstack-nova-api.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2019-04-15 15:26:18 CST; 2 days ago
Main PID: 8567 (nova-api)
Tasks: 3
CGroup: /system.slice/openstack-nova-api.service
├─8567 /usr/bin/python2 /usr/bin/nova-api
├─8607 /usr/bin/python2 /usr/bin/nova-api
└─8609 /usr/bin/python2 /usr/bin/nova-api
Apr 15 15:26:09 tony-controller systemd[1]: Stopped OpenStack Nova API Server.
Apr 15 15:26:09 tony-controller systemd[1]: Starting OpenStack Nova API Server...
Apr 15 15:26:18 tony-controller systemd[1]: Started OpenStack Nova API Server.
查看一下源代码,非常简单:从nova.cmd.api中导入main(),然后执行,main()退出后,main()的返回值送给sys.exit()函数。
[tony@tony-controller ~]$ cat /usr/bin/nova-api
#!/usr/bin/python2
# PBR Generated from u'console_scripts'
import sys
from nova.cmd.api import main
if __name__ == "__main__":
sys.exit(main())
Python语言编写的nova.cmd.api包位于/usr/lib/python2.7/site-packages/nova/cmd/api.py中,由python-nova安装包提供,而python-nova安装包对应的源代码即是OpenStack网站上的nova git库:https://git.openstack.org/openstack/nova。
[tony@tony-controller cmd]$ yum_provides /usr/lib/python2.7/site-packages/nova/cmd/api.py
1:python-nova-18.0.0-0.3.0rc3.el7.noarch : Nova Python libraries
Repo : centos-openstack-rocky
Matched from:
Filename : /usr/lib/python2.7/site-packages/nova/cmd/api.py
nova git库
# git库所在目录
[tony@tony-controller nova]$ pwd
/home/tony/nova
# git库的远程库
[tony@tony-controller nova]$ git remote -v
origin https://git.openstack.org/openstack/nova (fetch)
origin https://git.openstack.org/openstack/nova (push)
# 进入到nova子目录
[tony@tony-controller nova]$ cd nova
[tony@tony-controller nova]$ pwd
/home/tony/nova/nova
# 这个目录中的文件对应着安装到/usr/lib/python2.7/site-packages/nova/目录中的Nova Python库
# 例如cmd/api*即是/usr/bin/nova-api可执行文件导入的Python包 nova.cmd.api
[tony@tony-controller nova]$ ls -F
api/ conf/ filters.py manager.py quota.py utils.py
availability_zones.py config.py hacking/ monkey_patch.py rc_fields.py version.py
baserpc.py console/ hooks.py network/ rpc.py virt/
block_device.py consoleauth/ i18n.py notifications/ safe_utils.py vnc/
cache_utils.py context.py image/ objects/ scheduler/ volume/
cells/ crypto.py __init__.py pci/ service_auth.py weights.py
cmd/ db/ ipv6/ policies/ servicegroup/ wsgi.py
common/ debugger.py keymgr/ policy.py service.py
compute/ exception.py loadables.py privsep/ test.py
conductor/ exception_wrapper.py locale/ profiler.py tests/
[tony@tony-controller nova]$ ls -l cmd/api.py
-rw-rw-r--. 1 tony tony 2246 Apr 18 14:08 cmd/api.py