summaryrefslogtreecommitdiffstats
path: root/ogcp/forms/action_forms.py
blob: d8810656635525c027c390a8637178cdd66b36df (plain)
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
# Copyright (C) 2020-2021 Soleta Networks <info@soleta.eu>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the
# Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.

from wtforms import (
    Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField,
    StringField, RadioField, FormField, FieldList, DecimalField
)
from wtforms.validators import InputRequired
from flask_wtf import FlaskForm
from flask_babel import _

class WOLForm(FlaskForm):
    ips = HiddenField()
    wol_type = SelectField(label=_('Type'),
                           choices=[('broadcast', 'Broadcast'),
                                    ('unicast', 'Unicast')])
    submit = SubmitField(label=_('Submit'))

class PartitionForm(FlaskForm):
    partition = SelectField(label=_('Partition'),
                            choices=range(1,10))
    part_type = SelectField(label=_('Type'),
                            choices=[('LINUX', 'Linux'),
                                     ('NTFS', 'NTFS'),
                                     ('CACHE', 'CACHE'),
                                     ('EFI', 'EFI'),
                                     ('DATA', 'DATA'),
                                     ('LINUX-SWAP', 'LINUX-SWAP'),
                                     ('EXTENDED', 'EXTENDED'),
                                     ('FAT32', 'FAT32'),
                                     ('LINUX-LVM', 'LINUX-LVM'),
                                     ('LINUX-RAID', 'LINUX-RAID'),
                                     ('WIN-RECOV', 'WIN-RECOV'),
                                     ('HNTFS', 'HNTFS'),
                                     ('HFAT32', 'HFAT32'),
                                     ('HNTFS-WINRE', 'HNTFS-WINRE'),
                                     ('EMPTY', 'Empty')])
    fs = SelectField(label=_('Filesystem'),
                     choices=[('EXT4', 'EXT4'),
                              ('NTFS', 'NTFS'),
                              ('CACHE', 'CACHE'),
                              ('LINUX-SWAP', 'LINUX-SWAP'),
                              ('FAT32', 'FAT32'),
                              ('EXFAT', 'EXFAT'),
                              ('EMPTY', 'Empty')])
    size = IntegerField(label=_('Size (KB)'))
    format_partition = BooleanField(label=_('Format'))

class SetupForm(FlaskForm):
    ips = HiddenField()
    disk = HiddenField()
    disk_type = SelectField(label=_('Type'),
                            choices=[('MSDOS', 'MSDOS'),
                                     ('GPT', 'GPT')])
    partitions = FieldList(FormField(PartitionForm),
                           min_entries=1,
                           max_entries=10)

class HardwareForm(FlaskForm):
    ips = HiddenField()
    refresh = SubmitField(label=_('Refresh'))

class SoftwareForm(FlaskForm):
    ips = HiddenField()
    os = SelectField(label=_('Partition'), choices=[])
    view = SubmitField(label=_('View'))
    update = SubmitField(label=_('Update'))

class SessionForm(FlaskForm):
    ips = HiddenField()
    os = RadioField(label=_('Session'), choices=[])
    run = SubmitField(label=_('Run'))

class ImageRestoreForm(FlaskForm):
    ips = HiddenField()
    partition = SelectField(label=_('Partition'), choices=[])
    image = SelectField(label=_('Image'), choices=[])
    method = SelectField(label=_('Method'),
                         choices=[('UNICAST-CACHE', 'Unicast Cache'),
                                  ('UNICAST-DIRECT', 'Unicast Direct')])
    restore = SubmitField(label=_('Restore'))

class ClientDetailsForm(FlaskForm):
    name = StringField(label=_('Name'))
    ip = StringField(label=_('IP'))
    mac = StringField(label=_('MAC'))
    serial_number = StringField(label=_('Serial Number'))
    netmask = StringField(label=_('Netmask'))
    livedir = SelectField(label=_('ogLive'),
                          choices=[('ogLive', 'Default'),])
    remote = BooleanField(label=_('Remote'))
    maintenance = BooleanField(label=_('Maintenance'))
    netiface = SelectField(label=_('Interface'),
                           choices=[('eth0', 'eth0'),
                                    ('eth1', 'eth1'),
                                    ('eth2', 'eth2')])
    netdriver = SelectField(label=_('Driver'),
                            choices=[('generic', 'generic')])
    repo = SelectField(label=_('Repository'),
                       choices=[(1, 'Default')])
    room = SelectField(label=_('Room'))
    boot = SelectField(label=_('Boot Mode'))
    create = SubmitField(label=_('Create'))

class BootModeForm(FlaskForm):
    ips = HiddenField()
    boot = SelectField(label=_('Boot mode'))
    ok = SubmitField(label=_('Ok'))

class ImageCreateForm(FlaskForm):
    ip = HiddenField()
    os = SelectField(label=_('OS'), choices=[])
    name = StringField(label=_('Image name'),
                       validators=[InputRequired()])
    description = StringField(label=_('Description'))
    create = SubmitField(label=_('Create'))

class CenterForm(FlaskForm):
    name = StringField(label=_('Center name'),
                       validators=[InputRequired()])
    comment = StringField(label=_('Comment'))
    submit = SubmitField(label=_('Submit'))

class DeleteCenterForm(FlaskForm):
    center = SelectField(label=_('Center'),
                         validators=[InputRequired()])
    submit = SubmitField(label=_('Submit'))

class RoomForm(FlaskForm):
    center = SelectField(label=_('Center'),
                         validators=[InputRequired()])
    name = StringField(label=_('Room name'),
                       validators=[InputRequired()])
    netmask = StringField(label=_('Netmask'),
                          validators=[InputRequired()])
    submit = SubmitField(label=_('Submit'))

class DeleteRoomForm(FlaskForm):
    room = SelectField(label=_('Room'),
                       validators=[InputRequired()])
    submit = SubmitField(label=_('Submit'))

class ImageDetailsForm(FlaskForm):
    id = StringField(label=_('Id'))
    name = StringField(label=_('Name'))
    size = DecimalField(label=_('Size (GiB)'))
    datasize = DecimalField(label=_('Datasize (GiB)'))
    modified = StringField(label=_('Modified'))
    permissions = StringField(label=_('Permissions'))
    software_id = StringField(label=_('Software id'))