use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerNetworkController method list.
/**
* @return json
*/
@PostMapping(value = "list", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String list(@ValidatorItem String id, String name, String networkId) throws Exception {
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(id);
IPlugin plugin = PluginFactory.getPlugin(DockerInfoService.DOCKER_PLUGIN_NAME);
Map<String, Object> parameter = dockerInfoModel.toParameter();
parameter.put("name", name);
parameter.put("id", networkId);
List<JSONObject> listContainer = (List<JSONObject>) plugin.execute("listNetworks", parameter);
return JsonMessage.getString(200, "", listContainer);
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerInfoController method del.
@GetMapping(value = "del", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String del(@ValidatorItem String id) throws Exception {
DockerInfoModel infoModel = dockerInfoService.getByKey(id, getRequest());
if (infoModel != null) {
// 检查是否为最后一个 docker 需要删除证书文件
DockerInfoModel dockerInfoModel = new DockerInfoModel();
dockerInfoModel.setHost(infoModel.getHost());
long count = dockerInfoService.count(dockerInfoService.dataBeanToEntity(dockerInfoModel));
if (count <= 1) {
// 删除文件
FileUtil.del(infoModel.generateCertPath());
}
dockerInfoService.delByKey(id);
}
return JsonMessage.getString(200, "删除成功");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerInfoController method leaveForce.
/**
* 强制退出集群
*
* @param id 集群ID
* @return json
*/
@GetMapping(value = "swarm-leave-force", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public JsonMessage<String> leaveForce(@ValidatorItem String id) throws Exception {
//
DockerSwarmInfoMode dockerSwarmInfoMode = new DockerSwarmInfoMode();
dockerSwarmInfoMode.setDockerId(id);
long count = dockerSwarmInfoService.count(dockerSwarmInfoMode);
Assert.state(count <= 0, "需要先解绑集群才能强制退出集群");
//
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(id, getRequest());
IPlugin plugin = PluginFactory.getPlugin(DockerSwarmInfoService.DOCKER_PLUGIN_NAME);
Map<String, Object> parameter = dockerInfoModel.toParameter();
parameter.put("force", true);
plugin.execute("leaveSwarm", parameter, JSONObject.class);
//
dockerInfoService.unbind(id);
return new JsonMessage<>(200, "强制解绑成功");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerInfoController method info.
@GetMapping(value = "info", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String info(@ValidatorItem String id) throws Exception {
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(id, getRequest());
IPlugin plugin = PluginFactory.getPlugin(DockerInfoService.DOCKER_CHECK_PLUGIN_NAME);
JSONObject info = plugin.execute("info", dockerInfoModel.toParameter(), JSONObject.class);
return JsonMessage.getString(200, "", info);
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerSwarmInfoController method leave.
/**
* 退出集群
*
* @param id 集群ID
* @return json
*/
@GetMapping(value = "leave", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public JsonMessage<String> leave(@ValidatorItem String id, @ValidatorItem String nodeId) throws Exception {
//
IPlugin plugin = PluginFactory.getPlugin(DockerSwarmInfoService.DOCKER_PLUGIN_NAME);
// 查询节点信息
DockerInfoModel dockerInfoModel = new DockerInfoModel();
dockerInfoModel.setSwarmNodeId(nodeId);
List<DockerInfoModel> dockerInfoModels = dockerInfoService.queryList(dockerInfoModel, 2);
Assert.state(CollUtil.size(dockerInfoModels) == 1, "当前节点未在系统中绑定或者绑定信息异常,不能操作");
//
{
DockerInfoModel dockerInfoModel1 = CollUtil.getFirst(dockerInfoModels);
Map<String, Object> parameter = dockerInfoModel1.toParameter();
parameter.put("force", true);
plugin.execute("leaveSwarm", parameter, JSONObject.class);
}
{
Map<String, Object> map = dockerInfoService.getBySwarmPluginMap(id, getRequest());
map.put("nodeId", nodeId);
plugin.execute("removeSwarmNode", map);
}
//
dockerInfoService.unbind(id);
return new JsonMessage<>(200, "剔除成功");
}
Aggregations