parent
4038c75cb5
commit
e7f557862f
|
@ -143,7 +143,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
dpBypassManager.getTractionStrategyName().remove(v.getPolicyName());
|
||||
} else {
|
||||
log.info("!!!!Remove Traction Strategy {} Error: {}", v.getPolicyName(),
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
}
|
||||
|
||||
ret = getCleanTypePort().disableProtectionStrategyTemplateForUMC(objName,
|
||||
v.getProtectStrategyName());
|
||||
v.getProtectStrategyName());
|
||||
|
||||
if (ret.getResultRetVal() == 0) {
|
||||
log.debug("Disable Protection Strategy Template {} Succeed", objName);
|
||||
|
@ -169,7 +169,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
dpBypassManager.getProtectStrategy().remove(objName);
|
||||
} else {
|
||||
log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
break;
|
||||
|
@ -186,7 +186,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
dpBypassManager.getProtectObject().remove(objName);
|
||||
} else {
|
||||
log.error("!!!!Delete Protection Object {} Error: {}", objName,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
|
||||
|
@ -218,17 +218,17 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
// 创建对象
|
||||
NtcRequestResultInfo ret = getCleanTypePort()
|
||||
.addProtectionObjectForUMC("",
|
||||
allCleanupDevices,
|
||||
objName,
|
||||
ipSegment,
|
||||
ipType,
|
||||
0);
|
||||
allCleanupDevices,
|
||||
objName,
|
||||
ipSegment,
|
||||
ipType,
|
||||
0);
|
||||
|
||||
if (ret.getResultRetVal() == 0) {
|
||||
log.debug("Add Protection Object {} Succeed", objName);
|
||||
} else {
|
||||
log.error("!!!!Add Protection Object {}, {}, {} Error: {}", objName, ipSegment, ipType,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
log.debug("{} Link Protection Strategy Template {} Succeed", objName, template);
|
||||
} else {
|
||||
log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, template,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
|
||||
|
@ -288,14 +288,14 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
// 创建旁路手动牵引策略
|
||||
ret = getCleanTypePort().addBypassManualTractionStrategyForUMC(tractionName,
|
||||
objName,
|
||||
getIpSegmentFormat(disposeObject));
|
||||
objName,
|
||||
getIpSegmentFormat(disposeObject));
|
||||
if (ret.getResultRetVal() == 0) {
|
||||
log.debug("----Finish Create Traction Strategy {} Succeed", tractionName);
|
||||
return ErrorCode.ERR_OK;
|
||||
} else {
|
||||
log.error("----Create Traction Strategy Error: {}, {}, {}, {}", tractionName,
|
||||
objName, disposeObject, ret.getResultInfo().getValue());
|
||||
objName, disposeObject, ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
if (ret.getResultRetVal() != 0) {
|
||||
err = ErrorCode.ERR_CALLDEVICE;
|
||||
log.error("----Error Start Traction Strategy: {}, {}, {}", objName, disposeObject,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
} else {
|
||||
log.debug("----Finish Start Traction Strategy: {}, {}", objName, disposeObject);
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
return ErrorCode.ERR_OK;
|
||||
} else {
|
||||
log.error("!!!!Remove Traction Strategy {} Error: {}", tractionName,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
log.debug("Disable Protection Strategy Template {} Succeed", objName);
|
||||
} else {
|
||||
log.error("!!!!Disable Protection Strategy Template {} Error: {}", objName,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
|
||||
|
@ -448,13 +448,14 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
log.debug("{} Link Protection Strategy Template {} Succeed", objName, newTemplate);
|
||||
} else {
|
||||
log.error("!!!!{} Link Protection Strategy Template {} Error: {}", objName, newTemplate,
|
||||
ret.getResultInfo().getValue());
|
||||
ret.getResultInfo().getValue());
|
||||
return ErrorCode.ERR_CALLDEVICE;
|
||||
}
|
||||
|
||||
return ErrorCode.ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sync dp tech device info.
|
||||
*/
|
||||
|
@ -472,7 +473,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
// 未找到合适的模板
|
||||
if (TemplateConfigure.UMC_TEMPLATE.stream().noneMatch(m -> m.getName().equals(template))) {
|
||||
log.error("!!!!{} Can't Math Template: {}, {} From {}", v.getServiceId(), v.getServiceType(),
|
||||
v.getServiceBandwidth(), TemplateConfigure.UMC_TEMPLATE);
|
||||
v.getServiceBandwidth(), TemplateConfigure.UMC_TEMPLATE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -501,71 +502,13 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
// 防护对象存在
|
||||
if (dpBypassManager.getProtectObject().containsKey(protectName)) {
|
||||
DpProtectObject dp = dpBypassManager.getProtectObject().get(protectName);
|
||||
|
||||
// 判断关联模板是否正确
|
||||
if (dpBypassManager.getProtectStrategy().containsKey(protectName)) {
|
||||
// 已经关联防护模板
|
||||
String temp = dpBypassManager.getProtectStrategy()
|
||||
.get(protectName)
|
||||
.getProtectStrategyName();
|
||||
// 如果关联模板有变更
|
||||
if (!temp.equals(template)) {
|
||||
// 重新关联防护模板
|
||||
associationProtectionTemplate(protectName, template, temp);
|
||||
}
|
||||
} else {
|
||||
// 关联一个新的防护模板
|
||||
associationProtectionTemplate(protectName, template, null);
|
||||
}
|
||||
|
||||
|
||||
boolean upgradeIpSegment = false;
|
||||
|
||||
// 判断防护IP段是否有变化
|
||||
if (IpAddrType.IPV4.equals(entry.getKey())) {
|
||||
if (ipV4.size() != dp.getIpSegment().values().size()) {
|
||||
upgradeIpSegment = true;
|
||||
} else {
|
||||
List<String> ipList =
|
||||
ipV4.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList());
|
||||
|
||||
if (!ipList.containsAll(dp.getIpSegment().values())
|
||||
|| !dp.getIpSegment().values().containsAll(ipList)) {
|
||||
upgradeIpSegment = true;
|
||||
}
|
||||
}
|
||||
} else if (IpAddrType.IPV6.equals(entry.getKey())) {
|
||||
if (ipV6.size() != dp.getIpSegment().values().size()) {
|
||||
upgradeIpSegment = true;
|
||||
} else {
|
||||
List<String> ipList =
|
||||
ipV6.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList());
|
||||
|
||||
if (!ipList.containsAll(dp.getIpSegment().values())
|
||||
|| !dp.getIpSegment().values().containsAll(ipList)) {
|
||||
upgradeIpSegment = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新防护对象
|
||||
if (upgradeIpSegment) {
|
||||
err = upgradeProtectObject(protectName,
|
||||
ipSegment.get(entry.getKey()),
|
||||
IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1,
|
||||
template);
|
||||
if (err == ErrorCode.ERR_OK) {
|
||||
log.debug("upgrade Protection Object {} Succeed", protectName);
|
||||
} else {
|
||||
log.error("!!!!upgrade Protection Object {} Error: {}", protectName, err.getMsg());
|
||||
}
|
||||
}
|
||||
//进一步判断关联模板是都正确,防护IP段是否发生变化
|
||||
protectionObjExist(entry, protectName, template, ipV4, ipV6, ipSegment);
|
||||
} else {
|
||||
err = createProtectObject(protectName,
|
||||
ipSegment.get(entry.getKey()),
|
||||
IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1,
|
||||
template);
|
||||
ipSegment.get(entry.getKey()),
|
||||
IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1,
|
||||
template);
|
||||
if (err == ErrorCode.ERR_OK) {
|
||||
log.debug("Add Protection Object {} Succeed", protectName);
|
||||
} else {
|
||||
|
@ -575,6 +518,88 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
}
|
||||
});
|
||||
|
||||
// UMC 同步到处置平台
|
||||
umcSynDisPlatform();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 防护对象存在的情况
|
||||
*/
|
||||
private void protectionObjExist(Map.Entry<IpAddrType, String> entry, String protectName, String template,
|
||||
List<String> ipV4, List<String> ipV6, HashMap<IpAddrType, String> ipSegment) {
|
||||
|
||||
ErrorCode err;
|
||||
|
||||
// 防护对象存在
|
||||
DpProtectObject dp = dpBypassManager.getProtectObject().get(protectName);
|
||||
|
||||
// 判断关联模板是否正确
|
||||
if (dpBypassManager.getProtectStrategy().containsKey(protectName)) {
|
||||
// 已经关联防护模板
|
||||
String temp = dpBypassManager.getProtectStrategy()
|
||||
.get(protectName)
|
||||
.getProtectStrategyName();
|
||||
// 如果关联模板有变更
|
||||
if (!temp.equals(template)) {
|
||||
// 重新关联防护模板
|
||||
associationProtectionTemplate(protectName, template, temp);
|
||||
}
|
||||
} else {
|
||||
// 关联一个新的防护模板
|
||||
associationProtectionTemplate(protectName, template, null);
|
||||
}
|
||||
|
||||
|
||||
boolean upgradeIpSegment = false;
|
||||
|
||||
// 判断防护IP段是否有变化
|
||||
if (IpAddrType.IPV4.equals(entry.getKey())) {
|
||||
if (ipV4.size() != dp.getIpSegment().values().size()) {
|
||||
upgradeIpSegment = true;
|
||||
} else {
|
||||
List<String> ipList =
|
||||
ipV4.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList());
|
||||
|
||||
if (!ipList.containsAll(dp.getIpSegment().values())
|
||||
|| !dp.getIpSegment().values().containsAll(ipList)) {
|
||||
upgradeIpSegment = true;
|
||||
}
|
||||
}
|
||||
} else if (IpAddrType.IPV6.equals(entry.getKey())) {
|
||||
if (ipV6.size() != dp.getIpSegment().values().size()) {
|
||||
upgradeIpSegment = true;
|
||||
} else {
|
||||
List<String> ipList =
|
||||
ipV6.stream().map(k -> k.replaceAll("\\d+_", "")).collect(Collectors.toList());
|
||||
|
||||
if (!ipList.containsAll(dp.getIpSegment().values())
|
||||
|| !dp.getIpSegment().values().containsAll(ipList)) {
|
||||
upgradeIpSegment = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新防护对象
|
||||
if (upgradeIpSegment) {
|
||||
err = upgradeProtectObject(protectName,
|
||||
ipSegment.get(entry.getKey()),
|
||||
IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1,
|
||||
template);
|
||||
if (err == ErrorCode.ERR_OK) {
|
||||
log.debug("upgrade Protection Object {} Succeed", protectName);
|
||||
} else {
|
||||
log.error("!!!!upgrade Protection Object {} Error: {}", protectName, err.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UMC 同步到处置平台
|
||||
*/
|
||||
private void umcSynDisPlatform() {
|
||||
// UMC 同步到处置平台
|
||||
ArrayList<String> protectNames = new ArrayList<>();
|
||||
|
||||
|
@ -594,10 +619,10 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
log.error("!!!!Remove Protect Object Error: {}", protectName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets protect object name.
|
||||
*
|
||||
|
@ -648,7 +673,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
int dpTechMaxNameLen = 16;
|
||||
|
||||
if(tsName.length() >= dpTechMaxNameLen) {
|
||||
if (tsName.length() >= dpTechMaxNameLen) {
|
||||
try {
|
||||
tsName = objectPrefix + "_" + CryptoHelper.md5Encryption(disposeIp).substring(0, 14);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
|
@ -771,7 +796,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
log.debug("----Finish DPTech Get All Protection Strategy Association Relation");
|
||||
} catch (Exception ex) {
|
||||
log.error("----Exception DPTech Get All Protection Strategy Association Relation: {}",
|
||||
ex.getMessage());
|
||||
ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,8 +842,8 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
// 删除非法的防护对象
|
||||
if (!objName.startsWith(objectPrefix)) {
|
||||
log.error("!!!!Found Unexpect Protection Object [{}, {}], Deleted it.",
|
||||
objName,
|
||||
k.getIpSegment().getValue());
|
||||
objName,
|
||||
k.getIpSegment().getValue());
|
||||
|
||||
NtcRequestResultInfo rsp = getCleanTypePort().deleteProtectionObjectForUMC(objName);
|
||||
|
||||
|
@ -866,7 +891,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
log.warn("!!!!Remove Exception Protection IpSegment {}, {} Succeed", objName, v);
|
||||
} else {
|
||||
log.warn("!!!!Remove Exception Protection IpSegment {}, {} Error: {}", objName, v,
|
||||
rsp.getResultInfo().getValue());
|
||||
rsp.getResultInfo().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -941,7 +966,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
log.error("----Error DPTech Start Cleanup Task, Create Traction Strategy Error: {}, {}, {}",
|
||||
protectObjName, disposeObject, err);
|
||||
protectObjName, disposeObject, err);
|
||||
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
|
||||
}
|
||||
|
||||
|
@ -950,7 +975,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
log.error("----Error DPTech Start Cleanup Task, Start Traction Strategy Error: {}, {}, {}",
|
||||
protectObjName, disposeObject, err);
|
||||
protectObjName, disposeObject, err);
|
||||
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
|
||||
}
|
||||
|
||||
|
@ -999,7 +1024,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
log.error("----Error DPTech Stop Cleanup Task, Stop Traction Strategy Error: {}, {}", disposeObject,
|
||||
err);
|
||||
err);
|
||||
return new MulReturnType<>(err, null);
|
||||
}
|
||||
|
||||
|
@ -1009,7 +1034,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl {
|
|||
|
||||
if (err != ErrorCode.ERR_OK) {
|
||||
log.error("----Error DPTech Stop Cleanup Task, Clean Traction Strategy Error: {}, {}",
|
||||
disposeObject, err);
|
||||
disposeObject, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue