...
|
...
|
@@ -3,6 +3,7 @@ package com.monitor.cmdb.ctrl; |
|
|
import com.yoho.ops.cmdb.aws.autoscaling.AutoScalingFetcher;
|
|
|
import com.yoho.ops.cmdb.domain.BaseResponse;
|
|
|
import com.yoho.ops.cmdb.models.AutoScalingGroup;
|
|
|
import com.yoho.ops.cmdb.models.AutoScalingHost;
|
|
|
import com.yoho.ops.cmdb.qcloud.autoscaling.QcloudAutoScalingFetcher;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -12,6 +13,7 @@ import org.springframework.stereotype.Controller; |
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -54,5 +56,36 @@ public class AutoScalingCtrl { |
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 腾讯云:根据组id获取instanceIP
|
|
|
* 亚马逊云:待定
|
|
|
* @param groupId 伸缩组id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/getIpsByScalingGroupId")
|
|
|
@ResponseBody
|
|
|
public com.monitor.model.response.BaseResponse getIpsByScalingGroupId(int cloudType, String groupName , String groupId){
|
|
|
com.monitor.model.response.BaseResponse response = new com.monitor.model.response.BaseResponse();
|
|
|
List<String> ipList =new ArrayList<String>();;
|
|
|
AutoScalingGroup group=null;
|
|
|
if(1==cloudType){
|
|
|
if(groupName==null||groupName.length()<=0){
|
|
|
response.setCode(300);
|
|
|
response.setMessage("aws伸缩组名字为空");
|
|
|
return response;
|
|
|
}
|
|
|
group=awsFetcher.getAutoScalingByGroupName(groupName);
|
|
|
}else if(2==cloudType){
|
|
|
group=qcloudFetcher.getAutoScalingGroupByScalingGroupId(groupId);
|
|
|
}
|
|
|
if(group!=null&&group.getAutoScalingHosts()!=null){
|
|
|
for(AutoScalingHost host:group.getAutoScalingHosts()){
|
|
|
ipList.add(host.getIp());
|
|
|
}
|
|
|
}
|
|
|
response.setData(ipList);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|