本文整理汇总了Python中karesansui.lib.checker.Checker.check_number方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.check_number方法的具体用法?Python Checker.check_number怎么用?Python Checker.check_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.checker.Checker
的用法示例。
在下文中一共展示了Checker.check_number方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validates_cpu
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [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
示例2: validates_mail
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [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
示例3: validates_src_id
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [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
示例4: validates_network_storage
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [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
示例5: validates_network_storage
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [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
示例6: validates_param_id
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_param_id(obj, user_id):
checker = Checker()
check = True
_ = obj._
checker.errors = []
check = checker.check_number(
_('User ID'),
user_id,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
min = ID_MIN_LENGTH,
max = ID_MAX_LENGTH,
) and check
obj.view.alert = checker.errors
return check
示例7: validates_mail
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_mail(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'server'):
check = False
checker.add_error(_('"%s" is required.') % _('Mail Server Name'))
else:
check_server = checker.check_domainname(_('Mail Server Name'),
obj.input.server,
CHECK_EMPTY | CHECK_VALID,
) or \
checker.check_ipaddr(_('Mail Server Name'),
obj.input.server,
CHECK_EMPTY | 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_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
) and check
if not is_param(obj.input, 'email'):
check = False
checker.add_error(_('"%s" is required.') % _('Recipient Mail Address'))
else:
check = checker.check_mailaddress(_('Recipient Mail Address'),
obj.input.email,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH,
min = EMAIL_MIN_LENGTH,
max = EMAIL_MAX_LENGTH
) and check
obj.view.alert = checker.errors
return check
示例8: validates_page
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_page(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'p'):
check = checker.check_number(
_('Page Number'),
obj.input.p,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
min = PAGE_MIN_SIZE,
max = PAGE_MAX_SIZE,
) and check
obj.view.alert = checker.errors
return check
示例9: validates_sid
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_sid(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'sid'):
check = False
checker.add_error(_('"%s" is required.') % _('Copy Source'))
else:
check = checker.check_number(_('Copy Source'),
obj.input.sid,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
ID_MIN_LENGTH,
ID_MAX_LENGTH
) and check
obj.view.alert = checker.errors
return check
示例10: validates_rule
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_rule(obj, is_newrule=False):
checker = Checker()
check = True
_ = obj._
checker.errors = []
obj.view.error_msg = checker.errors
if is_newrule:
kit = KaresansuiIpTables()
rule_id_max_length = 1
if os.path.exists(kit.firewall_xml_file) is False:
check = False
checker.add_error(_('Has not been initialized. Please initialize.'))
else:
kit.firewall_xml = kit.read_firewall_xml()
rule_id_max_length += len(kit.get_rules())
if not is_param(obj.input, 'rule_id'):
check = False
checker.add_error(_('"%s" is required.') % _('ID'))
else:
check = checker.check_number(
_('ID'),
obj.input.rule_id,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
min = ID_MIN_LENGTH,
max = rule_id_max_length,
) and check
if not is_param(obj.input, 'target'):
check = False
checker.add_error(_('"%s" is required.') % _('Target'))
else:
check = checker.check_firewall_policy(
_('Target'),
obj.input.target,
CHECK_EMPTY | CHECK_VALID,
) and check
if not is_param(obj.input, 'protocol'):
check = False
checker.add_error(_('"%s" is required.') % _('Protocol'))
else:
check = checker.check_firewall_protocol(
_('Protocol'),
obj.input.protocol,
CHECK_VALID,
) and check
if not is_param(obj.input, 'source'):
check = False
checker.add_error(_('"%s" is required.') % _('Source Address'))
else:
check = checker.check_ipaddr(
_('Source Address'),
obj.input.source,
CHECK_VALID,
) and check
if not is_param(obj.input, 'sport'):
check = False
checker.add_error(_('"%s" is required.') % _('Source Port'))
else:
if obj.input.protocol == 'tcp' or obj.input.protocol == 'udp':
check = checker.check_number(
_('Source Port'),
obj.input.sport,
CHECK_VALID | CHECK_MIN | CHECK_MAX,
min = PORT_MIN_NUMBER,
max = PORT_MAX_NUMBER,
) and check
if not is_param(obj.input, 'destination'):
check = False
checker.add_error(_('"%s" is required.') % _('Destination Address'))
else:
check = checker.check_ipaddr(
_('Destination Address'),
obj.input.destination,
CHECK_VALID,
) and check
if not is_param(obj.input, 'dport'):
check = False
checker.add_error(_('"%s" is required.') % _('Destination Port'))
else:
if obj.input.protocol == 'tcp' or obj.input.protocol == 'udp':
check = checker.check_number(
_('Destination Port'),
obj.input.dport,
CHECK_VALID | CHECK_MIN | CHECK_MAX,
min = PORT_MIN_NUMBER,
max = PORT_MAX_NUMBER,
) and check
if not is_param(obj.input, 'inif'):
check = False
checker.add_error(_('"%s" is required.') % _('In Interface'))
#.........这里部分代码省略.........
示例11: validates_me
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_me(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
_password_flag = True
if not is_param(obj.input, 'password'):
_password_flag = False
check = False
checker.add_error(_('"%s" is required.') % _('Password'))
if not is_param(obj.input, 'new_password'):
_password_flag = False
check = False
checker.add_error(_('"%s" is required.') % _('New Password'))
if not is_param(obj.input, 'retype'):
_password_flag = False
check = False
checker.add_error(_('"%s" is required.') % _('Retype'))
if _password_flag == True:
if not is_empty(obj.input.password) or \
not is_empty(obj.input.new_password) or \
not is_empty(obj.input.retype):
check = checker.check_password(
_('Password'),
obj.input.password,
obj.input.password,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH,
min = PASSWORD_MIN_LENGTH,
max = PASSWORD_MAX_LENGTH,
) and check
check = checker.check_password(
_('Password'),
obj.input.new_password,
obj.input.retype,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH,
min = PASSWORD_MIN_LENGTH,
max = PASSWORD_MAX_LENGTH,
) and check
if not is_param(obj.input, 'id'):
check = False
checker.add_error(_('"%s" is required.') % _('ID'))
else:
check = checker.check_number(
_('ID'),
obj.input.id,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
min = ID_MIN_LENGTH,
max = ID_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_VALID | CHECK_LENGTH,
min = EMAIL_MIN_LENGTH,
max = EMAIL_MAX_LENGTH,
) and check
if not is_param(obj.input, 'nickname'):
check = False
checker.add_error(_('"%s" is required.') % _('User Name'))
else:
check = checker.check_username(
_('User Name'),
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, 'languages'):
check = False
checker.add_error(_('"%s" is required.') % _('Language'))
else:
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
示例12: validates_host_add
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_host_add(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'm_name'):
check = False
checker.add_error(_('Parameter m_name does not exist.'))
else:
check = checker.check_string(
_('Machine Name'),
obj.input.m_name,
CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
None,
min = MACHINE_NAME_MIN_LENGTH,
max = MACHINE_NAME_MAX_LENGTH,
) and check
if not is_param(obj.input, 'm_hostname'):
check = False
checker.add_error(_('"%s" is required.') % _('FQDN'))
else:
m_hostname_parts = obj.input.m_hostname.split(":")
if len(m_hostname_parts) > 2:
check = False
checker.add_error(_('%s contains too many colon(:)s.') % _('FQDN'))
else:
check = checker.check_domainname(
_('FQDN'),
m_hostname_parts[0],
CHECK_EMPTY | CHECK_LENGTH | CHECK_VALID,
min = FQDN_MIN_LENGTH,
max = FQDN_MAX_LENGTH,
) and check
try:
check = checker.check_number(
_('Port Number'),
m_hostname_parts[1],
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
) and check
except IndexError:
# when reach here, 'm_hostname' has only host name
pass
if not is_param(obj.input, 'm_uuid'):
check = False
checker.add_error(_('"%s" is required.') % _('Unique Key'))
else:
check = checker.check_unique_key(
_('Unique Key'),
obj.input.m_uuid,
CHECK_EMPTY | CHECK_VALID
) and check
if is_param(obj.input, 'note_title'):
check = checker.check_string(
_('Title'),
obj.input.note_title,
CHECK_LENGTH | CHECK_ONLYSPACE,
None,
min = NOTE_TITLE_MIN_LENGTH,
max = NOTE_TITLE_MAX_LENGTH,
) and check
if is_param(obj.input, 'note_value'):
check = checker.check_string(
_('Note'),
obj.input.note_value,
CHECK_ONLYSPACE,
None,
None,
None,
) and check
if is_param(obj.input, 'tags'):
for tag in comma_split(obj.input.tags):
check = checker.check_string(
_('Tag'),
tag,
CHECK_LENGTH | CHECK_ONLYSPACE,
None,
min = TAG_MIN_LENGTH,
max = TAG_MAX_LENGTH,
) and check
obj.view.alert = checker.errors
return check
示例13: validates_watch
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_watch(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'watch_name'):
check = checker.check_string(_('Name'),
obj.input.watch_name,
CHECK_EMPTY | CHECK_ONLYSPACE,
None,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Name'))
if is_param(obj.input, 'watch_target'):
check = checker.check_string(_('Watch Target'),
obj.input.watch_target,
CHECK_EMPTY | CHECK_ONLYSPACE,
None,
) and check
if obj.input.watch_target not in WATCH_PLUGINS.values():
check = False
# TRANSLATORS:
# %sは監視対象ではありません。
checker.add_error(_('"%s" is not watch target.') %_(obj.input.watch_target))
else:
check = False
checker.add_error(_('"%s" is required.') %_('Watch Target'))
if is_param(obj.input, 'continuation_count'):
check = checker.check_number(_('Alert Trigger Count'),
obj.input.continuation_count,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
CONTINUATION_COUNT_MIN,
CONTINUATION_COUNT_MAX,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Alert Trigger Count'))
if is_param(obj.input, 'prohibition_period'):
check = checker.check_number(_('Silent Period'),
obj.input.prohibition_period,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PROHIBITION_PERIOD_MIN,
PROHIBITION_PERIOD_MAX,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Silent Period'))
if is_param(obj.input, 'threshold_fraction'):
fraction = int(obj.input.threshold_fraction)
else:
fraction = 0
if is_param(obj.input, 'threshold_val1'):
if fraction == 0:
check = checker.check_number(_('Threshold Value'),
obj.input.threshold_val1,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
) and check
else:
check = checker.check_fraction(_('Threshold Value'),
obj.input.threshold_val1,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
fraction,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Threshold Value'))
if is_param(obj.input, 'threshold_val2'):
if fraction == 0:
check = checker.check_number(_('Threshold Value'),
obj.input.threshold_val2,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
) and check
else:
check = checker.check_fraction(_('Threshold Value'),
obj.input.threshold_val2,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
fraction,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Threshold Value'))
if not is_param(obj.input, 'threshold_type'):
check = False
#.........这里部分代码省略.........
示例14: validates_proxy
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_proxy(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, 'proxy_status'):
check = False
checker.add_error(_('"%s" is required.') % _('Proxy Settings'))
else:
if obj.input.proxy_status == PROXY_ENABLE:
if not is_param(obj.input, 'proxy_server'):
check = False
checker.add_error(_('"%s" is required.') % _('Proxy Server'))
else:
check = checker.check_domainname(
_('Proxy Server'),
obj.input.proxy_server,
CHECK_EMPTY | CHECK_VALID,
None,
None,
) and check
if not is_param(obj.input, 'proxy_port'):
check = False
checker.add_error(_('"%s" is required.') % _('Proxy Port Number'))
else:
check = checker.check_number(
_('Port Number'),
obj.input.proxy_port,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
) and check
if not is_param(obj.input, 'proxy_user'):
check = False
checker.add_error(_('"%s" is required.') % _('Proxy User Name'))
else:
check = checker.check_username(
_('Proxy User Name'),
obj.input.proxy_user,
CHECK_VALID | CHECK_ONLYSPACE,
None,
None,
) and check
if not is_param(obj.input, 'proxy_password'):
check = False
checker.add_error(_('"%s" is required.') % _('Proxy Password'))
else:
check = checker.check_password(
_('Proxy Password'),
obj.input.proxy_password,
obj.input.proxy_password,
CHECK_VALID,
) and check;
elif obj.input.proxy_status == PROXY_DISABLE:
check = True and check
else:
check = False
checker.add_error(_('"%s" is in invalid format.') % _('Proxy Status'))
obj.view.alert = checker.errors
return check
示例15: validates_server
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_number [as 别名]
def validates_server(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if not is_param(obj.input, "uniqkey"):
check = False
checker.add_error(_('"%s" is required.') % _("Unique Key"))
else:
check = checker.check_unique_key(_("Unique Key"), obj.input.uniqkey, CHECK_EMPTY | CHECK_VALID) 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_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PORT_MIN_NUMBER,
PORT_MAX_NUMBER,
)
and check
)
if not is_param(obj.input, "access"):
check = False
checker.add_error(_('"%s" is required.') % _("Access Policy"))
else:
if obj.input.access == "all":
check = True and check
elif obj.input.access == "network":
if not obj.input.has_key("network"):
check = False
checker.add_error(_('"%s" is required.') % _("Permit access from same network"))
else:
check = (
checker.check_cidr(
_("Permit Access From Same Network"), obj.input.network, CHECK_EMPTY | CHECK_VALID
)
and check
)
elif obj.input.access == "ipaddress":
if not obj.input.has_key("access_ipaddress"):
check = False
checker.add_error(_('"%s" is required.') % _("Permit access from specified IP address"))
else:
obj.input.ip_list = obj.input.access_ipaddress.split()
obj.input.ip_list = get_no_overlap_list(obj.input.ip_list)
if len(obj.input.ip_list) == 0:
check = False
checker.add_error(_('"%s" is required.') % _("IP Address"))
for input_ip in obj.input.ip_list:
check = (
checker.check_ipaddr(_("Permit specified IP address"), input_ip, CHECK_EMPTY | CHECK_VALID)
and check
)
else:
check = False
if not is_param(obj.input, "ssl_status"):
check = False
checker.add_error(_('"%s" is required.') % _("SSL Settings"))
else:
if obj.input.ssl_status == "enable":
check = True and check
elif obj.input.ssl_status == "disable":
check = True and check
else:
check = False
obj.view.alert = checker.errors
return check