- 整体结构
- bin
- doc
- etc
- init.d/
- neutron/
- api-paste.ini
- dhcp_agent.ini
- fwaas_driver.ini
- l3_agent.ini
- lbaas_agent.ini
- metadata_agent.ini
- metering_agent.ini
- vpn_agent.ini
- neutron.conf
- policy.json
- rootwrap.conf
- services.conf
- neutron
- agent
- common/
- linux/
- metadata/
- dhcp_agent.py
- firewall.py
- l2population_rpc.py
- l3_agent.py
- l3_ha_agent.py
- netns_cleanup_util.py
- ovs_cleanup_util.py
- rpc.py
- securitygroups_rpc.py
- api
- rpc
- v2
- views
- api_common.py
- extensions.py
- versions.py
- cmd
- common
- config.py
- constants.py
- exceptions.py
- ipv6_utils.py
- log.py
- rpc.py
- test_lib.py
- topics.py
- utils.py
- db
- agents_db.py
- agentschedulers_db.py
- api.py
- common_db_mixin.py
- db_base_plugin_v2.py
- migration
- model_base.py
- models_v2.py
- securitygroups_rpc_base.py
- sqlalchemyutils.py
- 扩展资源和操作类
- allowedaddresspairs_db.py
- dvr_mac_db.py
- external_net_db.py
- extradhcpopt_db.py
- extraroute_db.py
- firewall
- l3_agentschedulers_db.py
- l3_attrs_db.py
- l3_db.py
- l3_dvr_db.py
- l3_gwmode_db.py
- l3_hamode_db.py
- l3_hascheduler_db.py
- loadbalancer
- metering
- portbindings_base.py
- portbindings_db.py
- portsecurity_db.py
- quota_db.py
- routedserviceinsertion_db.py
- routerservicetype_db.py
- securitygroups_db.py
- servicetype_db.py
- vpn
- debug
- commands.py
- debug_agent.py
- shell.py
- extensions
- agent.py
- allowedaddresspairs.py
- dhcpagentscheduler.py
- dvr.py
- external_net.py
- extraroute.py
- extra_dhcp_opt.py
- firewall.py
- flavor.py
- l3.py
- l3agentscheduler.py
- l3_ext_gw_mode.py
- lbaas_agentscheduler.py
- loadbalancer.py
- metering.py
- multiprovidernet.py
- portbindings.py
- portsecurity.py
- providernet.py
- quotasv2.py
- routedserviceinsertion.py
- routerservicetype.py
- securitygroup.py
- servicetype.py
- vpnaas.py
- hacking
- checks.py
- locale
- notifiers
- nova.py
- openstack
- common
- cache
- context.py
- eventlet_backdoor.py
- fileutils.py
- fixture
- local.py
- lockutils.py
- log.py
- loopingcall.py
- middleware
- periodic_task.py
- policy.py
- processutils.py
- service.py
- systemd.py
- threadgroup.py
- uuidutils.py
- versionutils.py
- _i18n.py
- plugins
- bigswitch
- agent
- common
- ibm
- agent
- common
- sdnve_api.py
- sdnve_api_fake.py
- sdnve_neutron_plugin.py
- ml2
- common
- config.py
- db.py
- drivers
- driver_api.py
- driver_context.py
- managers.py
- models.py
- plugin.py
- rpc.py
- ofagent
- agent
- common
- openvswitch
- agent
- common
- ovs_models_v2.py
- scheduler
- dhcp_agent_scheduler.py
- l3_agent_scheduler.py
- server
- services
- firewall
- agents
- drivers
- fwaas_plugin.py
- l3_apic.py
- l3_router_plugin.py
- loadbalancer
- agent
- agent_scheduler.py
- constants.py
- drivers
- plugin.py
- metering
- agents
- drivers
- metering_plugin.py
- provider_configuration.py
- service_base.py
- tests
- auth.py
- context.py
- hooks.py
- i18n.py
- manager.py
- neutron_plugin_base_v2.py
- policy.py
- quota.py
- service.py
- version.py
- wsgi.py
- rally-jobs
- extra
- plugins
- __init__.py
- neutron-neutron.yaml
- tools
- check_bash.sh
- check_i18n.py
- check_i18n_test_case.txt
- clean.sh
- i18n_cfg.py
- install_venv.py
- install_venv_common.py
- pretty_tox.sh
- with_venv.sh
- 理解代码
- REST API 专题
- RPC 专题
- agent RPC
- plugin RPC
- neutron-server RPC
- Plugin 专题
- Extension 专题
- Agent 专题
REST API 专题
REST API 专题
neutron-server(相当于REST API Server)的核心作用之一就是要实现REST API。
在Neutron中,neutron-server(相当于REST API Server)负责将收到的REST API请求交由Plugin来进行相关处理。可以看出,这其实就是一个web服务器要完成的事情,将http请求转化为对资源的操作(通过plugin的方法调用),并返回响应。
REST API可以分为两类:标准API和扩展API。
前者主要是由原先的 nova-network项目沿用而来,实现对网络二层的支持,核心资源只有网络、端口和子网;后者则通过进行扩展,提供更多的网络服务。目前已有的扩展有L3(router),L4(TPC/udp firewall)及L7(http/https load balancer)。随着neutron项目的不断成熟,扩展API会演化为标准API。
这个过程的主要涉及的模块包括
neutron.server、service模块,以及定义了neutron API的neutron.api包。
以neutron.api.v2包为例,其中base.py中定义了Controller类,是实现URL到plugin的api进行mapping的核心。
其主要方法包括create、delete、index、show、update。
顾名思义,create用于创建资源,delete用于删除资源,show是获取资源、update是更新资源,index是返回请求资源的列表。
以create方法为例来看主要过程。
向network的notifier发送一个资源create.start的通知;然后进行policy的检查;之后调用plugin中相应的方法进行处理,最后向network的notifier发出一个资源create.end的通知。

发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。