Authored by qinchao

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

@@ -188,9 +188,9 @@ public class CloudToolController { @@ -188,9 +188,9 @@ public class CloudToolController {
188 */ 188 */
189 @RequestMapping("/updateIpToGit") 189 @RequestMapping("/updateIpToGit")
190 @ResponseBody 190 @ResponseBody
191 - public BaseResponse updateIpToGit(int cloudType, String projectName, String scalingGroupId){ 191 + public BaseResponse updateIpToGit(int cloudType, String projectName, String newInstanceIps){
192 BaseResponse response = null; 192 BaseResponse response = null;
193 - response = cloudToolService.updateIpToGit(cloudType, projectName, scalingGroupId); 193 + response = cloudToolService.updateIpToGit(cloudType, projectName, newInstanceIps);
194 return response; 194 return response;
195 } 195 }
196 196
@@ -20,10 +20,10 @@ public interface CloudToolService { @@ -20,10 +20,10 @@ public interface CloudToolService {
20 * 自动伸缩后,修改ip,ip从云管理中心重新获取 20 * 自动伸缩后,修改ip,ip从云管理中心重新获取
21 * @param cloudType 云类型 1:AWS 2:QCLOUD 21 * @param cloudType 云类型 1:AWS 2:QCLOUD
22 * @param projectName 项目名称 22 * @param projectName 项目名称
23 - * @param scalingGroupId 伸缩组ID 23 + * @param newInstanceIps 伸缩组的所有ips
24 * @return 24 * @return
25 */ 25 */
26 - BaseResponse updateIpToGit(int cloudType, String projectName, String scalingGroupId); 26 + BaseResponse updateIpToGit(int cloudType, String projectName, String newInstanceIps);
27 27
28 BaseResponse gatewayChangeUpstream(String operate,String cloudTypeStr, String ip); 28 BaseResponse gatewayChangeUpstream(String operate,String cloudTypeStr, String ip);
29 } 29 }
@@ -4,6 +4,8 @@ import com.model.JavaApiInfo; @@ -4,6 +4,8 @@ import com.model.JavaApiInfo;
4 import com.model.MObjectInfo; 4 import com.model.MObjectInfo;
5 import com.model.TypeInfo; 5 import com.model.TypeInfo;
6 import com.monitor.awstools.service.AwsQueryService; 6 import com.monitor.awstools.service.AwsQueryService;
  7 +import com.monitor.cloudtools.model.CommAutoScalingGroup;
  8 +import com.monitor.cloudtools.model.CommAutoScalingInstances;
7 import com.monitor.cloudtools.model.CommTestResponse; 9 import com.monitor.cloudtools.model.CommTestResponse;
8 import com.monitor.cloudtools.service.CloudToolService; 10 import com.monitor.cloudtools.service.CloudToolService;
9 import com.monitor.cloudtools.util.CommodUtil; 11 import com.monitor.cloudtools.util.CommodUtil;
@@ -21,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -21,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
22 24
23 import java.util.ArrayList; 25 import java.util.ArrayList;
  26 +import java.util.Arrays;
24 import java.util.List; 27 import java.util.List;
25 28
26 /** 29 /**
@@ -149,13 +152,13 @@ public class CloudToolServiceImpl implements CloudToolService { @@ -149,13 +152,13 @@ public class CloudToolServiceImpl implements CloudToolService {
149 * 自动伸缩后,修改ip,ip从云管理中心重新获取 152 * 自动伸缩后,修改ip,ip从云管理中心重新获取
150 * @param cloudType 云类型 1:AWS 2:QCLOUD 153 * @param cloudType 云类型 1:AWS 2:QCLOUD
151 * @param projectName 项目名称 154 * @param projectName 项目名称
152 - * @param scalingGroupId 伸缩组ID 155 + * @param newInstanceIps 伸缩组新的ips
153 * @return 156 * @return
154 */ 157 */
155 @Override 158 @Override
156 - public BaseResponse updateIpToGit(int cloudType, String projectName, String scalingGroupId) { 159 + public BaseResponse updateIpToGit(int cloudType, String projectName, String newInstanceIps) {
157 BaseResponse response = new BaseResponse(); 160 BaseResponse response = new BaseResponse();
158 - if(StringUtils.isBlank(projectName) || StringUtils.isBlank(scalingGroupId)){ 161 + if(StringUtils.isBlank(projectName)){
159 response.setCode(300); 162 response.setCode(300);
160 response.setMessage("参数不全"); 163 response.setMessage("参数不全");
161 return response; 164 return response;
@@ -163,53 +166,20 @@ public class CloudToolServiceImpl implements CloudToolService { @@ -163,53 +166,20 @@ public class CloudToolServiceImpl implements CloudToolService {
163 String commond = "ssh master@172.31.16.167 sh /home/master/auto_deploy/deploy/update-ips.sh -a%s -e%s -i%s"; 166 String commond = "ssh master@172.31.16.167 sh /home/master/auto_deploy/deploy/update-ips.sh -a%s -e%s -i%s";
164 167
165 try{ 168 try{
166 - List<String> ips = null; 169 + List<String> ips = new ArrayList<String>();
  170 + if(StringUtils.isNotBlank(newInstanceIps)){
  171 + for(String ip:newInstanceIps.split(",")){
  172 + if(StringUtils.isNotBlank(ip)){
  173 + ips.add(ip);
  174 + }
  175 + }
  176 + }
167 String cloudTypeStr = ""; 177 String cloudTypeStr = "";
168 String projectNameStr = ""; 178 String projectNameStr = "";
169 if(1 == cloudType){ 179 if(1 == cloudType){
170 cloudTypeStr = "aws"; 180 cloudTypeStr = "aws";
171 projectNameStr = projectName.replace('-', '_') + "_aws_ips"; 181 projectNameStr = projectName.replace('-', '_') + "_aws_ips";
172 }else if(2 == cloudType){ 182 }else if(2 == cloudType){
173 - ips = qCloudToolService.getIpsByScalingGroupId(scalingGroupId);  
174 -  
175 - //特殊处理:腾讯云不是70段的ip  
176 - /*if("asg-kwwpxavl".equals(scalingGroupId)){  
177 - //gateway项目  
178 - if(!ips.contains("10.66.0.4")){  
179 - ips.add("10.66.0.4");  
180 - }  
181 - if(!ips.contains("10.66.0.5")){  
182 - ips.add("10.66.0.5");  
183 - }  
184 - if(!ips.contains("10.66.0.240")){  
185 - ips.add("10.66.0.240");  
186 - }  
187 - }else if("asg-87m9rp31".equals(scalingGroupId)){  
188 - //uic  
189 - if(!ips.contains("10.66.0.24")){  
190 - ips.add("10.66.0.24");  
191 - }  
192 - if(!ips.contains("10.66.0.178")){  
193 - ips.add("10.66.0.178");  
194 - }  
195 - }else if("asg-1llhxawt".equals(scalingGroupId)){  
196 - //activity-brower-bigdata  
197 - if(!ips.contains("10.66.0.158")){  
198 - ips.add("10.66.0.158");  
199 - }  
200 - if(!ips.contains("10.66.0.219")){  
201 - ips.add("10.66.0.219");  
202 - }  
203 - }else if("asg-c1qbtoxh".equals(scalingGroupId)){  
204 - //search-service  
205 - if(!ips.contains("10.66.5.5")){  
206 - ips.add("10.66.5.5");  
207 - }  
208 - if(!ips.contains("10.66.5.4")){  
209 - ips.add("10.66.5.4");  
210 - }  
211 - }*/  
212 -  
213 cloudTypeStr = "qcloud"; 183 cloudTypeStr = "qcloud";
214 projectNameStr = projectName.replace('-', '_') + "_qcloud_ips"; 184 projectNameStr = projectName.replace('-', '_') + "_qcloud_ips";
215 } 185 }