feat(运维监控模块): 新增接口:获取微服务应用功能列表
这段代码为每个应用添加“启停管理”功能,设置对应的功能键和名称,并将命名空间和应用名称作为参数存入variables,最后将该功能对象加入功能列表中。
This commit is contained in:
parent
18f89d1b8e
commit
bac9eeda5f
|
|
@ -247,6 +247,15 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
|
|||
JSONObject applicationJson = remoteRancherService.getK8sApplicationDetail(cluster_id, K8sApplication.getApplicationFullKind(kind), namespace, applicationName, SecurityContextHolder.getUserKey());
|
||||
RancherApplicationVo rancherApplicationVo = applicationJson.toJavaObject(RancherApplicationVo.class);
|
||||
if (rancherApplicationVo != null && rancherApplicationVo.getMetadata() != null && rancherApplicationVo.getMetadata().getLabels() != null) {
|
||||
// 所有应用添加启停管理功能
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(ApplicationFunctionType.START_AND_STOP_MANAGEMENT);
|
||||
// 使用命名空间和应用名称作为搜索条件
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables.put("namespace", namespace);
|
||||
functionVariables.put("applicationName", applicationName);
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
applicationFunctionsList.add(applicationFunction);
|
||||
JSONObject LabelsJson = rancherApplicationVo.getMetadata().getLabels();
|
||||
for (String key : LabelsJson.keySet()) {
|
||||
String k8sLabelValue = LabelsJson.getString(key);
|
||||
|
|
@ -264,9 +273,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
|
|||
for (int i = 0; i < skywalkingServicesArray.size(); i++) {
|
||||
JSONObject skywalkingService = skywalkingServicesArray.getJSONObject(i);
|
||||
if (k8sLabelValue.equals(skywalkingService.getString("shortName"))) {
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(applicationFunctionType);
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables = new JSONObject();
|
||||
functionVariables.put("serviceId", skywalkingService.getString("id"));
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
applicationFunctionsList.add(applicationFunction);
|
||||
|
|
@ -282,9 +291,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
|
|||
for (int i = 0; i < sentinelAppListArray.size(); i++) {
|
||||
JSONObject sentinelApp = sentinelAppListArray.getJSONObject(i);
|
||||
if (k8sLabelValue.equals(sentinelApp.getString("app"))) {
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(applicationFunctionType);
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables = new JSONObject();
|
||||
functionVariables.put("app", k8sLabelValue);
|
||||
functionVariables.put("appType", sentinelApp.getLongValue("appType"));
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
|
|
@ -301,9 +310,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
|
|||
for (int i = 0; i < nacosServiceListArray.size(); i++) {
|
||||
JSONObject nacosService = nacosServiceListArray.getJSONObject(i);
|
||||
if (k8sLabelValue.equals(nacosService.getString("name"))) {
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(applicationFunctionType);
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables = new JSONObject();
|
||||
functionVariables.put("name", k8sLabelValue);
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
applicationFunctionsList.add(applicationFunction);
|
||||
|
|
@ -320,9 +329,9 @@ public class K8SDashboardServiceImpl extends CommonService implements IK8sDashbo
|
|||
JSONObject nacosService = nacosConfigListJSONArray.getJSONObject(i);
|
||||
String dataId = nacosService.getString("dataId");
|
||||
if (StringUtils.isNotEmpty(dataId) && dataId.contains(k8sLabelValue)) {
|
||||
ApplicationFunction applicationFunction = new ApplicationFunction();
|
||||
applicationFunction = new ApplicationFunction();
|
||||
applicationFunction.setKeyAndName(applicationFunctionType);
|
||||
JSONObject functionVariables = new JSONObject();
|
||||
functionVariables = new JSONObject();
|
||||
functionVariables.put("dataId", dataId);
|
||||
applicationFunction.setVariables(functionVariables);
|
||||
applicationFunctionsList.add(applicationFunction);
|
||||
|
|
|
|||
Loading…
Reference in New Issue