资源池 状态 用枚举表示
This commit is contained in:
parent
9d2e70bf0e
commit
4cfd6b5aad
|
@ -0,0 +1,15 @@
|
||||||
|
package io.metersphere.commons.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dongbin
|
||||||
|
*/
|
||||||
|
public enum ResourceStatusEnum {
|
||||||
|
/**
|
||||||
|
* 无效
|
||||||
|
*/
|
||||||
|
INVALID,
|
||||||
|
/**
|
||||||
|
* 有效
|
||||||
|
*/
|
||||||
|
VALID
|
||||||
|
}
|
|
@ -1,33 +0,0 @@
|
||||||
package io.metersphere.dto;
|
|
||||||
|
|
||||||
public class KubernetesDTO {
|
|
||||||
|
|
||||||
private String masterUrl;
|
|
||||||
private String token;
|
|
||||||
private Integer maxConcurrency;
|
|
||||||
|
|
||||||
public String getMasterUrl() {
|
|
||||||
return masterUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMasterUrl(String masterUrl) {
|
|
||||||
this.masterUrl = masterUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToken() {
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToken(String token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMaxConcurrency() {
|
|
||||||
return maxConcurrency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxConcurrency(Integer maxConcurrency) {
|
|
||||||
this.maxConcurrency = maxConcurrency;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,6 +4,7 @@ public class ClientCredential {
|
||||||
|
|
||||||
private String masterUrl;
|
private String masterUrl;
|
||||||
private String token;
|
private String token;
|
||||||
|
private Integer maxConcurrency;
|
||||||
|
|
||||||
public String getMasterUrl() {
|
public String getMasterUrl() {
|
||||||
return masterUrl;
|
return masterUrl;
|
||||||
|
@ -20,4 +21,12 @@ public class ClientCredential {
|
||||||
public void setToken(String token) {
|
public void setToken(String token) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getMaxConcurrency() {
|
||||||
|
return maxConcurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxConcurrency(Integer maxConcurrency) {
|
||||||
|
this.maxConcurrency = maxConcurrency;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.base.mapper.TestResourceMapper;
|
||||||
import io.metersphere.base.mapper.TestResourcePoolMapper;
|
import io.metersphere.base.mapper.TestResourcePoolMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestReourcePoolMapper;
|
import io.metersphere.base.mapper.ext.ExtTestReourcePoolMapper;
|
||||||
import io.metersphere.commons.constants.ResourcePoolTypeEnum;
|
import io.metersphere.commons.constants.ResourcePoolTypeEnum;
|
||||||
|
import io.metersphere.commons.constants.ResourceStatusEnum;
|
||||||
import io.metersphere.controller.request.resourcepool.QueryResourcePoolRequest;
|
import io.metersphere.controller.request.resourcepool.QueryResourcePoolRequest;
|
||||||
import io.metersphere.dto.NodeDTO;
|
import io.metersphere.dto.NodeDTO;
|
||||||
import io.metersphere.dto.TestResourcePoolDTO;
|
import io.metersphere.dto.TestResourcePoolDTO;
|
||||||
|
@ -44,7 +45,7 @@ public class TestResourcePoolService {
|
||||||
testResourcePool.setId(UUID.randomUUID().toString());
|
testResourcePool.setId(UUID.randomUUID().toString());
|
||||||
testResourcePool.setCreateTime(System.currentTimeMillis());
|
testResourcePool.setCreateTime(System.currentTimeMillis());
|
||||||
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
testResourcePool.setUpdateTime(System.currentTimeMillis());
|
||||||
testResourcePool.setStatus("1");
|
testResourcePool.setStatus(ResourceStatusEnum.VALID.name());
|
||||||
validateTestResourcePool(testResourcePool);
|
validateTestResourcePool(testResourcePool);
|
||||||
testResourcePoolMapper.insertSelective(testResourcePool);
|
testResourcePoolMapper.insertSelective(testResourcePool);
|
||||||
return testResourcePool;
|
return testResourcePool;
|
||||||
|
@ -83,10 +84,11 @@ public class TestResourcePoolService {
|
||||||
NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class);
|
NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class);
|
||||||
boolean isValidate = validateNode(nodeDTO);
|
boolean isValidate = validateNode(nodeDTO);
|
||||||
if (!isValidate) {
|
if (!isValidate) {
|
||||||
testResourcePool.setStatus("0");
|
testResourcePool.setStatus(ResourceStatusEnum.INVALID.name());
|
||||||
resource.setStatus("0");
|
resource.setStatus(ResourceStatusEnum.INVALID.name());
|
||||||
|
} else {
|
||||||
|
resource.setStatus(ResourceStatusEnum.VALID.name());
|
||||||
}
|
}
|
||||||
resource.setStatus("1");
|
|
||||||
resource.setTestResourcePoolId(testResourcePool.getId());
|
resource.setTestResourcePoolId(testResourcePool.getId());
|
||||||
updateTestResource(resource);
|
updateTestResource(resource);
|
||||||
|
|
||||||
|
@ -114,10 +116,10 @@ public class TestResourcePoolService {
|
||||||
try {
|
try {
|
||||||
KubernetesProvider provider = new KubernetesProvider(testResource.getConfiguration());
|
KubernetesProvider provider = new KubernetesProvider(testResource.getConfiguration());
|
||||||
provider.validateCredential();
|
provider.validateCredential();
|
||||||
testResource.setStatus("1");
|
testResource.setStatus(ResourceStatusEnum.VALID.name());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
testResource.setStatus("0");
|
testResource.setStatus(ResourceStatusEnum.INVALID.name());
|
||||||
testResourcePool.setStatus("0");
|
testResourcePool.setStatus(ResourceStatusEnum.INVALID.name());
|
||||||
}
|
}
|
||||||
deleteTestResource(testResourcePool.getId());
|
deleteTestResource(testResourcePool.getId());
|
||||||
updateTestResource(testResource);
|
updateTestResource(testResource);
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
<el-switch v-model="scope.row.status"
|
<el-switch v-model="scope.row.status"
|
||||||
active-color="#13ce66"
|
active-color="#13ce66"
|
||||||
inactive-color="#ff4949"
|
inactive-color="#ff4949"
|
||||||
active-value="1"
|
active-value="VALID"
|
||||||
inactive-value="0"
|
inactive-value="INVALID"
|
||||||
@change="changeSwitch(scope.row)"
|
@change="changeSwitch(scope.row)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue