|
|
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;
|
...
|
...
|
@@ -45,29 +44,11 @@ public class Pch5SwitchCtrl { |
|
|
private final String const_az1_host_under_prod_elb="az1_host_under_prod_elb";
|
|
|
private final String const_az2_host_under_prod_elb="az2_host_under_prod_elb";
|
|
|
private final String const_az2_in_gray="const_az2_in_gray";
|
|
|
private final List<String> const_tags_for_nginx_az1=new ArrayList<String>(){
|
|
|
{
|
|
|
add("pch5");
|
|
|
add("nginx");
|
|
|
add("az1");
|
|
|
}
|
|
|
};
|
|
|
private final String const_tags_for_nginx_az1="pch5,nginx,az1";
|
|
|
|
|
|
private final List<String> const_tags_for_nginx_az2=new ArrayList<String>(){
|
|
|
{
|
|
|
add("pch5");
|
|
|
add("nginx");
|
|
|
add("az2");
|
|
|
}
|
|
|
};
|
|
|
private final String const_tags_for_nginx_az2="pch5,nginx,az2";
|
|
|
|
|
|
private final List<String> const_tags_for_nginx_node_az2=new ArrayList<String>(){
|
|
|
{
|
|
|
add("pch5");
|
|
|
add("node");
|
|
|
add("az2");
|
|
|
}
|
|
|
};
|
|
|
private final String const_tags_for_nginx_node_az2="pch5,node,az2";
|
|
|
|
|
|
@Autowired
|
|
|
private QcloudLoadBalance qcloudLoadBalance;
|
...
|
...
|
@@ -80,8 +61,8 @@ public class Pch5SwitchCtrl { |
|
|
public BaseResponse getElbStatus() {
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
//az1 ,az2机器
|
|
|
List<String> az1_host_cmdb=getHostByType(const_tags_for_nginx_az1);
|
|
|
List<String> az2_host_cmdb=getHostByType(const_tags_for_nginx_az2);
|
|
|
List<String> az1_host_cmdb=hostInfoService.getHostIpByTags(const_tags_for_nginx_az1);
|
|
|
List<String> az2_host_cmdb=hostInfoService.getHostIpByTags(const_tags_for_nginx_az2);
|
|
|
BaseResponse checkAzResponse=checkAzCmdb(az1_host_cmdb,az2_host_cmdb);
|
|
|
if(checkAzResponse==null||checkAzResponse.getCode()!=200){
|
|
|
return checkAzResponse;
|
...
|
...
|
@@ -228,22 +209,6 @@ public class Pch5SwitchCtrl { |
|
|
return baseResponse;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 从标签获取机器信息
|
|
|
* @return
|
|
|
*/
|
|
|
private List<String> getHostByType(List<String> tagList){
|
|
|
|
|
|
List<HostInfo> hostInfos = hostInfoService.getHostInfosByTagList(tagList);
|
|
|
List<String> ips=new ArrayList<>();
|
|
|
if(hostInfos!=null&&hostInfos.size()>0){
|
|
|
for(HostInfo hostInfo:hostInfos){
|
|
|
ips.add(hostInfo.getHostIp());
|
|
|
}
|
|
|
}
|
|
|
return ips;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 可用区切换
|
...
|
...
|
@@ -254,8 +219,8 @@ public class Pch5SwitchCtrl { |
|
|
public BaseResponse switchArea(String area) {
|
|
|
|
|
|
//az1 ,az2机器,及对应instanceId
|
|
|
List<String> az1_host_cmdb=getHostByType(const_tags_for_nginx_az1);
|
|
|
List<String> az2_host_cmdb=getHostByType(const_tags_for_nginx_az2);
|
|
|
List<String> az1_host_cmdb=hostInfoService.getHostIpByTags(const_tags_for_nginx_az1);
|
|
|
List<String> az2_host_cmdb=hostInfoService.getHostIpByTags(const_tags_for_nginx_az2);
|
|
|
BaseResponse checkAzResponse=checkAzCmdb(az1_host_cmdb,az2_host_cmdb);
|
|
|
if(checkAzResponse==null||checkAzResponse.getCode()!=200){
|
|
|
return checkAzResponse;
|
...
|
...
|
@@ -334,7 +299,7 @@ public class Pch5SwitchCtrl { |
|
|
@RequestMapping(value = "/getPch5NodeHostUnderAz2")
|
|
|
@ResponseBody
|
|
|
public List<String> getPch5NodeHostIPs() {
|
|
|
return getHostByType(const_tags_for_nginx_node_az2);
|
|
|
return hostInfoService.getHostIpByTags(const_tags_for_nginx_node_az2);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -352,8 +317,8 @@ public class Pch5SwitchCtrl { |
|
|
}
|
|
|
|
|
|
//az1 ,az2机器,及对应instanceId
|
|
|
List<String> az1_host_cmdb=getHostByType(const_tags_for_nginx_az1);
|
|
|
List<String> az2_host_cmdb=getHostByType(const_tags_for_nginx_az2);
|
|
|
List<String> az1_host_cmdb=hostInfoService.getHostIpByTags(const_tags_for_nginx_az1);
|
|
|
List<String> az2_host_cmdb=hostInfoService.getHostIpByTags(const_tags_for_nginx_az2);
|
|
|
BaseResponse checkAzResponse=checkAzCmdb(az1_host_cmdb,az2_host_cmdb);
|
|
|
if(checkAzResponse==null||checkAzResponse.getCode()!=200){
|
|
|
return checkAzResponse;
|
...
|
...
|
|