计算规格
概览
计算规格:云主机涉及的CPU数量、内存、网络设置等规格定义。
清单
属性
| 名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
|---|---|---|---|---|
| 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 Cloud会使用shares=cpuSpeed *
cpuNum的结果来设置libvirt的虚拟机XML配置:
<cputune>
<shares>128</shares>
</cputune>
shares = cpuNum * cpuSpeedNote: 当cpuSpeed设置为0时,云主机shares值默认显示为2。
类型(Type)
计算规格的类型:当前有两种计算规格类型:
- UserVm:
创建用户云主机所使用的计算规格。
- VirtualRouter:
创建路由器(virtual router)云主机所使用的计算规格。
分配策略(Allocator Strategy)
分配策略定义了选择用于创建云主机的物理主机的算法。
DefaultHostAllocatorStrategy
算法(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)LastHostPreferredAllocatorStrategy
算法(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 pick_vm_last_host(host_set6)LeastVmPreferredHostAllocatorStrategy
算法(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 pick_host_with_the_fewest_vm(host_set6)MinimumMemoryUsageHostAllocatorStrategy
算法(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 pick_host_with_the_lowest_memory_load(host_set6)MinimumCPUUsageHostAllocatorStrategy
算法(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 pick_host_with_the_lowest_cpu_load(host_set6)MaxInstancePerHostHostAllocatorStrategy
算法(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 pick_host_with_vm_is_less_than_expected(host_set6)可用状态(State)
计算规格有两种可用状态:
- Enabled:
启用(Enabled)状态下,允许从计算规格创建云主机。
- Disabled:
禁用(Disabled)状态下,不允许从计算规格创建云主机。
操作(Operations)
创建云主机规格(CreateInstanceOffering)
管理员可以使用CreateInstanceOffering创建云主机规格。例如:
CreateInstanceOffering name=test cpuNum=1 memorySize=2097152000CreateInstanceOffering name=vm_num allocatorStrategy=LastHostPreferredAllocatorStrategy cpuNum=1 memorySize=1073741824CreateInstanceOffering name=vm_num allocatorStrategy=MinimumCPUUsageHostAllocatorStrategy cpuNum=1 memorySize=1073741824CreateInstanceOffering name=vm_num allocatorStrategy=MinimumMemoryUsageHostAllocatorStrategy cpuNum=1 memorySize=1073741824CreateInstanceOffering name=vm_num allocatorStrategy=MaxInstancePerHostHostAllocatorStrategy cpuNum=1 memorySize=1073741824 systemTags=maxInstancePerHost::2CreateInstanceOffering name=vm_num allocatorStrategy=LeastVmPreferredHostAllocatorStrategy cpuNum=1 memorySize=1073741824 systemTags=maxInstancePerHost::2参数(Parameters)
| 名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
|---|---|---|---|---|
| name | 计算规格名称 | 0.6 | ||
| description | 计算规格的详细描述 | 是 | 0.6 | |
| cpuNum | CPU数目 | 0.6 | ||
| memorySize | 内存大小,大小Byte | 0.6 | ||
| allocatorStrategy | 分配策略 | 是 |
|
0.6 |
| sortKey | 排序键 | 是 | 0.6 | |
| type | 类型 | 是 | 0.6 | |
| resourceUuid | 资源uuid。若指定,镜像会使用该字段值作为uuid | 是 | 0.6 | |
| userTags | 用户标签,请参见 创建用户标签(CreateUserTag);资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| systemTags | 系统标签,请参见 创建系统标签(CreateSystemTag); 资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| timeout | 是 |
Note:
- ZStack Cloud创建计算规格时支持添加GPU规格信息,SystemTags增加pciRom选项。
- 选项格式为:
pciRomUuid::UUID,UUID代表PCI设备固件UUID。 - 例如:
pciRomUuid::5fd71606d5af451d981413f35367a8d6
- 选项格式为:
- ZStack Cloud创建计算规格时支持自定义实例规格参数,SystemTags增加instanceOfferingUserConfig选项。
- 选项格式为:
instanceOfferingUserConfig::xxx,XXX要求JSON字符串。
- 选项格式为:
删除云主机规格(DeleteInstanceOffering)
管理员可以使用DeleteInstanceOffering删除云主机规格。例如:
DeleteInstanceOffering uuid=ecf1f40130b148b39f82c07921ee11ff参数(Parameters)
| 名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
|---|---|---|---|---|
| uuid | 计算规格uuid | 0.6 | ||
| deleteMode | 请参见 删除资源(Delete Resources) | 是 |
|
0.6 |
| userTags | 用户标签,请参见 创建用户标签(CreateUserTag);资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| systemTags | 系统标签,请参见 创建系统标签(CreateSystemTag); 资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| timeout | 是 |
查询云主机规格(QueryInstanceOffering)
管理员可以使用QueryInstanceOffering查询云主机规格。例如:
QueryInstanceOffering cpuSpeed=512 cpuNum>2QueryInstanceOffering vmInstance.state=Stopped原生域查询(Primitive Fields of Query)
嵌套和扩展域查询(Nested and Expanded Fields of Query)
| 域(Field) | 清单(Inventory) | 描述 | 起始支持版本 |
|---|---|---|---|
| vmInstance | vm inventory | 由该计算规格创建的云主机 | 0.6 |
更改云主机规格(ChangeInstanceOffering)
管理员可以使用ChangeInstanceOffering更改云主机规格。例如:
ChangeInstanceOffering vmInstanceUuid=108af59a0f4e4d6cb838a5591db1016a
instanceOfferingUuid=f1dacd026c7645deaeeaef4e89313c8e参数(Parameters)
| 名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
|---|---|---|---|---|
| vmInstanceUuid | 云主机uuid | 0.6 | ||
| instanceOfferingUuid | 计算规格uuid | 0.6 | ||
| userTags | 用户标签,请参见 创建用户标签(CreateUserTag);资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| systemTags | 系统标签,请参见 创建系统标签(CreateSystemTag); 资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| timeout | 是 |
更新云主机规格(UpdateInstanceOffering)
管理员可以使用UpdateInstanceOffering更新云主机规格。例如:
UpdateInstanceOffering uuid=32190aabcf47470c90b20bd849767a49参数(Parameters)
| 名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
|---|---|---|---|---|
| uuid | 计算规格uuid | 0.6 | ||
| name | 计算规格名称 | 是 | 0.6 | |
| description | 计算规格的详细描述 | 是 | 0.6 | |
| allocatorStrategy | 是 |
|
2.3 | |
| userTags | 用户标签,请参见 创建用户标签(CreateUserTag);资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| systemTags | 系统标签,请参见 创建系统标签(CreateSystemTag); 资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| timeout | 是 |
更改云主机规格的启用状态(ChangeInstanceOfferingState)
管理员可以使用ChangeInstanceOfferingState更改云主机规格的启用状态。例如:
ChangeInstanceOfferingState stateEvent=enable uuid=32190aabcf47470c90b20bd849767a49参数(Parameters)
| 名字 | 描述 | 可选的 | 可选的参数值 | 起始支持版本 |
|---|---|---|---|---|
| uuid | 计算规格uuid | 0.6 | ||
| stateEvent | 状态事件 |
|
0.6 | |
| userTags | 用户标签,请参见 创建用户标签(CreateUserTag);资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| systemTags | 系统标签,请参见 创建系统标签(CreateSystemTag); 资源类型是 InstanceOfferingVO | 是 | 0.6 | |
| timeout | 是 |
标签(Tags)
用户可以使用resourceType=InstanceOfferingVO在计算规格上创建用户标签。例如:
CreateUserTag resourceType=InstanceOfferingVO tag=web-server-offering \
resourceUuid=45f909969ce24865b1bbca4adb66710a系统标签(System Tags)
专用主存储(Dedicated Primary Storage)
当创建云主机的时候, 用户可以通过系统标签指定从哪个主存储创建根云盘。
| 标签 | 描述 | 示例 | 起始支持版本 |
|---|---|---|---|
| primaryStorage::allocator::uuid::{uuid} | 如果该标签存在, 云主机的根云盘会从uuid指定的主存储分配;如果指定的主存储不存在或没有足够的容量,会报告分配失败(allocation failure)。 | primaryStorage::allocator::uuid::b8398e8b7ff24527a3b81dc4bc64d974 | 0.6 |
| primaryStorage::allocator::userTag::{tag}::required | 如果该标签存在, 云主机的根云盘会从带有用户标签tag的主存储分配;如果指定的主存储不存在或没有足够的容量,会报告分配失败(allocation failure) | primaryStorage::allocator::userTag::SSD::required | 0.6 |
| primaryStorage::allocator::userTag::{tag} | 如果该标签存在, 云主机的根云盘会首先尝试从带有用户标签tag的主存储分配,如果找不到带指定标签的主存储或容量不足,ZStack Cloud会随机选择一个主存储分配这个根云盘 | primaryStorage::allocator::userTag::SSD | 0.6 |
如果在计算规格上有多个上面提到的系统标签存在,它们的优先顺序是:
primaryStorage::allocator::uuid::{uuid} > primaryStorage::allocator::userTag::{tag}::\
required > primaryStorage::allocator::userTag::{tag}