Esempio n. 1
0
class AddMailServiceForm(FlaskForm):
    team_name = SelectField('Team', coerce=int)
    service_name = StringField('Service Name', [validators.Length(min=1, max=50)], render_kw={"placeholder": "Service Name"})
    service_connection = StringField('Mail Server IP', [validators.IPAddress()], render_kw={"placeholder": "IP Address"})
    from_email = StringField('From', [validators.Length(min=1, max=50)], render_kw={"placeholder": "Username:[email protected]"})
    to_email = StringField('To', [validators.Length(min=1, max=50)], render_kw={"placeholder": "Username:[email protected]"})
    service_expected_result = StringField('Message', [validators.Length(min=1,max=200)], render_kw={"placeholder": "Message Content"})
Esempio n. 2
0
class FormClass(FlaskForm):
    htype = SelectField("*类型", choices=[('VM', 'VM'), ('PM', 'PM')])
    mroom = SelectField("*机房", choices=[('网信', '网信'), ('中商', '中商')])
    status = SelectField("*状态",
                         choices=[('使用中', '使用中'), ('已关机', '已关机'),
                                  ('已删除', '已删除')])
    hostname = TextField("*主机名", [validators.Required()])
    app = TextField("*应用名称", [validators.Required()])
    #       ip = TextField("ip",[validators.Required()])
    ip = TextField("*内网IP", [validators.IPAddress()])
    user = TextField("*应用负责人", [validators.Required()])
    os = TextField("*操作系统", [validators.Required()])
    active = TextField("*激活", [validators.Required()])
    cpu = IntegerField("*CPU", [validators.Required()])
    ram = IntegerField("*内存", [validators.Required()])
    cluster = SelectField("*集群",
                          choices=[('cluster1', 'cluster1'),
                                   ('cluster2', 'cluster2'),
                                   ('cluster3', 'cluster3')])
    mip = TextField("管理IP")
    location = TextField("机架位置")
    produce = TextField("生产商")
    warranty = TextField("保修日期")
    model = TextField("设备型号")
    serial = TextField("序列号")
    disk = TextField("硬盘Raid")
    storage = TextField("外连存储")
Esempio n. 3
0
class SubnetFormCSV(Form):
    ipv4 = StringField('ipv4',
                       validators=[
                           validators.IPAddress(
                               ipv4=True,
                               ipv6=False,
                               message='That is a strange IPv4 address.')
                       ])

    prefixlen = IntegerField('prefixlen',
                             validators=[
                                 validators.NumberRange(
                                     min=16,
                                     max=30,
                                     message='Valid prefix range 16 - 30!')
                             ])

    new_prefixlen = IntegerField(
        'prefixlen',
        validators=[
            validators.NumberRange(
                min=17, max=32, message='Valid child subnet range is 17 - 32!')
        ])

    netbox_text = TextAreaField('netbox_text',
                                render_kw={
                                    'class': 'form-control',
                                    'rows': '55'
                                },
                                validators=[validators.required()])
Esempio n. 4
0
class MyForm(FlaskForm):
    name = TextField('姓名', [validators.Required('请输入姓名')])
    email = TextField(
        'Email',
        [validators.Required('请输入Email'),
         validators.email('请输入正确的Email地址')])
    ip = TextField('IP', [
        validators.Required('请输入IP地址'),
        validators.IPAddress(message='请输入正确的IP地址')
    ])
    password1 = PasswordField('密码', [validators.Required('请输入密码')])
    password2 = PasswordField('确认密码', [
        validators.Required('请确认密码'),
        validators.EqualTo('password1', '两次输入的密码不一致')
    ])

    value = TextField('电子邮件',
                      [validators.Email('Email格式不正确'),
                       validators.optional()])
    url = TextField(
        'Url', [validators.URL(message='Url格式不正确'),
                validators.optional()])

    regexpValue = TextField('正则表达式', [
        validators.Regexp('^[a-z]{3}-[1-9]{3}$', message='格式错误,正确格式:abc-123'),
        validators.Optional()
    ])
    submit = SubmitField('提交')
Esempio n. 5
0
class RecordAForm(Form):
    name = StringField('name',
                       [validators.Regexp('(^$)|'
                                          '(^([a-z0-9\-]+\.)*([a-z0-9\-]+)$)')])
    # TODO: Check max length of name.
    ip = StringField('ip', [validators.IPAddress()])
    memo = StringField('memo', [validators.Length(max=1000)])
Esempio n. 6
0
class ServerForm(Form):
    display_name = StringField('Display Name',
                               validators=[
                                   validators.Length(
                                       min=-1,
                                       max=GameServer.display_name.type.length)
                               ])

    ip_string = StringField(
        'Server IP',
        validators=[validators.required(),
                    validators.IPAddress()])

    port = IntegerField('Server port',
                        default=27015,
                        validators=[validators.required()])

    rcon_password = StringField(
        'RCON password',
        validators=[
            validators.required(),
            validators.Length(min=-1, max=GameServer.rcon_password.type.length)
        ])

    public_server = BooleanField('Publicly usable server')
Esempio n. 7
0
class RecordAAAAForm(Form):
    name = TextField(
        'name',
        [validators.Regexp('(^$)|'
                           '(^([a-z0-9\-]+\.)*([a-z0-9\-]+)$)')])
    # TODO: Check max length of name.
    ip = TextField('ip', [validators.IPAddress(ipv4=False, ipv6=True)])
    memo = TextField('memo', [validators.Length(max=1000)])
Esempio n. 8
0
class RecordDDNSForm(Form):
    name = StringField(
        'name',
        [validators.Regexp('(^$)|'
                           '(^([a-z0-9\-]+\.)*'
                           '([a-z0-9\-]+)$)')])
    ip = StringField('ip', [validators.IPAddress()])
    memo = StringField('memo', [validators.Length(max=1000)])
Esempio n. 9
0
class ParsleyTestForm(Form):
    email = StringField(
        'E-Mail Address',
        [validators.Email('Sorrry, not a valid email address.')],
        default='*****@*****.**')
    first_value = StringField('Some Value', default='Some value')
    second_value = StringField('Should be identical', [
        validators.EqualTo(message='Sorry, values do not match.',
                           fieldname='first_value')
    ],
                               default='Some value')
    ip_address = StringField(
        'IP4 Address',
        [validators.IPAddress(message='Sorry, not a valid IP4 Address.')],
        default='127.0.0.1')
    string_length = StringField('Length of String (5 to 10)', [
        validators.Length(
            message='Length should be between 5 and 10 characters.',
            min=5,
            max=10)
    ],
                                default='Hello!')
    number_range = IntegerField('Number Range (5 to 10)', [
        validators.NumberRange(
            message='Range should be between 5 and 10.', min=5, max=10)
    ],
                                default=7)

    required_text = StringField(
        'Required Field',
        [validators.DataRequired(message='Sorry, this is a required field.')],
        default='Mandatory text')
    required_select = SelectField(
        'Required Select',
        [validators.DataRequired(message='Sorry, you have to make a choice.')],
        choices=[('', 'Please select an option'), ('cpp', 'C++'),
                 ('py', 'Python'), ('text', 'Plain Text')],
        default='py')
    required_checkbox = BooleanField(
        'Required Checkbox',
        [validators.DataRequired(message='Sorry, you need to accept this.')],
        default=True)
    regexp = StringField('Regex-Matched Hex Color-Code', [
        validators.Regexp(message='Not a proper color code, sorry.',
                          regex=r'^#[A-Fa-f0-9]{6}$')
    ],
                         default='#7D384F')
    url = StringField(
        'URL Field',
        [validators.URL(message='Sorry, this is not a valid URL,')],
        default='http://example.com/parsley')
    anyof = StringField('Car, Bike or Plane?', [
        validators.AnyOf(
            message='Sorry, you can only choose from car, bike and plane',
            values=['car', 'bike', 'plane'])
    ],
                        default='car')
