Authored by qinchao

增加接口

... ... @@ -572,14 +572,13 @@ public class DockerProjectCtrl {
String namespace=dockerJenkinsReq.getNamespace()==null?"":dockerJenkinsReq.getNamespace();
String serviceName=dockerJenkinsReq.getServiceName();
Map<String,String> statusMap = new HashMap<>();
Map<String,String> statusDescMap = new HashMap<>();
for(String clusterId:clusterIds.split(",")){
if(StringUtils.isBlank(clusterId)){
continue;
}
List<String> statusAndCreateAt=dockerServerDeployService.queryAppStatus(clusterId,namespace,serviceName);
statusMap.put(clusterId,statusAndCreateAt.get(0));
statusDescMap.put(clusterId,statusAndCreateAt.get(0)+",create at "+statusAndCreateAt.get(1));
}
boolean allNormal=false;
... ... @@ -595,8 +594,25 @@ public class DockerProjectCtrl {
Map<String,Object> rntMap = new HashMap<>();
rntMap.put("result",allNormal);
//rntMap.put("resultMap",statusMap);
rntMap.put("resultDescMap",statusDescMap);
rntMap.put("resultDescMap",statusMap);
if(allNormal){
//获取实例的更新时间
for(String clusterId:clusterIds.split(",")){
List<List<String>> instLs=dockerServerDeployService.queryInstanceStatus(clusterId,namespace,serviceName);
StringBuilder sb=new StringBuilder();
if(!CollectionUtils.isEmpty(instLs)){
for(List<String> tmp:instLs){
if(sb.length()>0){
sb.append(";");
}
sb.append(StringUtils.join(tmp,","));
}
rntMap.put("resultInstDesc",sb.toString());
}
}
}
rtn.setData(rntMap);
return rtn;
}
... ...
... ... @@ -163,6 +163,34 @@ public class DockerServerDeployService {
}
/**
* 检测服务实例状态
*/
public List<List<String>> queryInstanceStatus(String clusterId, String namespace, String serviceName) {
List<List<String>> ls=new ArrayList<>();
JSONObject searchResult = txServer.describeServiceInstance(clusterId, namespace,serviceName );
if(searchResult!=null&&searchResult.getInteger("code")!=null&& searchResult.getInteger("code").equals(NumberUtils.INTEGER_ZERO)){
JSONArray ja=searchResult.getJSONObject("data").getJSONArray("instanaces");
if(ja!=null){
for(int i=0;i<ja.size();i++){
List<String> tmp=new ArrayList<>();
JSONObject jo=ja.getJSONObject(i);
String name=jo.getString("name");
String status=jo.getString("status");
String createdAt=jo.getString("createdAt");
tmp.add(name);
tmp.add(status);
tmp.add(createdAt);
ls.add(tmp);
}
}
}else{
//只获取正常的数据,不正常的也不再关心
}
return ls;
}
/**
* 检测服务状态是否是Normal
* 返回标志信息和container信息
*
... ...
... ... @@ -132,6 +132,33 @@ public class QqDockerServiceUtils {
}
/**
* 查询服务的实例列表
*/
public JSONObject describeServiceInstance(String clusterId, String namespace, String serviceName) {
JSONObject resultJson=null;
try{
Map<String, String> paraMap = Maps.newHashMap();
paraMap.put("clusterId", clusterId);
paraMap.put("serviceName", serviceName);
paraMap.put("Action", "DescribeServiceInstance");
if (StringUtils.isNotEmpty(namespace)) {
paraMap.put("namespace", namespace);
} else {
paraMap.put("namespace", "default");
}
String backString = ccsApiQcloud.pushTest(paraMap);
String uri=requestUrl+"?"+backString;
String qqResponseJsonStr =HttpClientUtil.doget(uri,null,null);
if(StringUtils.isNotBlank(qqResponseJsonStr)){
resultJson = JSONObject.parseObject(qqResponseJsonStr);
}
}catch (Exception e){
logger.error("describeServiceInstance error",e);
}
return resultJson;
}
/**
* 用于更新镜像文件
*/
public JSONObject modifyClusterServiceImage (String clusterId, String namespace, String serviceName
... ...