1. 程式人生 > >【neutron原始碼分析】create_network/create_subnet/create_port原始碼分析

【neutron原始碼分析】create_network/create_subnet/create_port原始碼分析

  • 指定了subnet和fixed IP,執行NeutronDbPluginV2._allocate_specific_ip
  • 指定了subnet,未指定fixed IP,執行self._generate_ip程式碼

       主要是查詢neutron資料庫中的ipavailabilityranges表獲取IP的範圍,然後分配IP後,更新ipavailabilityranges表。

[neutron]> SELECT  * FROM ipavailabilityranges;
+--------------------------------------+----------------+----------------+
| allocation_pool_id                   | first_ip       | last_ip        |
+--------------------------------------+----------------+----------------+
| a5818bca-e7b5-4399-a405-a6a095800281 | 10.10.10.11    | 10.10.10.254   |
| a5818bca-e7b5-4399-a405-a6a095800281 | 10.10.10.2      | 10.10.10.9     |

        IP分配完畢後,則將被分配了的IP更到neutron資料庫的ipallocations表。

[neutron]> SELECT * FROM ipallocations;
+--------------------------------------+----------------+--------------------------------------+--------------------------------------+
| port_id                                    | ip_address     | subnet_id                            | network_id                           |
+--------------------------------------+----------------+--------------------------------------+--------------------------------------+
| 07130e1c-a6d4-4f28-843c-33b1e07b223e | 10.248.144.102 | 5eb54ff1-25a7-4ffd-87c8-99e492701f15 | c4206574-8125-41e6-be09-5a624dadb570 |
| dba288c4-3c63-4af3-87fc-929166d072e6 | 10.10.10.10    | 90cf42a5-61e5-4684-a9a3-ed241f8a00fb | 01978067-94f2-4758-b124-b33413a9d9f2 |
+--------------------------------------+----------------+--------------------------------------+--------------------------------------+