当前位置: 首页>>代码示例>>Python>>正文


Python Checker.check_empty方法代码示例

本文整理汇总了Python中karesansui.lib.checker.Checker.check_empty方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.check_empty方法的具体用法?Python Checker.check_empty怎么用?Python Checker.check_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在karesansui.lib.checker.Checker的用法示例。


在下文中一共展示了Checker.check_empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validates_network_storage

# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_empty [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
开发者ID:AdUser,项目名称:karesansui,代码行数:61,代码来源:hostby1networkstorageby1.py

示例2: validates_network_storage

# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_empty [as 别名]
def validates_network_storage(obj):
    checker = Checker()
    check = True

    _ = obj._
    checker.errors = []

    if is_param(obj.input, 'iqn'):
        check = checker.check_string(_('Target IQN'),
                                     obj.input.iqn,
                                     CHECK_EMPTY | CHECK_ONLYSPACE,
                                     None,
                                     None,
                                     None,
                                     ) and check
    else:
        check = False
        checker.add_error(_('"%s" is required.') %_('Target IQN'))

    if is_param(obj.input, 'status'):
        check = checker.check_empty(_('Action Status'),
                                     obj.input.status,
                                     ) and check
    else:
        check = False
        checker.add_error(_('"%s" is required.') %_('Action Status'))

    if is_param(obj.input, 'host'):
        check = checker.check_domainname(_('Target Hostname'),
                                         obj.input.host,
                                         CHECK_EMPTY | CHECK_VALID,
                                         ) and check
    else:
        check = False
        checker.add_error(_('"%s" is required.') %_('Target Hostname'))

    if is_param(obj.input, 'port'):
        check = checker.check_number(_('Target Port Number'),
                                     obj.input.port,
                                     CHECK_VALID | CHECK_MIN | CHECK_MAX,
                                     PORT_MIN_NUMBER,
                                     PORT_MAX_NUMBER,
                                     ) and check
    else:
        check = False
        checker.add_error(_('"%s" is required.') %_('Target Port Number'))

    obj.view.alert = checker.errors
    return check
开发者ID:goura,项目名称:karesansui,代码行数:51,代码来源:hostby1networkstorageby1status.py

示例3: validates_graphics

# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_empty [as 别名]
def validates_graphics(obj):
    checker = Checker()
    check = True

    _ = obj._
    checker.errors = []

    if not is_param(obj.input, 'port'):
        check = False
        checker.add_error(_('"%s" is required.') % _('Graphics Port Number'))
    else:
        check = checker.check_number(
                _('Graphics Port Number'),
                obj.input.port,
                CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
                min = GRAPHICS_PORT_MIN_NUMBER,
                max = GRAPHICS_PORT_MAX_NUMBER,
            ) and check

    if not is_param(obj.input, 'listen'):
        check = False
        checker.add_error(_('"%s" is required.') % _('Graphics Listen Address'))
    else:
        check = checker.check_empty(
                _('Graphics Listen Address'), 
                obj.input.listen
            ) and check

        if check is True:
            if not obj.input.listen in ["0.0.0.0", "127.0.0.1"]:
                checker.add_error(_('%s is in invalid format.') % (_('Graphics Listen Address')))
                check = False
            else:
                check = True

    if not is_param(obj.input, 'change_passwd'):
        check = False
        checker.add_error(_('"%s" is required.') % _('Graphics Password'))
    else:
        check = checker.check_empty(
                _('Graphics Password'), 
                obj.input.change_passwd
            ) and check

        if check is True:
            if not obj.input.change_passwd in ["random", "empty", "keep"]:
                checker.add_error(_('%s is in invalid format.') % (_('Graphics Password')))
                check = False
            else:
                check = True

    hypervisor = "KVM"
    if obj.input.VMType == 'XEN':
        hypervisor = "XEN"
    elif obj.input.VMType == 'KVM':
        hypervisor = "KVM"

    if not is_param(obj.input, 'keymap'):
        check = False
        checker.add_error(_('"%s" is required.') % _('Graphics Keymap'))
    else:
        check = checker.check_keymap(
                _('Graphics Keymap'),
                obj.input.keymap,
                CHECK_EMPTY | CHECK_EXIST,
                hypervisor) and check

    obj.view.alert = checker.errors
    return check
开发者ID:AdUser,项目名称:karesansui,代码行数:71,代码来源:guestby1graphics.py


注:本文中的karesansui.lib.checker.Checker.check_empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。