use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.
the class FileTailServiceImpl method tailFileList.
@Override
public DataGrid<FileTailVO> tailFileList(FileTailRequest request) {
LambdaQueryWrapper<FileTailListDO> wrapper = new LambdaQueryWrapper<FileTailListDO>().eq(Objects.nonNull(request.getMachineId()), FileTailListDO::getMachineId, request.getMachineId()).like(!Strings.isEmpty(request.getName()), FileTailListDO::getAliasName, request.getName()).like(!Strings.isEmpty(request.getPath()), FileTailListDO::getFilePath, request.getPath()).like(!Strings.isEmpty(request.getCommand()), FileTailListDO::getTailCommand, request.getCommand()).orderByDesc(FileTailListDO::getUpdateTime);
DataGrid<FileTailVO> dataGrid = DataQuery.of(fileTailListDAO).page(request).wrapper(wrapper).dataGrid(FileTailVO.class);
// 设置机器信息
Map<Long, MachineInfoDO> machineCache = Maps.newMap();
dataGrid.forEach(p -> {
MachineInfoDO machine = machineCache.computeIfAbsent(p.getMachineId(), mid -> machineInfoService.selectById(p.getMachineId()));
if (machine != null) {
p.setMachineName(machine.getMachineName());
p.setMachineHost(machine.getMachineHost());
}
});
return dataGrid;
}
use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.
the class MachineInfoServiceImpl method updateStatus.
@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateStatus(List<Long> idList, Integer status) {
int effect = 0;
for (Long id : idList) {
MachineInfoDO entity = new MachineInfoDO();
entity.setId(id);
entity.setMachineStatus(status);
entity.setUpdateTime(new Date());
effect += machineInfoDAO.updateById(entity);
}
// 设置日志参数
EventParamsHolder.addParam(EventKeys.ID_LIST, idList);
EventParamsHolder.addParam(EventKeys.COUNT, effect);
EventParamsHolder.addParam(EventKeys.OPERATOR, Const.ENABLE.equals(status) ? Const.ENABLE_LABEL : Const.DISABLE_LABEL);
return effect;
}
use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.
the class HostMachineInitialize method initMachine.
/**
* 初始化宿主机
*/
private void initMachine() {
LambdaQueryWrapper<MachineInfoDO> wrapper = new LambdaQueryWrapper<MachineInfoDO>().eq(MachineInfoDO::getId, Const.HOST_MACHINE_ID);
MachineInfoDO machineInfo = machineInfoDAO.selectOne(wrapper);
if (machineInfo == null) {
// 插入机器
MachineInfoDO insert = new MachineInfoDO();
insert.setMachineName(Systems.HOST_NAME);
insert.setMachineTag(Const.HOST_MACHINE_TAG);
insert.setMachineHost(IPs.IP);
insert.setSshPort(22);
insert.setDescription("宿主机");
insert.setUsername(Systems.USER_NAME);
insert.setAuthType(MachineAuthType.PASSWORD.getType());
insert.setMachineStatus(Const.ENABLE);
machineInfoDAO.insert(insert);
machineInfoDAO.setId(insert.getId(), Const.HOST_MACHINE_ID);
log.info("宿主机已初始化");
// 初始化环境变量
machineEnvService.initEnv(Const.HOST_MACHINE_ID);
}
}
use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.
the class MachineInfoServiceImpl method copyMachine.
@Override
public Long copyMachine(Long id) {
MachineInfoDO machine = machineInfoDAO.selectById(id);
Valid.notNull(machine, MessageConst.INVALID_MACHINE);
String sourceMachineName = machine.getMachineName();
String targetMachineName = sourceMachineName + Utils.getCopySuffix();
machine.setId(null);
machine.setCreateTime(null);
machine.setUpdateTime(null);
machine.setMachineName(targetMachineName);
machineInfoDAO.insert(machine);
Long insertId = machine.getId();
// 复制环境变量
LambdaQueryWrapper<MachineEnvDO> wrapper = new LambdaQueryWrapper<MachineEnvDO>().eq(MachineEnvDO::getMachineId, id).orderByAsc(MachineEnvDO::getUpdateTime);
machineEnvDAO.selectList(wrapper).forEach(e -> {
// 插入环境变量
e.setMachineId(insertId);
e.setCreateTime(null);
e.setUpdateTime(null);
machineEnvDAO.insert(e);
// 插入历史值
historyValueService.addHistory(e.getId(), HistoryValueType.MACHINE_ENV, HistoryOperator.ADD, null, e.getAttrValue());
});
// 设置日志参数
EventParamsHolder.addParam(EventKeys.ID, id);
EventParamsHolder.addParam(EventKeys.SOURCE, sourceMachineName);
EventParamsHolder.addParam(EventKeys.TARGET, targetMachineName);
return insertId;
}
use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.
the class MachineTerminalServiceImpl method updateSetting.
@Override
public Integer updateSetting(MachineTerminalRequest request) {
// 查询配置
Long id = request.getId();
MachineTerminalDO beforeConfig = machineTerminalDAO.selectById(id);
Valid.notNull(beforeConfig, MessageConst.UNKNOWN_DATA);
// 查询机器信息
MachineInfoDO machineInfo = machineInfoService.selectById(beforeConfig.getMachineId());
Valid.notNull(machineInfo, MessageConst.UNKNOWN_DATA);
// 设置修改信息
MachineTerminalDO update = new MachineTerminalDO();
update.setId(id);
update.setTerminalType(request.getTerminalType());
update.setFontSize(request.getFontSize());
update.setFontFamily(request.getFontFamily());
update.setFontColor(request.getFontColor());
update.setBackgroundColor(request.getBackgroundColor());
update.setUpdateTime(new Date());
update.setEnableWebLink(request.getEnableWebLink());
update.setEnableWebGL(request.getEnableWebGL());
// 修改
int effect = machineTerminalDAO.updateById(update);
// 设置日志参数
EventParamsHolder.addParams(request);
EventParamsHolder.addParam(EventKeys.NAME, machineInfo.getMachineName());
return effect;
}
Aggregations