本文整理汇总了Python中karesansui.lib.checker.Checker.check_hypervisor方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.check_hypervisor方法的具体用法?Python Checker.check_hypervisor怎么用?Python Checker.check_hypervisor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.checker.Checker
的用法示例。
在下文中一共展示了Checker.check_hypervisor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validates_guest_add
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_hypervisor [as 别名]
def validates_guest_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 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
if not is_param(obj.input, 'm_hypervisor'):
check = False
checker.add_error(_('Parameter m_hypervisor does not exist.'))
else:
check = checker.check_hypervisor(
_('Hypervisor'),
obj.input.m_hypervisor,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
HYPERVISOR_MIN_SIZE,
HYPERVISOR_MAX_SIZE,
) and check
if not is_param(obj.input, 'domain_name'):
check = False
checker.add_error(_('Parameter domain_name does not exist.'))
else:
check = checker.check_string(
_('Domain Name'),
obj.input.domain_name,
CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH | CHECK_ONLYSPACE,
'[^-a-zA-Z0-9_\.]+',
DOMAIN_NAME_MIN_LENGTH,
DOMAIN_NAME_MAX_LENGTH,
) and check
if obj.input.domain_name in get_dom_list():
dom_type = get_dom_type(obj.input.domain_name)
checker.add_error(_("The same domain name already exists for hypervisor '%s'.") % dom_type.upper())
check = False
if is_param(obj.input, 'vm_mem_size'):
check = checker.check_number(
_('Memory Size (MB)'),
obj.input.vm_mem_size,
CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
MEMORY_MIN_SIZE,
None,
) and check
if is_param(obj.input, 'pool_type'):
if obj.input.pool_type != "block":
if is_param(obj.input, 'vm_disk_size'):
check = checker.check_number(
_('Disk Size (MB)'),
obj.input.vm_disk_size,
CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
DISK_MIN_SIZE,
None,
#.........这里部分代码省略.........