REM:
1. 增加处置设备业务对象接口以及相关功能
2. 增加迪普旁路牵引设备对象管理功能
This commit is contained in:
HuangXin 2021-01-14 14:37:13 +08:00
parent 1f1abbfe4b
commit b640ce5f27
13 changed files with 258 additions and 19 deletions

View File

@ -32,15 +32,15 @@ template.umcTemplate[5].type=WEB
template.umcTemplate[6].name=General_Server_10G
template.umcTemplate[6].bandMin=1500
template.umcTemplate[6].bandMax=-1
template.umcTemplate[6].type=SERVER
template.umcTemplate[6].type=GENERAL
template.umcTemplate[7].name=General_Server_1G
template.umcTemplate[7].bandMin=500
template.umcTemplate[7].bandMax=1500
template.umcTemplate[7].type=SERVER
template.umcTemplate[7].type=GENERAL
template.umcTemplate[8].name=General_Server_100M
template.umcTemplate[8].bandMin=0
template.umcTemplate[8].bandMax=500
template.umcTemplate[8].type=SERVER
template.umcTemplate[8].type=GENERAL

View File

@ -4,10 +4,12 @@ import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import javax.annotation.Nullable;
import java.util.List;
/**
* The interface Dispose ability.
@ -109,5 +111,12 @@ public interface DisposeAbility {
*
* @return the boolean
*/
Boolean deviceReady();
boolean deviceReady();
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
void upgradeServiceGroup(List<ServiceInfo> svrList);
}

View File

@ -10,6 +10,7 @@ import com.dispose.common.DpTechConfigValue;
import com.dispose.common.ErrorCode;
import com.dispose.common.Helper;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.dptech.dispose.AbnormalFlowCleaningServicePortType;
@ -379,7 +380,17 @@ public class DpTechAbilityImpl implements DisposeAbility {
* @return the boolean
*/
@Override
public Boolean deviceReady() {
public boolean deviceReady() {
return true;
}
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
@Override
public void upgradeServiceGroup(List<ServiceInfo> svrList) {
}
}

View File

@ -4,8 +4,11 @@ import com.dispose.common.ConstValue;
import com.dispose.common.DisposeConfigValue;
import com.dispose.common.DpTechConfigValue;
import com.dispose.common.IpAddrType;
import com.dispose.pojo.dto.protocol.device.ability.DpBypassManager;
import com.dispose.pojo.dto.protocol.device.ability.DpProtectObject;
import com.dispose.pojo.entity.ServiceInfo;
import com.dptech.dispose.ArrayOfProtectionObjectDataForService;
import com.dptech.dispose.ArrayOfProtectionTargetWithStrategyForService;
import com.dptech.dispose.NtcRequestResultInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@ -14,6 +17,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.regex.Pattern;
/**
@ -24,6 +28,11 @@ import java.util.regex.Pattern;
@Slf4j
public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
/**
* The Dispose service group.
*/
private final Hashtable<Long, ServiceInfo> disposeServiceGroup = new Hashtable<>();
/**
* The Obj prefix.
*/
@ -34,9 +43,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
private final HashSet<String> allCleanupDevices = new HashSet<>();
/**
* The Umc object.
* The Dp bypass manager.
*/
private final Hashtable<String, DpProtectObject> umcObject = new Hashtable<>();
private DpBypassManager dpBypassManager;
/**
* The Timer cnt.
*/
@ -57,6 +66,31 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
}
}
/**
* Gets protection strategy template.
*/
private void getProtectionStrategyTemplate() {
try {
log.debug("++++Begging DPTech Get All Protection Strategy Association Relation");
ArrayOfProtectionTargetWithStrategyForService ret =
getCleanTypePort().getAllProtectionTargetWithStrategyAssociationRelationshipForUMC();
if (ret == null) {
log.error("----Finish DPTech Get All Protection Strategy Association Relation error");
return;
}
log.info("----Finish Begging DPTech Get All Protection Strategy Association Relation");
} catch (Exception ex) {
log.error("----Exception Begging DPTech Get All Protection Strategy Association Relation: {}",
ex.getMessage());
}
}
/**
* Init device env.
*
@ -66,6 +100,11 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
*/
@Override
public void initDeviceEnv(String urlPath, String username, String password) {
dpBypassManager = DpBypassManager.builder()
.protectObject(new Hashtable<>())
.protectStrategy(new Hashtable<>())
.tractionStrategyName(new Hashtable<>())
.build();
super.initDeviceEnv(urlPath, username, password);
// 获取所有检测设备
@ -74,9 +113,6 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
/**
* Gets dispose device protect object.
* 防护对象命名规则 前缀_对象唯一名称_IP地址类型
* CMHI_xxxx_V4
* CMHI_XXXX_V6
*/
@Override
public void getDisposeDeviceProtectObject() {
@ -107,9 +143,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
} else {
DpProtectObject obj;
if (!umcObject.contains(objName)) {
if (!dpBypassManager.getProtectObject().containsKey(objName)) {
// 获取防护对象
obj = umcObject.get(objName);
obj = dpBypassManager.getProtectObject().get(objName);
} else {
obj = DpProtectObject.builder()
.cleanupDevices(k.getCleaningDevices().getValue())
@ -119,7 +155,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
.ipSegment(new Hashtable<>())
.build();
// 添加到缓存
umcObject.put(objName, obj);
dpBypassManager.getProtectObject().put(objName, obj);
}
String ipSeg = k.getIpSegment().getValue();
@ -150,7 +186,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
});
// 判断是否需要更新IP段信息
if(!obj.getIpSegment().equals(tmpTable)) {
if (!obj.getIpSegment().equals(tmpTable)) {
obj.setIpSegment(tmpTable);
}
}
@ -176,4 +212,23 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
}
}
}
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
@Override
public void upgradeServiceGroup(List<ServiceInfo> svrList) {
for (ServiceInfo v : svrList) {
if (disposeServiceGroup.containsKey(v.getServiceId())) {
if (!disposeServiceGroup.get(v.getServiceId()).equals(v)) {
disposeServiceGroup.remove(v.getServiceId());
disposeServiceGroup.put(v.getServiceId(), v);
}
} else {
disposeServiceGroup.put(v.getServiceId(), v);
}
}
}
}

