Hello Yedidyah Bar David,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/22206

to review the following change.

Change subject: packaging: setup: Support NFSv4 storage domain
......................................................................

packaging: setup: Support NFSv4 storage domain

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1034873
Change-Id: Icca8a5f6296502da3610356620c336ae14e74353
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M man/ovirt-hosted-engine-setup.8
M src/bin/hosted-engine.in
M src/plugins/ovirt-hosted-engine-setup/storage/storage.py
M tests/answers
4 files changed, 56 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/06/22206/1

diff --git a/man/ovirt-hosted-engine-setup.8 b/man/ovirt-hosted-engine-setup.8
index 6eba5e7..68d1a04 100644
--- a/man/ovirt-hosted-engine-setup.8
+++ b/man/ovirt-hosted-engine-setup.8
@@ -48,7 +48,7 @@
 OVEHOSTED_STORAGE/hostID=int:1
 OVEHOSTED_STORAGE/storageType=none:None
 OVEHOSTED_STORAGE/volUUID=str:272b4067-1ae4-4755-b2e3-96bb600006e7
-OVEHOSTED_STORAGE/domainType=str:nfs
+OVEHOSTED_STORAGE/domainType=str:nfs3
 OVEHOSTED_STORAGE/imgSizeGB=str:25
 OVEHOSTED_STORAGE/storageDomainConnection=str:server.home:/home/images
 OVEHOSTED_STORAGE/connectionUUID=str:ca50f16a-23ab-465c-914b-b132f07a7151
diff --git a/src/bin/hosted-engine.in b/src/bin/hosted-engine.in
index 7cfad74..232e891 100644
--- a/src/bin/hosted-engine.in
+++ b/src/bin/hosted-engine.in
@@ -214,8 +214,13 @@
 __EOF__
 return ;}
 
-    if [ "${domainType}" == "nfs" ] ; then
+    protocol_version=''
+    if [ "${domainType}" == "nfs3" ] ; then
         storageType=1
+        protocol_version=3
+    elif [ "${domainType}" == "nfs4" ] ; then
+        storageType=1
+        protocol_version=4
     elif [ "${domainType}" == "glusterfs" ] ; then
         storageType=7
     else
@@ -226,7 +231,7 @@
     ${VDSCOMMAND} connectStorageServer \
         ${storageType} \
         ${spUUID} \
-        
connection=${storage},iqn=,portal=,user=kvm,password=,id=${connectionUUID},port=
+        
connection=${storage},iqn=,portal=,user=kvm,password=,id=${connectionUUID},port=,protocol_version=${protocol_version}
 }
 
 cmd_start_pool() {
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
index 642d6b9..7497519 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/storage.py
@@ -79,20 +79,36 @@
         self.serv = None
         self.waiter = None
         self.storageType = None
+        self.protocol_version = None
         self.domain_exists = False
         self.pool_exists = False
         self._connected = False
         self._monitoring = False
 
     def _mount(self, path, connection, domain_type):
+        fstype = ''
+        opts = []
+
+        if domain_type == 'nfs3':
+            fstype = 'nfs'
+            opts.append('vers=3')
+        elif domain_type == 'nfs4':
+            fstype = 'nfs'
+            opts.append('vers=4')
+
+        if fstype == 'nfs':
+            opts.append('retry=1')
+
         mount_cmd = (
             self.command.get('mount'),
-            '-t%s' % domain_type,
+            '-t%s' % fstype,
         )
-        if domain_type == 'nfs':
+
+        if opts:
             mount_cmd += (
-                '-oretry=1',
+                '-o%s' % ','.join(opts),
             )
+
         mount_cmd += (
             connection,
             path,
@@ -444,7 +460,8 @@
             "user=kvm,"
             "password=,"
             "id={connectionUUID},"
-            "port="
+            "port=,"
+            "protocol_version={protocol_version}"
         ).format(
             connection=self.environment[
                 ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION
@@ -452,6 +469,7 @@
             connectionUUID=self.environment[
                 ohostedcons.StorageEnv.CONNECTION_UUID
             ],
+            protocol_version=self.protocol_version,
         )
         method(args=[
             self.storageType,
@@ -717,32 +735,28 @@
                 ohostedcons.StorageEnv.DOMAIN_TYPE
             ] is None
         )
-        #{ Enforce DOMAIN_TYPE to nfs until glusterfs issues are solved.
-        self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] = 'nfs'
-        #}
         validDomain = False
         while not validDomain:
             try:
                 if interactive:
-                    #{ Enforce DOMAIN_TYPE to nfs until glusterfs
-                    # issues are solved.
-                    #self.environment[
-                    #    ohostedcons.StorageEnv.DOMAIN_TYPE
-                    #] = self.dialog.queryString(
-                    #    name='OVEHOSTED_STORAGE_DOMAIN_TYPE',
-                    #    note=_(
-                    #        'Please specify the storage '
-                    #        'you would like to use (@VALUES@)[@DEFAULT@]: '
-                    #    ),
-                    #    prompt=True,
-                    #    caseSensitive=True,
-                    #    validValues=(
-                    #        'glusterfs',
-                    #        'nfs',
-                    #    ),
-                    #    default='nfs',
-                    #)
-                    #}
+                    self.environment[
+                        ohostedcons.StorageEnv.DOMAIN_TYPE
+                    ] = self.dialog.queryString(
+                        name='OVEHOSTED_STORAGE_DOMAIN_TYPE',
+                        note=_(
+                            'Please specify the storage '
+                            'you would like to use (@VALUES@)[@DEFAULT@]: '
+                        ),
+                        prompt=True,
+                        caseSensitive=True,
+                        validValues=(
+                            # Enable when glusterfs issues are solved:
+                            # 'glusterfs',
+                            'nfs3',
+                            'nfs4',
+                        ),
+                        default='nfs3',
+                    )
 
                     self.environment[
                         ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION
@@ -803,8 +817,14 @@
                     )
         if self.environment[
             ohostedcons.StorageEnv.DOMAIN_TYPE
-        ] == 'nfs':
+        ] == 'nfs3':
             self.storageType = self.NFS_DOMAIN
+            self.protocol_version = 3
+        elif self.environment[
+            ohostedcons.StorageEnv.DOMAIN_TYPE
+        ] == 'nfs4':
+            self.storageType = self.NFS_DOMAIN
+            self.protocol_version = 4
         elif self.environment[
             ohostedcons.StorageEnv.DOMAIN_TYPE
         ] == 'glusterfs':
diff --git a/tests/answers b/tests/answers
index 3547e6e..eddb64e 100644
--- a/tests/answers
+++ b/tests/answers
@@ -1,7 +1,7 @@
 [environment:default]
 OVEHOSTED_NETWORK/bridgeIf=str:em1
 OVEHOSTED_NETWORK/fqdn=str:ovirt.home
-OVEHOSTED_STORAGE/domainType=str:nfs
+OVEHOSTED_STORAGE/domainType=str:nfs3
 OVEHOSTED_STORAGE/storageDatacenterName=str:hosted_datacenter
 OVEHOSTED_STORAGE/storageDomainConnection=str:192.168.1.104:/home/images
 OVEHOSTED_STORAGE/storageDomainName=str:hosted_storage


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icca8a5f6296502da3610356620c336ae14e74353
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: ovirt-hosted-engine-setup-1.0
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
Gerrit-Reviewer: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to