Esempio n. 10
0
class TokenForm(flask_wtf.FlaskForm):
    displayed_password = fields.StringField(
        _('Your token (write it down, as it will never be displayed again)'))
    raw_password = fields.HiddenField([validators.DataRequired()])
    comment = fields.StringField(_('Comment'))
    ip = fields.StringField(
        _('Authorized IP'),
        [validators.Optional(), validators.IPAddress()])
    submit = fields.SubmitField(_('Create'))
Esempio n. 11
0
class MachineForm(FlaskForm):
    hostname = StringField(
        'HostName',
        validators=[validators.required(), validate_hostname_exist])
    ip_addr = StringField('IP Address',
                          validators=[
                              validators.required(),
                              validators.IPAddress(), validate_ipaddr_exist
                          ])
Esempio n. 12
0
class DataForm(Form):
    choices = [(test_id, TEST_DEFINITIONS[test_id]["name"])
               for test_id in TEST_DEFINITIONS]
    choices = sorted(choices, key=lambda x: x[0])
    test = SelectField(label="Select test:", choices=choices)
    # TODO: Potentially add a mixed IS-04/05 test for where they cross over
    ip = StringField(
        label="IP:",
        validators=[
            validators.IPAddress(message="Please enter a valid IPv4 address.")
        ])
    port = IntegerField(label="Port:",
                        validators=[
                            validators.NumberRange(
                                min=0,
                                max=65535,
                                message="Please enter a valid port number "
                                "(0-65535).")
                        ])
    ip_sec = StringField(
        label="IP:",
        validators=[
            validators.IPAddress(message="Please enter a valid IPv4 address."),
            validators.optional()
        ])
    port_sec = IntegerField(label="Port:",
                            validators=[
                                validators.NumberRange(
                                    min=0,
                                    max=65535,
                                    message="Please enter a valid port "
                                    "number (0-65535)."),
                                validators.optional()
                            ])
    version = SelectField(label="API Version:",
                          choices=[("v1.0", "v1.0"), ("v1.1", "v1.1"),
                                   ("v1.2", "v1.2"), ("v1.3", "v1.3")])

    # Hide test data in the web form for dynamic modification of behaviour
    hidden_data = {}
    for test_id in TEST_DEFINITIONS:
        hidden_data[test_id] = copy.copy(TEST_DEFINITIONS[test_id])
        hidden_data[test_id].pop("class")
    hidden = HiddenField(default=json.dumps(hidden_data))
Esempio n. 13
0
class NetworkForm(Form):
    ip = StringField(lazy_gettext(u"Endereço IP"), default=socket.gethostbyname(
        socket.gethostname()), validators=[validators.IPAddress(),
            validators.Required()])
    domain = StringField(lazy_gettext(u"Domínio"), default=socket.getfqdn(),
            validators=[validators.Required()]) # TODO, split
    hostname = StringField(lazy_gettext(u"Hostname"), default=socket.gethostname(),
            validators=[validators.Required()])
    gateway = StringField(u"Gateway", validators=[validators.Required()]) # TODO
    dns = StringField(u"DNS", validators=[validators.Required()]) # TODO
    mask = StringField(lazy_gettext(u"Mascara"), validators=[validators.Required()])
Esempio n. 14
0
class NetForm(Form):

    ip_addr = StringField(
        'ip_addr',
        validators=[
            validators.Optional(),
            validators.IPAddress(message='Please enter a valid IP')
        ])

    computername = StringField('computername',
                               validators=[validators.Optional()])
    username = StringField('username', validators=[validators.Optional()])
Esempio n. 15
0
class ValidateJSONForm(Form):
    customerID = IntegerField('customerID', validators=[validators.Required()])
    tagID = IntegerField('tagID', validators=[validators.Required()])
    userID = StringField('userID', validators=[validators.Required()])
    #in the following we are validating the IP. Based on the given example, and since in the
    #database the IP is an ineteger, we assumed that only ipv4 is valid
    remoteIP = StringField('remoteIP',
                           validators=[
                               validators.IPAddress(ipv4=True, ipv6=False),
                               validators.Required()
                           ])
    timestamp = IntegerField('timestamp', validators=[validators.Required()])
Esempio n. 16
0
class CellNodeForm(BaseForm):
    node = SelectField(
        label=u'サーバ',
        coerce=int,
        choices=[],
    )
    udp_addr = StringField(
        label=u'ホストアドレス(UDP)',
        validators=[validators.DataRequired(),
                    validators.IPAddress()],
    )
    udp_port = IntegerField(
        label=u'UDPポート番号',
        validators=[
            validators.DataRequired(),
            validators.NumberRange(
                min=0,
                max=65535,
            )
        ],
        default=14000,
    )
    tcp_addr = StringField(
        label=u'ホストアドレス(TCP)',
        validators=[validators.DataRequired(),
                    validators.IPAddress()],
    )
    tcp_port = IntegerField(
        label=u'TCPポート番号',
        validators=[
            validators.DataRequired(),
            validators.NumberRange(
                min=0,
                max=65535,
            )
        ],
        default=14000,
    )
    node_id = HiddenField()
Esempio n. 17
0
class addFwRuleForm(Form):

    # Get list of managers from database
    result = dbGetNsxManagers()

    #Empty list to store the different choices
    choiceList = []

    #the choices property needs a tuple in the form of (value,label)
    for entry in result['results']:
        choiceList.append((entry['id'], entry['ip']))

    nsxmgr = SelectField('NSX Manager', choices=choiceList)
    srcip = StringField('Source IP',
                        [validators.DataRequired(),
                         validators.IPAddress()])
    dstip = StringField('Destination IP',
                        [validators.DataRequired(),
                         validators.IPAddress()])
    log = BooleanField('Enable Logging', [validators.DataRequired()])
    action = SelectField('Action',
                         choices=[('Permit', 'Permit'), ('Deny', 'Deny')])
Esempio n. 18
0
class HostForm(Form):
    name = StringField('Nom', [
        validators.InputRequired(
            message=u"Heu d'introduir un nom per l'equip"),
        validators.Length(
            max=35,
            message=u"El nom de l'equip no pot tenir més de 35 caràcters")
    ])
    ipv4_address = StringField(u'Adreça IPv4', [
        validators.InputRequired(message=u"Heu d'introduir una adreça IPv4"),
        validators.IPAddress(ipv4=True,
                             ipv6=False,
                             message=u"Heu d'introduir una adreça IPv4 vàlida")
    ])
Esempio n. 19
0
class HostForm(Form):
    name = StringField('First Name', [
        validators.InputRequired(
            message=u"You must enter a name for the computer"),
        validators.Length(
            max=35,
            message=u"Your team name cannot be longer than 35 characters")
    ])
    ipv4_address = StringField(u'IPv4 address', [
        validators.InputRequired(message=u"You must enter an IPv4 address"),
        validators.IPAddress(ipv4=True,
                             ipv6=False,
                             message=u"You must enter a valid IPv4 address")
    ])
Esempio n. 20
0
class AddHostForm(Form):
    alias = fields.TextField('Alias', [validators.InputRequired()])
    ip = fields.TextField('Ip', [validators.IPAddress()])
    ip2 = fields.TextField('Ip2')
    port = fields.IntegerField('Port', [validators.InputRequired()])
    remote_user = fields.TextField('Remote User', [validators.InputRequired()])

    def validate_alias(form, field):
        results = [
            i.get('alias') for i in g.mysql_db.query('SELECT alias FROM hosts')
            if i
        ]
        if field.data in results:
            raise validators.ValidationError("{} is exists!".format(
                field.data))
Esempio n. 21
0
class BaseForm(Form):
    ipv4 = StringField('ipv4',
                       validators=[
                           validators.IPAddress(
                               ipv4=True,
                               ipv6=False,
                               message='That is a strange IPv4 address.')
                       ])

    prefixlen = IntegerField('prefixlen',
                             validators=[
                                 validators.NumberRange(
                                     min=2,
                                     max=32,
                                     message='Valid prefix range 2 - 32!')
                             ])
