Search in sources :

Example 11 with MachineInfoDO

use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.

the class MachineInfoServiceImpl method testPing.

@Override
public Integer testPing(Long id) {
    MachineInfoDO machine = machineInfoDAO.selectById(id);
    Valid.notNull(machine, MessageConst.INVALID_MACHINE);
    boolean ping = IPs.ping(machine.getMachineHost(), Const.MS_S_3);
    return ping ? Const.ENABLE : Const.DISABLE;
}
Also used : MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO)

Example 12 with MachineInfoDO

use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.

the class MachineInfoServiceImpl method machineDetail.

@Override
public MachineInfoVO machineDetail(Long id) {
    MachineInfoDO machine = machineInfoDAO.selectById(id);
    Valid.notNull(machine, MessageConst.INVALID_MACHINE);
    MachineInfoVO vo = Converts.to(machine, MachineInfoVO.class);
    Optional.ofNullable(machine.getProxyId()).map(machineProxyDAO::selectById).ifPresent(p -> {
        vo.setProxyHost(p.getProxyHost());
        vo.setProxyPort(p.getProxyPort());
        vo.setProxyType(p.getProxyType());
    });
    return vo;
}
Also used : MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) MachineInfoVO(com.orion.ops.entity.vo.MachineInfoVO)

Example 13 with MachineInfoDO

use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.

the class FileTailServiceImpl method tailFileDetail.

@Override
public FileTailVO tailFileDetail(Long id) {
    FileTailListDO tail = fileTailListDAO.selectById(id);
    Valid.notNull(tail, MessageConst.UNKNOWN_DATA);
    FileTailVO vo = Converts.to(tail, FileTailVO.class);
    // 设置机器信息
    MachineInfoDO machine = machineInfoService.selectById(tail.getMachineId());
    Valid.notNull(machine, MessageConst.INVALID_MACHINE);
    vo.setMachineName(machine.getMachineName());
    vo.setMachineHost(machine.getMachineHost());
    return vo;
}
Also used : FileTailListDO(com.orion.ops.entity.domain.FileTailListDO) MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) FileTailVO(com.orion.ops.entity.vo.FileTailVO)

Example 14 with MachineInfoDO

use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.

the class MachineEnvServiceImpl method getFullMachineEnv.

@Override
public MutableLinkedHashMap<String, String> getFullMachineEnv(Long machineId) {
    // 查询机器
    MachineInfoDO machine = machineInfoDAO.selectById(machineId);
    Valid.notNull(machine, MessageConst.INVALID_MACHINE);
    MutableLinkedHashMap<String, String> env = Maps.newMutableLinkedMap();
    env.put(EnvConst.MACHINE_PREFIX + EnvConst.MACHINE_ID, machine.getId() + Strings.EMPTY);
    env.put(EnvConst.MACHINE_PREFIX + EnvConst.MACHINE_NAME, machine.getMachineName());
    env.put(EnvConst.MACHINE_PREFIX + EnvConst.MACHINE_TAG, machine.getMachineTag());
    env.put(EnvConst.MACHINE_PREFIX + EnvConst.MACHINE_HOST, machine.getMachineHost());
    env.put(EnvConst.MACHINE_PREFIX + EnvConst.MACHINE_PORT, machine.getSshPort() + Strings.EMPTY);
    env.put(EnvConst.MACHINE_PREFIX + EnvConst.MACHINE_USERNAME, machine.getUsername());
    // 查询环境变量
    LambdaQueryWrapper<MachineEnvDO> wrapper = new LambdaQueryWrapper<MachineEnvDO>().eq(MachineEnvDO::getMachineId, machineId).orderByAsc(MachineEnvDO::getId);
    machineEnvDAO.selectList(wrapper).forEach(e -> env.put(EnvConst.MACHINE_PREFIX + e.getAttrKey(), e.getAttrValue()));
    return env;
}
Also used : MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) MachineEnvDO(com.orion.ops.entity.domain.MachineEnvDO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 15 with MachineInfoDO

use of com.orion.ops.entity.domain.MachineInfoDO in project orion-ops by lijiahangmax.

the class MachineInfoServiceImpl method updateMachine.

@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateMachine(MachineInfoRequest request) {
    // 检查proxyId
    this.checkProxy(request.getProxyId());
    MachineInfoDO entity = new MachineInfoDO();
    String password = request.getPassword();
    this.copyProperties(request, entity);
    if (Strings.isNotBlank(password)) {
        entity.setPassword(ValueMix.encrypt(password));
    }
    // 修改
    int effect = machineInfoDAO.updateById(entity);
    // 设置日志参数
    EventParamsHolder.addParams(entity);
    return effect;
}
Also used : MachineInfoDO(com.orion.ops.entity.domain.MachineInfoDO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

MachineInfoDO (com.orion.ops.entity.domain.MachineInfoDO)16 Transactional (org.springframework.transaction.annotation.Transactional)4 FileTailListDO (com.orion.ops.entity.domain.FileTailListDO)3 FileTailVO (com.orion.ops.entity.vo.FileTailVO)3 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 MachineEnvDO (com.orion.ops.entity.domain.MachineEnvDO)2 UserDTO (com.orion.ops.entity.dto.UserDTO)2 Date (java.util.Date)2 ApplicationMachineDO (com.orion.ops.entity.domain.ApplicationMachineDO)1 CommandExecDO (com.orion.ops.entity.domain.CommandExecDO)1 MachineTerminalDO (com.orion.ops.entity.domain.MachineTerminalDO)1 FileTailDTO (com.orion.ops.entity.dto.FileTailDTO)1 TerminalConnectDTO (com.orion.ops.entity.dto.TerminalConnectDTO)1 MachineInfoVO (com.orion.ops.entity.vo.MachineInfoVO)1 MachineTerminalVO (com.orion.ops.entity.vo.MachineTerminalVO)1 TerminalAccessVO (com.orion.ops.entity.vo.TerminalAccessVO)1 CommandTaskSubmitVO (com.orion.ops.entity.vo.sftp.CommandTaskSubmitVO)1 ApplicationMachineService (com.orion.ops.service.api.ApplicationMachineService)1 SessionStore (com.orion.remote.channel.SessionStore)1 IOException (java.io.IOException)1