跳转到: 导航, 搜索

Neutron/ServiceDirectoryStructure

此页面描述了高级服务的可能源代码树结构。请注意,编写某种类型服务实现可能存在两种主要方法

  • 1. 由驱动程序扩展的通用插件
  • 2. 多个独立的插件

1. 由驱动程序扩展的通用插件

第一个建议的布局适用于 (1),我们将采用它来实现负载均衡服务


/plugins
   /services
       /loadbalancer
           /agents
               /vendorA
                   vendorA_agent.py
               /vendorB
                   vendorB_agent.py
           /drivers
               /vendorA
                    plugin_driver.py (plugin-side driver, could contain additional DB logic)
                    device_driver.py (driver to access a device, usually utilized by corresponding agent)
           /db
                loadbalancer_db.py
          plugin.py (generic loadbalancer plugin based on loadbalancer_db.py and using plugin_drivers to allow vendor-specific architectures)

请注意,当前负载均衡目录名为 agent_loadbalancer,指向特定的实现。
为了使其更通用,建议进行以下两步更改

  • 将 loadbalancer_db.py 从 quantum/db/loadbalancer/ 移动到 quantum/plugin/services/agent_loadbalancer/db/
  • 将 agent_loadbalancer 目录重命名为 loadbalancer。这将需要更改许多导入,并且会影响 devstack,因此最好分步骤进行。


需要考虑的选项
1) 将整个 services 树向上移动 1 层,移出 plugins

多个独立的插件

/plugins
   /services
       /vendorA_loadbalancer
           /agents
               vendorA_agent.py
           /drivers
               device_driver.py (driver to access a device, usually utilized by corresponding agent)
           /db
                vendorA_loadbalancer_db.py
           vendorA_plugin.py
       /vendorB_loadbalancer
           ...


类似的规则适用于单元测试文件,基本上所有与服务相关的文件都移动到 tests/unit/services/service_category/ 下。

最终目录布局

负载均衡命名和布局示例

 /db/
     /loadbalancer
          loadbalancer_db.py
 /common
     plugin_constants.py (service types, constants shared between core and service plugins)
 /services
     /loadbalancer
           /agents
               /vendorA
                   vendorA_agent.py
               /vendorB
                   vendorB_agent.py
           /drivers
               /vendorA
                    plugin_driver.py (plugin-side driver, could contain additional DB logic)
                    device_driver.py (driver to access a device, usually utilized by corresponding agent)
          plugin.py (generic loadbalancer plugin based on loadbalancer_db.py and using plugin_drivers to allow vendor-specific architectures)