接上一篇文章继续分析文件nova/api/openstack/compute/servers.py中类ServersController中的create()函数。
self._create_by_func_list(server_dict, create_kwargs, body)
availability_zone = create_kwargs.pop("availability_zone", None)
if api_version_request.is_supported(req, min_version='2.52'):
create_kwargs['tags'] = server_dict.get('tags')
helpers.translate_attributes(helpers.CREATE,
server_dict, create_kwargs)
target = {
'project_id': context.project_id,
'user_id': context.user_id,
'availability_zone': availability_zone}
context.can(server_policies.SERVERS % 'create', target)
# TODO(Shao He, Feng) move this policy check to os-availability-zone
# extension after refactor it.
parse_az = self.compute_api.parse_availability_zone
try:
availability_zone, host, node = parse_az(context,
availability_zone)
except exception.InvalidInput as err:
raise exc.HTTPBadRequest(explanation=six.text_type(err))
if host or node:
context.can(server_policies.SERVERS % 'create:forced_host', {})
min_compute_version = service_obj.get_minimum_version_all_cells(
nova_context.get_admin_context(), ['nova-compute'])
supports_device_tagging = (min_compute_version >=
DEVICE_TAGGING_MIN_COMPUTE_VERSION)
从create_kwargs中获取availability_zone,在本实例中,availability_zone位空。如果api的版本大于2.52,则从server中获取tags,在本实例中,也为空。
helpers.translate_attributes()函数继续从用户请求中提取变量,如access_ip_v4,函数在文件nova/api/openstack/compute/helpers.py中定义,在本实例中,改函数中提取的变量全都为空。
&n