def on_change(self, changes): self._model.update(changes) size_keys = ["storage.efi_size", "storage.root_size", "storage.swap_size", "storage.config_size", "storage.logging_size"] if not self._fill: size_keys.append("storage.data_size") if changes.contains_any(size_keys): self._free_space = self.__calculate_free_space() self._model["storage.free_space"] = "%s MB" % self._free_space if "storage.free_space" in self.widgets: self.widgets["storage.free_space"].text("%s MB" % self._free_space) if self._fill: self.widgets["storage.data_size"].text("%s" % self._free_space) if self._free_space < 0: if self._fill: raise InvalidData("Data partition must be at least 0 MB") else: raise InvalidData("Free space must not be negative") else: for w in self.widgets: if hasattr(self.widgets[w], "notice"): self.widgets[w].notice("") self._on_ui_change(self._NodePlugin__invalid_changes) if "storage.fill_data" in changes: self._on_ui_change(plugins.Changeset( {"storage.data_size": self._model["storage.data_size"]})) if self._fill is not changes["storage.fill_data"]: self._fill = changes["storage.fill_data"] self.application.show(self.ui_content())
def on_change(self, changes): self.logger.info("Checking network stuff") helper = plugins.Changeset(changes) bootproto = helper["dialog.nic.ipv4.bootproto"] if bootproto: if bootproto in ["static"]: self._nic_details_group.enabled(True) elif bootproto in ["dhcp"]: self._nic_details_group.enabled(False) self.widgets["dialog.nic.vlanid"].enabled(True) else: self._nic_details_group.enabled(False) self.widgets["dialog.nic.ipv4.bootproto"].enabled(True)
def on_change(self, changes): self.logger.info("Checking network stuff") helper = plugins.Changeset(changes) nic_ipv4_group = [ "dialog.nic.ipv4.bootproto", "dialog.nic.ipv4.address", "dialog.nic.ipv4.netmask", "dialog.nic.ipv4.gateway" ] nic_ipv6_group = [ "dialog.nic.ipv6.bootproto", "dialog.nic.ipv6.address", "dialog.nic.ipv6.netmask", "dialog.nic.ipv6.gateway" ] ipv4_bootproto = helper["dialog.nic.ipv4.bootproto"] if ipv4_bootproto: if ipv4_bootproto in ["static"]: for w in nic_ipv4_group: self.widgets[w].enabled(True) elif ipv4_bootproto in ["dhcp"]: for w in nic_ipv4_group: self.widgets[w].enabled(False) self.widgets["dialog.nic.vlanid"].enabled(True) else: for w in nic_ipv4_group: self.widgets[w].enabled(False) self.widgets["dialog.nic.vlanid"].enabled(True) self.widgets["dialog.nic.ipv4.bootproto"].enabled(True) ipv6_bootproto = helper["dialog.nic.ipv6.bootproto"] if ipv6_bootproto: if ipv6_bootproto in ["static"]: for w in nic_ipv6_group: self.widgets[w].enabled(True) elif ipv6_bootproto in ["dhcp"]: for w in nic_ipv6_group: self.widgets[w].enabled(False) self.widgets["dialog.nic.vlanid"].enabled(True) else: for w in nic_ipv6_group: self.widgets[w].enabled(False) self.widgets["dialog.nic.vlanid"].enabled(True) self.widgets["dialog.nic.ipv6.bootproto"].enabled(True) if "bond.slaves" in changes: self._model_extra["bond.slaves.selected"] = \ self.widgets["bond.slaves"].selection() elif "bond.name" in changes and changes["bond.name"] == "007": self.widgets["bond.options"].text("Bartender: Shaken or stirred?")
def on_merge(self, effective_changes): self.logger.info("Saving network stuff") changes = Changeset(self.pending_changes(False)) effective_model = Changeset(self.model()) effective_model.update(effective_changes) self.logger.debug("Changes: %s" % changes) self.logger.info("Effective changes %s" % effective_changes) self.logger.debug("Effective Model: %s" % effective_model) # This object will contain all transaction elements to be executed txs = utils.Transaction("Network Interface Configuration") # Special case: A NIC was selected, display that dialog! if "nics" in changes and len(changes) == 1: iface = changes["nics"] self.logger.debug("Opening NIC Details dialog for '%s'" % iface) self._model_extra["dialog.nic.ifname"] = iface self._nic_dialog = NicDetailsDialog(self, iface) return self._nic_dialog if "dialog.nic.close" in changes: self._nic_dialog.close() return if "button.toggle_bond" in changes: m_bond = defaults.NicBonding() mnet = defaults.Network() if m_bond.retrieve()["slaves"]: if mnet.retrieve()["iface"] == m_bond.retrieve()["name"]: # Remove network config if primary devce was this # bond mnet.configure_no_networking() m_bond.configure_no_bond() txs += m_bond.transaction() txs += mnet.transaction() else: self._bond_dialog = CreateBondDialog("dialog.bond") self.widgets.add(self._bond_dialog) return self._bond_dialog if "button.ping" in changes: self.logger.debug("Opening ping page") self.application.switch_to_plugin(ping.Plugin) return if "dialog.nic.identify" in changes: ifname = self._model_extra["dialog.nic.ifname"] utils.network.NIC(ifname).identify() self.application.notice("Flashing lights now") return e_changes_h = plugins.Changeset(effective_changes) nameservers = [] dns_keys = ["dns[0]", "dns[1]"] if e_changes_h.contains_any(dns_keys): nameservers += effective_model.values_for(dns_keys) if nameservers: self.logger.info("Setting new nameservers: %s" % nameservers) model = defaults.Nameservers() model.update(nameservers) txs += model.transaction() timeservers = [] ntp_keys = ["ntp[0]", "ntp[1]"] if e_changes_h.contains_any(ntp_keys): timeservers += effective_model.values_for(ntp_keys) if timeservers: self.logger.info("Setting new timeservers: %s" % timeservers) model = defaults.Timeservers() model.update(timeservers) txs += model.transaction() hostname_keys = ["hostname"] if e_changes_h.contains_any(hostname_keys): value = effective_model.values_for(hostname_keys) self.logger.info("Setting new hostname: %s" % value) model = defaults.Hostname() model.update(*value) txs += model.transaction() # For the NIC details dialog: if e_changes_h.contains_any(self._nic_details_group): # If any networking related key was changed, reconfigure networking # Fetch the values for the nic keys, they are used as arguments args = effective_model.values_for(self._nic_details_group) txs += self._configure_nic(*args) if effective_changes.contains_any(self._bond_group): mb = defaults.NicBonding() mnet = defaults.Network() args = effective_model.values_for( ["bond.name", "bond.slaves.selected", "bond.options"]) self.logger.debug("args: %s" % args) mb.update(*args) txs += mb.transaction() txs += mnet.transaction() self._bond_dialog.close() progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self) progress_dialog.run() if "dialog.nic.save" in changes: # Close the remaing details dialog self._nic_dialog.close() # Behaves like a page reload return self.ui_content()
def on_change(self, changes): for path, value in changes.items(): self.logger.debug("%s: %s" % (path, value)) if path == "engine_cfg.authPASS": self._pass["engine_cfg.authPASS"] = value elif path == "engine_cfg.authPASS_confirmation": self._pass["engine_cfg.authPASS_confirmation"] = value elif path == "engine_cfg.adminPASS": self._pass["engine_cfg.adminPASS"] = value elif path == "engine_cfg.adminPASS_confirmation": self._pass["engine_cfg.adminPASS_confirmation"] = value elif path == "engine_cfg.license": self._pass["engine_cfg.license"] = value elif path == "engine_cfg.httpPORT": self._pass["engine_cfg.httpPORT"] = value elif path == "engine_cfg.httpsPORT": self._pass["engine_cfg.httpsPORT"] = value elif path == "engine_cfg.orgNAME": self._pass["engine_cfg.orgNAME"] = value elif path == "engine_cfg.hostFQDN": self._pass["engine_cfg.hostFQDN"] = value elif path == "engine_cfg.isoPATH": self._pass["engine_cfg.isoPATH"] = value elif path == "engine_cfg.license": self._pass["engine_cfg.license"] = value helper = plugins.Changeset(changes) enable_buttons = True fetch_options = self.widgets["action.fetch_options"] save_button = self.widgets["action.register"] info_ui = self.widgets["engine_cfg.infomation"] http_port = self._pass["engine_cfg.httpPORT"] self.logger.debug("http_port:%s %s" % (http_port, enable_buttons)) if self.isstring(http_port): self.logger.debug("catch http_port :%s" % (http_port)) port = int(http_port) if not (port > 0 and port < 65535): if enable_buttons: info_ui.text("http port error!") enable_buttons = False else: self.logger.debug("catch http_port :%s" % (enable_buttons)) if enable_buttons: info_ui.text("http port error!") enable_buttons = False https_port = self._pass["engine_cfg.httpsPORT"] self.logger.debug("https_port:%s %s" % (https_port, enable_buttons)) if self.isstring(https_port): self.logger.debug("catch https_port :%s" % (https_port)) port = int(https_port) if not (port > 0 and port < 65535 and http_port != https_port): self.logger.debug("catch https_port :%s" % (http_port == https_port)) if enable_buttons: info_ui.text("https port error!") enable_buttons = False else: if enable_buttons: info_ui.text("https port error!") enable_buttons = False auth_pass = self._pass["engine_cfg.authPASS"] reauth_pass = self._pass["engine_cfg.authPASS_confirmation"] #self.widgets["engine_cfg.authPASS"].EngineConfigvalid(False) self.logger.debug("auth_pass:%s %s" % (auth_pass, enable_buttons)) if self.isstring(auth_pass) and self.isstring(reauth_pass): if auth_pass != reauth_pass: if enable_buttons: info_ui.text("auth password confirmation error!") enable_buttons = False else: if enable_buttons: info_ui.text("auth password confirmation error!") enable_buttons = False org_name = self._pass["engine_cfg.orgNAME"] self.logger.debug("org_name:%s %s" % (org_name, enable_buttons)) if not self.isstring(org_name): if enable_buttons: info_ui.text("org name error!") enable_buttons = False host_fqdn = self._pass["engine_cfg.hostFQDN"] self.logger.debug("host_fqdn:%s %s" % (host_fqdn, enable_buttons)) admin_pass = self._pass["engine_cfg.adminPASS"] readmin_pass = self._pass["engine_cfg.adminPASS_confirmation"] self.logger.debug("admin_pass:%s %s" % (admin_pass, enable_buttons)) if self.isstring(admin_pass) and self.isstring(readmin_pass): if admin_pass != readmin_pass: if enable_buttons: info_ui.text("db password confirmation error !") enable_buttons = False else: if enable_buttons: info_ui.text("db password confirmation error !") enable_buttons = False iso_path = self._pass["engine_cfg.isoPATH"] self.logger.debug("iso_path:%s %s" % (iso_path, enable_buttons)) if self.isstring(iso_path): if not self.validateMountPoint(iso_path): if enable_buttons: info_ui.text("may be iso path exist !") enable_buttons = False else: enable_buttons = False info_ui.text("Invalid Path Specified !") license = self._pass["engine_cfg.license"] #self.logger.debug("license:%s %s" % (license,enable_buttons)) if self.isstring(license): #self.logger.debug("aaaaaaaaaaaaaalicense:%s %s" % (license,enable_buttons)) if not self.islicense(license): self.logger.debug("catch license:%s" % (license)) if enable_buttons: info_ui.text("license error !") enable_buttons = False else: self.logger.debug("license: %s" % (enable_buttons)) if enable_buttons: info_ui.text("license error !") enable_buttons = False self.logger.debug("enable buttons %s" % enable_buttons) if enable_buttons: fetch_options.enabled(True) save_button.enabled(True) info_ui.text("") else: fetch_options.enabled(False) save_button.enabled(False)
def on_merge(self, effective_changes): self.logger.info("Saving network stuff") changes = Changeset(self.pending_changes(False)) effective_model = Changeset(self.model()) effective_model.update(effective_changes) self.logger.debug("Changes: %s" % changes) self.logger.info("Effective changes %s" % effective_changes) self.logger.debug("Effective Model: %s" % effective_model) # Special case: A NIC was selected, display that dialog! if "nics" in changes and len(changes) == 1: iface = changes["nics"] self.logger.debug("Opening NIC Details dialog for '%s'" % iface) self._nic_dialog = NicDetailsDialog(self, iface) return self._nic_dialog if "dialog.nic.close" in changes: self._nic_dialog.close() return if "button.ping" in changes: self.logger.debug("Opening ping page") plugin_type = ovirt.node.setup.ping.Plugin self.application.switch_to_plugin(plugin_type) return # This object will contain all transaction elements to be executed txs = utils.Transaction("DNS and NTP configuration") e_changes_h = plugins.Changeset(effective_changes) nameservers = [] dns_keys = ["dns[0]", "dns[1]"] if e_changes_h.contains_any(dns_keys): nameservers += effective_model.values_for(dns_keys) if nameservers: self.logger.info("Setting new nameservers: %s" % nameservers) model = defaults.Nameservers() model.update(nameservers) txs += model.transaction() timeservers = [] ntp_keys = ["ntp[0]", "ntp[1]"] if e_changes_h.contains_any(ntp_keys): timeservers += effective_model.values_for(ntp_keys) if timeservers: self.logger.info("Setting new timeservers: %s" % timeservers) model = defaults.Timeservers() model.update(timeservers) txs += model.transaction() hostname_keys = ["hostname"] if e_changes_h.contains_any(hostname_keys): value = effective_model.values_for(hostname_keys) self.logger.info("Setting new hostname: %s" % value) model = defaults.Hostname() model.update(*value) txs += model.transaction() # For the NIC details dialog: if e_changes_h.contains_any(self._nic_details_group): # If any networking related key was changed, reconfigure networking # Fetch the values for the nic keys, they are used as arguments args = effective_model.values_for(self._nic_details_group) txs += self._configure_nic(*args) progress_dialog = ui.TransactionProgressDialog("dialog.txs", txs, self) progress_dialog.run() if "dialog.nic.save" in changes: # Close the remaing details dialog self._nic_dialog.close() # Behaves like a page reload return self.ui_content()