use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerImagesController method createContainer.
/**
* @return json
*/
@PostMapping(value = "create-container", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.EXECUTE)
public String createContainer(@RequestBody JSONObject jsonObject) throws Exception {
Assert.hasText(jsonObject.getString("id"), "id 不能为空");
Assert.hasText(jsonObject.getString("imageId"), "镜像不能为空");
Assert.hasText(jsonObject.getString("name"), "容器名称不能为空");
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(jsonObject.getString("id"), getRequest());
IPlugin plugin = PluginFactory.getPlugin(DockerInfoService.DOCKER_PLUGIN_NAME);
Map<String, Object> parameter = dockerInfoModel.toParameter();
parameter.putAll(jsonObject);
plugin.execute("createContainer", parameter);
return JsonMessage.getString(200, "创建成功");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerImagesController method list.
/**
* @return json
*/
@PostMapping(value = "list", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String list(@ValidatorItem String id) throws Exception {
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(id, getRequest());
IPlugin plugin = PluginFactory.getPlugin(DockerInfoService.DOCKER_PLUGIN_NAME);
Map<String, Object> parameter = dockerInfoModel.toParameter();
parameter.put("name", getParameter("name"));
parameter.put("showAll", getParameter("showAll"));
parameter.put("dangling", getParameter("dangling"));
List<JSONObject> listContainer = (List<JSONObject>) plugin.execute("listImages", parameter);
return JsonMessage.getString(200, "", listContainer);
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerImagesController method del.
/**
* @return json
*/
@GetMapping(value = "remove", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String del(@ValidatorItem String id, String imageId) throws Exception {
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(id, getRequest());
IPlugin plugin = PluginFactory.getPlugin(DockerInfoService.DOCKER_PLUGIN_NAME);
Map<String, Object> parameter = dockerInfoModel.toParameter();
parameter.put("imageId", imageId);
plugin.execute("removeImage", parameter);
return JsonMessage.getString(200, "执行成功");
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerImagesController method inspect.
/**
* @return json
*/
@GetMapping(value = "inspect", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String inspect(@ValidatorItem String id, String imageId) throws Exception {
DockerInfoModel dockerInfoModel = dockerInfoService.getByKey(id, getRequest());
IPlugin plugin = PluginFactory.getPlugin(DockerInfoService.DOCKER_PLUGIN_NAME);
Map<String, Object> parameter = dockerInfoModel.toParameter();
parameter.put("imageId", imageId);
JSONObject inspectImage = (JSONObject) plugin.execute("inspectImage", parameter);
return JsonMessage.getString(200, "", inspectImage);
}
use of io.jpom.permission.Feature in project Jpom by dromara.
the class DockerImagesController method getNowLog.
/**
* 获取拉取的日志
*
* @param id id
* @param line 需要获取的行号
* @return json
*/
@GetMapping(value = "pull-image-log", produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.LIST)
public String getNowLog(@ValidatorItem(value = ValidatorRule.NOT_BLANK, msg = "没有数据") String id, @ValidatorItem(value = ValidatorRule.POSITIVE_INTEGER, msg = "line") int line) {
File file = FileUtil.file(ServerConfigBean.getInstance().getUserTempPath(), "docker-log", id + ".log");
if (!file.exists()) {
return JsonMessage.getString(201, "还没有日志文件");
}
JSONObject data = FileUtils.readLogFile(file, line);
return JsonMessage.getString(200, "ok", data);
}
Aggregations