Beispiel #1
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _


TrafficError = Error(
    REQUIRED_FIELD=_('x_required_field'),
    NAME_HAVE_EXISTED=_('x_name_existed'),
    OUT_OF_RANGE=_('x_out_of_range'),
    INVALID_CHARACTER=_('x_invalid_character'),
    FIELD_INVALID=_('x_field_invalid'),
    PLEASE_UPLOAD_PCAP=_('x_please_upload_pcap'),
    CATEGORY_BE_USED=_('x_category_be_used')
)
Beispiel #2
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _

error = Error(
    MISS_PARAMETER=_("x_missing_parameter"),
    NOT_FOUND=_('x_not_find_mission'),
    IS_RUNNING=_('x_is_running'),
    CONNECTION_REFUSED=_('x_connection_refused'),
    UNKNOW_ERROR=_('x_unknown_error'),
    REQUIRED_FIELD=_('x_required_field'),
    NAME_HAVE_EXISTED=_('x_name_have_existed'),
    NOT_EXISTED=_('x_not_existed'),
    OUT_OF_RANGE=_('x_out_of_range'),
    SCENE_NOT_FOUND=_("找不到场景"),
    MISSION_STATUS_ERROR=_('任务状态错误'),
)
Beispiel #3
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _

error = Error(REQUIRED_FIELD=_('x_required_field'),
              TRAFFIC_EVENT_NOT_FOUND=_('x_traffic_event_not_found'),
              GET_TRAFFIC_RESULT_ERROR=_('x_get_traffic_result_error'))
Beispiel #4
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _

error = Error(
    INVALID_PARAMS=_('x_invalid_parameters'),
    FIELDS_NOT_EXIST=_('x_fields_not_exist'),
    EVENT_IN_PROGRESS=_('x_event_in_progress'),
)
Beispiel #5
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _


error = Error(
    NAME_EXISTS=_('名称已存在')
)
Beispiel #6
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _

error = Error(MISSING_PARAMETERS=_('x_missing_parameters'), )
Beispiel #7
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _

MonitorError = Error(REQUIRED_FIELD=_('x_required_field'),
                     NAME_HAVE_EXISTED=_('x_name_existed'),
                     OUT_OF_RANGE=_('x_out_of_range'),
                     LENGTH_ERROR=_("x_len_three"),
                     TITLE_HAVE_EXISTED=_("x_name_existed"),
                     TITLE_ERROR=_("x_english_num"),
                     TITLE_HAVE_SPACE=_("x_name_not_spaces"),
                     ILLEGAL_PARAMETER=_("x_illegal_parameter_value"),
                     TLLEGAL_CODE=_("x_code_not_specifications"),
                     MONITOR_CATEGORY_BE_USED=_('x_monitor_category_be_used'))
Beispiel #8
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _

error = Error(
    REQUIRED_FIELD=_('x_required_field'),
    NAME_HAVE_EXISTED=_('x_name_have_existed'),
    TRAFFIC_ERROR=_('x_traffic_error'),
    NOT_FOUND=_('x_event_not_found'),
    IS_RUNNING=_('x_is_running'),
    CONNECTION_REFUSED=_('x_connection_refused'),
    UNKNOW_ERROR=_('x_unknown_error'),
    SCENE_NOT_FOUND=_('x_scene_not_found'),
    MISSING_PARAMETERS=_('x_missing_parameters'),
    INVALID_PARAMETERS=_('x_invalid_parameter'),
)
Beispiel #9
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _

