您的位置:首页 > 其它

Nova API简单介绍

2018-03-21 19:58 148 查看
Nova API是访问并使用Nova所提供的各种服务的唯一途径,作为客户端和Nova之间的中间层,Nova API扮演了一个桥梁,或者说中间人的角色,Nova API把客户端的请求传达给Nova,待Nova处理完请求后再将处理结果返回给客户端。基于这样的特殊性,Nova API要求保持高度稳定,他们的名称以及返回的数据结构都不能轻易地作出改变。Nova发展到现在,我们所需要的API现在已经比较完备,从这个意义上来说,在耗费宝贵的时间去研究API的实现是毫无意义的事情。然而,对于希望能够对Nova有更深理解的我们来说,仔细研究一下少量的API仍然是十分值得的。这样就有机会了解一些概念,并可以趁机详细了解一下Openstack开发特点,就像Nova API本身在客户端和Nova间的桥梁作用一样,学习并理解它也是我们走向Openstack的一个很好的过渡。此外,作为Openstack两种主要通信方式(RESTFUL API和消息总线)之一,理解API的设计思路和执行过程,也有助于我们对Openstack 有更好的理解。Nova API的代码位于nova/api目录下,目录结构为:
[root@localhost api]# tree
.
├── auth.py
├── auth.pyc
├── compute_req_id.py
├── compute_req_id.pyc
├── ec2
│   ├── cloud.py
│   ├── ec2utils.py
│   ├── ec2utils.pyc
│   ├── __init__.py
│   └── __init__.pyc
├── __init__.py
├── __init__.pyc
├── manager.py
├── manager.pyc
├── metadata
│   ├── base.py
│   ├── base.pyc
│   ├── handler.py
│   ├── handler.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── password.py
│   ├── password.pyc
│   ├── vendordata_dynamic.py
│   ├── vendordata_dynamic.pyc
│   ├── vendordata_json.py
│   ├── vendordata_json.pyc
│   ├── vendordata.py
│   └── vendordata.pyc
├── openstack
│   ├── api_version_request.py
│   ├── api_version_request.pyc
│   ├── auth.py
│   ├── common.py
│   ├── common.pyc
│   ├── compute
│   │   ├── admin_actions.py
│   │   ├── admin_actions.pyc
│   │   ├── admin_password.py
│   │   ├── admin_password.pyc
│   │   ├── agents.py
│   │   ├── agents.pyc
│   │   ├── aggregates.py
│   │   ├── aggregates.pyc
│   │   ├── assisted_volume_snapshots.py
│   │   ├── assisted_volume_snapshots.pyc
│   │   ├── attach_interfaces.py
│   │   ├── attach_interfaces.pyc
│   │   ├── availability_zone.py
│   │   ├── availability_zone.pyc
│   │   ├── baremetal_nodes.py
│   │   ├── baremetal_nodes.pyc
│   │   ├── block_device_mapping.py
│   │   ├── block_device_mapping.pyc
│   │   ├── block_device_mapping_v1.py
│   │   ├── block_device_mapping_v1.pyc
│   │   ├── cells.py
│   │   ├── cells.pyc
│   │   ├── certificates.py
│   │   ├── certificates.pyc
│   │   ├── cloudpipe.py
│   │   ├── cloudpipe.pyc
│   │   ├── config_drive.py
│   │   ├── config_drive.pyc
│   │   ├── console_auth_tokens.py
│   │   ├── console_auth_tokens.pyc
│   │   ├── console_output.py
│   │   ├── console_output.pyc
│   │   ├── consoles.py
│   │   ├── consoles.pyc
│   │   ├── create_backup.py
│   │   ├── create_backup.pyc
│   │   ├── deferred_delete.py
│   │   ├── deferred_delete.pyc
│   │   ├── evacuate.py
│   │   ├── evacuate.pyc
│   │   ├── extended_availability_zone.py
│   │   ├── extended_availability_zone.pyc
│   │   ├── extended_server_attributes.py
│   │   ├── extended_server_attributes.pyc
│   │   ├── extended_status.py
│   │   ├── extended_status.pyc
│   │   ├── extended_volumes.py
│   │   ├── extended_volumes.pyc
│   │   ├── extension_info.py
│   │   ├── extension_info.pyc
│   │   ├── fixed_ips.py
│   │   ├── fixed_ips.pyc
│   │   ├── flavor_access.py
│   │   ├── flavor_access.pyc
│   │   ├── flavor_manage.py
│   │   ├── flavor_manage.pyc
│   │   ├── flavor_rxtx.py
│   │   ├── flavor_rxtx.pyc
│   │   ├── flavors_extraspecs.py
│   │   ├── flavors_extraspecs.pyc
│   │   ├── flavors.py
│   │   ├── flavors.pyc
│   │   ├── floating_ip_dns.py
│   │   ├── floating_ip_dns.pyc
│   │   ├── floating_ip_pools.py
│   │   ├── floating_ip_pools.pyc
│   │   ├── floating_ips_bulk.py
│   │   ├── floating_ips_bulk.pyc
│   │   ├── floating_ips.py
│   │   ├── floating_ips.pyc
│   │   ├── fping.py
│   │   ├── fping.pyc
│   │   ├── helpers.py
│   │   ├── helpers.pyc
│   │   ├── hide_server_addresses.py
│   │   ├── hide_server_addresses.pyc
│   │   ├── hosts.py
│   │   ├── hosts.pyc
│   │   ├── hypervisors.py
│   │   ├── hypervisors.pyc
│   │   ├── image_metadata.py
│   │   ├── image_metadata.pyc
│   │   ├── image_size.py
│   │   ├── image_size.pyc
│   │   ├── images.py
│   │   ├── images.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── instance_actions.py
│   │   ├── instance_actions.pyc
│   │   ├── instance_usage_audit_log.py
│   │   ├── instance_usage_audit_log.pyc
│   │   ├── ips.py
│   │   ├── ips.pyc
│   │   ├── keypairs.py
│   │   ├── keypairs.pyc
│   │   ├── limits.py
│   │   ├── limits.pyc
│   │   ├── lock_server.py
│   │   ├── lock_server.pyc
│   │   ├── migrate_server.py
│   │   ├── migrate_server.pyc
│   │   ├── migrations.py
│   │   ├── migrations.pyc
│   │   ├── multinic.py
│   │   ├── multinic.pyc
│   │   ├── multiple_create.py
│   │   ├── multiple_create.pyc
│   │   ├── networks_associate.py
│   │   ├── networks_associate.pyc
│   │   ├── networks.py
│   │   ├── networks.pyc
│   │   ├── pause_server.py
│   │   ├── pause_server.pyc
│   │   ├── pci.py
│   │   ├── quota_classes.py
│   │   ├── quota_classes.pyc
│   │   ├── quota_sets.py
│   │   ├── quota_sets.pyc
│   │   ├── remote_consoles.py
│   │   ├── remote_consoles.pyc
│   │   ├── rescue.py
│   │   ├── rescue.pyc
│   │   ├── rest_api_version_history.rst
│   │   ├── scheduler_hints.py
│   │   ├── scheduler_hints.pyc
│   │   ├── schemas
│   │   │   ├── admin_password.py
│   │   │   ├── admin_password.pyc
│   │   │   ├── agents.py
│   │   │   ├── agents.pyc
│   │   │   ├── aggregates.py
│   │   │   ├── aggregates.pyc
│   │   │   ├── assisted_volume_snapshots.py
│   │   │   ├── assisted_volume_snapshots.pyc
│   │   │   ├── attach_interfaces.py
│   │   │   ├── attach_interfaces.pyc
│   │   │   ├── availability_zone.py
│   │   │   ├── availability_zone.pyc
│   │   │   ├── block_device_mapping.py
│   │   │   ├── block_device_mapping.pyc
│   │   │   ├── block_device_mapping_v1.py
│   │   │   ├── block_device_mapping_v1.pyc
│   │   │   ├── cells.py
│   │   │   ├── cells.pyc
│   │   │   ├── cloudpipe.py
│   │   │   ├── cloudpipe.pyc
│   │   │   ├── config_drive.py
│   │   │   ├── config_drive.pyc
│   │   │   ├── console_output.py
│   │   │   ├── console_output.pyc
│   │   │   ├── create_backup.py
│   │   │   ├── create_backup.pyc
│   │   │   ├── evacuate.py
│   │   │   ├── evacuate.pyc
│   │   │   ├── fixed_ips.py
│   │   │   ├── fixed_ips.pyc
│   │   │   ├── flavor_access.py
│   │   │   ├── flavor_access.pyc
│   │   │   ├── flavor_manage.py
│   │   │   ├── flavor_manage.pyc
│   │   │   ├── flavors_extraspecs.py
│   │   │   ├── flavors_extraspecs.pyc
│   │   │   ├── floating_ip_dns.py
│   │   │   ├── floating_ip_dns.pyc
│   │   │   ├── floating_ips_bulk.py
│   │   │   ├── floating_ips_bulk.pyc
│   │   │   ├── floating_ips.py
│   │   │   ├── floating_ips.pyc
│   │   │   ├── hosts.py
│   │   │   ├── hosts.pyc
│   │   │   ├── image_metadata.py
│   │   │   ├── image_metadata.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── keypairs.py
│   │   │   ├── keypairs.pyc
│   │   │   ├── migrate_server.py
│   │   │   ├── migrate_server.pyc
│   │   │   ├── multinic.py
│   │   │   ├── multinic.pyc
│   │   │   ├── multiple_create.py
│   │   │   ├── multiple_create.pyc
│   │   │   ├── networks_associate.py
│   │   │   ├── networks_associate.pyc
│   │   │   ├── networks.py
│   │   │   ├── networks.pyc
│   │   │   ├── quota_classes.py
│   │   │   ├── quota_classes.pyc
│   │   │   ├── quota_sets.py
│   │   │   ├── quota_sets.pyc
│   │   │   ├── remote_consoles.py
│   │   │   ├── remote_consoles.pyc
│   │   │   ├── rescue.py
│   │   │   ├── rescue.pyc
│   │   │   ├── reset_server_state.py
│   │   │   ├── reset_server_state.pyc
│   │   │   ├── scheduler_hints.py
│   │   │   ├── scheduler_hints.pyc
│   │   │   ├── security_groups.py
│   │   │   ├── security_groups.pyc
│   │   │   ├── server_external_events.py
│   │   │   ├── server_external_events.pyc
│   │   │   ├── server_groups.py
│   │   │   ├── server_groups.pyc
│   │   │   ├── server_metadata.py
│   │   │   ├── server_metadata.pyc
│   │   │   ├── server_migrations.py
│   │   │   ├── server_migrations.pyc
│   │   │   ├── servers.py
│   │   │   ├── servers.pyc
│   │   │   ├── server_tags.py
│   │   │   ├── server_tags.pyc
│   │   │   ├── services.py
│   │   │   ├── services.pyc
│   │   │   ├── tenant_networks.py
│   │   │   ├── tenant_networks.pyc
│   │   │   ├── user_data.py
│   │   │   ├── user_data.pyc
│   │   │   ├── volumes.py
│   │   │   └── volumes.pyc
│   │   ├── security_group_default_rules.py
│   │   ├── security_group_default_rules.pyc
│   │   ├── security_groups.py
│   │   ├── security_groups.pyc
│   │   ├── server_diagnostics.py
│   │   ├── server_diagnostics.pyc
│   │   ├── server_external_events.py
│   │   ├── server_external_events.pyc
│   │   ├── server_groups.py
│   │   ├── server_groups.pyc
│   │   ├── server_metadata.py
│   │   ├── server_metadata.pyc
│   │   ├── server_migrations.py
│   │   ├── server_migrations.pyc
│   │   ├── server_password.py
│   │   ├── server_password.pyc
│   │   ├── servers.py
│   │   ├── servers.pyc
│   │   ├── server_tags.py
│   │   ├── server_tags.pyc
│   │   ├── server_usage.py
│   │   ├── server_usage.pyc
│   │   ├── services.py
│   │   ├── services.pyc
│   │   ├── shelve.py
│   │   ├── shelve.pyc
│   │   ├── simple_tenant_usage.py
│   │   ├── simple_tenant_usage.pyc
│   │   ├── suspend_server.py
│   │   ├── suspend_server.pyc
│   │   ├── tenant_networks.py
│   │   ├── tenant_networks.pyc
│   │   ├── used_limits.py
│   │   ├── used_limits.pyc
│   │   ├── user_data.py
│   │   ├── user_data.pyc
│   │   ├── versions.py
│   │   ├── versions.pyc
│   │   ├── versionsV21.py
│   │   ├── versionsV21.pyc
│   │   ├── views
│   │   │   ├── addresses.py
│   │   │   ├── addresses.pyc
│   │   │   ├── flavors.py
│   │   │   ├── flavors.pyc
│   │   │   ├── hypervisors.py
│   │   │   ├── hypervisors.pyc
│   │   │   ├── images.py
│   │   │   ├── images.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── keypairs.py
│   │   │   ├── keypairs.pyc
│   │   │   ├── limits.py
│   │   │   ├── limits.pyc
│   │   │   ├── servers.py
│   │   │   ├── servers.pyc
│   │   │   ├── server_tags.py
│   │   │   ├── server_tags.pyc
│   │   │   ├── usages.py
│   │   │   ├── usages.pyc
│   │   │   ├── versions.py
│   │   │   └── versions.pyc
│   │   ├── virtual_interfaces.py
│   │   ├── virtual_interfaces.pyc
│   │   ├── volumes.py
│   │   └── volumes.pyc
│   ├── extensions.py
│   ├── extensions.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── placement
│   │   ├── auth.py
│   │   ├── auth.pyc
│   │   ├── deploy.py
│   │   ├── deploy.pyc
│   │   ├── handler.py
│   │   ├── handler.pyc
│   │   ├── handlers
│   │   │   ├── aggregate.py
│   │   │   ├── aggregate.pyc
│   │   │   ├── allocation.py
│   │   │   ├── allocation.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── inventory.py
│   │   │   ├── inventory.pyc
│   │   │   ├── resource_class.py
│   │   │   ├── resource_class.pyc
│   │   │   ├── resource_provider.py
│   │   │   ├── resource_provider.pyc
│   │   │   ├── root.py
│   │   │   ├── root.pyc
│   │   │   ├── usage.py
│   │   │   └── usage.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── microversion.py
│   │   ├── microversion.pyc
│   │   ├── policy.py
│   │   ├── policy.pyc
│   │   ├── requestlog.py
│   │   ├── requestlog.pyc
│   │   ├── rest_api_version_history.rst
│   │   ├── util.py
│   │   ├── util.pyc
│   │   ├── wsgi.py
│   │   └── wsgi.pyc
│   ├── urlmap.py
│   ├── urlmap.pyc
│   ├── versioned_method.py
│   ├── versioned_method.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
└── validation
├── __init__.py
├── __init__.pyc
├── parameter_types.py
├── parameter_types.pyc
├── validators.py
└── validators.pyc
9 directories, 369 files
目录ec2、openstack与metadata分别对应了Amazon EC2 API、Openstack API与Metadata API三种API服务,而在juno版本中共存v2、v3、v2.1三个版本的Openstack API源码都位于nova/api/openstack/compute目录下。对于Openstack API来说,每一个API都对应一种资源,Openstack共定义了两种类型的资源:核心资源与扩展资源。核心资源可简单认为是云平台中最为基础的资源,比如images、servers等。而扩展资源根据是否为核心资源的扩展又分两种情况,比如:keypairs是对server的扩展,cells则是独立资源。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Nova