Esempio n. 22
0
class Form_SystemConfig_BridgeServer(Form):
    BRIDGE_SERVER_IP = StringField(
        'BRIDGE_SERVER_IP',
        validators=[
            validators.DataRequired(),
            validators.IPAddress(message='Invalid IPv4 address')
        ])
    BRIDGE_SERVER_PORT = IntegerField('BRIDGE_SERVER_PORT',
                                      validators=[
                                          validators.DataRequired(),
                                          validators.NumberRange(
                                              min=1,
                                              max=65535,
                                              message='Invalid port number')
                                      ])
    bs_save = SubmitField("Save")
Esempio n. 23
0
class Form_SystemConfig_FrontEnd(Form):
    FRONTEND_LISTEN_IP = StringField(
        'FRONTEND_LISTEN_IP',
        validators=[
            validators.DataRequired(),
            validators.IPAddress(message='IPv4 address')
        ])
    FRONTEND_LISTEN_PORT = IntegerField('FRONTEND_LISTEN_PORT',
                                        validators=[
                                            validators.DataRequired(),
                                            validators.NumberRange(
                                                min=1,
                                                max=65535,
                                                message='Invalid port number')
                                        ])
    fe_save = SubmitField("Save")
Esempio n. 24
0
class EditNetworkForm(Form):
    network_type = StringField(
        'Network Type',
        validators=[
            validators.required('Please provide a network type.'),
            ValidEnumType(NetworkTypeEnum,
                          'Please select a valid network type')
        ])
    network_name = StringField('Network Name',
                               validators=[ValidNetworkName(),
                                           ValidName()])
    network_ip = StringField('IP',
                             validators=[
                                 validators.Optional(strip_whitespace=True),
                                 validators.IPAddress(
                                     ipv4=True,
                                     ipv6=False,
                                     message='Please enter a valid IP Address')
                             ])
class DataForm(Form):
    test = SelectField(label="Select test:",
                       choices=[("IS-04-01", "IS-04-01: Node API"),
                                ("IS-05-01", "IS-05-01: ConnectionMgmt API")])
    ip = StringField(
        label="Ip:",
        validators=[
            validators.IPAddress(message="Please enter a valid IPv4 address.")
        ])
    port = IntegerField(
        label="Port:",
        validators=[
            validators.NumberRange(
                min=0,
                max=65535,
                message="Please enter a valid port number (0-65535).")
        ])
    version = SelectField(label="API Version:",
                          choices=[("v1.0", "v1.0"), ("v1.1", "v1.1"),
                                   ("v1.2", "v1.2")])
Esempio n. 26
0
class EndpointForm(Form):
    ip = StringField(
        label="IP:",
        validators=[
            validators.IPAddress(message="Please enter a valid IPv4 address."),
            validators.optional()
        ])
    port = IntegerField(label="Port:",
                        validators=[
                            validators.NumberRange(
                                min=0,
                                max=65535,
                                message="Please enter a valid port number "
                                "(0-65535)."),
                            validators.optional()
                        ])
    version = NonValidatingSelectField(label="API Version:",
                                       choices=[("v1.0", "v1.0"),
                                                ("v1.1", "v1.1"),
                                                ("v1.2", "v1.2"),
                                                ("v1.3", "v1.3")])
Esempio n. 27
0
class ServerMachineAddEditForm(Form):
    """Form for adding new server"""
    host_name = StringField(label='Host Name')
    host_ip = StringField(
        label='Host IP Address',
        validators=[validators.IPAddress(),
                    validators.DataRequired()])
    host_address = StringField(label='Host Address',
                               validators=[validators.DataRequired()])
    ssh_username = StringField(label='SSH Username',
                               validators=[validators.DataRequired()])
    ssh_password = PasswordField(
        label='SSH Password',
        validators=[validators.DataRequired()],
        widget=widgets.PasswordInput(hide_value=False))
    ssh_port = IntegerField(label='SSH Port',
                            validators=[validators.DataRequired()])
    db_username = StringField(label='Database System Username',
                              validators=[validators.DataRequired()])
    db_password = PasswordField(label='Database System Password',
                                validators=[validators.DataRequired()],
                                widget=widgets.PasswordInput(hide_value=False))
