本文主要解释CS中全局变量ha.tag的用法,默认情况下该变量为空,我们先来看一下官方对它的解释
HA tag defining that the host marked with this tag can be used for HA purposes only
假如我们设置该全局变量的值为test_ha
,那么所有标签为test_ha
的主机就只能用作HA主机,意思就是说当我们创建常规的客户VM的时候会排除掉这些主机。我们来看FirstFitAllocator类中的allocatorTo方法
//只有High Availability当中重启虚拟机时该haVmTag才不为空并等于全局变量ha.tag的值
String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
if (haVmTag != null) {
clusterHosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, haVmTag);
} else {
//如果VM所选计算方案和模板都没有主机标签则查找不带ha.tag的主机
if (hostTagOnOffering == null && hostTagOnTemplate == null) {
clusterHos