defmain(): config.parse_args(sys.argv) logging.setup(CONF, "nova") utils.monkey_patch() objects.register_all() gmr_opts.set_defaults(CONF) if'osapi_compute'in CONF.enabled_apis: # NOTE(mriedem): This is needed for caching the nova-compute service # version. objects.Service.enable_min_version_cache() log = logging.getLogger(__name__)
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 or1) started += 1 except exception.PasteAppNotFound as ex: log.warning("%s. ``enabled_apis`` includes bad values. " "Fix to remove this warning.", ex)
具体服务在CONF/SERVICE.PY中定义
1 2 3 4 5 6 7 8
cfg.ListOpt('enabled_apis', item_type=cfg.types.String(choices=['osapi_compute', 'metadata']), default=['osapi_compute', 'metadata'], help="List of APIs to be enabled by default."), cfg.ListOpt('enabled_ssl_apis', default=[], help="""
像之前的glance中的glance-api启动一样。找到nova的配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13
[composite:osapi_compute] use = call:nova.api.openstack.urlmap:urlmap_factory /: oscomputeversions # v21 is an exactly feature match for v2, except it has more stringent # input validation on the wsgi surface (prevents fuzzing early on the # API). It also provides new features via API microversions which are # opt into for clients. Unaware clients will receive the same frozen # v2 API feature set, but with some relaxed validation /v2: openstack_compute_api_v21_legacy_v2_compatible /v2.1: openstack_compute_api_v21 #。。。。。 [app:osapi_compute_app_v21] paste.app_factory = nova.api.openstack.compute:APIRouterV21.factory#跟进
defcreate(self, req, body): """Creates a new server for a given user.""" context = req.environ['nova.context'] server_dict = body['server'] password = self._get_server_admin_password(server_dict) name = common.normalize_name(server_dict['name']) description = name if api_version_request.is_supported(req, min_version='2.19'): description = server_dict.get('description')
# Arguments to be passed to instance create function create_kwargs = {}#以上获取post的各类参数,计划创建。
# TODO(alex_xu): This is for back-compatible with stevedore # extension interface. But the final goal is that merging # all of extended code into ServersController. self._create_by_func_list(server_dict, create_kwargs, body)#跟进
# We can't do this check earlier because we need bdms from all sources # to have been merged in order to get the root bdm. self._checks_for_create_and_rebuild(context, image_id, boot_meta, instance_type, metadata, injected_files, block_device_mapping.root_bdm())
for rs, build_request, im in instances_to_build: build_requests.append(build_request) instance = build_request.get_new_instance(context) instances.append(instance) request_specs.append(rs)