Esempio n. 28
0
class Form_IP_Add(Form):
    ipAdress = StringField('ipAdress', validators=[validators.DataRequired(),
                                                validators.Length(max=25, message='max 25 characters'),
                                                validators.IPAddress(message='Sorry, not a valid IP4 Address.')])
    
    hostName = StringField('hostName', validators=[validators.DataRequired(message='What is hostname?')])
    
    Owner = StringField('Owner', validators=[validators.DataRequired(message='Who is the owner?')])

    Owner = StringField('Owner', validators=[validators.DataRequired(message='Who is the owner?')])
    
    dateStart = DateField('dateStart', format='%d/%m/%Y')

# class Form_Service_Add(Form):
#     serviceName = StringField('serviceName', validators=[validators.DataRequired(),
#                                              validators.Length(max=25, message='max 25 characters')])
#     ipAddress = StringField('ipAddress', validators=[validators.DataRequired(),
#                                              validators.Length(max=25, message='max 25 characters')])
#     proto = StringField('proto', validators=[validators.DataRequired(),
#                                              validators.Length(max=25, message='max 25 characters')])
#     port = StringField('port', validators=[validators.DataRequired(),
#                                              validators.Length(max=25, message='max 25 characters')])
Esempio n. 29
0
class lgw_form(Form):
    router_name = StringField('Router Name:', [validators.InputRequired()])
    cube_capacity = IntegerField('Cube Capacity: ', [validators.InputRequired(), validators.NumberRange(min=1)]) 
    smart_token = StringField('Smart Token:')
    lic_bandwidth = IntegerField('Bandwidth Licence value (MB):', [validators.InputRequired()])
    dns = StringField('DNS Server(s):', [validators.InputRequired(), validators.IPAddress()])
    domain_name = StringField('Domain Name:', [validators.InputRequired()])
    interface = StringField('Router Interface:', [validators.InputRequired()])
    int_ip = StringField('Main Interface IP Address:', [validators.InputRequired()])
    int_subnet = StringField('Main Interface Subnet Mask:', [validators.InputRequired()])
    int_gateway = StringField('Default Route:', [validators.InputRequired()])
    username = StringField('Router Username:'******'Router Password:'******'NTP Server:', [validators.InputRequired()])
    password_encrypt = StringField('Config Key Password Encrypt:', [validators.InputRequired()])
    sip_networks = StringField('SIP Networks:', [validators.InputRequired()])
    webex_otg = StringField('Webex OTG:', [validators.InputRequired()])
    webex_domain = StringField('Webex Domain:', [validators.InputRequired()])
    webex_LGU = StringField('Webex LGU:', [validators.InputRequired()])
    webex_username = StringField('Webex Username:'******'Webex Password:'******'Webex Proxy:', [validators.InputRequired()])
    sip_sbcip= StringField('PSTN SBC IP Address:', [validators.InputRequired()])
Esempio n. 30
0
class SubnetForm(Form):
    ipv4 = StringField('ipv4',
                       validators=[
                           validators.IPAddress(
                               ipv4=True,
                               ipv6=False,
                               message='That is a strange IPv4 address.')
                       ])

    prefixlen = IntegerField('prefixlen',
                             validators=[
                                 validators.NumberRange(
                                     min=16,
                                     max=30,
                                     message='Valid prefix range 16 - 30!')
                             ])

    new_prefixlen = IntegerField(
        'prefixlen',
        validators=[
            validators.NumberRange(
                min=17, max=32, message='Valid child subnet range is 17 - 32!')
        ])