nova/nova/cmd/api.py
from nova import config
def main():
config.parse_args(sys.argv)
logging.setup(CONF, "nova")
utils.monkey_patch()
objects.register_all()
if 'osapi_compute' in CONF.enabled_apis:
# NOTE(mriedem): This is needed for caching the nova-compute service
# version which is looked up when a server create request is made with
# network id of 'auto' or 'none'.
objects.Service.enable_min_version_cache()
log = logging.getLogger(__name__)
gmr.TextGuruMeditation.setup_autorun(version)
launcher = service.process_launcher()
started = 0
for api in CONF.enabled_apis:
should_use_ssl = api in CONF.enabled_ssl_apis
try:
server = service.WSGIService(api, use_ssl=should_use_ssl)
launcher.launch_service(server, workers=server.workers or 1)
started += 1
except exception.PasteAppNotFound as ex:
log.warning(
_LW("%s. ``enabled_apis`` includes bad values. "
"Fix to remove this warning."), six.text_type(ex))
if started == 0:
log.error(_LE('No APIs were started. '
'Check the enabled_apis config option.'))
sys.exit(1)
launcher.wait()
nova/nova/config.py
def parse_args(argv, default_config_files=None, configure_db=True,
init_rpc=True):
log.register_options(CONF)
# We use the oslo.log default log levels which includes suds=INFO
# and add only the extra levels that Nova needs
if CONF.glance.debug:
extra_default_log_levels = ['glanceclient=DEBUG']
else:
extra_default_log_levels = ['glanceclient=WARN']
log.set_defaults(default_log_levels=log.get_default_log_levels() +
extra_default_log_levels)
rpc.set_defaults(control_exchange='nova')
config.set_middleware_defaults()
CONF(argv[1:], 代码从这里跟进去会用到第三方库,然后会去查找配置文件从etc 下面
project='nova',
version=version.version_string(),
default_config_files=default_config_files)
if init_rpc:
rpc.init(CONF)
if configure_db:
sqlalchemy_api.configure(CONF)