提交 1.SNAT复用策略、相关sql 2.IP复用调用CGI接口url字典
This commit is contained in:
@@ -21,20 +21,25 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.callback.InlineIp;
|
||||
import com.nis.domain.callback.IpAddrPool;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.IpAddrPoolCfg;
|
||||
import com.nis.domain.configuration.IpMultiplexPoolCfg;
|
||||
import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.UserManage;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.MaatCfg.IpCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.dao.configuration.IpAddrPoolCfgDao;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.BaseService;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.nis.web.service.basics.PolicyGroupInfoService;
|
||||
import com.nis.web.service.basics.SysDictInfoService;
|
||||
|
||||
import jersey.repackaged.com.google.common.collect.Maps;
|
||||
|
||||
@@ -282,4 +287,115 @@ public class IpAddrPoolCfgService extends BaseService{
|
||||
return ipAddrPoolCfgDao.getCfgInfo(cfg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 策略管理获取地址池信息(至少有1个IP地址有效状态该地址池才能被使用)
|
||||
* @param response
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public List<IpAddrPoolCfg> getEffectiveAddrPool() {
|
||||
List<IpAddrPoolCfg> addrPools = ipAddrPoolCfgDao.findAddrPoolCfg();
|
||||
|
||||
/*String cgiUrl = "http://localhost:8080/gwall/nis/maintenance/ipMultiplexPoolCfg/cgiCall";
|
||||
if(StringUtils.isNotBlank(Constants.IP_REUSE_CGI_URL)){
|
||||
cgiUrl = Constants.IP_REUSE_CGI_URL;
|
||||
}
|
||||
for (IpAddrPoolCfg cfg : addrPools) {
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("cmd", "IpNumGet");
|
||||
params.put("addr_pool_id", cfg.getAddrPoolId());
|
||||
try {
|
||||
String resJson = HttpClientUtil.getMsg(cgiUrl, params, req);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("获取地址池信息失败!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
return addrPools;
|
||||
}
|
||||
|
||||
/**
|
||||
* 策略配置审核
|
||||
* @param ids
|
||||
* @param cfg
|
||||
* @param auditTime
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditSnatStrategy(String id, IpPortCfg cfg, Date auditTime) {
|
||||
cfg.setCfgId(Long.valueOf(id));
|
||||
cfg.setTableName(IpPortCfg.getTablename());
|
||||
cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
cfg.setAuditTime(auditTime);
|
||||
// 更新配置审核状态
|
||||
IpCfgDao ipCfgDao = SpringContextHolder.getBean(IpCfgDao.class);
|
||||
IpCfgService IpCfgService = SpringContextHolder.getBean(IpCfgService.class);
|
||||
ipCfgDao.auditCfg(cfg);
|
||||
|
||||
// 获取配置信息
|
||||
BaseIpCfg ipCfg = IpCfgService.getIpCfgById(cfg);
|
||||
SysDictInfoService sysDictInfoService = SpringContextHolder.getBean(SysDictInfoService.class);
|
||||
UserManageService userManageService = SpringContextHolder.getBean(UserManageService.class);
|
||||
UserManage user = userManageService.getUserById(ipCfg.getUserRegion1());
|
||||
String json="";
|
||||
if(cfg.getIsAudit() == Constants.AUDIT_YES){
|
||||
Map<String, Object> params = new HashMap<String,Object>();
|
||||
params.put("configId", ipCfg.getCompileId());
|
||||
params.put("addrPoolId", ipCfg.getUserRegion2());
|
||||
params.put("userType", user.getUserType());
|
||||
params.put("userId", user.getId());
|
||||
params.put("isValid", 1);
|
||||
params.put("opTime", auditTime);
|
||||
if(ipCfg.getIsAreaEffective() == 1){
|
||||
params.put("effectiveRange", sysDictInfoService.setEffectiveRange(ipCfg.getAreaEffectiveIds()));
|
||||
}
|
||||
List list = Lists.newArrayList();
|
||||
list.add(params);
|
||||
//调用服务接口下发配置数据
|
||||
json=gsonToJson(list);
|
||||
logger.info("SNAT策略配置下发参数:"+json);
|
||||
//调用服务接口下发配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
||||
if(result!=null){
|
||||
logger.info("SNAT地址池配置下发响应信息:"+result.getMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("SNAT策略配置下发失败",e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}else if(cfg.getIsAudit() == Constants.AUDIT_NOT_YES){
|
||||
Map<String, Object> params = new HashMap<String,Object>();
|
||||
params.put("configId", ipCfg.getCompileId());
|
||||
params.put("addrPoolId", ipCfg.getUserRegion2());
|
||||
params.put("userType", user.getUserType());
|
||||
params.put("userId", user.getId());
|
||||
params.put("isValid", 0);
|
||||
params.put("opTime", auditTime);
|
||||
if(ipCfg.getIsAreaEffective() == 1){
|
||||
params.put("effectiveRange", sysDictInfoService.setEffectiveRange(ipCfg.getAreaEffectiveIds()));
|
||||
}
|
||||
List list = Lists.newArrayList();
|
||||
list.add(params);
|
||||
//调用服务接口取消配置
|
||||
json=gsonToJson(list);
|
||||
logger.info("SNAT策略配置下发参数:"+json);
|
||||
//调用服务接口取消配置
|
||||
try {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
||||
logger.info("SNAT策略配置响应信息:"+result.getMsg());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("SNAT策略配置配置失败");
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user