# where does nova.conf comes in for nova services?

When I read the source code of nova-scheduler, I don't find the entry where the nova.con comes in. Here is my searching path:

/etc/init.d/nova-scheduler : nothing, just run nova-scheduler(in /usr/bin/nova-scheduler)

/usr/bin/nova-scheduler : run nova.cmd.scheduler main()

/usr/share/pyshared/nova/cmd/scheduler.py:

Well, I guess this code is where nova.conf comes in. And the most probably entry is:

config.parse_args(sys.argv)

if we assign --config-file=/etc/nova/nova.conf option when running nova-scheduler, then this is the entry where nova.conf comes in manually

The reason why I emphasise "manually" is because when we run the service, we don't need to assign such option.(We can see the openstack installation guide of docs.openstack.org with version icehouse, that when executing the nova services, we just only run:service nova-xxxx restart)

Well, this is not a big deal since when creating nova services, all of the options has the default values:(for instance, /usr/share/pyshared/nova/service.py, we can see that there are settings of default options at the beginning of the file). But even if so, then that seems there are no entry of nova.conf for the nova services. Then why do we need it?

Anyone has any idea?

edit retag close merge delete

Sort by » oldest newest most voted

Got the answer: if we run the nova services without assigning --config-file=/etc/nova/nova.conf like:

service nova-scheduler start

Then scheduler.py in /usr/share/pyshared/nova/cmd/ will run with nova.conf.

Actually yes, the entry is config.parse_args(sys.argv) in scheduler.py, lets trace parse_args() in /usr/share/pyshared/nova/config.py:

cfg.CONF(argv[1:],
project='nova',
version=version.version_string(),
default_config_files=default_config_files)

Well if we don't manually assign default_config_file when running nova service, then this value is None. So let's find out the entry of nova.con in cfg.CONF:

/usr/share/pyshared/oslo/config/cfg.py:

CONF = ConfigOpts()

let's see the caller in ConfigOpts(), first note that we have this pre_setup to assign the config_file(s):

prog, default_config_files = self._pre_setup(project,
prog,
version,
usage,
default_config_files)

We can find that the nova.conf enters in:

if default_config_files is None:
default_config_files = find_config_files(project, prog)

If we trace the find_config_file, we can see that it will find the nova.conf in the directories:

~/.${project}/ ~/ /etc/${project}/
/etc/
more