Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 16

张鹏/DevNet2019

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
DevNet2019
/
devnet
/
forms.py
DevNet2019
/
devnet
/
forms.py
forms.py 30.09 KB
Copy Edit Raw Blame History
现任明教教主-乾颐堂 authored 2019年09月03日 08:19 +08:00 . 登录并且权限控制!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
#!/usr/bin/env python3
# -*- coding=utf-8 -*-
# 本脚由亁颐堂现任明教教主编写,用于乾颐盾Python课程!
# 教主QQ:605658506
# 亁颐堂官网www.qytang.com
# 教主技术进化论拓展你的技术新边疆
# https://ke.qq.com/course/271956?tuin=24199d8a
from django import forms
from devnet.models import SNMPtype, DeviceSNMP, Devicetype, Devicedb
from django.core.validators import RegexValidator
# 添加设备类型
class AddDeviceType(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
# 设备类型名称
device_type_name = forms.CharField(label='设备类型名称',
widget=forms.TextInput(attrs={"class": "form-control"}))
# CPU利用率
cpu_usage = forms.CharField(label='CPU利用率',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 内存使用
mem_usage = forms.CharField(label='内存使用',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 内存闲置
mem_free = forms.CharField(label='内存闲置',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口名称
if_name = forms.CharField(label='接口名称',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口速率
if_speed = forms.CharField(label='接口速率',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口状态
if_state = forms.CharField(label='接口状态',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口入向字节数
if_in_bytes = forms.CharField(label='接口入向字节数',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口出向字节数
if_out_bytes = forms.CharField(label='接口出向字节数',
widget=forms.TextInput(attrs={"class": "form-control"}))
def clean_device_type_name(self):
device_type_name = self.cleaned_data['device_type_name']
try:
Devicetype.objects.get(type_name=device_type_name)
raise forms.ValidationError("设备类型已存在!")
except Devicetype.DoesNotExist:
return device_type_name
# 添加设备类型
class EditDeviceType(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
device_id = forms.IntegerField(label='设备类型ID',
required=True,
widget=forms.TextInput(attrs={"class": "form-control", 'readonly': True}))
# 设备类型名称
device_type_name = forms.CharField(label='设备类型名称',
widget=forms.TextInput(attrs={"class": "form-control"}))
# CPU利用率
cpu_usage = forms.CharField(label='CPU利用率',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 内存使用
mem_usage = forms.CharField(label='内存使用',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 内存闲置
mem_free = forms.CharField(label='内存闲置',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口名称
if_name = forms.CharField(label='接口名称',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口速率
if_speed = forms.CharField(label='接口速率',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口状态
if_state = forms.CharField(label='接口状态',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口入向字节数
if_in_bytes = forms.CharField(label='接口入向字节数',
widget=forms.TextInput(attrs={"class": "form-control"}))
# 接口出向字节数
if_out_bytes = forms.CharField(label='接口出向字节数',
widget=forms.TextInput(attrs={"class": "form-control"}))
def clean_device_type_name(self):
device_type_name = self.cleaned_data['device_type_name']
device_id = self.cleaned_data['device_id']
try:
if device_id != Devicetype.objects.get(type_name=device_type_name).id:
raise forms.ValidationError("设备类型已存在!")
else:
return device_type_name
except Devicetype.DoesNotExist:
return device_type_name
# 添加设备表单
class AddDevice(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
name = forms.CharField(max_length=100,
min_length=2,
label='设备名称',
required=True,
widget=forms.TextInput(attrs={"class": "form-control"}))
# 类型为GenericIPAddressField,可以对输入的IP地址进行校验
ip = forms.GenericIPAddressField(required=True,
label='IP地址',
widget=forms.TextInput(attrs={"class": "form-control"}))
description = forms.CharField(label="设备描述",
required=False,
# 输入为Textarea,支持多行输入,"rows": 3 控制展示的行数
widget=forms.Textarea(attrs={"class": "form-control", "rows": 3}))
# 选择的设备类型
type_choices = []
devicetype = Devicetype.objects.all()
for x in devicetype:
type_choices.append([x.id, x.type_name])
type = forms.CharField(label='设备类型',
required=True,
widget=forms.Select(choices=type_choices,
attrs={"class": "form-control"}))
TRUE_FALSE_CHOICES = ((True, 'Yes'), (False, 'No'))
snmp_enable = forms.ChoiceField(label='是否激活SNMP',
required=True,
choices=TRUE_FALSE_CHOICES,
initial=False,
widget=forms.Select(attrs={"class": "required checkbox form-control"}))
community_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="SNMP community 只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
snmp_ro_community = forms.CharField(max_length=100,
min_length=2,
label='SNMP只读',
required=True,
validators=[community_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
snmp_rw_community = forms.CharField(max_length=100,
min_length=2,
label='SNMP读写',
required=False,
validators=[community_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
username_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="用户名只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
ssh_username = forms.CharField(max_length=100,
min_length=2,
label='SSH用户名',
required=True,
validators=[username_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
password_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="密码只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
ssh_password = forms.CharField(max_length=100,
min_length=2,
label='SSH密码',
required=True,
validators=[password_regex],
widget=forms.PasswordInput(attrs={"class": "form-control"}))
enable_password_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="特权密码只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
enable_password = forms.CharField(max_length=100,
min_length=2,
label='特权密码',
required=False,
validators=[enable_password_regex],
widget=forms.PasswordInput(attrs={"class": "form-control"}))
# 校验设备名称不能重复, 在此系统中,设备并没有指定唯一ID,设备名就是唯一ID,不能重复
def clean_name(self):
name = self.cleaned_data['name'] # 提取客户输入的设备名
# 在数据库中查找是否存在这个设备名
existing = Devicedb.objects.filter(
name=name
).exists()
# 如果存在就显示校验错误信息
if existing:
raise forms.ValidationError("设备名不能重复")
# 如果校验成功就返回设备名
return name
# 校验IP地址不能重复
def clean_ip(self):
ip = self.cleaned_data['ip'] # 提取客户输入的设备IP
# 在数据库中查找是否存在这个设备IP
existing = Devicedb.objects.filter(
ip=ip
).exists()
# 如果存在就显示校验错误信息
if existing:
raise forms.ValidationError("设备IP不能重复")
# 如果校验成功就返回设备IP
return ip
# 确认激活SNMP,才能设置只读Community
def clean_snmp_ro_community(self):
snmp_enable = self.cleaned_data['snmp_enable']
snmp_ro_community = self.cleaned_data['snmp_ro_community']
if snmp_enable == 'True' and snmp_ro_community:
return snmp_ro_community
else:
raise forms.ValidationError("设置只读Community之前请激活SNMP")
# 确认激活SNMP,才能设置读写Community
def clean_snmp_rw_community(self):
snmp_enable = self.cleaned_data['snmp_enable']
snmp_rw_community = self.cleaned_data['snmp_rw_community']
if snmp_rw_community:
if snmp_enable == 'True' and snmp_rw_community:
return snmp_rw_community
else:
raise forms.ValidationError("设置读写Community之前请激活SNMP")
else:
return snmp_rw_community
# 编辑设备表单
class EditDevice(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
id = forms.IntegerField(label='设备ID',
required=True,
widget=forms.TextInput(attrs={"class": "form-control", 'readonly': True}))
name = forms.CharField(max_length=100,
min_length=2,
label='设备名称',
required=True,
widget=forms.TextInput(attrs={"class": "form-control"}))
ip = forms.GenericIPAddressField(required=True,
label='IP地址',
widget=forms.TextInput(attrs={"class": "form-control"}))
description = forms.CharField(label="设备描述",
required=False,
widget=forms.Textarea(attrs={"class": "form-control", "rows": 3}))
type_choices = []
devicetype = Devicetype.objects.all()
for x in devicetype:
type_choices.append([x.id, x.type_name])
type = forms.CharField(label='设备类型',
required=True,
widget=forms.Select(choices=type_choices,
attrs={"class": "form-control"}))
TRUE_FALSE_CHOICES = ((True, 'Yes'), (False, 'No'))
snmp_enable = forms.ChoiceField(label='是否激活SNMP',
required=True,
choices=TRUE_FALSE_CHOICES,
initial=False,
widget=forms.Select(attrs={"class": "required checkbox form-control"}))
community_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="SNMP community 只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
snmp_ro_community = forms.CharField(max_length=100,
min_length=2,
label='SNMP只读',
required=True,
validators=[community_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
snmp_rw_community = forms.CharField(max_length=100,
min_length=2,
label='SNMP读写',
required=False,
validators=[community_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
username_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="用户名只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
ssh_username = forms.CharField(max_length=100,
min_length=2,
label='SSH用户名',
required=True,
validators=[username_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
password_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="密码只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
ssh_password = forms.CharField(max_length=100,
min_length=2,
label='SSH密码',
required=True,
validators=[password_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
enable_password_regex = RegexValidator(regex=r'[0-9a-zA-Z~!@#$%^&*()_+=,./]+',
message="特权密码只能包含数字,小写,大写字母 ~!@#$%^&*()_+=,./")
enable_password = forms.CharField(max_length=100,
min_length=2,
label='特权密码',
required=False,
validators=[enable_password_regex],
widget=forms.TextInput(attrs={"class": "form-control"}))
def clean_name(self):
name = self.cleaned_data['name'] # 提取客户输入的设备名称
for i in Devicedb.objects.filter(name=name):
if i.id != self.cleaned_data['id']:
raise forms.ValidationError("设备名称已经存在")
else:
return name
def clean_ip(self):
ip = self.cleaned_data['ip'] # 提取客户输入的设备IP
# 在数据库中查找是否存在其他设备使用这个IP地址
for i in Devicedb.objects.filter(ip=ip):
if i.id != self.cleaned_data['id']:
raise forms.ValidationError("设备IP地址已经存在")
else:
return ip
def clean_snmp_ro_community(self):
snmp_enable = self.cleaned_data['snmp_enable']
snmp_ro_community = self.cleaned_data['snmp_ro_community']
if snmp_enable == 'True' and snmp_ro_community:
return snmp_ro_community
else:
raise forms.ValidationError("设置只读Community之前请激活SNMP")
def clean_snmp_rw_community(self):
snmp_enable = self.cleaned_data['snmp_enable']
snmp_rw_community = self.cleaned_data['snmp_rw_community']
if snmp_rw_community:
if snmp_enable == 'True' and snmp_rw_community:
return snmp_rw_community
else:
raise forms.ValidationError("设置读写Community之前请激活SNMP")
else:
return snmp_rw_community
# 系统设置, 监控周期表单
class SysconfigmonitorintervalForm(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
interval_regex = RegexValidator(regex=r'^\d{1,2}$',
message="监控周期只能支持最多2位整数")
# CPU监控周期
cpu_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=2,
label='CPU监控周期(单位小时,默认1小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# CPU最大值计算周期
cpu_max_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=2,
label='CPU最大值计算周期(单位小时,默认1小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 内存监控周期
mem_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=2,
label='内存监控周期(单位小时,默认1小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 内存最大值计算周期
mem_max_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=2,
label='内存最大值计算周期(单位小时,默认1小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 速率监控周期
speed_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=2,
label='接口速率监控周期(单位小时,默认1小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 利用率监控周期
utilization_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=2,
label='接口利用率监控周期(单位小时,默认1小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 系统设置, 监控周期表单
class SysconfigdatabaselifetimeForm(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
interval_regex = RegexValidator(regex=r'^\d{1,3}$',
message="数据老化时间只能支持最多3位整数")
# 可达性数据老化时间
reachable_lifetime = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=3,
label='可达性数据老化时间(单位小时,默认24小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# CPU数据老化时间
cpu_lifetime = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=3,
label='CPU数据老化时间(单位小时,默认24小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 内存数据老化时间
mem_lifetime = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=3,
label='内存数据老化时间(单位小时,默认24小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 接口数据老化时间
interface_lifetime = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=3,
label='接口数据老化时间(单位小时,默认24小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# Netflow数据老化时间
netflow_lifetime = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=3,
label='Netflow数据老化时间(单位小时,默认24小时)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 系统设置, 告警阈值,周期与SMTP相关表单
class Sysconfigthreshold(forms.Form):
# 如果希望出现必选左边的红色星标 ,必须配置下面的内容,并且在HTML中还要配置CSS
required_css_class = 'required'
threshold_regex = RegexValidator(regex=r'^1?\d{1,2}$',
message="阈值取值范围为1-100的整数")
interval_regex = RegexValidator(regex=r'^\d{1,2}$',
message="监控周期只能支持最多2位整数")
# CPU告警阈值
cpu_threshold = forms.CharField(validators=[threshold_regex],
min_length=1,
max_length=3,
label='CPU告警阈值(单位%)设置为0表示取消',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# CPU告警周期
cpu_alarm_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=5,
label='CPU告警周期(单位分钟)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 内存告警阈值
mem_threshold = forms.CharField(validators=[threshold_regex],
min_length=1,
max_length=3,
label='内存告警阈值(单位%)设置为0表示取消',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 内存告警周期
mem_alarm_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=5,
label='内存告警周期(单位分钟)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 接口利用率告警阈值
utilization_threshold = forms.CharField(validators=[threshold_regex],
min_length=1,
max_length=3,
label='接口利用率告警阈值(单位%)设置为0表示取消',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# 接口利用率告警周期
utilization_alarm_interval = forms.CharField(validators=[interval_regex],
min_length=1,
max_length=5,
label='接口利用率告警周期(单位分钟)',
required=True,
widget=forms.NumberInput(attrs={"class": "form-control"}))
# SMTP邮件服务器
mailserver = forms.CharField(min_length=1,
max_length=50,
label='邮件服务器',
required=False,
widget=forms.TextInput(attrs={"class": "form-control"}))
# SMTP认证用用户名
mailusername = forms.CharField(min_length=1,
max_length=50,
label='用户名',
required=False,
widget=forms.TextInput(attrs={"class": "form-control"}))
# SMTP认证用密码
mailpassword = forms.CharField(min_length=1,
max_length=50,
label='密码',
required=False,
widget=forms.TextInput(attrs={"class": "form-control"}))
# 发件人
mailfrom = forms.CharField(min_length=1,
max_length=50,
label='发件人FROM',
required=False,
widget=forms.TextInput(attrs={"class": "form-control"}))
# 收件人
mailto = forms.CharField(min_length=1,
max_length=50,
label='收件人TO',
required=False,
widget=forms.TextInput(attrs={"class": "form-control"}))
def clean_cpu_alarm_interval(self):
cpu_threshold = int(self.cleaned_data['cpu_threshold'])
cpu_alarm_interval = int(self.cleaned_data['cpu_alarm_interval'])
if (cpu_threshold and cpu_alarm_interval) >= 1:
pass
elif cpu_threshold == 0 and cpu_alarm_interval == 0:
pass
else:
raise forms.ValidationError("CPU阈值与告警周期,要么都设置,要么都保持默认的0!不能只设置其中一个!")
def clean_mem_alarm_interval(self):
mem_threshold = int(self.cleaned_data['mem_threshold'])
mem_alarm_interval = int(self.cleaned_data['mem_alarm_interval'])
if (mem_threshold and mem_alarm_interval) >= 1:
pass
elif mem_threshold == 0 and mem_alarm_interval == 0:
pass
else:
raise forms.ValidationError("内存阈值与告警周期,要么都设置,要么都保持默认的0!不能只设置其中一个!")
def clean_utilization_alarm_interval(self):
utilization_threshold = int(self.cleaned_data['utilization_threshold'])
utilization_alarm_interval = int(self.cleaned_data['utilization_alarm_interval'])
if (utilization_threshold and utilization_alarm_interval) >= 1:
pass
elif utilization_threshold == 0 and utilization_alarm_interval == 0:
pass
else:
raise forms.ValidationError("利用率阈值与告警周期,要么都设置,要么都保持默认的0!不能只设置其中一个!")
def clean_mailto(self):
mailserver = self.cleaned_data['mailserver']
mailusername = self.cleaned_data['mailusername']
mailpassword = self.cleaned_data['mailpassword']
mailfrom = self.cleaned_data['mailfrom']
mailto = self.cleaned_data['mailto']
if mailserver and mailusername and mailpassword and mailfrom and mailto:
pass
elif not mailserver and not mailusername and not mailpassword and not mailfrom and not mailto:
pass
else:
raise forms.ValidationError("邮件信息要么全部设置!要么全部保持空!不能只设置其中的一部分!")
class UserForm(forms.Form):
username = forms.CharField(label='用户名',
max_length=100,
required=True,
widget=forms.TextInput(attrs={"class": "form-control", "placeholder": "用户名"})
)
password = forms.CharField(label='密码',
max_length=100,
required=True,
widget=forms.PasswordInput(attrs={"class": "form-control", "placeholder": "密码"})
)
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/networker-python/DevNet2019.git
git@gitee.com:networker-python/DevNet2019.git
networker-python
DevNet2019
DevNet2019
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /