|
|
package com.monitor.switchs;
|
|
|
|
|
|
import com.model.HostInfo;
|
|
|
import com.monitor.cmdb.service.IHostInfoService;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.yoho.ops.cmdb.models.Host;
|
...
|
...
|
@@ -195,9 +196,14 @@ public class Pch5SwitchCtrl { |
|
|
//检查是否启用了灰度
|
|
|
//如果az2机器不再生产环境下,且host为gray,则是灰度
|
|
|
//TODO 检查是否灰度
|
|
|
String hostFileContent="";
|
|
|
if(StringUtils.isNotBlank(hostFileContent)&&hostFileContent.indexOf("gray")>=0){
|
|
|
az2InGray=true;
|
|
|
List<HostInfo> ls=hostInfoService.getHostInfosByTagList(Arrays.asList(const_tags_for_nginx_node_az2.split(",")));
|
|
|
if(ls!=null){
|
|
|
for(HostInfo hostInfo:ls){
|
|
|
if(hostInfo.getTags()!=null&&hostInfo.getTags().indexOf("灰度")>=0){
|
|
|
az2InGray=true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -316,6 +322,17 @@ public class Pch5SwitchCtrl { |
|
|
}
|
|
|
|
|
|
|
|
|
private void updateAz2NodeTags(String newTags){
|
|
|
List<HostInfo> ls=hostInfoService.getHostInfosByTagList(Arrays.asList(const_tags_for_nginx_node_az2.split(",")));
|
|
|
if(ls!=null){
|
|
|
for(HostInfo hostInfo:ls){
|
|
|
hostInfo.setTags(newTags);
|
|
|
hostInfoService.saveHostInfo(hostInfo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* az2切换
|
|
|
* 获取productElb下面的az2类型host
|
...
|
...
|
@@ -362,6 +379,9 @@ public class Pch5SwitchCtrl { |
|
|
exe(arg);
|
|
|
qcloudLoadBalance.registerInstancesAndWeightWithLoadBalancer(ELB_PCH5_ID,az2HostIds,weights);
|
|
|
|
|
|
//getHostInfosByTagList
|
|
|
updateAz2NodeTags(const_tags_for_nginx_node_az2);
|
|
|
|
|
|
}else if("gray".equals(onlineOrGray)){
|
|
|
//卸载之前先检查是否存在az1机器,否则不允许卸载
|
|
|
boolean allow=false;
|
...
|
...
|
@@ -390,6 +410,9 @@ public class Pch5SwitchCtrl { |
|
|
arg += " --h ";
|
|
|
arg +=getPch5NodeHostIPsWithComm();
|
|
|
exe(arg);
|
|
|
|
|
|
//getHostInfosByTagList
|
|
|
updateAz2NodeTags(const_tags_for_nginx_node_az2+",灰度");
|
|
|
}else{
|
|
|
return new BaseResponse(201,"pch5 prod elb 请先挂载az1区域的host,再切换用作灰度环境");
|
|
|
}
|
...
|
...
|
|