def get_pool_details_page(self, screen): fields = [] if self.__config.needs_target_path(): self.__target_path = Entry(50, self.__config.get_target_path()) fields.append(("Target Path", self.__target_path)) if self.__config.needs_format(): formats = [] for fmt in self.__config.get_formats(): formats.append([fmt, fmt, fmt is self.__config.get_format()]) self.__formats = RadioBar(screen, formats) fields.append(("Format", self.__formats)) if self.__config.needs_hostname(): self.__hostname = Entry(50, self.__config.get_hostname()) fields.append(("Host Name", self.__hostname)) if self.__config.needs_source_path(): self.__source_path = Entry(50, self.__config.get_source_path()) fields.append(("Source Path", self.__source_path)) if self.__config.needs_build_pool(): self.__build_pool = Checkbox("Build Pool", self.__config.get_build_pool()) fields.append((None, self.__build_pool)) return [ Label("Add Storage Pool"), Label(HELPER_TEXT), self.create_grid_from_fields(fields) ]
def form(self): elements = Grid(2, 8) is_network_up = network_up() if is_network_up: header_message = "oVirt Engine Configuration" else: header_message = "Network Down, oVirt Engine Configuration Disabled" heading = Label(header_message) self.ncs.screen.setColor(customColorset(1), "black", "magenta") heading.setColors(customColorset(1)) elements.setField(heading, 0, 0, anchorLeft = 1) rhevm_grid = Grid(2,2) rhevm_grid.setField(Label("Management Server:"), 0, 0, anchorLeft = 1) self.rhevm_server = Entry(25, "") self.rhevm_server.setCallback(self.valid_rhevm_server_callback) rhevm_grid.setField(Label("Management Server Port:"), 0, 1, anchorLeft = 1) self.rhevm_server_port = Entry(6, "", scroll = 0) self.rhevm_server_port.setCallback(self.valid_rhevm_server_port_callback) rhevm_grid.setField(self.rhevm_server, 1, 0, anchorLeft = 1, padding=(2, 0, 0, 1)) rhevm_grid.setField(self.rhevm_server_port, 1, 1, anchorLeft = 1, padding=(2, 0, 0, 1)) elements.setField(rhevm_grid, 0, 1, anchorLeft = 1, padding = (0,0,0,0)) elements.setField(Label(""), 0, 2, anchorLeft = 1) self.verify_rhevm_cert = Checkbox("Connect to oVirt Engine and Validate Certificate", isOn=True) elements.setField(self.verify_rhevm_cert, 0, 3, anchorLeft = 1, padding = (0,0,0,0)) elements.setField(Label(""), 0, 4, anchorLeft = 1) elements.setField(Label("Set oVirt Engine Admin Password"), 0, 5, anchorLeft = 1) pw_elements = Grid(3,3) pw_elements.setField(Label("Password: "******"Confirm Password: "******"", wrap=1) elements.setField(pw_elements, 0, 6, anchorLeft=1) elements.setField(self.pw_msg, 0, 7, padding = (0,0,0,0)) inputFields = [self.rhevm_server, self.rhevm_server_port, self.verify_rhevm_cert, self.root_password_1, self.root_password_2] if not is_network_up: for field in inputFields: field.setFlags(FLAG_DISABLED, FLAGS_SET) try: rhevm_server = get_rhevm_config() rhevm_server,rhevm_port = rhevm_server.split(":") if rhevm_server.startswith("None"): self.rhevm_server.set("") else: self.rhevm_server.set(rhevm_server) self.rhevm_server_port.set(rhevm_port) except: pass return [Label(""), elements]
def get_confirm_page(self, screen): ignore = screen network = self.get_selected_network() self.__confirm_remove = Checkbox("Check here to confirm undefining %s." % network.get_name()) fields = [] fields.append((self.__confirm_remove, None)) return [self.create_grid_from_fields(fields)]
def get_confirm_page(self, screen): ignore = screen self.__confirm = Checkbox("Check here to confirm deleting pool: %s" % self.get_selected_pool()) fields = [] fields.append((None, self.__confirm)) return [ Label("Remove Selected Storage Pool"), self.create_grid_from_fields(fields) ]
def form(self): elements = Grid(2, 8) is_network_up = network_up() if is_network_up: header_message = "RHEV-M Configuration" else: header_message = "Network Down, RHEV-M Configuration Disabled" heading = Label(header_message) self.ncs.screen.setColor(customColorset(1), "black", "magenta") heading.setColors(customColorset(1)) elements.setField(heading, 0, 0, anchorLeft=1) rhevm_grid = Grid(2, 2) rhevm_grid.setField(Label("Management Server:"), 0, 0, anchorLeft=1) self.rhevm_server = Entry(25, "") self.rhevm_server.setCallback(self.valid_rhevm_server_callback) rhevm_grid.setField(Label("Management Server Port:"), 0, 1, anchorLeft=1) self.rhevm_server_port = Entry(6, "", scroll=0) self.rhevm_server_port.setCallback( self.valid_rhevm_server_port_callback) rhevm_grid.setField(self.rhevm_server, 1, 0, anchorLeft=1, padding=(2, 0, 0, 1)) rhevm_grid.setField(self.rhevm_server_port, 1, 1, anchorLeft=1, padding=(2, 0, 0, 1)) elements.setField(rhevm_grid, 0, 1, anchorLeft=1, padding=(0, 0, 0, 0)) elements.setField(Label(""), 0, 2, anchorLeft=1) self.verify_rhevm_cert = Checkbox( "Connect to RHEV Manager and Validate Certificate", isOn=True) elements.setField(self.verify_rhevm_cert, 0, 3, anchorLeft=1, padding=(0, 0, 0, 0)) elements.setField(Label(""), 0, 4, anchorLeft=1) elements.setField(Label("Set RHEV-M Admin Password"), 0, 5, anchorLeft=1) pw_elements = Grid(3, 3) pw_elements.setField(Label("Password: "******"Confirm Password: "******"", wrap=1) elements.setField(pw_elements, 0, 6, anchorLeft=1) elements.setField(self.pw_msg, 0, 7, padding=(0, 0, 0, 0)) inputFields = [ self.rhevm_server, self.rhevm_server_port, self.verify_rhevm_cert, self.root_password_1, self.root_password_2 ] if not is_network_up: for field in inputFields: field.setFlags(FLAG_DISABLED, FLAGS_SET) try: rhevm_server = get_rhevm_config() rhevm_server, rhevm_port = rhevm_server.split(":") if rhevm_server.startswith("None"): self.rhevm_server.set("") else: self.rhevm_server.set(rhevm_server) self.rhevm_server_port.set(rhevm_port) except: pass return [Label(""), elements]
class Plugin(PluginBase): """Plugin for RHEV-M configuration. """ def __init__(self, ncs): PluginBase.__init__(self, "RHEV-M", ncs) def form(self): elements = Grid(2, 8) is_network_up = network_up() if is_network_up: header_message = "RHEV-M Configuration" else: header_message = "Network Down, RHEV-M Configuration Disabled" heading = Label(header_message) self.ncs.screen.setColor(customColorset(1), "black", "magenta") heading.setColors(customColorset(1)) elements.setField(heading, 0, 0, anchorLeft=1) rhevm_grid = Grid(2, 2) rhevm_grid.setField(Label("Management Server:"), 0, 0, anchorLeft=1) self.rhevm_server = Entry(25, "") self.rhevm_server.setCallback(self.valid_rhevm_server_callback) rhevm_grid.setField(Label("Management Server Port:"), 0, 1, anchorLeft=1) self.rhevm_server_port = Entry(6, "", scroll=0) self.rhevm_server_port.setCallback( self.valid_rhevm_server_port_callback) rhevm_grid.setField(self.rhevm_server, 1, 0, anchorLeft=1, padding=(2, 0, 0, 1)) rhevm_grid.setField(self.rhevm_server_port, 1, 1, anchorLeft=1, padding=(2, 0, 0, 1)) elements.setField(rhevm_grid, 0, 1, anchorLeft=1, padding=(0, 0, 0, 0)) elements.setField(Label(""), 0, 2, anchorLeft=1) self.verify_rhevm_cert = Checkbox( "Connect to RHEV Manager and Validate Certificate", isOn=True) elements.setField(self.verify_rhevm_cert, 0, 3, anchorLeft=1, padding=(0, 0, 0, 0)) elements.setField(Label(""), 0, 4, anchorLeft=1) elements.setField(Label("Set RHEV-M Admin Password"), 0, 5, anchorLeft=1) pw_elements = Grid(3, 3) pw_elements.setField(Label("Password: "******"Confirm Password: "******"", wrap=1) elements.setField(pw_elements, 0, 6, anchorLeft=1) elements.setField(self.pw_msg, 0, 7, padding=(0, 0, 0, 0)) inputFields = [ self.rhevm_server, self.rhevm_server_port, self.verify_rhevm_cert, self.root_password_1, self.root_password_2 ] if not is_network_up: for field in inputFields: field.setFlags(FLAG_DISABLED, FLAGS_SET) try: rhevm_server = get_rhevm_config() rhevm_server, rhevm_port = rhevm_server.split(":") if rhevm_server.startswith("None"): self.rhevm_server.set("") else: self.rhevm_server.set(rhevm_server) self.rhevm_server_port.set(rhevm_port) except: pass return [Label(""), elements] def password_check_callback(self): resp, msg = password_check(self.root_password_1.value(), self.root_password_2.value()) self.pw_msg.setText(msg) return def action(self): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") if self.root_password_1.value() != "" and self.root_password_2.value( ) != "" and self.root_password_1.value() == self.root_password_2.value( ): set_password(self.root_password_1.value(), "root") augtool("set", "/files/etc/ssh/sshd_config/PasswordAuthentication", "yes") dn = file('/dev/null', 'w+') subprocess.Popen(['/sbin/service', 'sshd', 'restart'], stdout=dn, stderr=dn) if len(self.rhevm_server.value()) > 0: deployUtil.nodeCleanup() if self.verify_rhevm_cert.selected(): if deployUtil.getRhevmCert(self.rhevm_server.value(), self.rhevm_server_port.value()): path, dontCare = deployUtil.certPaths('') fp = deployUtil.generateFingerPrint(path) approval = ButtonChoiceWindow( self.ncs.screen, "Certificate Fingerprint:", fp, buttons=['Approve', 'Reject']) if 'reject' == approval: ButtonChoiceWindow(self.ncs.screen, "Fingerprint rejected", "RHEV-M Configuration Failed", buttons=['Ok']) return False else: ovirt_store_config(path) self.ncs.reset_screen_colors() else: ButtonChoiceWindow(self.ncs.screen, "RHEV-M Configuration", "Failed downloading RHEV-M certificate", buttons=['Ok']) self.ncs.reset_screen_colors() # Stopping vdsm-reg may fail but its ok - its in the case when the menus are run after installation deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'stop']) if write_vdsm_config(self.rhevm_server.value(), self.rhevm_server_port.value()): deployUtil._logExec( [constants.EXT_SERVICE, 'vdsm-reg', 'start']) ButtonChoiceWindow(self.ncs.screen, "RHEV-M Configuration", "RHEV-M Configuration Successfully Updated", buttons=['Ok']) self.ncs.reset_screen_colors() return True else: ButtonChoiceWindow(self.ncs.screen, "RHEV-M Configuration", "RHEV-M Configuration Failed", buttons=['Ok']) self.ncs.reset_screen_colors() return False def valid_rhevm_server_callback(self): if not is_valid_host_or_ip(self.rhevm_server.value()): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") ButtonChoiceWindow(self.ncs.screen, "Configuration Check", "Invalid RHEV-M Hostname or Address", buttons=['Ok']) self.ncs.reset_screen_colors() def valid_rhevm_server_port_callback(self): if not is_valid_port(self.rhevm_server_port.value()): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") ButtonChoiceWindow(self.ncs.screen, "Configuration Check", "Invalid RHEV-M Server Port", buttons=['Ok']) self.ncs.reset_screen_colors()
def __init__(self, name, default, display_name=None): self.name = name self.display_name = display_name or name Checkbox.__init__(self, "%s" % self.display_name, int(default))
class Plugin(PluginBase): """Plugin for oVirt Engine configuration. """ def __init__(self, ncs): PluginBase.__init__(self, "oVirt Engine", ncs) def form(self): elements = Grid(2, 8) is_network_up = network_up() if is_network_up: header_message = "oVirt Engine Configuration" else: header_message = "Network Down, oVirt Engine Configuration Disabled" heading = Label(header_message) self.ncs.screen.setColor(customColorset(1), "black", "magenta") heading.setColors(customColorset(1)) elements.setField(heading, 0, 0, anchorLeft = 1) rhevm_grid = Grid(2,2) rhevm_grid.setField(Label("Management Server:"), 0, 0, anchorLeft = 1) self.rhevm_server = Entry(25, "") self.rhevm_server.setCallback(self.valid_rhevm_server_callback) rhevm_grid.setField(Label("Management Server Port:"), 0, 1, anchorLeft = 1) self.rhevm_server_port = Entry(6, "", scroll = 0) self.rhevm_server_port.setCallback(self.valid_rhevm_server_port_callback) rhevm_grid.setField(self.rhevm_server, 1, 0, anchorLeft = 1, padding=(2, 0, 0, 1)) rhevm_grid.setField(self.rhevm_server_port, 1, 1, anchorLeft = 1, padding=(2, 0, 0, 1)) elements.setField(rhevm_grid, 0, 1, anchorLeft = 1, padding = (0,0,0,0)) elements.setField(Label(""), 0, 2, anchorLeft = 1) self.verify_rhevm_cert = Checkbox("Connect to oVirt Engine and Validate Certificate", isOn=True) elements.setField(self.verify_rhevm_cert, 0, 3, anchorLeft = 1, padding = (0,0,0,0)) elements.setField(Label(""), 0, 4, anchorLeft = 1) elements.setField(Label("Set oVirt Engine Admin Password"), 0, 5, anchorLeft = 1) pw_elements = Grid(3,3) pw_elements.setField(Label("Password: "******"Confirm Password: "******"", wrap=1) elements.setField(pw_elements, 0, 6, anchorLeft=1) elements.setField(self.pw_msg, 0, 7, padding = (0,0,0,0)) inputFields = [self.rhevm_server, self.rhevm_server_port, self.verify_rhevm_cert, self.root_password_1, self.root_password_2] if not is_network_up: for field in inputFields: field.setFlags(FLAG_DISABLED, FLAGS_SET) try: rhevm_server = get_rhevm_config() rhevm_server,rhevm_port = rhevm_server.split(":") if rhevm_server.startswith("None"): self.rhevm_server.set("") else: self.rhevm_server.set(rhevm_server) self.rhevm_server_port.set(rhevm_port) except: pass return [Label(""), elements] def password_check_callback(self): resp, msg = password_check(self.root_password_1.value(), self.root_password_2.value()) self.pw_msg.setText(msg) return def action(self): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") if self.root_password_1.value() != "" and self.root_password_2.value() != "" and self.root_password_1.value() == self.root_password_2.value(): set_password(self.root_password_1.value(), "root") augtool("set", "/files/etc/ssh/sshd_config/PasswordAuthentication", "yes") dn = file('/dev/null', 'w+') subprocess.Popen(['/sbin/service', 'sshd', 'restart'], stdout=dn, stderr=dn) if len(self.rhevm_server.value()) > 0: deployUtil.nodeCleanup() if self.verify_rhevm_cert.selected(): if deployUtil.getRhevmCert(self.rhevm_server.value(), self.rhevm_server_port.value()): path, dontCare = deployUtil.certPaths('') fp = deployUtil.generateFingerPrint(path) approval = ButtonChoiceWindow(self.ncs.screen, "Certificate Fingerprint:", fp, buttons = ['Approve', 'Reject']) if 'reject' == approval: ButtonChoiceWindow(self.ncs.screen, "Fingerprint rejected", "oVirt Engine Configuration Failed", buttons = ['Ok']) return False else: ovirt_store_config(path) self.ncs.reset_screen_colors() else: ButtonChoiceWindow(self.ncs.screen, "oVirt Engine Configuration", "Failed downloading oVirt Engine certificate", buttons = ['Ok']) self.ncs.reset_screen_colors() # Stopping vdsm-reg may fail but its ok - its in the case when the menus are run after installation deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'stop']) if write_vdsm_config(self.rhevm_server.value(), self.rhevm_server_port.value()): deployUtil._logExec([constants.EXT_SERVICE, 'vdsm-reg', 'start']) ButtonChoiceWindow(self.ncs.screen, "oVirt Engine Configuration", "oVirt Engine Configuration Successfully Updated", buttons = ['Ok']) self.ncs.reset_screen_colors() return True else: ButtonChoiceWindow(self.ncs.screen, "oVirt Engine Configuration", "oVirt Engine Configuration Failed", buttons = ['Ok']) self.ncs.reset_screen_colors() return False def valid_rhevm_server_callback(self): if not is_valid_host_or_ip(self.rhevm_server.value()): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") ButtonChoiceWindow(self.ncs.screen, "Configuration Check", "Invalid oVirt Engine Hostname or Address", buttons = ['Ok']) self.ncs.reset_screen_colors() def valid_rhevm_server_port_callback(self): if not is_valid_port(self.rhevm_server_port.value()): self.ncs.screen.setColor("BUTTON", "black", "red") self.ncs.screen.setColor("ACTBUTTON", "blue", "white") ButtonChoiceWindow(self.ncs.screen, "Configuration Check", "Invalid oVirt Engine Server Port", buttons = ['Ok']) self.ncs.reset_screen_colors()
def CheckboxListWindow(screen, title, text, items, buttons=(BTN_OK[0], BTN_CANCEL[0]), width=40, scroll=0, default=None, help=None, timer_ms=None, secondary_message=None, secondary_message_width=None, run_type=RT_EXECUTEANDPOP, default_check_state=False, default_check_states=None): if not default_check_states: default_check_states = [default_check_state for i in xrange(len(items))] elif len(default_check_states) != len(items): raise Exception("Number (%d) of check states does not match number of " "items (%d)." % (len(default_check_states), len(items))) primary_message_height = 1 button_height = 1 checklist_margin = 0 rows = primary_message_height + \ button_height + \ (2 if secondary_message else 0) + \ len(items) + \ checklist_margin bb = ButtonBar(screen, buttons) t = TextboxReflowed(width, text) g = GridFormHelp(screen, title, help, 1, rows) row = 0 g.add(t, 0, row) row += 1 if secondary_message: if not secondary_message_width: secondary_message_width = width t2 = TextboxReflowed(secondary_message_width, secondary_message) g.add(t2, 0, row, padding = (0, 1, 0, 0)) row += 1 checkboxes = [] i = 0 for item in items: if (type(item) == types.TupleType): (text, state) = item else: text = item state = default_check_state padding = [0, 0, 0, 0] if i == 0: padding[1] = 1 if i == len(items) - 1: padding[3] = 1 checkbox = Checkbox(text, int(state)) checkboxes.append(checkbox) g.add(checkbox, 0, row, padding) row += 1 i += 1 g.add(bb, 0, row, growx = 1) row += 1 if timer_ms: g.form.w.settimer(timer_ms) (button, is_esc) = ActivateWindow(g, run_type, bb) values = [checkbox.selected() for checkbox in checkboxes] return {'values': values, 'button': button, 'is_esc': is_esc, 'grid': g, }
def welcome(): global NvLtDrvURL, LatestFile, LatestHeader, DownloadFlag, SymlinkFlag screen = SnackScreen() bb = ButtonBar(screen, (("Continue", "continue"), ("Cancel", "cancel"))) tbTittle = Textbox( 65, 3, "To check for latest Nvidia Driver form NVIDIA Website, download and optionaly create a symlink to the latest File", 0, 1) for File in os.listdir(path): if File.find('.run') > 0 and os.path.isfile(path + "/" + File): FList.append(File) FList.sort() FileText = urllib.request.urlopen(NvLtTxtURL).read().decode('utf-8') for i in range(0, len(FileText)): if FileText[i] == ' ': LatestHeader = FileText[0:i] for i in range(0, len(FileText)): if FileText[i] == '/': LatestFile = FileText[i + 1:len(FileText) - 1] NvLtDrvURL = NvLtDrvURL + LatestHeader + "/" + LatestFile tbLatestL = Textbox(110, 2, "Latest Local Version: " + FList[-1], 0, 1) tbLatestR = Textbox( 110, 4, "Latest Remote Version: " + LatestFile + "\nLatest Driver URL: " + NvLtDrvURL, 0, 1) if LatestFile > FList[-1]: cbDowload = Checkbox( "Download the Latest Driver", 1, ) cbSymlink = Checkbox( "Create / Update Symlink", 1, ) else: cbDowload = Checkbox( "Download the Latest Driver", 0, ) cbSymlink = Checkbox( "Create / Update Symlink", 0, ) g = GridForm(screen, "chkltdr (NvDrIn) - by Trodskovich", 1, 8) g.add(tbTittle, 0, 2) g.add(tbLatestL, 0, 3, growx=1) g.add(tbLatestR, 0, 4, growx=1) g.add(cbDowload, 0, 5, growx=1) g.add(cbSymlink, 0, 6, growx=1) g.add(bb, 0, 7, growx=1) result = g.runOnce() screen.finish() DownloadFlag = cbDowload.value() SymlinkFlag = cbSymlink.value() return bb.buttonPressed(result)