openstack之flavor管理


概覽

[root@cc07 ~]# nova help | grep flavor
    flavor-access-add           Add flavor access for the given tenant.
    flavor-access-list          Print access information about the given
                                flavor.
    flavor-access-remove        Remove flavor access for the given tenant.
    flavor-create               Create a new flavor.
    flavor-delete               Delete a specific flavor
    flavor-key                  Set or unset extra_spec for a flavor.
    flavor-list                 Print a list of available 'flavors' (sizes of
    flavor-show                 Show details about the given flavor.
    flavor-update               Update the description of an existing flavor.

 

列表

[root@cc07 ~]# nova flavor-list
+------------------------------------------------------------+------------------------------------------------------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                                         | Name                                                       | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+------------------------------------------------------------+------------------------------------------------------------+-----------+------+-----------+------+-------+-------------+-----------+
| boshen_ram_1024_disk_1_vcpus_1                             | boshen_ram_1024_disk_1_vcpus_1                             | 1024      | 1    | 0         |      | 1     | 1.0         | True      |
| e6e7ffa7-52e5-47b0-8a74-669adcbe64c2                       | warm_wocloud_vpn_2_2048                                    | 2048      | 2    | 0         |      | 2     | 1.0         | True      |
| ubuntu_1604                                                | ubuntu_1604                                                | 4096      | 50   | 0         |      | 2     | 1.0         | True      |
| vcpus_16_cpu_cores_8_cpu_sockets_2_ram_16384_disk_50_eph_0 | vcpus_16_cpu_cores_8_cpu_sockets_2_ram_16384_disk_50_eph_0 | 16384     | 50   | 0         |      | 16    | 1.0         | True      |
| vcpus_16_cpu_cores_8_cpu_sockets_2_ram_32768_disk_50_eph_0 | vcpus_16_cpu_cores_8_cpu_sockets_2_ram_32768_disk_50_eph_0 | 32768     | 50   | 0         |      | 16    | 1.0         | True      |
| vcpus_1_cpu_cores_1_cpu_sockets_1_ram_1024_disk_10_eph_0   | vcpus_1_cpu_cores_1_cpu_sockets_1_ram_1024_disk_10_eph_0   | 1024      | 10   | 0         |      | 1     | 1.0         | True      |
| vcpus_1_cpu_cores_1_cpu_sockets_1_ram_1024_disk_1_eph_0    | vcpus_1_cpu_cores_1_cpu_sockets_1_ram_1024_disk_1_eph_0    | 1024      | 1    | 0         |      | 1     | 1.0         | True      |
| vcpus_1_cpu_cores_1_cpu_sockets_1_ram_1024_disk_2_eph_0    | vcpus_1_cpu_cores_1_cpu_sockets_1_ram_1024_disk_2_eph_0    | 1024      | 2    | 0         |      | 1     | 1.0         | True      |
+------------------------------------------------------------+------------------------------------------------------------+-----------+------+-----------+------+-------+-------------+-----------+

 

創建自定義的flavor

格式:nova flavor-create --is-public true FLAVOR_NAME FLAVOR_ID RAM_IN_MB ROOT_DISK_IN_GB NUMBER_OF_VCPUS

例子:

[root@cc07 ~]# nova flavor-create --is-public true boshen_ram_1024_disk_1_vcpus_1 boshen_ram_1024_disk_1_vcpus_1 1024 1 1
+--------------------------------+--------------------------------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                             | Name                           | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------+--------------------------------+-----------+------+-----------+------+-------+-------------+-----------+
| boshen_ram_1024_disk_1_vcpus_1 | boshen_ram_1024_disk_1_vcpus_1 | 1024      | 1    | 0         |      | 1     | 1.0         | True      |
+--------------------------------+--------------------------------+-----------+------+-----------+------+-------+-------------+-----------+

查看詳情

[root@cc07 ~]# nova flavor-show boshen_ram_1024_disk_1_vcpus_1
+----------------------------+--------------------------------+
| Property                   | Value                          |
+----------------------------+--------------------------------+
| OS-FLV-DISABLED:disabled   | False                          |
| OS-FLV-EXT-DATA:ephemeral  | 0                              |
| disk                       | 1                              |
| extra_specs                | {}                             |
| id                         | boshen_ram_1024_disk_1_vcpus_1 |
| name                       | boshen_ram_1024_disk_1_vcpus_1 |
| os-flavor-access:is_public | True                           |
| ram                        | 1024                           |
| rxtx_factor                | 1.0                            |
| swap                       |                                |
| vcpus                      | 1                              |
+----------------------------+--------------------------------+

設置flavor的extra_specs屬性

[root@cc07 ~]# nova flavor-key boshen_ram_1024_disk_1_vcpus_1 set aggregate_instance_extra_specs:ssd=true
[root@cc07 ~]# nova flavor-show boshen_ram_1024_disk_1_vcpus_1
+----------------------------+------------------------------------------------+
| Property                   | Value                                          |
+----------------------------+------------------------------------------------+
| OS-FLV-DISABLED:disabled   | False                                          |
| OS-FLV-EXT-DATA:ephemeral  | 0                                              |
| disk                       | 1                                              |
| extra_specs                | {"aggregate_instance_extra_specs:ssd": "true"} |
| id                         | boshen_ram_1024_disk_1_vcpus_1                 |
| name                       | boshen_ram_1024_disk_1_vcpus_1                 |
| os-flavor-access:is_public | True                                           |
| ram                        | 1024                                           |
| rxtx_factor                | 1.0                                            |
| swap                       |                                                |
| vcpus                      | 1                                              |
+----------------------------+------------------------------------------------+

創建flavor后,指定一個或多個鍵值對,讓這些鍵值對與主機集群上的鍵值對匹配,范圍為aggregate_instance_extra_specs。 在這種情況下,設置格式為:aggregate_instance_extra_specs:ssd = true鍵值對。

當用戶請求具有 boshen_ram_1024_disk_1_vcpus_1 規格的實例時,調度程序僅考慮具有ssd = true鍵值對的主機

 

將flavor賦給tenant

(nova-api)[root@cc07 /]# openstack project list |grep hzb
| 26a8e1feb372493d831c19d4d9e28d73 | hzb_tenant                                                       |
| c49b95e8961249ea9e87a4507c10e122 | hzb_tenant2 
[root@cc07 ~]# nova flavor-access-add boshen_ram_1024_disk_1_vcpus_1 26a8e1feb372493d831c19d4d9e28d73
+--------------------------------+----------------------------------+
| Flavor_ID                      | Tenant_ID                        |
+--------------------------------+----------------------------------+
| boshen_ram_1024_disk_1_vcpus_1 | 26a8e1feb372493d831c19d4d9e28d73 |
+--------------------------------+----------------------------------+
[root@cc07 ~]# nova  flavor-access-list --flavor boshen_ram_1024_disk_1_vcpus_1
ERROR (CommandError): Access list not available for public flavors.
[root@cc07 ~]# nova  flavor-access-list --flavor boshen_ram_1024_disk_1_vcpus_1
ERROR (CommandError): Access list not available for public flavors.

 

解除租戶

[root@cc07 ~]# nova flavor-access-remove boshen_ram_1024_disk_1_vcpus_1 26a8e1feb372493d831c19d4d9e28d73
+-----------+-----------+
| Flavor_ID | Tenant_ID |
+-----------+-----------+
+-----------+-----------+

刪除flavor

nova flavor-delete boshen_ram_1024_disk_1_vcpus_1

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM