def __init__(self, plugin, iface, app_mode, config_nfs, db_type, firewall, dc_type): super(AdvanceOptionsDialog, self).__init__("dialog.options", iface, []) self.plugin = plugin #padd = lambda l: l.ljust(14) ws = [ ui.Options("engine_cfg.model", "App modes:", self._model), ui.Options("engine_cfg.storage", "Storage:", self._storage), ui.Options("engine_cfg.isoASK", "NFS ISO Domain:", self._iso_domain), ui.Options("engine_cfg.dbTYPE", "DB type:", self._db_type), ui.Options("engine_cfg.firewall", "Firewall:", self._firewall), ] self.plugin._model_extra.update({ "engine_cfg.firewall": firewall, "engine_cfg.model": app_mode or 'both', "engine_cfg.storage": dc_type or 'nfs', "engine_cfg.isoASK": config_nfs or False, "engine_cfg.dbTYPE": db_type, }) self.plugin.widgets.add(ws) self.children = ws self.buttons = [ ui.SaveButton("dialog.options.save", "Aplly"), ui.CloseButton("dialog.options.close", "Cancel"), ]
def ui_content(self): """Describes the UI this plugin requires This is an ordered list of (path, widget) tuples. """ # _types needs to be rebuild on every page view, as the network # state can change between page views # NodeNetwork relies on runtime information which is N/A in dev mode if self.application.args.dry: net_is_configured = True else: net_is_configured = NodeNetwork().is_configured() ws = [ui.Header("kdump._header", _("Configure Kdump"))] if not net_is_configured: self._types = self._types_local ws.extend([ ui.Notice( _("network.notice"), _("Networking is not configured, ") + _("please configure it before NFS ") + _("or SSH-based kdump")), ui.Divider("notice.divider") ]) ws.extend([ui.Options("kdump.type", _("Type"), self._types)]) else: self._types = self._types_local + self._types_remote ws.extend([ui.Options("kdump.type", _("Type"), self._types)]) ws.extend([ ui.Divider("divider[0]"), ui.Entry("kdump.nfs_location", _("NFS Location ") + _("(example.com:/var/crash):"), align_vertical=True), ui.Divider("divider[1]"), ui.Entry("kdump.ssh_location", _("SSH Location ") + _("([email protected]):"), align_vertical=True), ui.Entry("kdump.ssh_key", "SSH Key URL (optional):", align_vertical=True) ]) page = ui.Page("page", ws) self.widgets.add(page) return page
def ui_content(self): ws = [ ui.Header("header[0]", _("Logging")), ui.Label( "logrotate.header", _("The logs will be rotated at the ") + _("specified size not more often than the ") + _("set inerval")), ui.Entry("logrotate.max_size", _("Logrotate Max Log ") + _("Size (KB):")), ui.Options("logrotate.interval", _("Interval"), self._intervals), ui.Divider("divider[0]") ] net_is_configured = utils.network.NodeNetwork().is_configured() if not net_is_configured: ws.extend([ ui.Notice( "network.notice", _("Networking is not configured, ") + _("please configure it before rsyslog ") + _("and/or netconsole")), ui.Divider("notice.divider") ]) ws.extend([ ui.Label( "rsyslog.header", _("RSyslog is an enhanced multi-") + _("threaded syslogd")), ui.Entry("rsyslog.address", _("Server Address:"), enabled=net_is_configured), ui.Entry("rsyslog.port", _("Server Port:"), enabled=net_is_configured), ui.Divider("divider[1]"), ui.Label( "netconsole.label", _("Netconsole service allows a remote sys") + _("log daemon to record printk() messages")), ui.Entry("netconsole.address", _("Server Address:"), enabled=net_is_configured), ui.Entry("netconsole.port", _("Server Port:"), enabled=net_is_configured) ]) page = ui.Page("page", ws) self.widgets.add(page) return page
def ui_content(self): if self.application.args.dry: net_is_configured = True else: net_is_configured = NodeNetwork().is_configured() if not net_is_configured: ws = ([ ui.Divider("notice.divider"), ui.Notice( "network.notice", "Networking is not configured, please " + "configure it before configuring RHN"), ui.Divider("notice.divider") ]) else: status, rhn_type = get_rhn_status() if status == 0: rhn_msg = ("RHN Registration is required only if you wish " + "to use Red Hat Enterprise Linux with virtual " + "guests subscriptions for your guests.") else: rhn_msg = "RHN Registration\n\nRegistration Status: %s" \ % rhn_type ws = [ ui.Header("header[0]", rhn_msg), ui.Entry("rhn.user", "Login:"******"rhn.password", "Password:"******"rhn.profilename", "Profile Name (optional):"), ui.Divider("divider[0]"), ui.Options("rhn.type", "Type", self._rhn_types), ui.Entry("rhn.url", "URL:"), ui.Entry("rhn.ca", "CA URL:"), ui.Header("header[0]", "HTTP Proxy Configuration"), ui.Entry("rhn.proxyhost", "Server:"), ui.Entry("rhn.proxyport", "Port:"), ui.Entry("rhn.proxyuser", "Username:"******"rhn.proxypassword", "Password:"******"divider[1]"), ] page = ui.Page("page", ws) self.widgets.add(ws) return page
def ui_content(self): """Describes the UI this plugin requires This is an ordered list of (path, widget) tuples. """ ws = [ ui.Header("kdump._header", "Configure Kdump"), ui.Options("kdump.type", "Type", self._types), ui.Divider("divider[0]"), ui.Entry("kdump.nfs_location", "NFS Location " + "(example.com:/var/crash):", align_vertical=True), ui.Divider("divider[1]"), ui.Entry("kdump.ssh_location", "SSH Location " + "([email protected]):", align_vertical=True), ] page = ui.Page("page", ws) self.widgets.add(page) return page
def ui_content(self): cfg = rhn_model.RHN().retrieve() if self.application.args.dry: net_is_configured = True else: net_is_configured = NodeNetwork().is_configured() if not net_is_configured: ws = ([ ui.Divider("notice.divider"), ui.Notice( "network.notice", "Networking is not configured, please " + "configure it before configuring RHSM"), ui.Divider("notice.divider") ]) else: rhn_msg = ("RHSM Registration is required only if you wish " + "to use Red Hat Enterprise Linux with virtual " + "guests subscriptions for your guests.") if cfg["rhntype"] and self._get_status(cfg) is not None: rhn_msg = self._get_status(cfg) ws = [ ui.Header("header[0]", rhn_msg), ui.Entry("rhn.username", "Login:"******"rhn.password", "Password:"******"rhn.profilename", "Profile Name (optional):"), ui.Divider("divider[0]"), ui.Options("rhn.type", "Type", self._rhn_types), ui.Entry("rhn.url", "URL:"), ui.Entry("rhn.ca", "CA URL:"), ui.Entry("rhn.org", "Organization:"), ui.Entry("rhn.environment", "Environment:"), ui.Entry("rhn.activation_key", "Activation Key:"), ui.Button("button.proxy", "HTTP Proxy Configuration"), ] page = ui.Page("page", ws) self.widgets.add(ws) return page
def __init__(self, title, plugin): self.keys = ["maintenance.level"] self.plugin = plugin def clear_invalid(dialog, changes): [plugin.stash_change(prefix) for prefix in self.keys] entries = [ui.Options("maintenance.level", "Maintenance Level", self.states, selected=self.__vm_status())] children = [ui.Divider("divider.options"), ui.Label("label[0]", "Please select the maintenance " "level"), ui.Divider("divider[0]")] children.extend(entries) super(MaintenanceDialog, self).__init__( "maintenance.dialog", title, children) self.buttons = [ui.SaveButton("maintenance.confirm", "Set"), ui.CloseButton("maintenance.close", "Cancel")] b = plugins.UIElements(self.buttons) b["maintenance.close"].on_activate.clear() b["maintenance.close"].on_activate.connect(ui.CloseAction()) b["maintenance.close"].on_activate.connect(clear_invalid)
def __init__(self, plugin, ifname): super(NicDetailsDialog, self).__init__("dialog.nic", "NIC Details: %s" % ifname, []) self.plugin = plugin # Populate model with nic specific informations self.logger.debug("Building NIC details dialog for %s" % ifname) nic = utils.network.NodeNetwork().nics()[ifname] model = defaults.Network().retrieve() ip6model = defaults.IPv6().retrieve() m_layout = defaults.NetworkLayout().retrieve() self.logger.debug("nic: %s" % nic) self.logger.debug("model: %s" % model) self.logger.debug("ip6model: %s" % ip6model) is_primary_interface = model["iface"] == ifname if not is_primary_interface: # The config contains the information for the primary ifnamee, # because this ifnamee is not the primaryifnameme we clear the # config model = dict((k, "") for k in model.keys()) ipaddr, netmask, gateway, vlanid = (model["ipaddr"], model["netmask"], model["gateway"], model["vlanid"]) ip6addr, ip6netmask, ip6gateway, ip6bootproto = (ip6model["ipaddr"], ip6model["netmask"], ip6model["gateway"], ip6model["bootproto"]) bootproto = model["bootproto"] if model["bootproto"] == "dhcp": if nic.exists(): routes = utils.network.Routes() gateway = routes.default() ipaddr, netmask = nic.ipv4_address().items() vlanid = ",".join(nic.vlanids()) else: if ipaddr: bootproto = "static" link_status_txt = ("Connected" if nic.has_link() else "Disconnected") vendor_txt = nic.vendor[:24] if nic.vendor else "" self.plugin._model_extra.update({ "dialog.nic.driver": nic.driver, "dialog.nic.vendor": vendor_txt, "dialog.nic.link_status": link_status_txt, "dialog.nic.hwaddress": nic.hwaddr, "dialog.nic.ipv4.bootproto": bootproto, "dialog.nic.ipv4.address": ipaddr, "dialog.nic.ipv4.netmask": netmask, "dialog.nic.ipv4.gateway": gateway, "dialog.nic.ipv6.bootproto": ip6bootproto, "dialog.nic.ipv6.address": ip6addr, "dialog.nic.ipv6.netmask": ip6netmask, "dialog.nic.ipv6.gateway": ip6gateway, "dialog.nic.vlanid": vlanid, "dialog.nic.layout_bridged": m_layout["layout"] == "bridged", }) self.logger.debug("model: %s" % self.plugin.model()) padd = lambda l: l.ljust(12) ws = [ ui.Row("dialog.nic._row[0]", [ ui.KeywordLabel("dialog.nic.driver", padd("Driver: ")), ui.KeywordLabel("dialog.nic.vendor", padd("Vendor: ")), ]), ui.Row("dialog.nic._row[2]", [ ui.KeywordLabel("dialog.nic.link_status", padd("Link Status: ")), ui.KeywordLabel("dialog.nic.hwaddress", padd("MAC Address: ")), ]), ui.Divider("dialog.nic._divider[0]"), ui.Label("dialog.nic.ipv4._header", "IPv4 Settings"), ui.Options("dialog.nic.ipv4.bootproto", "Bootprotocol: ", [("none", "Disabled"), ("dhcp", "DHCP"), ("static", "Static")]), ui.Row("dialog.nic._row[4]", [ ui.Entry("dialog.nic.ipv4.address", padd("IP Address: ")), ui.Entry("dialog.nic.ipv4.netmask", padd(" Netmask: ")) ]), ui.Row("dialog.nic._row[5]", [ ui.Entry("dialog.nic.ipv4.gateway", padd("Gateway: ")), ui.Label("dummy[0]", "") ]), ui.Divider("dialog.nic._divider[1]"), ui.Label("dialog.nic.ipv6._header", "IPv6 Settings"), ui.Options("dialog.nic.ipv6.bootproto", "Bootprotocol: ", [("none", "Disabled"), ("auto", "Auto"), ("dhcp", "DHCP"), ("static", "Static")]), ui.Row("dialog.nic._row[6]", [ ui.Entry("dialog.nic.ipv6.address", padd("IP Address: ")), ui.Entry("dialog.nic.ipv6.netmask", padd(" Prefix Length: ")) ]), ui.Row("dialog.nic._row[7]", [ ui.Entry("dialog.nic.ipv6.gateway", padd("Gateway: ")), ui.Label("dummy[1]", "") ]), ui.Divider("dialog.nic._divider[2]"), ui.Row("dialog.nic._row[8]", [ ui.Entry("dialog.nic.vlanid", padd("VLAN ID: ")), ui.Label("dummy[2]", "") ]), ui.Divider("dialog.nic._divider[3]"), ui.Checkbox("dialog.nic.layout_bridged", "Use Bridge: "), ui.Divider("dialog.nic._divider[4]"), ui.Button("dialog.nic.identify", "Flash Lights to Identify"), ] self.plugin.widgets.add(ws) self.children = ws self.buttons = [ ui.SaveButton("dialog.nic.save", "Save"), ui.CloseButton("dialog.nic.close", "Close") ] self.plugin._nic_details_group.enabled(False) self.plugin.widgets["dialog.nic.vlanid"].enabled(True) self.plugin.widgets["dialog.nic.layout_bridged"].enabled(True)
def __init__(self, plugin, iface): super(NicDetailsDialog, self).__init__("dialog.nic", "NIC Details: %s" % iface, []) self.plugin = plugin # Populate model with nic specific informations self.logger.debug("Building NIC details dialog for %s" % iface) self.logger.debug("Getting informations for NIC details page") live = utils.network.node_nics()[iface] cfg = defaults.Network().retrieve() self.logger.debug("live: %s" % live) self.logger.debug("cfg: %s" % cfg) # The primary interface of this Node: node_bridge_slave = config.network.node_bridge_slave() if node_bridge_slave != iface: # The config contains the information for the primary iface, # because this iface is not the primary iface we clear the config cfg = {k: "" for k in cfg.keys()} ipaddr, netmask, gateway, vlanid = (cfg["ipaddr"], cfg["netmask"], cfg["gateway"], cfg["vlanid"]) bridge_nic = utils.network.NIC(live["bridge"]) if cfg["bootproto"] == "dhcp": if bridge_nic.exists(): routes = utils.network.Routes() ipaddr, netmask = bridge_nic.ipv4_address().items() gateway = routes.default() vlanid = bridge_nic.vlanid() else: self.logger.warning("Bridge assigned but couldn't gather " + "live info: %s" % bridge_nic) self.plugin._model_extra.update({ "dialog.nic.iface": live["name"], "dialog.nic.driver": live["driver"], "dialog.nic.protocol": live["bootproto"] or "N/A", "dialog.nic.vendor": live["vendor"], "dialog.nic.link_status": "Connected" if live["link_detected"] else "Disconnected", "dialog.nic.hwaddress": live["hwaddr"], "dialog.nic.ipv4.bootproto": cfg["bootproto"], "dialog.nic.ipv4.address": ipaddr, "dialog.nic.ipv4.netmask": netmask, "dialog.nic.ipv4.gateway": gateway, "dialog.nic.vlanid": vlanid, }) self.logger.debug("model: %s" % self.plugin.model()) padd = lambda l: l.ljust(14) ws = [ ui.Row("dialog.nic._row[0]", [ ui.KeywordLabel("dialog.nic.iface", padd("Interface: ")), ui.KeywordLabel("dialog.nic.driver", padd("Driver: ")), ]), ui.Row("dialog.nic._row[1]", [ ui.KeywordLabel("dialog.nic.protocol", padd("Protocol: ")), ui.KeywordLabel("dialog.nic.vendor", padd("Vendor: ")), ]), ui.Row("dialog.nic._row[2]", [ ui.KeywordLabel("dialog.nic.link_status", padd("Link Status: ")), ui.KeywordLabel("dialog.nic.hwaddress", padd("MAC Address: ")), ]), ui.Divider("dialog.nic._divider[0]"), ui.Header("dialog.nic.ipv4._header", "IPv4 Settings"), ui.Options("dialog.nic.ipv4.bootproto", "Bootprotocol: ", [("none", "Disabled"), ("dhcp", "DHCP"), ("static", "Static")]), ui.Entry("dialog.nic.ipv4.address", padd("IP Address: ")), ui.Entry("dialog.nic.ipv4.netmask", padd("Netmask: ")), ui.Entry("dialog.nic.ipv4.gateway", padd("Gateway: ")), ui.Divider("dialog.nic._divider[1]"), ui.Entry("dialog.nic.vlanid", padd("VLAN ID: ")), ] self.plugin.widgets.add(ws) self.children = ws self.buttons = [ ui.SaveButton("dialog.nic.save", "Save"), ui.CloseButton("dialog.nic.close", "Close"), ] self.plugin._nic_details_group.enabled(False)
def __init__(self, plugin, ifname): super(NicDetailsDialog, self).__init__("dialog.nic", "NIC Details: %s" % ifname, []) self.plugin = plugin # Populate model with nic specific informations self.logger.debug("Building NIC details dialog for %s" % ifname) nic = utils.network.NodeNetwork().nics()[ifname] model = defaults.Network().retrieve() ip6model = defaults.IPv6().retrieve() self.logger.debug("nic: %s" % nic) self.logger.debug("model: %s" % model) self.logger.debug("ip6model: %s" % ip6model) is_primary_interface = model["iface"] == ifname link_status_txt = ("Connected" if nic.has_link() else "Disconnected") vendor_txt = nic.vendor[:24] if nic.vendor else "" self.plugin._model_extra.update({ "dialog.nic.driver": nic.driver, "dialog.nic.vendor": vendor_txt, "dialog.nic.link_status": link_status_txt, "dialog.nic.hwaddress": nic.hwaddr, }) if isinstance(nic, network.BondedNIC): self.plugin._model_extra.update({ "dialog.nic.bond_mode": nic.mode, "dialog.nic.bond_slaves": " ".join(nic.slaves) }) bootproto = model["bootproto"] ipaddr = model["ipaddr"] netmask = model["netmask"] gateway = model["gateway"] vlanid = model["vlanid"] if model["bootproto"] == "dhcp": if nic.exists(): routes = utils.network.Routes() gateway = routes.default() ipaddr, netmask = nic.ipv4_address().items() vlanid = ",".join(nic.vlanids()) else: if ipaddr: bootproto = "static" nicfields = { "dialog.nic.ipv4.bootproto": bootproto, "dialog.nic.ipv4.address": ipaddr, "dialog.nic.ipv4.netmask": netmask, "dialog.nic.ipv4.gateway": gateway, "dialog.nic.ipv6.bootproto": ip6model["bootproto"], "dialog.nic.ipv6.address": ip6model["ipaddr"], "dialog.nic.ipv6.netmask": ip6model["netmask"], "dialog.nic.ipv6.gateway": ip6model["gateway"], "dialog.nic.vlanid": vlanid, } self.plugin._model_extra.update(nicfields) if not is_primary_interface: # Unset all NIC fields. Because their values are only relevant # for the primary interface self.plugin._model_extra.update(dict.fromkeys(nicfields.keys())) self.logger.debug("model: %s" % self.plugin.model()) padd = lambda l: l.ljust(12) ws = [ ui.Row("dialog.nic._row[0]", [ ui.KeywordLabel("dialog.nic.driver", padd(_("Driver: "))), ui.KeywordLabel("dialog.nic.vendor", padd(_("Vendor: "))), ]), ui.Row("dialog.nic._row[2]", [ ui.KeywordLabel("dialog.nic.link_status", padd("Link Status: ")), ui.KeywordLabel("dialog.nic.hwaddress", padd("MAC Address: ")), ]) ] if isinstance(nic, network.BondedNIC): ws += [ ui.Row("dialog.nic._row[3]", [ ui.KeywordLabel("dialog.nic.bond_mode", _("Bond Mode: ")), ui.KeywordLabel("dialog.nic.bond_slaves", _("Bond Slaves: ")) ]) ] ws += [ ui.Divider("dialog.nic._divider[0]"), ui.Label("dialog.nic.ipv4._header", _("IPv4 Settings")), ui.Options("dialog.nic.ipv4.bootproto", "Bootprotocol: ", [("none", _("Disabled")), ("dhcp", _("DHCP")), ("static", _("Static"))]), ui.Row("dialog.nic._row[4]", [ ui.Entry("dialog.nic.ipv4.address", padd(_("IP Address: "))), ui.Entry("dialog.nic.ipv4.netmask", padd(_(" Netmask: "))) ]), ui.Row("dialog.nic._row[5]", [ ui.Entry("dialog.nic.ipv4.gateway", padd(_("Gateway: "))), ui.Label("dummy[0]", "") ]), ui.Divider("dialog.nic._divider[1]"), ui.Label("dialog.nic.ipv6._header", _("IPv6 Settings")), ui.Options("dialog.nic.ipv6.bootproto", "Bootprotocol: ", [("none", _("Disabled")), ("auto", _("Auto")), ("dhcp", _("DHCP")), ("static", _("Static"))]), ui.Row("dialog.nic._row[6]", [ ui.Entry("dialog.nic.ipv6.address", padd(_("IP Address: "))), ui.Entry("dialog.nic.ipv6.netmask", padd( _(" Prefix Length: "))) ]), ui.Row("dialog.nic._row[7]", [ ui.Entry("dialog.nic.ipv6.gateway", padd(_("Gateway: "))), ui.Label("dummy[1]", "") ]), ui.Divider("dialog.nic._divider[2]"), ui.Row("dialog.nic._row[8]", [ ui.Entry("dialog.nic.vlanid", padd(_("VLAN ID: "))), ui.Label("dummy[2]", "") ]), ui.Divider("dialog.nic._divider[3]"), ui.Divider("dialog.nic._divider[4]"), ui.Button("dialog.nic.identify", _("Flash Lights to Identify")) ] self.plugin.widgets.add(ws) self.children = ws self.plugin._nic_details_group.enabled(False) if isinstance(nic, network.BridgedNIC): self.buttons = [ui.CloseButton("dialog.nic.close", _("Close"))] else: self.plugin.widgets["dialog.nic.vlanid"].enabled(True) self.buttons = [ ui.SaveButton("dialog.nic.save", _("Save")), ui.CloseButton("dialog.nic.close", _("Close")) ]