Exemplo n.º 1
0
    def form_pageForm(self, data):
        f = form.Form()

        ifaces = getNetInterfaces()
        for n in ifaces:
            print n
            f.addField(n,
                       form.String(required=True),
                       form.widgetFactory(form.SelectChoice,
                                          options=(
                                              ('Unused', 'Unused'),
                                              ('LAN', 'LAN'),
                                              ('WAN', 'WAN'),
                                              ('PPPoE', 'PPPoE'),
                                          )),
                       label=n.replace('eth', 'Port '))

            f.data[n] = 'Unused'

        f.data['eth0'] = 'LAN'
        f.data['eth1'] = 'WAN'

        f.addAction(self.next)

        return f
Exemplo n.º 2
0
 def gotServerGroups(server):
     servers = [(i[0], i[1]) for i in server]
     addMember.addField('server',
                        form.Integer(required=True),
                        form.widgetFactory(form.SelectChoice,
                                           options=servers),
                        label="Server")
     addMember.addAction(self.addServerMembership)
     return addMember
Exemplo n.º 3
0
 def gotServerGroups(doms):
     domains = [(i[0], i[1]) for i in doms]
     addMember.addField('domain',
                        form.Integer(required=True),
                        form.widgetFactory(form.SelectChoice,
                                           options=domains),
                        label="Domain")
     addMember.addAction(self.addDomainMembership)
     return addMember
Exemplo n.º 4
0
 def form_switchView(self, data):
     f = form.Form()
     f.addField('view',
                form.String(required=True),
                form.widgetFactory(form.SelectChoice,
                                   options=(('load', 'System Load'),
                                            ('latency', 'Latency'),
                                            ('mailq', 'Mail Queue'),
                                            ('internet',
                                             'Internet Traffic'),
                                            ('mailrate', 'Mail Rate'))),
                label="Change view")
     f.addAction(self.submitView)
     return f
Exemplo n.º 5
0
        def gotDisks(disks):
            print "HERE"
            print disks
            f = form.Form()
            myDisks = {}
            # Split on new lines, and remove the * that signifies bootable partitions
            for n in disks.replace('*','').split('\n'):
                if not n.strip():
                    continue
                parts = n.split()
                device = parts[0].strip('/dev/')

                cyls = int(parts[3].strip('-').strip('+'))

                myDisks[device] = cyls

            self.disks = []

            cnt = 0

            for dev, cyls in myDisks.items():
                cnt += 1 
                size = (int(cyls) * 8225280)/(1024*1024)
                self.disks.append(dev)

                f.addField(dev, form.String(),
                    form.widgetFactory(form.SelectChoice, 
                        options=(
                            ('/', '/'), 
                            ('/var', '/var'), 
                            ('/storage', '/storage')
                        )
                    ),
                    label = [tags.strong[dev], " (%sMB)" % size]
                )

                if cnt == 1:
                    f.data[dev] = '/'
                if cnt ==2:
                    f.data[dev] = '/var'
                if cnt ==3:
                    f.data[dev] = '/storage'

            # If more than one drive exists..
                
            f.addAction(self.nextSingle)
            
            return f
Exemplo n.º 6
0
        def gotServerGroups(server):
            servers = [(i[0], i[1]) for i in server]
            vlics.addField(
                'sidlink',
                form.Integer(required=True),
                form.widgetFactory(form.SelectChoice, options=servers),
                label="SID Link",
                description=
                "The entry we have created - this will bond the server to the ordering group"
            )

            vlics.addField('completed',
                           form.Boolean(),
                           label="Complete",
                           description="Tick to complete the order. ")

            vlics.addAction(self.vlicOrder)
            return vlics
Exemplo n.º 7
0
    def form_diskConfig(self, data):
        f = form.Form()

        f.addField('setup', form.String(),
            form.widgetFactory(form.RadioChoice, 
                options=(
                    ('raid1', 'RAID 1'),
                    ('noraid', 'Single device')
                )
            ),
            label = "Setup"
        )
        
        # If more than one drive exists..
        f.data['setup'] = 'raid1'

        f.addAction(self.next)
        return f
