本文整理汇总了Python中karesansui.lib.checker.Checker.errors方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.errors方法的具体用法?Python Checker.errors怎么用?Python Checker.errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.checker.Checker
的用法示例。
在下文中一共展示了Checker.errors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validates_mail
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_mail(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'hostname'):
check = False
checker.add_error(_('"%s" is required.') % _('Server Name'))
else:
check_server = checker.check_domainname(_('Server Name'),
obj.input.hostname,
CHECK_VALID,
) or \
checker.check_ipaddr(_('Server Name'),
obj.input.hostname,
CHECK_VALID,
)
check = check_server and check
if not is_param(obj.input, 'port'):
check = False
checker.add_error(_('"%s" is required.') % _('Port Number'))
else:
check = checker.check_number(_('Port Number'),
obj.input.port,
CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
) and check
obj.view.alert = checker.errors
return check
示例2: validates_policy
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_policy(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, "input_policy"):
check = False
checker.add_error(_('"%s" is required.') % _("INPUT Chain"))
else:
check = (
checker.check_firewall_policy(_("INPUT Chain"), obj.input.input_policy, CHECK_EMPTY | CHECK_VALID) and check
)
if not is_param(obj.input, "output_policy"):
check = False
checker.add_error(_('"%s" is required.') % _("OUTPUT Chain"))
else:
check = (
checker.check_firewall_policy(_("OUTPUT Chain"), obj.input.output_policy, CHECK_EMPTY | CHECK_VALID)
and check
)
if not is_param(obj.input, "forward_policy"):
check = False
checker.add_error(_('"%s" is required.') % _("FORWARD Chain"))
else:
check = (
checker.check_firewall_policy(_("FORWARD Chain"), obj.input.input_policy, CHECK_EMPTY | CHECK_VALID)
and check
)
obj.view.alert = checker.errors
return check
示例3: validates_log
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_log(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, "s"):
check = (
checker.check_datetime_string(_("Start Date"), obj.input.s, CHECK_EMPTY | CHECK_VALID, obj.me.languages)
and check
)
if is_param(obj.input, "e"):
check = (
checker.check_datetime_string(_("End Date"), obj.input.e, CHECK_EMPTY | CHECK_VALID, obj.me.languages)
and check
)
if is_param(obj.input, "st"):
check = checker.check_time_string(_("Start Time"), obj.input.st, CHECK_EMPTY | CHECK_VALID) and check
if is_param(obj.input, "et"):
check = checker.check_time_string(_("End Time"), obj.input.et, CHECK_EMPTY | CHECK_VALID) and check
obj.view.alert = checker.errors
return check
示例4: validates_staticroute
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_staticroute(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'target'):
check = False
checker.add_error(_('Specify target address for the route.'))
else:
check = checker.check_ipaddr(
_('Target'),
obj.input.target,
CHECK_EMPTY | CHECK_VALID,
) and check
if not is_param(obj.input, 'gateway'):
check = False
checker.add_error(_('Specify gateway address for the route.'))
else:
check = checker.check_ipaddr(
_('Gateway'),
obj.input.gateway,
CHECK_VALID,
) and check
obj.view.alert = checker.errors
return check
示例5: validates_uriguest_status
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_uriguest_status(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, "status"):
check = (
checker.check_status(
_("Status"),
obj.input.status,
CHECK_EMPTY | CHECK_VALID,
[
GUEST_ACTION_CREATE,
GUEST_ACTION_SHUTDOWN,
GUEST_ACTION_DESTROY,
GUEST_ACTION_SUSPEND,
GUEST_ACTION_RESUME,
GUEST_ACTION_REBOOT,
GUEST_ACTION_ENABLE_AUTOSTART,
GUEST_ACTION_DISABLE_AUTOSTART,
],
)
and check
)
else:
check = False
checker.add_error(_('"%s" is required.') % _("Status"))
obj.view.alert = checker.errors
return check
示例6: validates_user
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_user(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'nickname'):
check = False
checker.add_error(_('"%s" is required.') % _('Nickname'))
else:
check = checker.check_username(
_('Nickname'),
obj.input.nickname,
CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
min = USER_MIN_LENGTH,
max = USER_MAX_LENGTH,
) and check
if not is_param(obj.input, 'email'):
check = False
checker.add_error(_('"%s" is required.') % _('Mail Address'))
else:
check = checker.check_mailaddress(
_('Mail Address'),
obj.input.email,
CHECK_EMPTY | CHECK_LENGTH | CHECK_VALID,
min = EMAIL_MIN_LENGTH,
max = EMAIL_MAX_LENGTH,
) and check
_password_flag = True
if not is_param(obj.input, 'new_password'):
_password_flag = False
checker.add_error(_('"%s" is required.') % _('New Password'))
if not is_param(obj.input, 'retype'):
check = False
_password_flag = False
checker.add_error(_('"%s" is required.') % _('Retype'))
if _password_flag == True:
check = checker.check_password(
_('Password'),
obj.input.new_password,
obj.input.retype,
CHECK_VALID | CHECK_LENGTH | CHECK_EMPTY,
min = PASSWORD_MIN_LENGTH,
max = PASSWORD_MAX_LENGTH,
) and check
check = checker.check_languages(
_('Language'),
obj.input.languages,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH,
min = LANGUAGES_MIN_LENGTH,
max = LANGUAGES_MAX_LENGTH,
) and check
obj.view.alert = checker.errors
return check
示例7: validates_snapshot
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_snapshot(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'title'):
check = checker.check_string(
_('Title'),
obj.input.title,
CHECK_LENGTH | CHECK_ONLYSPACE,
None,
min = NOTE_TITLE_MIN_LENGTH,
max = NOTE_TITLE_MAX_LENGTH,
) and check
if is_param(obj.input, 'value'):
check = checker.check_string(
_('Note'),
obj.input.value,
CHECK_ONLYSPACE,
None,
None,
None,
) and check
obj.view.alert = checker.errors
return check
示例8: validates_iptables_save
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_iptables_save(obj, host):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'iptables_save'):
check = False
checker.add_error(_('"%s" is required.') % _('Rule'))
else:
check = checker.check_string(
_('Rule'),
obj.input.iptables_save,
CHECK_EMPTY | CHECK_VALID,
'[^-a-zA-Z0-9_\,\.\@\$\%\!\#\*\[\]\:\/\r\n\+ ]+',
None,
None,
) and check
if check is True:
ret = iptables_lint_contents(obj.input.iptables_save, obj, host)
if str(ret) != "":
check = False
checker.add_error(ret)
"""
m = re.match(".* line (?P<line>[0-9]+).*",str(ret))
if m:
checker.add_error("LINE:"+m.group("line"))
"""
obj.view.alert = checker.errors
return check
示例9: validates_cpu
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_cpu(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'max_vcpus'):
check = checker.check_number(
_('Maximum Allocatable Virtual CPUs'),
obj.input.max_vcpus,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
min = VCPUS_MIN_SIZE,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') % _('Maximum Allocatable Virtual CPUs'))
if is_param(obj.input, 'vcpus'):
check = checker.check_number(
_("Number of Virtual CPUs to Allocate"),
obj.input.vcpus,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
min = VCPUS_MIN_SIZE,
) and check;
obj.view.alert = checker.errors
return check
示例10: validates_log
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_log(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 's'):
check = checker.check_datetime_string(_('Start Date'),
obj.input.s,
CHECK_EMPTY | CHECK_VALID,
obj.me.languages,
) and check
if is_param(obj.input, 'e'):
check = checker.check_datetime_string(_('End Date'),
obj.input.e,
CHECK_EMPTY | CHECK_VALID,
obj.me.languages,
) and check
if is_param(obj.input, 'st'):
check = checker.check_time_string(_('Start Time'),
obj.input.st,
CHECK_EMPTY | CHECK_VALID,
) and check
if is_param(obj.input, 'et'):
check = checker.check_time_string(_('End Time'),
obj.input.et,
CHECK_EMPTY | CHECK_VALID,
) and check
obj.view.alert = checker.errors
return check
示例11: validates_nic
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_nic(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
# nic_type - [phydev, virnet]
if is_param(obj.input, 'nic_type'):
if (obj.input.nic_type in ['phydev', 'virnet']) is False:
check = False
checker.add_error(_(""))
else:
check = False
checker.add_error(_('"%s" is required.') % _('Interface Type'))
# mac_address
if is_param(obj.input, 'mac_address'):
check = checker.check_macaddr(
_('MAC Address'),
obj.input.mac_address,
CHECK_EMPTY | CHECK_VALID
) and check
else:
check = False
checker.add_error(_('"%s" is required.') % _('MAC Address'))
obj.view.alert = checker.errors
return check
示例12: validates_disk
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_disk(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
""" TODO
# sparse
# disk
if is_param(obj.input, 'disk_size'):
check = checker.check_number(_('Disk Size (MB)'),
obj.input.disk_size,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
min = DISK_MIN_SIZE,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') % _('Disk Size (MB)'))
"""
obj.view.alert = checker.errors
return check
示例13: validates_src_id
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_src_id(obj):
"""<comment-ja>
ゲストOSコピー元のチェッカー
@param obj: karesansui.lib.rest.Rest オブジェクト
@type obj: karesansui.lib.rest.Rest
@return: check
@rtype: bool
</comment-ja>
<comment-en>
TODO: English Comment
</comment-en>
"""
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'src_id'):
check = False
checker.add_error(_('"%s" is required.') % _('Copy Source'))
else:
check = checker.check_number(_('Copy Source'),
obj.input.src_id,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
ID_MIN_LENGTH,
ID_MAX_LENGTH
) and check
obj.view.alert = checker.errors
return check
示例14: validates_report
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_report(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'report_start_day'):
check = checker.check_datetime_string(_('Start Date'),
obj.input.report_start_day,
CHECK_EMPTY | CHECK_VALID,
obj.me.languages,
) and check
if is_param(obj.input, 'report_end_day'):
check = checker.check_datetime_string(_('End Date'),
obj.input.report_end_day,
CHECK_EMPTY | CHECK_VALID,
obj.me.languages,
) and check
if is_param(obj.input, 'report_start_time'):
check = checker.check_time_string(_('Start Time'),
obj.input.report_start_time,
CHECK_EMPTY | CHECK_VALID,
) and check
if is_param(obj.input, 'report_end_time'):
check = checker.check_time_string(_('End Time'),
obj.input.report_end_time,
CHECK_EMPTY | CHECK_VALID,
) and check
obj.view.alert = checker.errors
return check
示例15: validates_network_storage
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import errors [as 别名]
def validates_network_storage(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'network_storage_host_name'):
check = checker.check_domainname(_('Target Hostname'),
obj.input.network_storage_host_name,
CHECK_EMPTY | CHECK_VALID,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Target Hostname'))
if is_param(obj.input, 'network_storage_port_number'):
check = checker.check_number(_('Target Port Number'),
obj.input.network_storage_port_number,
CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
) and check
if is_param(obj.input, 'network_storage_authentication'):
check = checker.check_empty(_('iSCSI Authentication Type'),
obj.input.network_storage_authentication,
) and check
if obj.input.network_storage_authentication == ISCSI_CONFIG_VALUE_AUTH_METHOD_CHAP:
if is_param(obj.input, 'network_storage_user'):
check = checker.check_username_with_num(_('iSCSI Authentication User'),
obj.input.network_storage_user,
CHECK_VALID | CHECK_LENGTH,
CHAP_USER_MIN_LENGTH,
CHAP_USER_MAX_LENGTH,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('iSCSI Authentication User'))
if is_param(obj.input, 'network_storage_password'):
check = checker.check_password(_('iSCSI Authentication Password'),
obj.input.network_storage_password,
obj.input.network_storage_password,
CHECK_LENGTH,
CHAP_PASSWORD_MIN_LENGTH,
CHAP_PASSWORD_MAX_LENGTH,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('iSCSI Authentication Password'))
else:
check = False
checker.add_error(_('"%s" is required.') %_('iSCSI Authentication Type'))
obj.view.alert = checker.errors
return check