View File

@ -6,6 +6,7 @@ import com.dispose.common.DisposeConfigValue;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.haohan.dispose.common.HaoHanStartCleanResp;
@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Nullable;
import java.util.List;
/**
* The type Hao han ability.
@ -265,7 +267,17 @@ public class HaoHanAbilityImpl implements DisposeAbility {
* @return the boolean
*/
@Override
public Boolean deviceReady() {
public boolean deviceReady() {
return true;
}
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
@Override
public void upgradeServiceGroup(List<ServiceInfo> svrList) {
}
}

View File

@ -7,6 +7,7 @@ import com.dispose.common.DisposeConfigValue;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -21,6 +22,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Nullable;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* The type Hua wei ability.
@ -376,8 +378,18 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
* @return the boolean
*/
@Override
public Boolean deviceReady() {
public boolean deviceReady() {
return true;
}
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
@Override
public void upgradeServiceGroup(List<ServiceInfo> svrList) {
}
}

View File

@ -9,6 +9,7 @@ import com.dispose.common.Helper;
import com.dispose.common.IpAddrType;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.pengxin.dispose.common.PengXinDisposeAbilityRsp;
@ -525,7 +526,17 @@ public class PengXinAbilityImpl implements DisposeAbility {
* @return the boolean
*/
@Override
public Boolean deviceReady() {
public boolean deviceReady() {
return true;
}
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
@Override
public void upgradeServiceGroup(List<ServiceInfo> svrList) {
}
}

View File

@ -5,10 +5,12 @@ import com.dispose.common.DisposeCapacityType;
import com.dispose.common.DisposeObjectType;
import com.dispose.common.ErrorCode;
import com.dispose.common.NetflowDirection;
import com.dispose.pojo.entity.ServiceInfo;
import com.dispose.pojo.po.MulReturnType;
import com.dispose.pojo.vo.DeviceFirewareInfo;
import javax.annotation.Nullable;
import java.util.List;
/**
* The type Virtual ability.
@ -158,7 +160,17 @@ public class VirtualAbilityImpl implements DisposeAbility {
* @return the boolean
*/
@Override
public Boolean deviceReady() {
public boolean deviceReady() {
return true;
}
/**
* Upgrade service group.
*
* @param svrList the svr list
*/
@Override
public void upgradeServiceGroup(List<ServiceInfo> svrList) {
}
}

View File

@ -7,6 +7,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;
/**
@ -20,8 +21,22 @@ import java.util.List;
@ConfigurationProperties(prefix = "template")
@Configuration
public class TemplateConfigure {
/**
* The Umc template.
*/
List<TemplateInfo> umcTemplate;
public static List<TemplateInfo> UMC_TEMPLATE;
/**
* The Umc template.
*/
private List<TemplateInfo> umcTemplate;
/**
* Init template configure.
*/
@PostConstruct
private void initTemplateConfigure() {
TemplateConfigure.UMC_TEMPLATE = umcTemplate;
}
}

View File

@ -0,0 +1,34 @@
package com.dispose.pojo.dto.protocol.device.ability;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Hashtable;
/**
* The type Dp bypass manager.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DpBypassManager {
/**
* The Protect object.
*/
Hashtable<String, DpProtectObject> protectObject;
/**
* The Protect strategy.
*/
Hashtable<String, DpProtectionStrategyInfo> protectStrategy;
/**
* The Traction strategy name.
*/
Hashtable<String, DpTractionStrategy> tractionStrategyName;
}

View File

@ -0,0 +1,26 @@
package com.dispose.pojo.dto.protocol.device.ability;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Dp protection strategy info.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DpProtectionStrategyInfo {
/**
* The Protect target name.
*/
private String protectTargetName;
/**
* The Protect strategy name.
*/
private String protectStrategyName;
}

View File

@ -0,0 +1,34 @@
package com.dispose.pojo.dto.protocol.device.ability;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* The type Dp traction strategy.
*
* @author <huangxin@cmhi.chinamoblie.com>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class DpTractionStrategy {
/**
* The Policy name.
*/
private String policyName;
/**
* The Protect name.
*/
private String protectName;
/**
* The Ip range.
*/
private String ipRange;
/**
* The Running.
*/
private boolean running;
}

View File

@ -11,6 +11,7 @@ import com.dispose.common.DisposeCapacityType;
import com.dispose.common.ErrorCode;
import com.dispose.common.HttpType;
import com.dispose.manager.DisposeDeviceManager;
import com.dispose.mapper.ServiceGroupMapper;
import com.dispose.pojo.entity.DisposeDevice;
import com.dispose.pojo.po.AbilityInfo;
import com.dispose.service.DisposeAbilityRouterService;
@ -44,6 +45,12 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
@Resource
private DisposeDeviceManager disposeDeviceManager;
/**
* The Service group mapper.
*/
@Resource
private ServiceGroupMapper serviceGroupMapper;
/**
* Init dispose ability.
*/
@ -127,6 +134,7 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
break;
case DPTECH_BYPASS_UMC:
db = new DpTechBypassAbilityImpl();
db.upgradeServiceGroup(serviceGroupMapper.selectAll());
break;
default:
log.error("Unknown dispose device type: {}", dev.getDeviceType());