Authored by qinchao

Merge branch 'master' of http://git.yoho.cn/ops/monitor-service into dev_gml

... ... @@ -188,9 +188,9 @@ public class CloudToolController {
*/
@RequestMapping("/updateIpToGit")
@ResponseBody
public BaseResponse updateIpToGit(int cloudType, String projectName, String scalingGroupId){
public BaseResponse updateIpToGit(int cloudType, String projectName, String newInstanceIps){
BaseResponse response = null;
response = cloudToolService.updateIpToGit(cloudType, projectName, scalingGroupId);
response = cloudToolService.updateIpToGit(cloudType, projectName, newInstanceIps);
return response;
}
... ...
... ... @@ -20,10 +20,10 @@ public interface CloudToolService {
* 自动伸缩后,修改ip,ip从云管理中心重新获取
* @param cloudType 云类型 1:AWS 2:QCLOUD
* @param projectName 项目名称
* @param scalingGroupId 伸缩组ID
* @param newInstanceIps 伸缩组的所有ips
* @return
*/
BaseResponse updateIpToGit(int cloudType, String projectName, String scalingGroupId);
BaseResponse updateIpToGit(int cloudType, String projectName, String newInstanceIps);
BaseResponse gatewayChangeUpstream(String operate,String cloudTypeStr, String ip);
}
\ No newline at end of file
... ...
... ... @@ -4,6 +4,8 @@ import com.model.JavaApiInfo;
import com.model.MObjectInfo;
import com.model.TypeInfo;
import com.monitor.awstools.service.AwsQueryService;
import com.monitor.cloudtools.model.CommAutoScalingGroup;
import com.monitor.cloudtools.model.CommAutoScalingInstances;
import com.monitor.cloudtools.model.CommTestResponse;
import com.monitor.cloudtools.service.CloudToolService;
import com.monitor.cloudtools.util.CommodUtil;
... ... @@ -21,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
... ... @@ -149,13 +152,13 @@ public class CloudToolServiceImpl implements CloudToolService {
* 自动伸缩后,修改ip,ip从云管理中心重新获取
* @param cloudType 云类型 1:AWS 2:QCLOUD
* @param projectName 项目名称
* @param scalingGroupId 伸缩组ID
* @param newInstanceIps 伸缩组新的ips
* @return
*/
@Override
public BaseResponse updateIpToGit(int cloudType, String projectName, String scalingGroupId) {
public BaseResponse updateIpToGit(int cloudType, String projectName, String newInstanceIps) {
BaseResponse response = new BaseResponse();
if(StringUtils.isBlank(projectName) || StringUtils.isBlank(scalingGroupId)){
if(StringUtils.isBlank(projectName)){
response.setCode(300);
response.setMessage("参数不全");
return response;
... ... @@ -163,53 +166,20 @@ public class CloudToolServiceImpl implements CloudToolService {
String commond = "ssh master@172.31.16.167 sh /home/master/auto_deploy/deploy/update-ips.sh -a%s -e%s -i%s";
try{
List<String> ips = null;
List<String> ips = new ArrayList<String>();
if(StringUtils.isNotBlank(newInstanceIps)){
for(String ip:newInstanceIps.split(",")){
if(StringUtils.isNotBlank(ip)){
ips.add(ip);
}
}
}
String cloudTypeStr = "";
String projectNameStr = "";
if(1 == cloudType){
cloudTypeStr = "aws";
projectNameStr = projectName.replace('-', '_') + "_aws_ips";
}else if(2 == cloudType){
ips = qCloudToolService.getIpsByScalingGroupId(scalingGroupId);
//特殊处理:腾讯云不是70段的ip
/*if("asg-kwwpxavl".equals(scalingGroupId)){
//gateway项目
if(!ips.contains("10.66.0.4")){
ips.add("10.66.0.4");
}
if(!ips.contains("10.66.0.5")){
ips.add("10.66.0.5");
}
if(!ips.contains("10.66.0.240")){
ips.add("10.66.0.240");
}
}else if("asg-87m9rp31".equals(scalingGroupId)){
//uic
if(!ips.contains("10.66.0.24")){
ips.add("10.66.0.24");
}
if(!ips.contains("10.66.0.178")){
ips.add("10.66.0.178");
}
}else if("asg-1llhxawt".equals(scalingGroupId)){
//activity-brower-bigdata
if(!ips.contains("10.66.0.158")){
ips.add("10.66.0.158");
}
if(!ips.contains("10.66.0.219")){
ips.add("10.66.0.219");
}
}else if("asg-c1qbtoxh".equals(scalingGroupId)){
//search-service
if(!ips.contains("10.66.5.5")){
ips.add("10.66.5.5");
}
if(!ips.contains("10.66.5.4")){
ips.add("10.66.5.4");
}
}*/
cloudTypeStr = "qcloud";
projectNameStr = projectName.replace('-', '_') + "_qcloud_ips";
}
... ...