Exemplo n.º 8
0
    def form_pageForm(self, data):
        f = form.Form()

        f.addField('CompanyName', form.String(required=True), label = "Company Name")

        f.addField('ExternalName', form.String(required=True), label = "External Name", description = "Fully qualified hostname by which this server will be reachable")

        f.addField('Hostname', form.String(required=True), label = "Hostname", description = "The short hostname for this server")

        f.addField('Domain', form.String(required=True), label = "Domain", description = "The DNS domain for this server")

        f.addField('SambaDomain', form.String(), label = "Windows Domain", description = "The Windows domain this server will provide")


        fi = open('/home/installer/tzs')

        zones = []

        for i in fi:
            ln = i.strip('\n').strip('/')

            if ln:
                zones.append(ln)

        zones.sort()

        timezones = [(i,i) for i in zones]

        f.addField('timezone', form.String(required=True), form.widgetFactory(form.SelectChoice, options=timezones), label = "Timezone")

        f.data = {
            'CompanyName':'My Company',
            'ExternalName':'vulani-gw.yourdomain.co.za',
            'Hostname':'vulani',
            'Domain':'yourdomain.co.za',
            'SambaDomain': ''
        }

        f.addAction(self.next)

        return f
Exemplo n.º 9
0
    def form_vlic(self, data):
        vlics = form.Form()
        vlics.addField('name',
                       form.String(required=True),
                       label="Client Name",
                       description="Where this server will be installed")
        vlics.addField(
            'host',
            form.String(),
            label="Hostname",
            description="The external hostname this server will be reachable on"
        )

        vlics.addField('support',
                       form.String(required=True),
                       form.widgetFactory(form.SelectChoice,
                                          options=(
                                              ('none', 'No support'),
                                              ('standard',
                                               'Standard update protection'),
                                              ('silver', 'Silver SLA'),
                                              ('gold', 'Gold SLA'),
                                              ('platinum', 'Platinum SLA'),
                                          )),
                       description="Select a support option")

        vlics.addField(
            'terms',
            form.Boolean(required=True),
            label="Accept Terms and Conditions",
            description=[
                "Please read and accept the ",
                tags.
                a(href=
                  "http://www.vulani.net/sites/default/files/downloads/T&C.pdf"
                  )["Terms and Conditions"]
            ])

        vlics.addAction(self.vlicOrder)
        return vlics
Exemplo n.º 10
0
        def gotDisks(disks):
            f = form.Form()

            # Decide how many raid sets we can create from numbers of even partitions

            raidDisks = {}
            
            # Split on new lines, and remove the * that signifies bootable partitions
            for n in disks.replace('*','').split('\n'):
                if not n.strip():
                    continue
                parts = n.split()
                device = parts[0].strip('/dev/')
                cyls = int(parts[3].strip('-').strip('+'))
                raidDisks[device] = cyls

            # Find congruency 

            raidSets = {}

            used = []
            
            for k, v in raidDisks.items():
                if k in used:
                    continue 

                raidSets[k] = [k]

                used.append(k)

                # one partition per drive only
                usedHere = [k[:-1]]

                for otherk, otherv in raidDisks.items():
                    # Never check disks twice
                    if otherk in used:
                        # Already got this
                        continue

                    if otherk[:-1] in usedHere:
                        # Make sure we only check different drives
                        continue

                    if otherv == v:
                        # Same size
                        raidSets[k].append(otherk)
                        used.append(otherk)
                        usedHere.append(otherk[:-1])

            print raidSets

            sets = [v for k,v in raidSets.items()]

            self.raidSets = {}

            for raidNum, set in enumerate(sets):
                size = (int(raidDisks[set[0]]) * 8225280)/(1024*1024)

                # Store it.
                self.raidSets["md%s" % raidNum] = set

                f.addField('md%s' % raidNum, form.String(),
                    form.widgetFactory(form.SelectChoice, 
                        options=(
                            ('/', '/'), 
                            ('/var', '/var'), 
                            ('/storage', '/storage')
                        )
                    ),
                    label = [tags.strong["md%s" % (raidNum)], " (%sMB)" % size]
                )

            f.data = {
                'md0': '/',
                'md1': '/var',
                'md2': '/storage',
            }
 
            # If more than one drive exists..
                
            f.addAction(self.next)
            
            # Time to find some disks

            return f
