Ask Your Question
0

where does nova.conf comes in for nova services?

asked 2015-03-04 21:48:22 -0500

Waid gravatar image

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-03-05 19:53:46 -0500

Waid gravatar image

updated 2015-03-05 19:55:02 -0500

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/
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

2 followers

Stats

Asked: 2015-03-04 21:48:22 -0500

Seen: 159 times

Last updated: Mar 05 '15