[node-patches] Change in ovirt-node[master]: Add storage and SNMP pages
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Tue Dec 11 20:09:43 UTC 2012
Fabian Deutsch has uploaded a new change for review.
Change subject: Add storage and SNMP pages
......................................................................
Add storage and SNMP pages
Change-Id: Id72a5bf592e04825e5b282e9ef6573cd6090c652
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/setup/engine_page.py
M scripts/tui/src/ovirt/node/setup/kdump_page.py
M scripts/tui/src/ovirt/node/setup/keyboard_page.py
M scripts/tui/src/ovirt/node/setup/logging_page.py
M scripts/tui/src/ovirt/node/setup/network_page.py
M scripts/tui/src/ovirt/node/setup/remote_storage_page.py
M scripts/tui/src/ovirt/node/setup/security_page.py
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/tui.py
M scripts/tui/src/ovirt/node/ui/widgets.py
A scripts/tui/src/ovirt/node/utils/storage.py
M scripts/tui/src/ovirt/node/valid.py
13 files changed, 147 insertions(+), 62 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/66/9966/1
diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 148fce5..19a7069 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -676,8 +676,11 @@
@NodeConfigFileSection.map_and_update_defaults_decorator
def update(self, name, target_name, target_host, target_port):
- # FIXME add validation
- pass
+ # FIXME add more validation
+ valid.IQN()(name)
+ (valid.Empty() | valid.IQN())(target_name)
+ (valid.Empty() | valid.FQDNOrIPAddress())(target_host)
+ (valid.Empty() | valid.Port())(target_port)
def transaction(self):
cfg = dict(self.retrieve())
@@ -685,8 +688,8 @@
class ConfigureIscsiInitiator(utils.Transaction.Element):
def commit(self):
- from ovirtnode.iscsi import set_iscsi_initiator
- set_iscsi_initiator(initiator_name)
+ iscsi = utils.storage.iSCSI()
+ iscsi.initiator_name(initiator_name)
tx = utils.Transaction("Configuring the iSCSI Initiator")
tx.append(ConfigureIscsiInitiator())
@@ -710,6 +713,23 @@
# FIXME add validation
pass
+ def transaction(self):
+ cfg = dict(self.retrieve())
+ password = cfg["password"]
+
+ class ConfigureSNMP(utils.Transaction.Element):
+ def commit(self):
+ # FIXME snmp plugin needs to be placed somewhere else (in src)
+ import ovirt_config_setup.snmp as osnmp
+ if password:
+ osnmp.enable_snmpd(password)
+ else:
+ osnmp.disable_snmpd()
+
+ tx = utils.Transaction("Configuring SNMP")
+ tx.append(ConfigureSNMP())
+ return tx
+
class Netconsole(NodeConfigFileSection):
"""Configure netconsole
diff --git a/scripts/tui/src/ovirt/node/setup/engine_page.py b/scripts/tui/src/ovirt/node/setup/engine_page.py
index 41eff6e..a522d86 100644
--- a/scripts/tui/src/ovirt/node/setup/engine_page.py
+++ b/scripts/tui/src/ovirt/node/setup/engine_page.py
@@ -23,13 +23,10 @@
Configure Engine
"""
-import ovirt.node.plugins
-import ovirt.node.valid
-import ovirt.node.ui
-import ovirt.node.utils
+from ovirt.node import plugins, valid, ui, utils, exceptions
-class Plugin(ovirt.node.plugins.NodePlugin):
+class Plugin(plugins.NodePlugin):
_model = None
_widgets = None
@@ -44,7 +41,7 @@
self._model = {
"vdsm.address": "",
"vdsm.port": "7634",
- "vdsm.connect_and_validate": ovirt.node.utils.parse_bool(True),
+ "vdsm.connect_and_validate": utils.parse_bool(True),
"vdsm.password": "",
"vdsm.password_confirmation": "",
}
@@ -52,34 +49,37 @@
def validators(self):
return {
- "vdsm.address": ovirt.node.valid.FQDNOrIPAddress(),
- "vdsm.port": ovirt.node.valid.Port(),
- "vdsm.password": ovirt.node.valid.Text(),
- "vdsm.password_confirmation": ovirt.node.valid.Text(),
+ "vdsm.address": valid.FQDNOrIPAddress() | valid.Empty(),
+ "vdsm.port": valid.Port(),
+ "vdsm.password": valid.Text(),
+ "vdsm.password_confirmation": valid.Text(),
}
def ui_content(self):
widgets = [
- ("header", ovirt.node.ui.Header("oVirt Engine Configuration")),
+ ("header", ui.Header("oVirt Engine Configuration")),
- ("vdsm.address", ovirt.node.ui.Entry("Server Address:")),
- ("vdsm.port", ovirt.node.ui.Entry("Server Port:")),
- ("vdsm.connect_and_validate", ovirt.node.ui.Checkbox(
+ ("vdsm.address", ui.Entry("Management Server:")),
+ ("vdsm.port", ui.Entry("Management Server Port:")),
+
+ ("divider[1]", ui.Divider()),
+
+ ("vdsm.connect_and_validate", ui.Checkbox(
"Connect to oVirt Engine and Validate Certificate")),
- ("vdsm.password._divider", ovirt.node.ui.Divider("-")),
- ("vdsm.password._label", ovirt.node.ui.Label(
+ ("divider[0]", ui.Divider()),
+ ("vdsm.password._label", ui.Label(
"Optional password for adding Node through oVirt " +
"Engine UI")),
- ("vdsm.password", ovirt.node.ui.PasswordEntry("Password:")),
- ("vdsm.password_confirmation", ovirt.node.ui.PasswordEntry(
- "Confirm Password:")),
+ ("vdsm.password", ui.PasswordEntry("Password:")),
+ ("vdsm.password_confirmation",
+ ui.PasswordEntry("Confirm Password:")),
]
# Save it "locally" as a dict, for better accessability
self._widgets = dict(widgets)
- page = ovirt.node.ui.Page(widgets)
+ page = ui.Page(widgets)
return page
def on_change(self, changes):
@@ -87,7 +87,7 @@
if self._model["vdsm.password"] != \
self._model["vdsm.password_confirmation"]:
- raise ovirt.node.exceptions.InvalidData("Passwords do not match.")
+ raise exceptions.InvalidData("Passwords do not match.")
def on_merge(self, effective_changes):
pass
diff --git a/scripts/tui/src/ovirt/node/setup/kdump_page.py b/scripts/tui/src/ovirt/node/setup/kdump_page.py
index 9daf83b..846e05b 100644
--- a/scripts/tui/src/ovirt/node/setup/kdump_page.py
+++ b/scripts/tui/src/ovirt/node/setup/kdump_page.py
@@ -81,9 +81,11 @@
widgets = [
("kdump._header", ui.Header("Configure Kdump")),
("kdump.type", ui.Options("Type", self._types)),
- ("kdump.ssh_location", ui.Entry("SSH Location:",
+ ("kdump.ssh_location", ui.Entry("SSH Location " +
+ "(example.redhat.com:/var/crash):",
align_vertical=True)),
- ("kdump.nfs_location", ui.Entry("NFS Location:",
+ ("kdump.nfs_location", ui.Entry("NFS Location " +
+ "root at example.redhat.com):",
align_vertical=True)),
]
# Save it "locally" as a dict, for better accessability
diff --git a/scripts/tui/src/ovirt/node/setup/keyboard_page.py b/scripts/tui/src/ovirt/node/setup/keyboard_page.py
index c321020..840aca6 100644
--- a/scripts/tui/src/ovirt/node/setup/keyboard_page.py
+++ b/scripts/tui/src/ovirt/node/setup/keyboard_page.py
@@ -38,10 +38,11 @@
return 30
def model(self):
- cfg = defaults.Logrotate().retrieve()
-
+ cfg = defaults.Keyboard().retrieve()
+ self.logger.debug(cfg)
model = {}
model["keyboard.layout"] = cfg["layout"] or ""
+ return model
def validators(self):
return {}
diff --git a/scripts/tui/src/ovirt/node/setup/logging_page.py b/scripts/tui/src/ovirt/node/setup/logging_page.py
index fa5ba0d..65e9af6 100644
--- a/scripts/tui/src/ovirt/node/setup/logging_page.py
+++ b/scripts/tui/src/ovirt/node/setup/logging_page.py
@@ -77,13 +77,14 @@
("logrotate.max_size", ui.Entry("Logrotate Max Log " +
"Size (KB):")),
- ("rsyslog.header", ui.Label(
- "RSyslog is an enhanced multi-threaded " +
- "syslogd")),
+ ("divider[1]", ui.Divider()),
+ ("rsyslog.header", ui.Label("RSyslog is an enhanced multi-" +
+ "threaded syslogd")),
("rsyslog.address", ui.Entry("Server Address:")),
("rsyslog.port", ui.Entry("Server Port:")),
- ("netconsole.header", ui.Label(
+ ("divider[1]", ui.Divider()),
+ ("netconsole.label", ui.Label(
"Netconsole service allows a remote sys" +
"log daemon to record printk() messages")),
("netconsole.address", ui.Entry("Server Address:")),
diff --git a/scripts/tui/src/ovirt/node/setup/network_page.py b/scripts/tui/src/ovirt/node/setup/network_page.py
index 8330191..eedbb88 100644
--- a/scripts/tui/src/ovirt/node/setup/network_page.py
+++ b/scripts/tui/src/ovirt/node/setup/network_page.py
@@ -96,14 +96,9 @@
This is an ordered list of (path, widget) tuples.
"""
widgets = [
- ("hostname",
- ui.Entry("Hostname:")),
+ ("headers[0]", ui.Header("System Identification")),
+ ("hostname", ui.Entry("Hostname:")),
("hostname._space", ui.Divider()),
-
- ("nics", ui.Table("Available System NICs",
- "Device Status Model MAC Address",
- self._get_nics())),
- ("nics._space", ui.Divider()),
("dns[0]", ui.Entry("DNS Server 1:")),
("dns[1]", ui.Entry("DNS Server 2:")),
@@ -112,6 +107,10 @@
("ntp[0]", ui.Entry("NTP Server 1:")),
("ntp[1]", ui.Entry("NTP Server 2:")),
("ntp._space", ui.Divider()),
+
+ ("nics", ui.Table("Available System NICs",
+ "Device Status Model MAC Address",
+ self._get_nics())),
]
# Save it "locally" as a dict, for better accessability
self._widgets.update(dict(widgets))
@@ -130,7 +129,7 @@
description = " ".join([
justify(nic["name"], 8),
justify(bootproto, 14),
- justify(nic["driver"], 8),
+ justify(nic["vendor"], 14),
justify(nic["hwaddr"], 17)
])
node_nics.append((name, description))
diff --git a/scripts/tui/src/ovirt/node/setup/remote_storage_page.py b/scripts/tui/src/ovirt/node/setup/remote_storage_page.py
index fbf983c..202e8f6 100644
--- a/scripts/tui/src/ovirt/node/setup/remote_storage_page.py
+++ b/scripts/tui/src/ovirt/node/setup/remote_storage_page.py
@@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
-from ovirt.node import utils
+from ovirt.node import utils, valid
from ovirt.node.config import defaults
from ovirt.node.plugins import ChangesHelper
import ovirt.node.plugins
@@ -40,17 +40,17 @@
return 70
def model(self):
- if not self._model:
- self._model = {
- "iscsi.initiator_name": "",
- }
- return self._model
+ icfg = defaults.iSCSI().retrieve()
+ ncfg = defaults.NFSv4().retrieve()
+ model = {}
+ model["iscsi.initiator_name"] = icfg["name"]
+ model["nfsv4.domain"] = ncfg["domain"]
+ return model
def validators(self):
- is_initiator_name = lambda v: (None if len(v.split(":")) == 2
- else "Invalid IQN.")
return {
- "iscsi.initiator_name": is_initiator_name,
+ "iscsi.initiator_name": valid.IQN(),
+ "nfsv4.domain": valid.FQDN(),
}
def ui_content(self):
@@ -60,7 +60,14 @@
("iscsi.initiator_name", ovirt.node.ui.Entry("iSCSI Initiator " +
"Name:",
align_vertical=True)),
+
+ ("divider", ovirt.node.ui.Divider()),
+
+ ("nfsv4.domain", ovirt.node.ui.Entry("NFSv4 Domain " +
+ "(example.redhat.com):",
+ align_vertical=True)),
]
+
# Save it "locally" as a dict, for better accessability
self._widgets = dict(widgets)
@@ -69,7 +76,6 @@
def on_change(self, changes):
pass
- self._model.update(changes)
def on_merge(self, effective_changes):
self.logger.debug("Saving remote storage page")
diff --git a/scripts/tui/src/ovirt/node/setup/security_page.py b/scripts/tui/src/ovirt/node/setup/security_page.py
index bd36277..65f89b3 100644
--- a/scripts/tui/src/ovirt/node/setup/security_page.py
+++ b/scripts/tui/src/ovirt/node/setup/security_page.py
@@ -61,17 +61,13 @@
widgets = [
("header[0]", ui.Header("Remote Access")),
("ssh.enabled", ui.Checkbox("Enable ssh password authentication")),
- ("divider[0]", ui.Divider()),
("header[1]", ui.Header("Strong Random Number Generator")),
("strongrng.aesni", ui.Checkbox("Enable AES-NI")),
("strongrng.num_bytes", ui.Entry("Bytes Used:")),
- ("divider[1]", ui.Divider()),
-
- ("header[2]", ui.Label("Local Access")),
- ("passwd.admin.password", ui.PasswordEntry(
- "Password:")),
+ ("header[2]", ui.Header("Local Access")),
+ ("passwd.admin.password", ui.PasswordEntry("Password:")),
("passwd.admin.password_confirmation", ui.PasswordEntry(
"Confirm Password:")),
]
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index 348e610..dc3f086 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -140,6 +140,7 @@
class Header(Label):
template = "\n %s\n"
+
def __init__(self, text, template=template):
super(Header, self).__init__(text)
self.template = template
diff --git a/scripts/tui/src/ovirt/node/ui/tui.py b/scripts/tui/src/ovirt/node/ui/tui.py
index 31535c5..3756d5a 100644
--- a/scripts/tui/src/ovirt/node/ui/tui.py
+++ b/scripts/tui/src/ovirt/node/ui/tui.py
@@ -72,11 +72,13 @@
('notice', 'light red'),
('plugin.widget.entry', element_styles["text"], "white"),
('plugin.widget.entry.disabled', element_styles["disabled"]),
- ('plugin.widget.entry.invalid', element_styles["invalid"], "white"),
+ ('plugin.widget.entry.invalid', element_styles["invalid"],
+ "white"),
('plugin.widget.entry.label', element_styles["label"]),
('plugin.widget.entry.label.invalid', element_styles["label"]),
('plugin.widget.entry.frame', element_styles["text"]),
- ('plugin.widget.entry.frame.invalid', element_styles["invalid"]),
+ ('plugin.widget.entry.frame.invalid',
+ element_styles["invalid"]),
('plugin.widget.entry.frame.disabled',
element_styles["disabled"]),
('plugin.widget.notice', 'light red'),
@@ -190,7 +192,8 @@
msg += "- %s\n" % (field.strip(":"))
if msg:
self.__display_as_dialog(urwid.Filler(urwid.Text(
- "The following fields were changed:\n%s" % msg)),
+ "The following fields were changed:\n%s" %
+ msg)),
"Pending changes")
has_outstanding_changes = True
return has_outstanding_changes
@@ -257,7 +260,6 @@
def __register_default_hotkeys(self):
self.register_hotkey(["esc"], self.quit)
- self.register_hotkey(["q"], self.quit)
self.register_hotkey(["window resize"], self._check_min_size_cb)
def _draw_screen(self):
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index b9f8f74..5967f8a 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -326,7 +326,7 @@
return self._selectable
def set_notice(self, txt):
- self._notice_txt= txt
+ self._notice_txt = txt
if txt:
self._notice.set_text(txt)
if len(self._pile.contents) < 2:
diff --git a/scripts/tui/src/ovirt/node/utils/storage.py b/scripts/tui/src/ovirt/node/utils/storage.py
new file mode 100644
index 0000000..037e51d
--- /dev/null
+++ b/scripts/tui/src/ovirt/node/utils/storage.py
@@ -0,0 +1,42 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# storage.py - Copyright (C) 2012 Red Hat, Inc.
+# Written by Fabian Deutsch <fabiand at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+from ovirt.node import base
+
+
+class iSCSI(base.Base):
+ """A class to deal with some external iSCSI related functionality
+ """
+ def initiator_name(self, initiator_name=None):
+ import ovirtnode.iscsi as oiscsi
+ if initiator_name:
+ oiscsi.set_iscsi_initiator(initiator_name)
+ return oiscsi.get_current_iscsi_initiator_name()
+
+
+class NFSv4(base.Base):
+ """A class to deal some external NFSv4 related functionality
+ """
+ def domain(self, domain=None):
+ import ovirtnode.network as onet
+ if domain:
+ onet.set_nfsv4_domain(domain)
+ return onet.get_current_nfsv4_domain()
diff --git a/scripts/tui/src/ovirt/node/valid.py b/scripts/tui/src/ovirt/node/valid.py
index 0620faa..52f01a6 100644
--- a/scripts/tui/src/ovirt/node/valid.py
+++ b/scripts/tui/src/ovirt/node/valid.py
@@ -345,3 +345,18 @@
def validate(self, value):
return value in [True, False]
+
+
+class IQN(RegexValidator):
+ """Matches a IQN
+
+ >>> IQN()("iqn.1994-05.com.redhat.com:6edea1b458e5")
+ True
+ >>> FQDN().validate("example.com.")
+ False
+ >>> FQDN().validate("")
+ False
+ """
+
+ description = "a valid IQN"
+ pattern = "^iqn\.(\d{4}-\d{2})\.([^:]+):"
--
To view, visit http://gerrit.ovirt.org/9966
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id72a5bf592e04825e5b282e9ef6573cd6090c652
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list