Exemplo n.º 11
0
        def renderForm(user):
            self.user = user
            domains = ['asd.co.za']
            username = self.user[3]
            domain = self.user[2]

            u_form = formal.Form(
                self.submitForm
            )[formal.Group('userSettings')[tags.div(_class="field")[
                tags.label[self.text.userFormLabelEmailAddress],
                tags.div(id="emailAd", _class="inputs")["%s@%s" %
                                                        (username, domain)]],
                                           formal.Field('uid',
                                                        formal.String(
                                                            required=True),
                                                        label=self.text.
                                                        userFormLabelUsername),
                                           formal.Field('givenName',
                                                        formal.String(
                                                            required=True),
                                                        label=self.text.
                                                        userFormLabelName),
                                           formal.Field('sn',
                                                        formal.String(),
                                                        label=self.text.
                                                        userFormLabelSurname),
                                           formal.Field('userPassword',
                                                        formal.String(),
                                                        formal.CheckedPassword,
                                                        label=self.text.
                                                        userFormLabelPass), ],
              formal.Group('mailSettings')
              [formal.Field('mailForwardingAddress0',
                            formal.String(),
                            label=self.text.userFormLabelForward),
               formal.
               Field('mailForwardingAddress1', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress2', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress3', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress4', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress5', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress6', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress7', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress8', formal.String(), label=""),
               formal.
               Field('mailForwardingAddress9', formal.String(), label=""),
               tags.div(
                   _class="userLine")[tags.a(href="#", onclick="addForward();")
                                      [self.text.userFormLabelAddline]],
               formal.Field('mailAlternateAddress0',
                            formal.String(),
                            label=self.text.userFormLabelAlias),
               formal.Field('mailAlternateAddress1', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress2', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress3', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress4', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress5', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress6', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress7', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress8', formal.String(), label=""
                            ),
               formal.Field('mailAlternateAddress9', formal.String(), label=""
                            ),
               tags.div(
                   _class="userLine")[tags.a(href="#", onclick="addAlias();")[
                       self.text.userFormLabelAddline]],
               formal.Field('vacen',
                            formal.Boolean(),
                            label=self.text.userFormLabelVacationActive,
                            description=self.text.userFormTextVacationNote),
               formal.Field('vacation',
                            formal.String(),
                            formal.TextArea,
                            label=self.text.userFormLabelVacation), ],
              formal.Group('userPermissions')
              [formal.Field('employeeType',
                            formal.Boolean(),
                            label=self.text.userFormLabelWeb),
               formal.Field('accountStatus',
                            formal.Boolean(),
                            label=self.text.userFormLabelEmail),
               formal.Field('tumsAdmin',
                            formal.Boolean(),
                            label=self.text.userFormLabelAdmin),
               formal.Field(
                   'tumsUser', formal.Sequence(formal.String()),
                   formal.widgetFactory(formal.CheckboxMultiChoice,
                                        [(i, i) for i in domains])),
               formal.Field('tumsReports',
                            formal.Boolean(),
                            label=self.text.userFormLabelReports),
               #      formal.Field('copyto', formal.String(), label = self.text.userFormLabelCopy,
               #          description = self.text.userFormTextCopy)
               ],
              #  formal.Group('userAccess')[
              #      formal.Field('vpnEnabled', formal.Boolean(), label = self.text.userFormLabelVPN,
              #          description = self.text.userFormTextVPN),
              #      formal.Field('ftpEnabled', formal.Boolean(), label = self.text.userFormLabelFTP,
              #          description = self.text.userFormTextFTP),
              #      formal.Field('ftpGlobal', formal.Boolean(), label = self.text.userFormLabelGlobalFTP,
              #          description = self.text.userFormTextGlobal)
              #  ]
              ]

            u_form.addAction(self.submitForm)

            u_form.data['userSettings.uid'] = self.user[3]
            u_form.data['userSettings.givenName'] = self.user[4]
            u_form.data['userSettings.sn'] = self.user[5]

            u_form.data['userPermissions.employeeType'] = "squid" in self.user[
                9]
            u_form.data['userPermissions.tumsUser'] = []
            u_form.data[
                'userPermissions.accountStatus'] = "active" in self.user[10]
            u_form.data[
                'userPermissions.tumsAdmin'] = "tumsAdmin" in self.user[9]
            u_form.data['userPermissions.tumsReports'] = "Repor" in self.user[
                9]

            u_form.data['mailSettings.vacen'] = self.user[20] == 1
            u_form.data['mailSettings.vacation'] = self.user[19]

            return u_form