@Transactional(readOnly = false) public void updateIpPoolByIpAddress(String ipAddress, Integer status, HostServer hostServer) { // TODO 待优化,最终目标是删除此方法. IpPool ipPool = ipPoolDao.findByIpAddress(ipAddress); if (ipPool != null) { ipPool.setStatus(status); ipPool.setHostServer(hostServer); ipPoolDao.save(ipPool); } }
/** * IP分页查询,值显示当前用户创建的EIP. * * @param page * @param size * @return */ public Page<IpPool> getIpPoolPageable( Map<String, Object> searchParams, int pageNumber, int pageSize) { PageRequest pageRequest = buildPageRequest(pageNumber, pageSize); Map<String, SearchFilter> filters = SearchFilter.parse(searchParams); Specification<IpPool> spec = DynamicSpecifications.bySearchFilter(filters.values(), IpPool.class); return ipPoolDao.findAll(spec, pageRequest); }
/** * 删除IP(同时删除oneCMDB下的ip) * * @param id * @return */ @Transactional(readOnly = false) public void deleteIpPool(Integer id) { // 删除oneCMDB下的ip comm.oneCmdbUtilService.deleteIpPoolToOneCMDB(this.getIpPool(id)); ipPoolDao.delete(id); }
/** * 初始化IP,将IP的状态设置为未使用状态,关联的HostServer设置为null. 如果IP不存在数据库中,则返回null值. * * @param ipAddress * @return */ public IpPool initIpPool(String ipAddress) { IpPool ipPool = ipPoolDao.findByIpAddress(ipAddress); if (ipPool != null) { ipPool.setStatus(IpPoolConstant.IpStatus.未使用.toInteger()); ipPool.setHostServer(null); return this.saveOrUpdate(ipPool); } return null; }
/** * 保存IP * * @param ipPool */ @Transactional(readOnly = false) public void saveIpPool(IpPool ipPool) { // 同步至oneCMDB List<IpPool> ipPools = new ArrayList<IpPool>(); ipPools.add(ipPool); comm.oneCmdbUtilService.saveIpPoolToOneCMDB(ipPools, ipPool.getPoolType()); ipPoolDao.save(ipPool); }
/** * 返回类型为String的所有IpAddress List * * @return */ private List<String> getAllIpAddress() { List<IpPool> ipPools = (List<IpPool>) ipPoolDao.findAll(); List<String> list = new ArrayList<String>(); for (IpPool ipPool : ipPools) { list.add(ipPool.getIpAddress()); } return list; }
/** * 保存IP(可以单个,也可以多条),并将IP同步至oneCMDB * * @param ipAddressList ip列表 * @param poolType IP所属IP池 * @param ipStatus IP状态 */ @Transactional(readOnly = false) private boolean saveIpPool( List<String> ipAddressList, Integer poolType, Integer ipStatus, Vlan vlan) { List<IpPool> ipPoolList = new ArrayList<IpPool>(); for (String ipAddress : ipAddressList) { IpPool ipPool = new IpPool(poolType, vlan, ipAddress, ipStatus, new Date()); ipPoolList.add(ipPool); } ipPoolDao.save(ipPoolList); // 同步至oneCMDB comm.oneCmdbUtilService.saveIpPoolToOneCMDB(ipPoolList, poolType); return true; }
/** * 新增,更新IpPool * * @param ipPool * @return */ @Transactional(readOnly = false) public IpPool saveOrUpdate(IpPool ipPool) { return ipPoolDao.save(ipPool); }
public IpPool getIpPool(Integer id) { return ipPoolDao.findOne(id); }
/** * 根据VLAN查询其下所有IP * * @param vlan * @return */ public List<IpPool> findIpPoolByVlan(String vlanAlias) { return ipPoolDao.findByVlanAliasAndStatus(vlanAlias, 1); }
/** * 根据IP池类型和ip状态获得ip列表 * * @param poolType * @return */ public List<IpPool> getIpPoolByPoolTypeAndStatus(Integer poolType, Integer status) { return ipPoolDao.findByPoolTypeAndStatus(poolType, status); }
/** * 根据ipAddress获得指定的IpPool . * * @param ipAddress * @return */ public IpPool findIpPoolByIpAddress(String ipAddress) { return ipPoolDao.findByIpAddress(ipAddress); }