error = Error(
    MISSING_PARAMETERS=_('x_missing_parameters'),
    ONLY_EXAM=_('x_only_exam'),
    HAS_DOWN=_('x_has_down'),
    IS_NUMBER=_('x_is_number'),
    NOT_FOUND=_('x_not_found'),
    CHECK_NOT_COMMIT=_('x_check_not_commit'),
    NAME_EXISTS=_('x_name_exists'),
    NAME_EXIST=_('x_name_exist'),
    NAME_NOT_EMPTY=_('x_name_not_empty'),
    IS_RUNNING=_('x_event_is_running'),
    SCENE_ID_IS_NOT_ALLOW=_('x_scene_id_is_not_allow'),
    CR_SCENE_INSTANCE_IS_NONE=_('x_cr_scene_instance_is_none'),
    CONNECTION_REFUSED=_('x_connection_refused'),
    PARAMETER_SYNTAX_ERROR=_('x_parameter_syntax_error'),
    START_TIME_IS_GREATER_THAN_END_TIME=_(
        'x_start_time_is_greater_than_end_time'),
    FIELD_LENGTH_CANNOT_EXCEED=_('x_field_length_cannot_exceed'),  # 传参的使用不了
    XSS_ATTACK=_('x_XSS_attack'),
    SELECT_AT_LEAST_ONE_SCENE=_('x_select_at_least_one_scene'),
    LOGO_CAN_NOT_BE_EMPTY=_('x_logo_can_not_be_empty'),
    UNFINISHED_MISSION_CANNOT_MODIFY_SCORES=_(
        "x_unfinished_mission_cannot_modify_scores"),
    SUBMIT_SCORE_MUST_BE_GREATER_THAN_0=_(
Beispiel #10
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _


error = Error(
    AUTHENTICATION_FAILED=_('用户名或密码错误'),
    PERMISSION_NOT_ALLOWED=_('权限不允许')
)
Beispiel #11
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _

error = Error(GATEWAY_NOT_FOUND=_('网关不存在'), )
Beispiel #12
0
# -*- coding: utf-8 -*-
import copy
import logging
import sys
import traceback

from django.utils import six
from rest_framework.exceptions import ErrorDetail

from base.utils.enum import Enum
from base.utils.text import Txt, trans as _

logger = logging.getLogger(__name__)

common_error = Enum(
    ERROR=_('x_busy_server'),
    NO_PERMISSION=_('x_no_operation_permission'),
    INVALID_PARAMS=_('x_invalid_parameter'),
    INVALID_VALUE=_('x_invalid_parameter_value'),
    DUPLICATE_SUBMIT=_('x_duplicate_submission'),
    DUPLICATE_REQUEST=_('x_duplicate_request'),
    SAVE_FAILED=_('x_data_save_failed'),
)


class Error(object):
    error = Enum()

    def __new__(cls, **errors):
        custom_errors = copy.copy(common_error.source)
        for attr_name, error_desc in errors.items():
Beispiel #13
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _

error = Error(
    CONFLICT_WITH_BASE_IMAGE_NAME=_('和基础镜像名称冲突'),
    SNAPSHOT_BAN_UPLOAD=_('标靶已有快照, 不允许上传'),
    NAME_EXISTS=_('名称已存在'),
    STANDARD_DEVICE_NO_LOGO=_('标靶不能没有logo'),
    DEVICE_NO_SCENE=_('标靶没有机器'),
    TERMINAL_NOT_READY=_('终端未准备好'),
    IMAGE_SAVING=_('镜像保存中'),
    NO_SCENE_CONFIG=_('没有配置'),
    GATEWAY_NOT_FOUND=_('网关不存在'),
    TERMINAL_NOT_FOUND=_('终端不存在'),
)
Beispiel #14
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _

error = Error()

mission_period_error = Error(
    INVALID_SCENE_ID=_('x_invalid_scene_id'),
    SCENE_ID_REQUIRED=_('x_scene_id_required'),
    PERIODS_REQUIRED=_('x_period_required'),
    PERIOD_TYPE_ERROR=_('x_period_type_must_list'),
    PERIOD_DUPLICATE=_('x_duplicate_period'),
    PERIOD_DELETE_ERROR=_('x_delete_period_error'),
)
Beispiel #15
0
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from base.utils.error import Error
from base.utils.text import trans as _

error = Error(
    # config
    NO_CONFIG=_('无场景配置'),
    DUMPLICATE_NETWORK_ID=_('重复的网络ID: {id}'),
    DUMPLICATE_GATEWAY_ID=_('重复的网关ID: {id}'),
    INVALID_GATEWAY_NETS=_('网关[{id}]连接了无效的网络: {nets}'),
    DUMPLICATE_SERVER_ID=_('重复的终端ID: {id}'),
    CHECKER_SERVER_NOT_EXIST=_('无效的检查终端: {id}'),
    ATTACKER_SERVER_NOT_EXIST=_('无效的攻击终端: {id}'),
    INVALID_SERVER_NETS=_('终端[{id}]连接了无效的网络: {nets}'),
    SERVER_CANT_ACCESS_EXTERNAL_NET=_('终端[{id}]无法连接外网'),

    # scene
    PARSE_SERVER_SCRIPT_VAL_ERROR=_('终端[{id}]解析脚本参数\'{val}\'错误'),
    NVM_NO_CONSOLE=_('非虚拟机终端暂无控制台'),
    LOCAL_CONTAINER_NOT_SUPPORT_IMAGE=_('本地容器不支持保存镜像'),
    NO_ENOUGH_EXTERNAL_NET_PORT=_('外网没有足够的端口'),
    NO_ENOUGH_FLOAT_IP=_('没有足够的外网ip'),
    NO_ENOUGH_IP=_('没有足够的ip'),
    EXIST_STATIC_ROUTE=_('静态路由已存在'),
    ROUTER_NOT_PREPARED=_('路由未准备好'),
    STATIC_ROUTE_NOT_EXIST=_('静态路由不存在'),
    INVALID_STATIC_ROUTE=_('无效的静态路由'),
    EXIST_FIREWALL_RULE=_('防火墙规则已存在'),
Beispiel #16
0
# -*- coding: utf-8 -*-
from base.utils.error import Error
from base.utils.text import trans as _

error = Error(AUTHENTICATION_FAILED=_('用户名或密码错误'))