OCT
REM: 1.更新华为设备能力接口 2.增加华为设备查询所有zone接口 3.增加华为设备启动、停止处置任务接口 4.增加错误码
This commit is contained in:
parent
6781d98a6d
commit
2e47fc9ff8
|
@ -92,7 +92,46 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
|
|||
@Nullable NetflowDirection nfDirection,
|
||||
@Nullable Integer attackType,
|
||||
@Nullable Long duration) {
|
||||
return null;
|
||||
String url = urlRootPath + "/divert";
|
||||
String disposeObj = disposeObject + "/32";
|
||||
|
||||
if (token == null || token.length() == 0) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, "");
|
||||
}
|
||||
|
||||
try {
|
||||
log.info("++++Begging HuaWei Start Cleanup Task: {}", disposeObject);
|
||||
|
||||
if (capType != DisposeCapacityType.CLEANUP) {
|
||||
log.error("----Error HuaWei don't support dispose capacity type: {}", capType);
|
||||
return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
|
||||
}
|
||||
|
||||
ErrorCode resp = restfulInterface.createDivert(url, token, new String[]{disposeObj});
|
||||
|
||||
// 判断是否token过期
|
||||
if (resp == ErrorCode.ERR_TOKENNOTFOUND) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
resp = restfulInterface.createDivert(url, token, new String[]{disposeObject});
|
||||
}
|
||||
|
||||
if (resp == null) {
|
||||
log.error("----Error HuaWei start clean {} server return error", disposeObject);
|
||||
return new MulReturnType<>(ErrorCode.ERR_HUAWEI_ERROR, null);
|
||||
}
|
||||
|
||||
if (resp != ErrorCode.ERR_OK) {
|
||||
log.error("----Error HuaWei start clean {} return error: {}, {}", disposeObject, resp.getCode(), resp.getMsg());
|
||||
return new MulReturnType<>(ErrorCode.ERR_HUAWEI_ERROR, null);
|
||||
}
|
||||
|
||||
log.debug("----Finish HuaWei Start Cleanup Task: {}", disposeObject);
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
} catch (Exception ex) {
|
||||
log.error("----Exception HuaWei Start Cleanup Task: {}, {}, {}", disposeObject, nfDirection, duration);
|
||||
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +150,51 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
|
|||
@Nullable NetflowDirection nfDirection,
|
||||
@Nullable Integer attackType,
|
||||
@Nullable String taskId) {
|
||||
return null;
|
||||
|
||||
String disposeObj = disposeObject + "-32";
|
||||
String url = urlRootPath + "/divert/" + disposeObj;
|
||||
|
||||
if (token == null || token.length() == 0) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_LOGOUT, null);
|
||||
}
|
||||
|
||||
try {
|
||||
log.debug("++++Begging HuaWei Stop Cleanup Task: {}", taskId);
|
||||
|
||||
if (capType != DisposeCapacityType.CLEANUP) {
|
||||
log.error("----Error HuaWei don't support dispose capacity type: {}", capType);
|
||||
return new MulReturnType<>(ErrorCode.ERR_UNSUPPORT, null);
|
||||
}
|
||||
|
||||
if (taskId == null) {
|
||||
return new MulReturnType<>(ErrorCode.ERR_PARAMS, null);
|
||||
}
|
||||
|
||||
ErrorCode rspInfo = restfulInterface.deleteZones(url, token);
|
||||
|
||||
// 判断是否token过期
|
||||
if (rspInfo == ErrorCode.ERR_TOKENNOTFOUND) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
rspInfo = restfulInterface.deleteZones(url, token);
|
||||
}
|
||||
|
||||
if (rspInfo == null) {
|
||||
log.error("----Error HuaWei stop task{} server return error", taskId);
|
||||
return new MulReturnType<>(ErrorCode.ERR_HUAWEI_ERROR, null);
|
||||
}
|
||||
|
||||
if (rspInfo != ErrorCode.ERR_OK) {
|
||||
log.error("----Error HuaWei stop task{} server return error", taskId);
|
||||
return new MulReturnType<>(ErrorCode.ERR_CALLDEVICE, null);
|
||||
}
|
||||
|
||||
log.debug("----Finish HuaWei Stop Cleanup Task: {}", taskId);
|
||||
return new MulReturnType<>(ErrorCode.ERR_OK, null);
|
||||
} catch (Exception ex) {
|
||||
log.error("----Exception HuaWei Stop Cleanup Task: {}, {}, {}", disposeObject, nfDirection, taskId);
|
||||
return new MulReturnType<>(ErrorCode.ERR_SYSTEMEXCEPTION, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,9 +250,23 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
|
|||
public boolean getDeviceLinkStatus() {
|
||||
try {
|
||||
//查询所有的zone接口调用成功认为设备心跳正常
|
||||
//return (restfulInterface.queryAllZones(this.urlRootPath, token) != null);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
String url = urlRootPath + "/allzone";
|
||||
|
||||
if (token == null || token.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HttpResponse response = restfulInterface.queryAllZones(url, token);
|
||||
|
||||
if (response.getStatus() == ErrorCode.ERR_TOKENNOTFOUND.getCode()) {
|
||||
// 重新登录获取 token
|
||||
upgradeToken();
|
||||
response = restfulInterface.queryAllZones(url, token);
|
||||
}
|
||||
|
||||
return response.getStatus() == ErrorCode.ERR_OK.getCode();
|
||||
} catch (
|
||||
Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
|
||||
|
@ -212,3 +309,4 @@ public class HuaWeiAbilityImpl implements DisposeAbility {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,6 +232,10 @@ public enum ErrorCode {
|
|||
* The Err server processing request.
|
||||
*/
|
||||
ERR_SERVER_PROCESSREQ(115, "服务器处理请求错误"),
|
||||
/**
|
||||
* The Err huawei error.
|
||||
*/
|
||||
ERR_HUAWEI_ERROR(34, "华为设备返回错误"),
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
|
@ -68,26 +68,26 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||
// 设置启动任务攻击类型状态
|
||||
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
|
||||
deviceTask.getTaskAttackType());
|
||||
deviceTask.getTaskAttackType());
|
||||
|
||||
// 调用设备执行处置任务
|
||||
ret = ai.getDb()
|
||||
.runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
|
||||
disposeTask.getDisposeCapacity(),
|
||||
null, null, null);
|
||||
disposeTask.getDisposeCapacity(),
|
||||
null, null, null);
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 设置攻击类型任务启动结果
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
// 更改处置任务状态为处置中
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(),
|
||||
DisposeTaskStatus.TASK_STARTED);
|
||||
DisposeTaskStatus.TASK_STARTED);
|
||||
log.info("VIRTUAL_DISPOSE setup task succeed: {}", deviceTask);
|
||||
} else {
|
||||
// 任务出错,不在重试,当做失败任务处理
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
log.error("VIRTUAL_DISPOSE setup task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
@ -137,17 +137,17 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||
// 设置启动任务攻击类型状态
|
||||
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
|
||||
deviceTask.getTaskAttackType());
|
||||
deviceTask.getTaskAttackType());
|
||||
|
||||
ret = ai.getDb()
|
||||
.runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
|
||||
disposeTask.getDisposeCapacity(), null,
|
||||
null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60));
|
||||
disposeTask.getDisposeCapacity(), null,
|
||||
null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60));
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 设置攻击类型任务启动结果
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
// 更改处置任务状态为处置中
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED);
|
||||
|
||||
|
@ -164,11 +164,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
// 记录任务出错重试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||
log.error("HAOHAN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||
ret.getSecondParam(), deviceTask);
|
||||
ret.getSecondParam(), deviceTask);
|
||||
} else {
|
||||
// 任务出错,不在重试,当做失败任务处理
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
log.error("HAOHAN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
|
||||
// 停止处置任务
|
||||
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
|
||||
deviceTask.getExternId());
|
||||
deviceTask.getExternId());
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
log.info("HAOHAN_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam());
|
||||
|
@ -197,7 +197,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
// 记录任务出错重试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||
log.error("HAOHAN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||
ret.getSecondParam(), deviceTask);
|
||||
ret.getSecondParam(), deviceTask);
|
||||
} else {
|
||||
log.error("HAOHAN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
|
@ -226,16 +226,16 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
}
|
||||
// 设置启动任务攻击类型状态
|
||||
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
// 调用迪普设备启动处置任务
|
||||
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
|
||||
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_OUT,
|
||||
t.getValue(), null);
|
||||
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_OUT,
|
||||
t.getValue(), null);
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 标志启动成功
|
||||
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
|
||||
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t, NetflowDirection.DIRECTION_OUT, deviceTask);
|
||||
|
||||
|
@ -247,12 +247,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
|
||||
//清除任务攻击类型启动标志
|
||||
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t,
|
||||
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
|
||||
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
|
||||
} else {
|
||||
log.error("DPTECH_UMC setup task {}, {} error {}: {}", t,
|
||||
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
|
||||
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,16 +264,16 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
}
|
||||
// 设置启动任务攻击类型状态
|
||||
deviceTaskManager.execAttackTypeSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
// 调用迪普设备启动处置任务
|
||||
ret = ai.getDb().runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
|
||||
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_IN,
|
||||
t.getValue(), null);
|
||||
disposeTask.getDisposeCapacity(), NetflowDirection.DIRECTION_IN,
|
||||
t.getValue(), null);
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 标志启动成功
|
||||
deviceTaskManager.attackTypeStatusSetBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
|
||||
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t, NetflowDirection.DIRECTION_IN, deviceTask);
|
||||
|
||||
|
@ -285,12 +285,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
|
||||
//清除任务攻击类型启动标志
|
||||
deviceTaskManager.execAttackTypeCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
log.error("DPTECH_UMC setup task {}, {} times {} error: {}", t,
|
||||
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
|
||||
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
|
||||
} else {
|
||||
log.error("DPTECH_UMC setup task {}, {} error {}: {}", t,
|
||||
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
|
||||
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,12 +343,12 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_IN) {
|
||||
// 调用迪普设备停止处置任务
|
||||
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(),
|
||||
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
|
||||
NetflowDirection.DIRECTION_OUT, t.getValue(), null);
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 标志停止成功
|
||||
deviceTaskManager.attackTypeStatusCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_OUT,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
|
||||
log.info("DPTECH_UMC stop task {}, {} succeed: {}", t, NetflowDirection.DIRECTION_OUT, deviceTask);
|
||||
|
||||
|
@ -358,10 +358,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
|
||||
log.error("DPTECH_UMC stop task {}, {} times {} error: {}", t,
|
||||
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
|
||||
NetflowDirection.DIRECTION_OUT, deviceTask.getErrRetry(), deviceTask);
|
||||
} else {
|
||||
log.info("DPTECH_UMC stop task {}, {} error {}: {}", t,
|
||||
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
|
||||
NetflowDirection.DIRECTION_OUT, ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,15 +369,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
if (disposeTask.getFlowDirection() != NetflowDirection.DIRECTION_OUT) {
|
||||
// 调用迪普设备启动处置任务
|
||||
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(),
|
||||
NetflowDirection.DIRECTION_IN, t.getValue(), null);
|
||||
NetflowDirection.DIRECTION_IN, t.getValue(), null);
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 标志启动成功
|
||||
deviceTaskManager.attackTypeStatusCleanBit(deviceTask.getId(), NetflowDirection.DIRECTION_IN,
|
||||
t.getValue());
|
||||
t.getValue());
|
||||
|
||||
log.info("DPTECH_UMC setup task {}, {} succeed: {}", t,
|
||||
NetflowDirection.DIRECTION_IN, deviceTask);
|
||||
NetflowDirection.DIRECTION_IN, deviceTask);
|
||||
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
||||
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES * 10) {
|
||||
|
@ -385,10 +385,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTask.setErrRetry(deviceTask.getErrRetry() + 1);
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry());
|
||||
log.error("DPTECH_UMC stop task {}, {} times {} error: {}", t,
|
||||
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
|
||||
NetflowDirection.DIRECTION_IN, deviceTask.getErrRetry(), deviceTask);
|
||||
} else {
|
||||
log.info("DPTECH_UMC stop task {}, {} error {}: {}", t,
|
||||
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
|
||||
NetflowDirection.DIRECTION_IN, ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -442,17 +442,17 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||
// 设置启动任务攻击类型状态
|
||||
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
|
||||
deviceTask.getTaskAttackType());
|
||||
deviceTask.getTaskAttackType());
|
||||
|
||||
ret = ai.getDb()
|
||||
.runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
|
||||
disposeTask.getDisposeCapacity(), null,
|
||||
null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60));
|
||||
disposeTask.getDisposeCapacity(), null,
|
||||
null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60));
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 设置攻击类型任务启动结果
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
// 更改处置任务状态为处置中
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED);
|
||||
|
||||
|
@ -469,11 +469,11 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
// 记录任务出错重试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||
log.error("PENGXIN_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||
ret.getSecondParam(), deviceTask);
|
||||
ret.getSecondParam(), deviceTask);
|
||||
} else {
|
||||
// 任务出错,不在重试,当做失败任务处理
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
log.error("PENGXIN_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
|
||||
// 停止处置任务
|
||||
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
|
||||
deviceTask.getExternId());
|
||||
deviceTask.getExternId());
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
log.info("PENGXIN_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam());
|
||||
|
@ -502,12 +502,94 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
// 记录任务出错重试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||
log.error("PENGXIN_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||
ret.getSecondParam(), deviceTask);
|
||||
ret.getSecondParam(), deviceTask);
|
||||
} else {
|
||||
log.error("PENGXIN_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Huawei ATIC device task run.
|
||||
*
|
||||
* @param ai the ai
|
||||
* @param deviceTask the device task
|
||||
* @param disposeTask the dispose task
|
||||
*/
|
||||
private void huaWeiDeviceTaskRun(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
|
||||
MulReturnType<ErrorCode, String> ret;
|
||||
|
||||
// 重试错误次数过多
|
||||
if (deviceTask.getErrRetry() >= DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置任务状态为启动中
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTING);
|
||||
// 设置启动任务攻击类型状态
|
||||
deviceTaskManager.setExecAttackType(deviceTask.getId(), NetflowDirection.DIRECTION_BI,
|
||||
deviceTask.getTaskAttackType());
|
||||
|
||||
ret = ai.getDb()
|
||||
.runDispose(disposeTask.getDisposeObject(), disposeTask.getObjectType(),
|
||||
disposeTask.getDisposeCapacity(), null,
|
||||
null, (long) -(Helper.getTimestampDiffNow(disposeTask.getPlanEndTime()) / 60));
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
// 设置攻击类型任务启动结果
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), deviceTask.getTaskAttackType());
|
||||
// 更改处置任务状态为处置中
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_STARTED);
|
||||
|
||||
log.info("HUAWEI_PLATFORM setup task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam());
|
||||
|
||||
// 重置错误尝试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
||||
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||
// 设置该任务为新任务,待下次重试启动
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_NEW);
|
||||
// 记录任务出错重试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||
log.error("HUAWEI_PLATFORM setup task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||
ret.getSecondParam(), deviceTask);
|
||||
} else {
|
||||
// 任务出错,不在重试,当做失败任务处理
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(),
|
||||
disposeTask.getFlowDirection(), 0L);
|
||||
log.error("HUAWEI_PLATFORM setup task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Huawei ATIC device task stop.
|
||||
*
|
||||
* @param ai the ai
|
||||
* @param deviceTask the device task
|
||||
* @param disposeTask the dispose task
|
||||
*/
|
||||
private void huaWeiDeviceTaskStop(AbilityInfo ai, DeviceTask deviceTask, DisposeTask disposeTask) {
|
||||
MulReturnType<ErrorCode, Long> ret;
|
||||
|
||||
// 停止处置任务
|
||||
ret = ai.getDb().stopDispose(disposeTask.getDisposeObject(), disposeTask.getDisposeCapacity(), null, null,
|
||||
deviceTask.getExternId());
|
||||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
log.info("HUAWEI_PLATFORM stop task succeed: {}, device taskId {}", deviceTask, ret.getSecondParam());
|
||||
// 设置任务状态为结束
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoStatus(deviceTask.getId(), DisposeTaskStatus.TASK_FINISHED);
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), 0);
|
||||
deviceTaskManager.setAttackTypeStatus(deviceTask.getId(), disposeTask.getFlowDirection(), 0L);
|
||||
} else if (deviceTask.getErrRetry() < DisposeConfigValue.CALL_ERROR_RETRY_TIMES) {
|
||||
// 记录任务出错重试次数
|
||||
deviceTaskManager.setTaskErrRetryTimes(deviceTask.getId(), deviceTask.getErrRetry() + 1);
|
||||
log.error("HUAWEI_PLATFORM stop task times {} error {}: {}", deviceTask.getErrRetry(),
|
||||
ret.getSecondParam(), deviceTask);
|
||||
} else {
|
||||
log.error("HUAWEI_PLATFORM stop task error {}: {}", ret.getFirstParam(), deviceTask);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose task manager schedule.
|
||||
*/
|
||||
|
@ -517,7 +599,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
// 清理过期任务
|
||||
for (DisposeTask v : disposeTaskManager.getExpiredTasks()) {
|
||||
log.info("Task {} {} {} is expired, expect finished at {}",
|
||||
v.getId(), v.getDisposeCapacity(), v.getDisposeObject(), v.getPlanEndTime());
|
||||
v.getId(), v.getDisposeCapacity(), v.getDisposeObject(), v.getPlanEndTime());
|
||||
// 设置任务状态,过期任务不再为设备创建处置任务
|
||||
disposeTaskManager.changeDisposeTaskStatus(v.getId(), DisposeTaskStatus.TASK_EXPIRED);
|
||||
}
|
||||
|
@ -542,8 +624,8 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
log.info("Add dispose task for device: {}", d.getDev());
|
||||
|
||||
if (!deviceTaskManager.addDisposeDeviceTaskInfo(v.getId(), d.getDev().getId(),
|
||||
d.getDb()
|
||||
.toDeviceAttackType(v.getAttackType()))) {
|
||||
d.getDb()
|
||||
.toDeviceAttackType(v.getAttackType()))) {
|
||||
log.error("Add task {} to device {} error", v, d);
|
||||
}
|
||||
});
|
||||
|
@ -601,6 +683,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
pengXinDeviceTaskRun(ai, v, task);
|
||||
break;
|
||||
|
||||
case HUAWEI_PLATFORM:
|
||||
huaWeiDeviceTaskRun(ai, v, task);
|
||||
break;
|
||||
|
||||
default:
|
||||
log.error("Unknown dispose device type: {}", ai.getDev());
|
||||
break;
|
||||
|
@ -672,6 +758,10 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
pengXinDeviceTaskStop(ai, v, task);
|
||||
break;
|
||||
|
||||
case HUAWEI_PLATFORM:
|
||||
huaWeiDeviceTaskStop(ai, v, task);
|
||||
break;
|
||||
|
||||
default:
|
||||
log.error("Unknown dispose device type: {}", ai.getDev());
|
||||
break;
|
||||
|
@ -722,7 +812,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
|||
|
||||
if (ret.getFirstParam() == ErrorCode.ERR_OK) {
|
||||
deviceTaskManager.changeDisposeDeviceTaskInfoDevStatus(v.getExternId(),
|
||||
ret.getSecondParam());
|
||||
ret.getSecondParam());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.dispose.ability.impl.DpTechAbilityImpl;
|
|||
import com.dispose.ability.impl.HaoHanAbilityImpl;
|
||||
import com.dispose.ability.impl.PengXinAbilityImpl;
|
||||
import com.dispose.ability.impl.VirtualAbilityImpl;
|
||||
import com.dispose.ability.impl.HuaWeiAbilityImpl;
|
||||
import com.dispose.common.DisposeCapacityType;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.common.HttpType;
|
||||
|
@ -115,6 +116,9 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ
|
|||
case PENGXIN_PLATFORM:
|
||||
db = new PengXinAbilityImpl();
|
||||
break;
|
||||
case HUAWEI_PLATFORM:
|
||||
db = new HuaWeiAbilityImpl();
|
||||
break;
|
||||
case VIRTUAL_DISPOSE:
|
||||
db = new VirtualAbilityImpl();
|
||||
break;
|
||||
|
|
|
@ -36,12 +36,12 @@ public class HuaWeiInterface {
|
|||
*
|
||||
* @param baseUrlPath the base url path
|
||||
* @param token the token
|
||||
* @param zone_ip zone ip
|
||||
* @param zone_ip zone ip
|
||||
* @return the delete zone status
|
||||
*/
|
||||
public ErrorCode createDivert(String baseUrlPath, String token, String[] zone_ip){
|
||||
public ErrorCode createDivert(String baseUrlPath, String token, String[] zone_ip) {
|
||||
//获取HTTP部分
|
||||
HttpResponse response = RestfulInterface.huaWeiProRun(baseUrlPath + "/divert",
|
||||
HttpResponse response = RestfulInterface.huaWeiProRun(baseUrlPath,
|
||||
token,
|
||||
new HuaWeiCreatDivertReq(zone_ip),
|
||||
RequestMethod.POST);
|
||||
|
@ -49,13 +49,13 @@ public class HuaWeiInterface {
|
|||
if (response != null) {
|
||||
if (response.getStatus() == HttpServletResponse.SC_CREATED) {
|
||||
return ErrorCode.ERR_OK;
|
||||
}else if(response.getStatus() == HttpServletResponse.SC_BAD_REQUEST) {
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_BAD_REQUEST) {
|
||||
return ErrorCode.ERR_PARAMS;
|
||||
}else if(response.getStatus() == HttpServletResponse.SC_CONFLICT){
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_CONFLICT) {
|
||||
return ErrorCode.ERR_SPECIFIEDIP_EXISTS;
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_PRECONDITION_FAILED) {
|
||||
return ErrorCode.ERR_TOKENNOTFOUND;
|
||||
}else if(response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR){
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
|
||||
return ErrorCode.ERR_SERVER_PROCESSREQ;
|
||||
}
|
||||
}
|
||||
|
@ -69,12 +69,11 @@ public class HuaWeiInterface {
|
|||
*
|
||||
* @param baseUrlPath the base url path
|
||||
* @param token the token
|
||||
* @param zone_ip zone ip
|
||||
* @return the delete zone status
|
||||
*/
|
||||
public ErrorCode deleteZones(String baseUrlPath, String token, String zone_ip) {
|
||||
public ErrorCode deleteZones(String baseUrlPath, String token) {
|
||||
//获取HTTP部分
|
||||
HttpResponse response = RestfulInterface.huaWeiProRun(baseUrlPath + "/divert/" + zone_ip,
|
||||
HttpResponse response = RestfulInterface.huaWeiProRun(baseUrlPath,
|
||||
token,
|
||||
null,
|
||||
RequestMethod.DELETE);
|
||||
|
@ -82,17 +81,31 @@ public class HuaWeiInterface {
|
|||
if (response != null) {
|
||||
if (response.getStatus() == HttpServletResponse.SC_OK) {
|
||||
return ErrorCode.ERR_OK;
|
||||
}else if(response.getStatus() == HttpServletResponse.SC_BAD_REQUEST){
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_BAD_REQUEST) {
|
||||
return ErrorCode.ERR_PARAMS;
|
||||
}else if(response.getStatus() == HttpServletResponse.SC_NOT_FOUND){
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
|
||||
return ErrorCode.ERR_SPECIFIEDIP_NOTEXISTS;
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_PRECONDITION_FAILED) {
|
||||
return ErrorCode.ERR_TOKENNOTFOUND;
|
||||
}else if(response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR){
|
||||
} else if (response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
|
||||
return ErrorCode.ERR_SERVER_PROCESSREQ;
|
||||
}
|
||||
}
|
||||
|
||||
return ErrorCode.ERR_UNKNOWNCMD;
|
||||
}
|
||||
|
||||
/**
|
||||
* query all zones protocol resp dto.
|
||||
*
|
||||
* @param baseUrlPath the base url path
|
||||
* @param token the token
|
||||
* @return the http resp
|
||||
*/
|
||||
public HttpResponse queryAllZones(String baseUrlPath, String token) {
|
||||
return RestfulInterface.huaWeiProRun(baseUrlPath,
|
||||
token,
|
||||
null,
|
||||
RequestMethod.GET);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue