清单
属性
名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
---|---|---|---|---|
uuid | 请参见 资源属性 | 0.6 | ||
name | 请参见 资源属性 | 0.6 | ||
description | 请参见 资源属性 | 是 | 0.6 | |
cpuNum | VCPU数目, 请参见 CPU capacity | 0.6 | ||
cpuSpeed | VCPU速度, 请参见 CPU capacity | 0.6 | ||
memorySize | 内存大小,单位是字节 | 0.6 | ||
type | 计算规格类型, 默认为UserVm, 请参见 type | 是 |
|
0.6 |
allocatorStrategy | 主机分配策略, 请参见 allocator strategy |
|
0.6 | |
state | 请参见 state |
|
0.6 | |
sortKey | 0.6 | |||
createDate | 请参见 资源属性 | 0.6 | ||
lastOpDate | 请参见 资源属性 | 0.6 |
示例
{
"inventories": [
{
"allocatorStrategy": "LeastVmPreferredHostAllocatorStrategy",
"cpuNum": 1,
"cpuSpeed": 0,
"createDate": "Oct 30, 2017 3:51:50 PM",
"description": "",
"lastOpDate": "Oct 30, 2017 4:49:03 PM",
"memorySize": 1073741824,
"name": "1G-1CPU",
"sortKey": 0,
"state": "Enabled",
"type": "VirtualRouter",
"uuid": "fa550cb9bdcc4fd397ae37f9ddf4c390"
}
],
"success": true
}
CPU容量(CPU Capacity)
计算规格使用cpuNum和cpuSpeed来定义云主机的CPU容量。 cpuNum直接代表了云主机所拥有的VCPU数量;cpuSpeed有些特别:云主机的VCPU总是和物理主机上的物理CPU有相同的频率, 这里的cpuSpeed实际上是指在虚拟机管理程序中的VCPU权重(weight)。虚拟机管理程序不同,对于cpuSpeed的使用和实现也不同。
KVM CPU速度(KVM CPU Speed)
在KVM中, ZStack会使用shares=cpuSpeed *
cpuNum的结果来设置libvirt的虚拟机XML配置:
<cputune>
<shares>128</shares>
</cputune>
shares = cpuNum * cpuSpeed
Note: 当cpuSpeed设置为0时,云主机shares值默认显示为2。
类型(Type)
计算规格的类型:当前有两种计算规格类型:
- UserVm:
创建用户云主机所使用的计算规格。
- VirtualRouter:
创建云路由(virtual router)云主机所使用的计算规格。
分配策略(Allocator Strategy)
分配策略定义了选择用于创建云主机的物理主机的算法。
DefaultHostAllocatorStrategy
输入参数(Input
Parameters)
:widths: 30 70
:header-rows: 1
* - 名字
- 描述
* - **image**
- 用于创建虚拟机的镜像
* - **L3 network**
- 虚拟机的网卡将连接到的L3网络
* - **instance offering**
- 计算规格
* - **tags**
- 用于主机分配的标签
算法(Algorithm)
l2_networks = get_parent_l2_networks(l3_networks)
host_set1 = find_hosts_in_cluster_that_have_attached_to_l2_networks()
check_if_backup_storage_having_image_have_attached_to_zone_of_hosts(host_set1)
host_set2 = remove_hosts_not_having_state_Enabled_and_status_Connected(host_set1)
host_set3 = remove_hosts_not_having_capacity_required_by_instance_offering(host_set2)
primary_storage = find_Enabled_Connected_primary_storage_having_enough_capacity_for_root_volume_and_attached\
_to_clusters_of_hosts(image, host_set3)
host_set4 = remove_hosts_that_cannot_access_primary_storage(host_set3)
host_set5 = remove_avoided_hosts(host_set4)
host_set6 = call_tag_plugin(tags, host_set5)
return randomly_pick_one_host(host_set6)
DesignatedHostAllocatorStrategy
DesignatedHostAllocatorStrategy使用下面的算法:
输入参数(Input
Parameters)
:widths: 30 60 10
:header-rows: 1
* - 名字
- 描述
- 可选的
* - **image**
- 用于创建虚拟机的镜像
-
* - **L3 network**
- 虚拟机的网卡将连接到的L3网络
-
* - **instance offering**
- 计算规格
-
* - **tags**
- 用于主机分配的标签
-
* - **zone**
- 虚拟机想要运行的区域
- 是
* - **cluster**
- 虚拟机想要运行的集群
- 是
* - **host**
- 虚拟机想要运行的主机
- 是
算法(Algorithm)
l2_networks = get_parent_l2_networks(l3_networks)
host_set1 = find_hosts_in_cluster_that_have_attached_to_l2_networks()
check_if_backup_storage_having_image_have_attached_to_zone_of_hosts(host_set1)
if host is not null:
host_set2 = list(find_host_in_host_set1(host))
else if cluster is not null:
host_set2 = find_host_in_cluster_and_host_set1(cluster)
else if zone is not null:
host_set2 = find_host_in_zone_and_host_set1(zone)
host_set3 = remove_hosts_not_having_state_Enabled_and_status_Connected(host_set2)
host_set4 = remove_hosts_not_having_capacity_required_by_instance_offering(host_set3)
primary_storage = find_Enabled_Connected_primary_storage_having_enough_capacity_for_root_volume_and_attached\
_to_clusters_of_hosts(image, host_set4)
host_set5 = remove_hosts_that_cannot_access_primary_storage(host_set4)
host_set6 = remove_avoided_hosts(host_set5)
host_set7 = call_tag_plugin(tags, host_set6)
return randomly_pick_one_host(host_set7)
可用状态(State)
计算规格有两种可用状态:
- Enabled:
启用(Enabled)状态下,允许从计算规格创建云主机。
- Disabled:
禁用(Disabled)状态下,不允许从计算规格创建云主机。