跳转到: 导航, 搜索

ServerInstanceCountForFlavors

Nova Flavor 实例数量

总结

目前 Nova Flavor(实例类型)API 没有提供关于 Flavor 使用的实例数量的信息。将实例数量添加到当前 Flavor 列表和 Flavor 详情 API 将有助于云管理员/用户在修改或删除给定的 Flavor 之前做出明智的决策。它还可以用于指标数据以评估系统资源的使用情况。添加支持以防止云用户删除被服务器引用的 Flavor 并增强错误处理,将帮助云管理员管理 Flavor 并快速定位问题。

发布说明

此功能将作为基于 OpenStack 扩展模型的 API 扩展提供。因此,现有用户不应受到影响。高级用户和云提供商可以利用实例数量进行分析和规划。

原理

用户故事

  • 作为云管理员,我想根据 Flavor 的服务器使用情况来规划云资源的更新。
  • 作为云管理员,我想能够轻松删除或修改 Flavor,而无需猜测 Flavor 是否被服务器使用
  • 作为云管理员,我想查看 Flavor 被服务器利用的图表
  • 作为云管理员,我想防止在 Flavor 被服务器引用时删除该 Flavor
  • 作为云管理员,我想看到更好的错误处理,以帮助我快速定位问题

前提条件

待定

设计

此功能的初始实现作为 nova 扩展添加。此外,在返回的标头中添加了通知和“sub-code:”,以帮助客户端轻松识别 Flavor 删除操作期间的问题和根本原因。

模块

  • nova/api/openstack/compute/contrib/isc_flavor.py
  • nova/db/sqlalchemy/isc_flavor_sql_api.py
  • nova/db/isc_flavor_api.py

Nova CLI 变更

  • 用于程序化访问的 REST API
  • 支持 Nova CLI 以利用实例数量列表


SAMPLE of NOVA CLI OUTPUT

# nova flavor-list
+----+------------------+-----------+------+-----------+------+-------+-------------+--------------+
| ID |       Name       | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Server Count |
+----+------------------+-----------+------+-----------+------+-------+-------------+--------------+
| 1  | standard.xsmall  | 1024      | 30   | 0         |      | 1     | 1.0         | 10           |
| 2  | standard.small   | 2048      | 60   | 0         |      | 2     | 1.0         | 0            |
| 3  | standard.medium  | 4096      | 120  | 0         |      | 2     | 1.0         | 99           |
| 4  | standard.large   | 8192      | 240  | 0         |      | 4     | 1.0         | 15           |
| 5  | standard.xlarge  | 16384     | 480  | 0         |      | 4     | 1.0         | 0            |
| 6  | standard.2xlarge | 32768     | 960  | 0         |      | 8     | 1.0         | 5            |
+----+------------------+-----------+------+-----------+------+-------+-------------+--------------+
#


子代码的实现

class FlavorHasInvalidCpuCount(IscBadRequest):
SUBCODE = '502001'
explanation = _("Flavor '%(flavorname)s' cannot be created. The number of "
"cpus inserted is '%(count)i' but it must be between "
"'%(min)i' and '%(max)i'.")


class FlavorHasInvalidMemorySize(IscBadRequest):
SUBCODE = '502002'
explanation = _("Flavor '%(flavorname)s' cannot be created. The memory "
"size in MB inserted is '%(count)i' but it must be between "
"'%(min)i' and '%(max)i'.")


class FlavorHasInvalidDiskSize(IscBadRequest):
SUBCODE = '502003'
explanation = _("Flavor '%(flavorname)s' cannot be created. The disk size "
"in GB inserted is '%(count)i' but it must be between "
"'%(min)i' and '%(max)i'.")


class FlavorHasInvalidAdditionalDiskSize(IscBadRequest):
SUBCODE = '502004'
explanation = _("Flavor '%(flavorname)s' cannot be created. The "
"additional disk size in GB inserted is '%(count)i' but it "
"must be between '%(min)i' and '%(max)i'.")


class FlavorNameHasInvalidSize(IscBadRequest):
SUBCODE = '502005'
explanation = _("Flavor '%(flavorname)s' cannot be created. The length of "
"the flavor name is '%(count)i' but it must be between "
"'%(min)i' and '%(max)i'.")


class FlavorNameHasTrailingWhitespaces(IscBadRequest):
SUBCODE = '502006'
explanation = _("Flavor '%(flavorname)s' cannot be created. It contains "
"whitespaces either at its beginning or at its end. Please "
"remove them and repeat the operation.")


列出服务器实例数量

  • 用于索引的 REST API
    • HTTP GET 方法: http://<isc-name>/rest/compute/v2/<tenant_id>/flavors?instance_count=yes
  • 用于详细信息的 REST API
    • HTTP GET 方法: http://<isc-name>/rest/compute/v2/<tenant_id>/flavors/detail?instance_count=yes

预期的 JSON 输出

EXAMPLES:

http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/?instance_count=yes

{
    "flavors": [{
        "instance_count": 10,
        "id": "1",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/1",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/1",
            "rel": "bookmark"
        }],
        "name": "standard.xsmall"
    }, {
        "instance_count": 0,
        "id": "2",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/2",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/2",
            "rel": "bookmark"
        }],
        "name": "standard.small"
    }, {
        "instance_count": 99,
        "id": "3",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/3",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/3",
            "rel": "bookmark"
        }],
        "name": "standard.medium"
    }, {
        "instance_count": 15,
        "id": "4",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/4",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/4",
            "rel": "bookmark"
        }],
        "name": "standard.large"
    }, {
        "instance_count": 0,
        "id": "5",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/5",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/5",
            "rel": "bookmark"
        }],
        "name": "standard.xlarge"
    }, {
        "instance_count": 5,
        "id": "6",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/6",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/6",
            "rel": "bookmark"
        }],
        "name": "standard.2xlarge"
    }]
}

http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/1?instance_count=yes


{
    "flavor": {
        "vcpus": 1,
        "disk": 0,
        "OS-FLV-EXT-DATA:ephemeral": 10,
        "name": "m1.tiny",
        "links": [{
            "href": "http://16.125.106.178:8774/v2/26180ca86661451d91f7d812d80c18b7/flavors/1",
            "rel": "self"
        }, {
            "href": "http://16.125.106.178:8774/26180ca86661451d91f7d812d80c18b7/flavors/1",
            "rel": "bookmark"
        }],
        "rxtx_factor": 1.0,
        "instance_count": 0,
        "ram": 512,
        "id": "1",
        "swap": ""
    }
}



错误代码

  • 正常响应代码: 200, 203
  • 错误响应代码: computeFault (400), serviceUnavailable (503), unauthorized (401), forbidden (403), badRequest (400), badMethod (405), overLimit (413)

测试/演示计划

已添加此属性的测试。

未解决的问题

none

BoF 议程和讨论

在 BoF 期间使用此部分进行笔记;如果将其保留在批准的规范中,请使用它来总结讨论的内容并记录被拒绝的选项。

待定