...
|
...
|
@@ -3,16 +3,16 @@ package com.yoho.ops.cmdb.qcloud; |
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.monitor.model.response.BaseResponse;
|
|
|
import com.qcloud.Module.Cvm;
|
|
|
import com.qcloud.Module.Scaling;
|
|
|
import com.yoho.ops.cmdb.models.AutoScalingGroup;
|
|
|
import com.yoho.ops.cmdb.models.AutoScalingHost;
|
|
|
import com.yoho.ops.cmdb.models.DataCenter;
|
|
|
import com.yoho.ops.cmdb.models.Host;
|
|
|
import com.yoho.ops.cmdb.models.*;
|
|
|
import com.yoho.ops.cmdb.qcloud.constant.QcloudConstant;
|
|
|
import com.yoho.ops.cmdb.qcloud.model.QcloudAutoScalingGroup;
|
|
|
import com.yoho.ops.cmdb.qcloud.model.QcloudInstanceSet;
|
|
|
import com.yoho.ops.cmdb.qcloud.model.QcloudResponse;
|
|
|
import com.yoho.ops.cmdb.qcloud.model.QcloudScalingInstancesSet;
|
|
|
import com.yoho.ops.cmdb.qcloud.util.CommQcloudUtil;
|
|
|
import com.yoho.ops.cmdb.qcloud.util.QcloudSdkUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -112,6 +112,49 @@ public class QcloudClientFactory { |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改腾讯云的伸缩组信息
|
|
|
* @return
|
|
|
*/
|
|
|
public BaseResponse modifyScalingGroup(QcloudModifyScalingGroupReq req) {
|
|
|
BaseResponse response = new BaseResponse();
|
|
|
|
|
|
if(null == req){
|
|
|
return null;
|
|
|
}
|
|
|
try{
|
|
|
TreeMap<String, Object> map = CommQcloudUtil.getTreeMapParam(req);
|
|
|
String rootJson = QcloudSdkUtil.getCommonData(new Scaling(), "GET", QcloudConstant.QCLOUD_API_MODIFY_SCALING_GROUP_FUN, map, true);
|
|
|
logger.info("QcloudToolServiceImpl-modifyScalingGroup"+map);
|
|
|
logger.info("QcloudToolServiceImpl-modifyScalingGroup"+rootJson);
|
|
|
if(StringUtils.isBlank(rootJson)){
|
|
|
return null;
|
|
|
}
|
|
|
QcloudResponse rootObj = JSON.parseObject(rootJson, QcloudResponse.class);
|
|
|
if(rootObj != null){
|
|
|
//我们系统只默认200是成功,腾讯云默认是0是成功
|
|
|
if(0 != rootObj.getCode()){
|
|
|
int errorCode=rootObj.getCode();
|
|
|
if(errorCode==200){
|
|
|
errorCode=201;
|
|
|
}
|
|
|
response.setCode(errorCode);
|
|
|
|
|
|
}
|
|
|
response.setMessage(rootObj.getMessage());
|
|
|
}
|
|
|
/*response = new BaseResponse();
|
|
|
response.setCode(200);
|
|
|
response.setMessage("因为匹配期望实例数,扩容2台");*/
|
|
|
}catch (Exception e){
|
|
|
logger.error(" - QcloudToolServiceImpl - modifyScalingGroup- error", e);
|
|
|
response.setCode(300);
|
|
|
response.setMessage(e.getMessage());
|
|
|
}
|
|
|
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args){
|
|
|
QcloudClientFactory f=new QcloudClientFactory();
|
|
|
List<AutoScalingGroup> g=f.getAutoScalingGroup();
|
...
|
...
|
|