[node-patches] Change in ovirt-node[master]: setup: add nfsv4 domain option to remote storage page

jboggs at redhat.com jboggs at redhat.com
Fri Oct 12 18:45:21 UTC 2012


Joey Boggs has uploaded a new change for review.

Change subject: setup: add nfsv4 domain option to remote storage page
......................................................................

setup: add nfsv4 domain option to remote storage page

rhbz#855734

Change-Id: Id1f3b565be2ebff1516cd236a404b995872b5363
Signed-off-by: Joey Boggs <jboggs at redhat.com>
---
M scripts/ovirt-config-setup.py
M scripts/ovirtnode/network.py
2 files changed, 44 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/19/8519/1

diff --git a/scripts/ovirt-config-setup.py b/scripts/ovirt-config-setup.py
index 54fbade..7f66cdb 100755
--- a/scripts/ovirt-config-setup.py
+++ b/scripts/ovirt-config-setup.py
@@ -673,6 +673,14 @@
             self.gridform.draw()
         return
 
+    def valid_nfsv4_domain_callback(self):
+        if not is_valid_hostname(self.nfsv4_domain.value()):
+            self._create_warn_screen()
+            ButtonChoiceWindow(self.screen, "Network", "Invalid NFS Domain",
+                               buttons=['Ok'])
+            self.reset_screen_colors()
+            self.gridform.draw()
+
     def screen_locked_page(self, screen):
         self.screen_locked = True
         elements = Grid(1, 3)
@@ -1450,10 +1458,18 @@
         self.iscsi_initiator_config = Entry(50, "")
         self.iscsi_initiator_config.setCallback(self.valid_iqn_callback)
         elements.setField(self.iscsi_initiator_config, 0, 3, anchorLeft=1,
-                          padding=(0, 0, 0, 11))
+                          padding=(0, 0, 0, 1))
+        elements.setField(Label("NFSv4 Domain:"), 0, 4, anchorLeft=1)
+        self.nfsv4_domain = Entry(30, "")
+        self.nfsv4_domain.setCallback(self.valid_nfsv4_domain_callback)
+        elements.setField(self.nfsv4_domain, 0, 5, anchorLeft=1,
+                          padding=(0, 0, 0, 8))
         current_iscsi_initiator_name = get_current_iscsi_initiator_name()
         if current_iscsi_initiator_name is not None:
             self.iscsi_initiator_config.set(current_iscsi_initiator_name)
+        current_nfsv4_domain = get_current_nfsv4_domain()
+        if not current_nfsv4_domain.startswith("#"):
+            self.nfsv4_domain.set(current_nfsv4_domain)
         return [Label(""), elements]
 
     def menuSpacing(self):
@@ -1837,7 +1853,7 @@
 
     def process_remote_storage_config(self):
         set_iscsi_initiator(self.iscsi_initiator_config.value())
-
+        set_nfsv4_domain(self.nfsv4_domain.value())
     def ssh_hostkey_btn_cb(self):
         self._create_warn_screen()
         ssh_hostkey_msg = ("RSA Host Key Fingerprint:\n%s\n\nRSA Host " +
diff --git a/scripts/ovirtnode/network.py b/scripts/ovirtnode/network.py
index b4b5667..159ea9c 100644
--- a/scripts/ovirtnode/network.py
+++ b/scripts/ovirtnode/network.py
@@ -572,6 +572,32 @@
         _functions.ovirt_store_config("/etc/default/ovirt")
     return True
 
+def get_current_nfsv4_domain():
+    nfs_config = open("/etc/idmapd.conf")
+    domain = None
+    for line in nfs_config:
+        if "Domain =" in line:
+            domain = line.replace("Domain =", "").strip()
+    nfs_config.close()
+    return domain
+
+def set_nfsv4_domain(domain):
+    idmap_conf = "/etc/idmapd.conf"
+    current_domain = get_current_nfsv4_domain()
+    _functions.unmount_config(idmap_conf)
+    if current_domain.startswith("#"):
+        current_domain = "#Domain = %s" % current_domain.replace("# ","")
+        _functions.system("sed -i 's/%s/Domain = %s/g' %s" \
+            % (current_domain, domain, idmap_conf))
+    else:
+        _functions.system("sed -i 's/%s/%s/g' %s" \
+            % (current_domain, domain, idmap_conf))
+    if _functions.ovirt_store_config(idmap_conf):
+        _functions.logger.info("NFSv4 domain set as: " + domain)
+    else:
+        _functions.logger.warning("Setting nfsv4 domain failed")
+    _functions.system_closefds("service rpcidmapd restart")
+    _functions.system_closefds("nfsidmap -c &>/dev/null")
 
 def network_auto():
     try:


--
To view, visit http://gerrit.ovirt.org/8519
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1f3b565be2ebff1516cd236a404b995872b5363
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>



More information about the node-patches mailing list