use of com.orion.ops.entity.request.SystemEnvRequest in project orion-ops by lijiahangmax.
the class SystemServiceImpl method configIpList.
@Override
@Transactional(rollbackFor = Exception.class)
public void configIpList(ConfigIpListRequest request) {
// 检查名单
String blackIpList = request.getBlackIpList();
String whiteIpList = request.getWhiteIpList();
this.validIpConfig(blackIpList);
this.validIpConfig(whiteIpList);
// 设置黑名单
SystemEnvDO blackEnv = systemEnvService.selectByName(SystemEnvAttr.BLACK_IP_LIST.getKey());
SystemEnvRequest updateBlack = new SystemEnvRequest();
updateBlack.setValue(blackIpList);
systemEnvService.updateEnv(blackEnv, updateBlack);
SystemEnvAttr.BLACK_IP_LIST.setValue(blackIpList);
// 设置白名单
SystemEnvDO whiteEnv = systemEnvService.selectByName(SystemEnvAttr.WHITE_IP_LIST.getKey());
SystemEnvRequest updateWhite = new SystemEnvRequest();
updateWhite.setValue(whiteIpList);
systemEnvService.updateEnv(whiteEnv, updateWhite);
SystemEnvAttr.WHITE_IP_LIST.setValue(whiteIpList);
// 更改启用状态
EnableType enableIpFilter = EnableType.of(request.getEnableIpFilter());
SystemEnvDO filterEnv = systemEnvService.selectByName(SystemEnvAttr.ENABLE_IP_FILTER.getKey());
SystemEnvRequest updateFilter = new SystemEnvRequest();
updateFilter.setValue(enableIpFilter.getLabel());
systemEnvService.updateEnv(filterEnv, updateFilter);
SystemEnvAttr.ENABLE_IP_FILTER.setValue(enableIpFilter.getLabel());
// 更改启用列表
EnableType enableWhiteIp = EnableType.of(request.getEnableWhiteIpList());
SystemEnvDO enableWhiteIpEnv = systemEnvService.selectByName(SystemEnvAttr.ENABLE_WHITE_IP_LIST.getKey());
SystemEnvRequest updateEnableWhiteIp = new SystemEnvRequest();
updateEnableWhiteIp.setValue(enableWhiteIp.getLabel());
systemEnvService.updateEnv(enableWhiteIpEnv, updateEnableWhiteIp);
SystemEnvAttr.ENABLE_WHITE_IP_LIST.setValue(enableWhiteIp.getLabel());
// 设置日志参数
EventParamsHolder.addParams(request);
// 设置 ip 过滤器
Boolean enableIpFilterValue = enableIpFilter.getValue();
Boolean enableWhiteIpValue = enableWhiteIp.getValue();
ipFilterInterceptor.set(enableIpFilterValue, enableWhiteIpValue, enableWhiteIpValue ? whiteIpList : blackIpList);
}
use of com.orion.ops.entity.request.SystemEnvRequest in project orion-ops by lijiahangmax.
the class SystemEnvServiceImpl method saveEnv.
@Override
@Transactional(rollbackFor = Exception.class)
public void saveEnv(Map<String, String> env) {
SystemEnvService self = SpringHolder.getBean(SystemEnvService.class);
// 倒排
List<Map.Entry<String, String>> entries = Lists.newList(env.entrySet());
int size = entries.size();
for (int i = size - 1; i >= 0; i--) {
// 更新
Map.Entry<String, String> entry = entries.get(i);
SystemEnvRequest request = new SystemEnvRequest();
request.setKey(entry.getKey());
request.setValue(entry.getValue());
self.addEnv(request);
}
// 设置日志参数
EventParamsHolder.addParam(EventKeys.COUNT, size);
}
use of com.orion.ops.entity.request.SystemEnvRequest in project orion-ops by lijiahangmax.
the class SystemServiceImpl method updateSystemOption.
@Override
public void updateSystemOption(SystemEnvAttr env, String value) {
String key = env.getKey();
String beforeValue = env.getValue();
// 更新系统配置
SystemEnvDO systemEnv = systemEnvService.selectByName(key);
SystemEnvRequest updateEnv = new SystemEnvRequest();
updateEnv.setValue(value);
systemEnvService.updateEnv(systemEnv, updateEnv);
env.setValue(value);
// 设置日志参数
EventParamsHolder.addParam(EventKeys.KEY, env.getDescription());
EventParamsHolder.addParam(EventKeys.LABEL, env.getDescription());
EventParamsHolder.addParam(EventKeys.BEFORE, beforeValue);
EventParamsHolder.addParam(EventKeys.AFTER, value);
}
use of com.orion.ops.entity.request.SystemEnvRequest in project orion-ops by lijiahangmax.
the class HistoryValueServiceImpl method rollback.
@Override
public void rollback(Long id) {
HistoryValueSnapshotDO historyValue = historyValueSnapshotDAO.selectById(id);
Valid.notNull(historyValue, MessageConst.HISTORY_VALUE_ABSENT);
// 设置修改值
HistoryOperator operator = HistoryOperator.of(historyValue.getOperatorType());
String updateValue;
switch(operator) {
case ADD:
updateValue = historyValue.getAfterValue();
break;
case UPDATE:
case DELETE:
default:
updateValue = historyValue.getBeforeValue();
}
// 修改值
Long valueId = historyValue.getValueId();
HistoryValueType valueType = HistoryValueType.of(historyValue.getValueType());
switch(valueType) {
case MACHINE_ENV:
MachineEnvRequest machineEnvRequest = new MachineEnvRequest();
machineEnvRequest.setId(valueId);
machineEnvRequest.setValue(updateValue);
machineEnvService.updateEnv(machineEnvRequest);
return;
case APP_ENV:
ApplicationEnvRequest appEnvRequest = new ApplicationEnvRequest();
appEnvRequest.setId(valueId);
appEnvRequest.setValue(updateValue);
applicationEnvService.updateAppEnv(appEnvRequest);
return;
case SYSTEM_ENV:
SystemEnvRequest systemRequest = new SystemEnvRequest();
systemRequest.setId(valueId);
systemRequest.setValue(updateValue);
systemEnvService.updateEnv(systemRequest);
return;
default:
}
}
Aggregations