def form_confirm_installation(self, ctx): form = formal.Form() sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('confirm', formal.String(), label='Start installation')) sg.add( formalutils.SubmitField('reselect', formal.String(), label='Back')) sg.add( formalutils.SubmitField('cancel', formal.String(), label='Cancel')) form.add(sg) form.addAction(self.submitted_confirm_installation, name='confirm', label='Start installation', validate=False) form.addAction(self.submitted_reselect, name='reselect', label='Back', validate=False) form.addAction(self.submitted_cancel_installation, name='cancel', label='Cancel', validate=False) return form
def form_start_install(self, ctx): lbl = 'I have read and accept the License Agreement and the Privacy Policy' form = formal.Form() g = formalutils.CollapsibleGroup( 'startinstall', label='License Agreement and Privacy Policy') g.setCollapsed(False) g.add( formal.Field('acceptlicense', formal.Boolean(required=True), label=lbl)) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('startinstallation', formal.String(), label='Next')) g.add(sg) form.add(g) form.addAction(self.submitted_start_install, name='startinstallation', label='Next', validate=False) form.data['startinstall.acceptlicense'] = False return form
def form_changepassword(self, ctx): form = formal.Form() g = formalutils.CollapsibleGroup('changepassword', label='Change Password') g.setCollapsed(False) g.add( formal.Field('pw1', formal.String(required=True), formal.widgetFactory(formalutils.HiddenPassword), label='Old password')) g.add( formal.Field('pw2', formal.String(required=True), formal.widgetFactory(formalutils.HiddenPassword), label='New password')) g.add( formal.Field('pw3', formal.String(required=True), formal.widgetFactory(formalutils.HiddenPassword), label='New password (again)')) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('changepassword', formal.String(), label='Change password')) g.add(sg) form.add(g) form.addAction(self.submitted, name='changepassword', validate=False) return form
def form_config(self, ctx): form = formal.Form() g = self.create_radius_group(ctx, form) form.add(g) try: self.fill_radius_group(ctx, form, g) except: _log.exception('failed to fill radius group, skipping') g = self.create_users_group(ctx, form) form.add(g) try: self.fill_users_group(ctx, form, g) except: _log.exception('failed to fill users group, skipping') sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit', formal.String(), label='Save changes')) form.add(sg) form.addAction(self.submitted, name='submit', validate=False) return form
def form_config(self, ctx): form = formal.Form() form.add(self.create_debug_group(form, ctx)) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit', formal.String(), label='Save changes')) form.add(sg) form.addAction(self.submitted, name='submit', validate=False) return form
def form_controls(self, ctx): form = formal.Form() g = formal.Group('debug_controls', 'Debug controls') sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit1', formal.String(), label='Start runner')) sg.add( formalutils.SubmitField('submit2', formal.String(), label='Stop runner')) g.add(sg) form.add(g) form.addAction(self.submitted_startrunner, name='submit1', validate=False) form.addAction(self.submitted_stoprunner, name='submit2', validate=False) return form
def form_updatebutton(self, ctx): form = formal.Form() sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submitupdate', formal.String(), label='Update product (causes reboot)')) form.add(sg) form.addAction(self.submitted_update, name='submitupdate', validate=False) return form
def form_buttons(self, ctx): form = formal.Form() sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submitdiagexport', formal.String(), label='Export diagnostics')) form.add(sg) form.addAction(self.submitted_diagexport, name='submitdiagexport', validate=False) return form
def form_buttons(self, ctx): form = formal.Form() sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submitshutdown', formal.String(), label='Shut down')) form.add(sg) form.addAction(self.submitted_shutdown, name='submitshutdown', validate=False) return form
def form_rescan_targets(self, ctx): form = formal.Form() sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('rescan', formal.String(), label='Rescan targets')) form.add(sg) form.addAction(self.submitted_rescan, name='rescan', label='Rescan targets', validate=False) return form
def form_reboot_computer(self, ctx): form = formal.Form() sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('reboot', formal.String(), label='Reboot computer')) form.add(sg) form.addAction(self.submitted_reboot_computer, name='reboot', label='Reboot computer', validate=False) return form
def form_config(self, ctx): form = formal.Form() g = self.create_s2s_list(form, ctx) form.add(g) try: self.fill_s2s_list(form, ctx, g) except: _log.exception('cannot fill data for s2s connections, skipping') sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit', formal.String(), label='Save changes')) form.add(sg) form.addAction(self.submitted, name='submit', validate=False) return form
def form_config(self, ctx): form = formal.Form() dr = self.create_default_route_group(form, ctx) ar = self.create_additional_routes_group(form, ctx) sr = self.create_source_routing_group(form, ctx) fw = self.create_firewall_group(form, ctx) fwrule = self.create_ppp_firewall_group(form, ctx) pf = self.create_port_forwarding_group(form, ctx) form.add(dr) form.add(ar) form.add(sr) form.add(fwrule) form.add(fw) form.add(pf) try: toplevel_fda = formalutils.FormDataAccessor(form, [], ctx) self.fill_routing_group(form, ctx, toplevel_fda) except: _log.exception('failed to fill in form data, ignoring') try: fw_fda = formalutils.FormDataAccessor(form, ['firewall'], ctx) self.fill_firewall_group(form, ctx, fw_fda) except: _log.exception('failed to fill in form data, ignoring') try: pf_fda = formalutils.FormDataAccessor(form, ['port_forwards'], ctx) self.fill_port_forwarding_group(form, ctx, pf_fda) except: _log.exception('failed to fill in form data, ignoring') sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit', formal.String(), label='Save changes')) form.add(sg) form.addAction(self.submitted, name='submit', validate=False) return form
def form_buttons(self, ctx): form = formal.Form() g = formalutils.CollapsibleGroup('import', label='Import Configuration') g.setCollapsed(False) # makes no sense to collapse really g.add( formalutils.Field('importfile', formal.File(required=False), label='File to import')) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submitconfigimport', formal.String(), label='Import configuration')) g.add(sg) form.add(g) form.addAction(self.submitted_configimport, name='submitconfigimport', validate=False) return form
def form_config(self, ctx): form = formal.Form() ifcount = self.create_iface_count_group(form, ctx) pubif = self.create_internet_connection_group(form, ctx) privif = self.create_private_network_group(form, ctx) dns = self.create_dns_group(form, ctx) dyndns = self.create_dynamic_dns_group(form, ctx) client = self.create_client_connection_group(form, ctx) form.add(ifcount) form.add(pubif) form.add(privif) form.add(dns) form.add(dyndns) form.add(client) try: # XXX: this data filler is one unit because ifcount, pubif, privif, dns, and dyndns # were previously part of one group fda = formalutils.FormDataAccessor(form, [], ctx) self.fill_network_config(form, ctx, fda) except: _log.exception('failed to fill in form data, ignoring') try: cc_fda = formalutils.FormDataAccessor(form, ['client_connection'], ctx) self.fill_client_connection_group(form, ctx, cc_fda) except: _log.exception('failed to fill in form data, ignoring') sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit', formal.String(), label='Save changes')) form.add(sg) form.addAction(self.submitted, name='submit', validate=False) return form
def form_select_target(self, ctx): form = formal.Form() g = formalutils.CollapsibleGroup('selecttarget', label='Installation Targets') g.setCollapsed(False) targets = [] for m in self._get_disks(): errors = [] if m.get_size() < constants.DISK_SIZE_MINIMUM: errors.append('device too small') if m.is_write_protected(): errors.append('write-protected') if errors: errorstr = ' [' + (', '.join(errors)) + ']' else: errorstr = '' devname = m.get_device() devstring = '%s %s (%s) %s' % (m.get_size_pretty(), m.get_human_readable_description(), m.get_device(), errorstr) targets.append((devname, devstring)) def _target_cmp(x, y): x_dev, x_info = x y_dev, y_info = y return unicode.__cmp__(unicode(x_dev), unicode(y_dev)) targets.sort(cmp=_target_cmp) # XXX: we can't currently disable individual radiobuttons in Formal. # We thus leave them enabled, and check for device size below. This # is unfortunate, but better than not showing small devices at all lbl = 'Target device' g.add( formal.Field('target', formal.String(required=True), formal.widgetFactory(formal.RadioChoice, options=targets), label=lbl)) g.add( formal.Field('recovery', formal.Boolean(required=False), label='Attempt recovery')) sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('selecttarget', formal.String(), label='Next')) sg.add( formalutils.SubmitField('rescan', formal.String(), label='Rescan')) sg.add( formalutils.SubmitField('cancel', formal.String(), label='Cancel')) g.add(sg) form.add(g) form.addAction(self.submitted_select_target, name='selecttarget', label='Next', validate=False) form.addAction(self.submitted_rescan, name='rescan', label='Rescan', validate=False) form.addAction(self.submitted_cancel_installation, name='cancel', label='Cancel', validate=False) # set previous selection if exists as default value cfg = livecddb.get_livecd_database_root() if cfg.hasS(ns_ui.targetDevice): form.data['selecttarget.target'] = cfg.getS( ns_ui.targetDevice, rdf.String) if cfg.hasS(ns_ui.attemptRecovery): form.data['selecttarget.recovery'] = cfg.getS( ns_ui.attemptRecovery, rdf.Boolean) return form
def form_management(self, ctx): form = formal.Form() fda = formalutils.FormDataAccessor(form, [], ctx) tzhelp = uihelpers.TimezoneHelper() txt = self.mng_uitexts ### License g = formalutils.CollapsibleGroup('license_group', label=txt.license_group_caption) g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseLicense)) g.add( formalutils.Field('license_key', formal.String(required=False), label=txt.license_key_label)) form.add(g) ### Locale tzoptions = [] for tzname in tzhelp.get_timezones(): tzoptions.append((tzname, tzname)) def _tz_cmp(x, y): x_name, x_label = x y_name, y_label = y return unicode.__cmp__(unicode(x_label), unicode(y_label)) tzoptions.sort(cmp=_tz_cmp) # XXX: keymap values are truncated because they are so long keymapoptions = [] for gname, gname_escaped, human in gnomeconfig.get_keymap_list(): keymapoptions.append( (gname_escaped, uihelpers.ui_truncate(human, 56))) def _km_cmp(x, y): x_name, x_label = x y_name, y_label = y return unicode.__cmp__(unicode(x_label), unicode(y_label)) keymapoptions.sort(cmp=_km_cmp) g = formalutils.CollapsibleGroup('locale_group', label='Locale Settings') g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseLocale)) g.add( formalutils.Field('timezone', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options=tzoptions), label='Timezone')) g.add( formalutils.Field('keymap', formal.String(required=True), formal.widgetFactory(formal.SelectChoice, options=keymapoptions), label='Keyboard layout')) # XXX: it would be good if we could show a time example using the timezone # admin has selected. form.add(g) ### Reboots g = formalutils.CollapsibleGroup('reboot_group', label=txt.reboot_group_caption) g.setCollapsed( uihelpers.collapse_setting(ns_ui.collapseProductMaintenance)) g.add( formalutils.Field('reboot_day', formal.Integer(required=True), formal.widgetFactory( formal.SelectChoice, options=txt.reboot_day_options), label=txt.reboot_day_label)) g.add( formalutils.Field('reboot_time', formal.Integer(required=True), formal.widgetFactory( formal.SelectChoice, options=txt.reboot_time_options), label=txt.reboot_time_label)) # Information about the periodic reboot consequences (about 5 minutes downtime). g.add( formalutils.Field('automatic_updates', formal.Boolean(required=True), label=txt.automatic_update_label)) form.add(g) ### SNMP g = formalutils.CollapsibleGroup('snmp_group', label='SNMP Monitoring') g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseSnmp)) g.add( uihelpers.create_access_control_dropdown('snmp_access', 'SNMP read-only access')) g.add( formalutils.Field('snmp_community', formal.String(required=False), formal.widgetFactory( formalutils.SemiHiddenPassword), label='SNMP community string (password)')) form.add(g) ### Remote management g = formalutils.CollapsibleGroup('remote_group', label=txt.remote_group_caption) g.setCollapsed( uihelpers.collapse_setting(ns_ui.collapseRemoteManagement)) g.add( uihelpers.create_access_control_dropdown('www_administration', 'Web administration')) g.add( uihelpers.create_access_control_dropdown('ssh_connection', 'SSH connection')) g.add( formalutils.Field('root_password1', formal.String(required=False), formal.widgetFactory(formalutils.HiddenPassword), label='Set root password')) g.add( formalutils.Field('root_password2', formal.String(required=False), formal.widgetFactory(formalutils.HiddenPassword), label='Re-enter root password')) form.add(g) ### Admin e-mails # XXX: not yet implemented #g = formalutils.CollapsibleGroup('email_group', label='Administrator E-mail') #g.setCollapsed(uihelpers.collapse_setting(ns_ui.collapseAdminEmail)) #g.add(formalutils.Field('smtp_server', formal.String(required=False), label='SMTP server')) #g.add(formalutils.Field('smtp_from', formal.String(required=False), label='FROM address')) #g.add(formalutils.Field('smtp_to', formal.String(required=False), label='TO address(es) (comma separated)')) #form.add(g) ### SSL certificate g = formalutils.CollapsibleGroup('ssl_group', label='SSL Certificate') g.setCollapsed(uihelpers.collapse_setting( ns_ui.collapseSslCertificate)) g.add( formalutils.Field( 'ssl_certificate_chain', formal.String(required=False), formal.widgetFactory(formal.TextArea, cols=80, rows=10), label= 'SSL Certificate Chain (PEM format, server certificate first)') ) g.add( formalutils.Field('ssl_private_key', formal.String(required=False), formal.widgetFactory(formal.TextArea, cols=80, rows=10), label='SSL Private Key (PEM format)')) form.add(g) ### Submit buttons sg = formalutils.SubmitFieldGroup('buttons') sg.add( formalutils.SubmitField('submit', formal.String(), label='Save changes')) form.add(sg) form.addAction(self.submitted, name='submit', validate=False) ### Fill data to form try: self.fill_management(ctx, fda) except: # ignore failure so user has chance to edit the form _log.exception('fill_form_data failed, ignoring') return form