|
|
package com.monitor.switchs;
|
|
|
|
|
|
import com.model.BuildProcessHistory;
|
|
|
import com.model.HostInfo;
|
|
|
import com.monitor.cmdb.service.IHostInfoService;
|
|
|
import com.monitor.model.page.PageResponse;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.monitor.mysql.mapper.BuildHistoryMapper;
|
|
|
import com.yoho.ops.cmdb.models.Host;
|
|
|
import com.yoho.ops.cmdb.models.LoadBalance;
|
|
|
import com.yoho.ops.cmdb.qcloud.lb.QcloudLoadBalance;
|
...
|
...
|
@@ -31,6 +34,11 @@ import java.util.stream.Collectors; |
|
|
public class Pch5SwitchCtrl {
|
|
|
private final static Logger logger = LoggerFactory.getLogger("switchLogger");
|
|
|
|
|
|
@Autowired
|
|
|
private BuildHistoryMapper buildHistoryMapper;
|
|
|
|
|
|
private final String[] PROJECTS_IN_AZ={"YOHOBUY-WAP-NODE","YOHOBUY-PC-NODE","YOHOBLK-WAP"};
|
|
|
|
|
|
//Pch5的负载均衡器,传统型,生产
|
|
|
private final String ELB_PCH5_ID="lb-ceg44td5";
|
|
|
private final String ELB_BLK_ID="lb-2wfrxx7p";
|
...
|
...
|
@@ -93,6 +101,45 @@ public class Pch5SwitchCtrl { |
|
|
return response;
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/queryAz2InGray")
|
|
|
@ResponseBody
|
|
|
public BaseResponse<Boolean> queryAz2InGray() {
|
|
|
boolean az2InGray=false;
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return new BaseResponse(az2InGray);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 最近发布记录(success)
|
|
|
*
|
|
|
*/
|
|
|
@RequestMapping(value = "/getAzProjectLatestReleaseHistory")
|
|
|
@ResponseBody
|
|
|
public BaseResponse getAzProjectLatestReleaseHistory() {
|
|
|
List<BuildProcessHistory> ls=new ArrayList();
|
|
|
for(String proj:PROJECTS_IN_AZ){
|
|
|
BuildProcessHistory history=buildHistoryMapper.selectLatestSuccessProjectRecord(proj,"az2");
|
|
|
if(history!=null){
|
|
|
ls.add(history);
|
|
|
}
|
|
|
}
|
|
|
BaseResponse rtn=new BaseResponse();
|
|
|
PageResponse<BuildProcessHistory> pi=new PageResponse();
|
|
|
pi.setTotal(ls.size());
|
|
|
pi.setRows(ls);
|
|
|
pi.setCurrentPage(1);
|
|
|
rtn.setData(pi);
|
|
|
return rtn;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检查
|
|
|
* @param az1_host_cmdb
|
...
|
...
|
@@ -207,15 +254,7 @@ public class Pch5SwitchCtrl { |
|
|
//检查是否启用了灰度
|
|
|
//如果az2机器不再生产环境下,且host为gray,则是灰度
|
|
|
//TODO 检查是否灰度
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
az2InGray=this.queryAz2InGray().getData();
|
|
|
}
|
|
|
|
|
|
if(i==0){
|
...
|
...
|
|