From b640ce5f277e5e48cb7a0f42c46fccf7ba683f85 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Thu, 14 Jan 2021 14:37:13 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E5=A2=9E=E5=8A=A0=E5=A4=84?= =?UTF-8?q?=E7=BD=AE=E8=AE=BE=E5=A4=87=E4=B8=9A=E5=8A=A1=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BB=A5=E5=8F=8A=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202.=20=E5=A2=9E=E5=8A=A0=E8=BF=AA=E6=99=AE=E6=97=81?= =?UTF-8?q?=E8=B7=AF=E7=89=B5=E5=BC=95=E8=AE=BE=E5=A4=87=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application-template.properties | 6 +- .../com/dispose/ability/DisposeAbility.java | 11 ++- .../ability/impl/DpTechAbilityImpl.java | 13 +++- .../ability/impl/DpTechBypassAbilityImpl.java | 73 ++++++++++++++++--- .../ability/impl/HaoHanAbilityImpl.java | 14 +++- .../ability/impl/HuaWeiAbilityImpl.java | 14 +++- .../ability/impl/PengXinAbilityImpl.java | 13 +++- .../ability/impl/VirtualAbilityImpl.java | 14 +++- .../com/dispose/config/TemplateConfigure.java | 17 ++++- .../device/ability/DpBypassManager.java | 34 +++++++++ .../ability/DpProtectionStrategyInfo.java | 26 +++++++ .../device/ability/DpTractionStrategy.java | 34 +++++++++ .../impl/DisposeAbilityRouterServiceImpl.java | 8 ++ 13 files changed, 258 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpBypassManager.java create mode 100644 src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpProtectionStrategyInfo.java create mode 100644 src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpTractionStrategy.java diff --git a/config/application-template.properties b/config/application-template.properties index 942415b4..22532c3e 100644 --- a/config/application-template.properties +++ b/config/application-template.properties @@ -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 diff --git a/src/main/java/com/dispose/ability/DisposeAbility.java b/src/main/java/com/dispose/ability/DisposeAbility.java index ee81b79d..58b68cc9 100644 --- a/src/main/java/com/dispose/ability/DisposeAbility.java +++ b/src/main/java/com/dispose/ability/DisposeAbility.java @@ -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 svrList); } diff --git a/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java index a68f9025..600d8535 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechAbilityImpl.java @@ -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 svrList) { + + } } diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index 189d3225..fa0f5298 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -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 disposeServiceGroup = new Hashtable<>(); + /** * The Obj prefix. */ @@ -34,9 +43,9 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { private final HashSet allCleanupDevices = new HashSet<>(); /** - * The Umc object. + * The Dp bypass manager. */ - private final Hashtable 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 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); + } + } + } } diff --git a/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java b/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java index 1721bd14..f41d45fe 100644 --- a/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/HaoHanAbilityImpl.java @@ -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 svrList) { + + } } diff --git a/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java b/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java index 4bca4e2b..09400234 100644 --- a/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/HuaWeiAbilityImpl.java @@ -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 svrList) { + + } } diff --git a/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java b/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java index 19431d8d..bb2c6b0d 100644 --- a/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/PengXinAbilityImpl.java @@ -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 svrList) { + + } } diff --git a/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java b/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java index 25e28c77..852244a8 100644 --- a/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/VirtualAbilityImpl.java @@ -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 svrList) { + + } } diff --git a/src/main/java/com/dispose/config/TemplateConfigure.java b/src/main/java/com/dispose/config/TemplateConfigure.java index 4b64344b..ffb1f664 100644 --- a/src/main/java/com/dispose/config/TemplateConfigure.java +++ b/src/main/java/com/dispose/config/TemplateConfigure.java @@ -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 umcTemplate; + public static List UMC_TEMPLATE; + + /** + * The Umc template. + */ + private List umcTemplate; + + /** + * Init template configure. + */ + @PostConstruct + private void initTemplateConfigure() { + TemplateConfigure.UMC_TEMPLATE = umcTemplate; + } } diff --git a/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpBypassManager.java b/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpBypassManager.java new file mode 100644 index 00000000..8c4898a7 --- /dev/null +++ b/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpBypassManager.java @@ -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 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DpBypassManager { + /** + * The Protect object. + */ + Hashtable protectObject; + + /** + * The Protect strategy. + */ + Hashtable protectStrategy; + + /** + * The Traction strategy name. + */ + Hashtable tractionStrategyName; +} diff --git a/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpProtectionStrategyInfo.java b/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpProtectionStrategyInfo.java new file mode 100644 index 00000000..72e5fa07 --- /dev/null +++ b/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpProtectionStrategyInfo.java @@ -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 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class DpProtectionStrategyInfo { + /** + * The Protect target name. + */ + private String protectTargetName; + /** + * The Protect strategy name. + */ + private String protectStrategyName; +} diff --git a/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpTractionStrategy.java b/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpTractionStrategy.java new file mode 100644 index 00000000..edd4f2be --- /dev/null +++ b/src/main/java/com/dispose/pojo/dto/protocol/device/ability/DpTractionStrategy.java @@ -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 + */ +@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; +} diff --git a/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java b/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java index e35afa02..c2fd1f9f 100644 --- a/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java @@ -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());