mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
Merge pull request #40721 from rhcs-dashboard/49925-fix-nfs-ganesha
mgr/dashboard: fix errors when creating NFS export. Reviewed-by: Avan Thakkar <athakkar@redhat.com> Reviewed-by: Ernesto Puerta <epuertat@redhat.com> Reviewed-by: Nizamudeen A <nia@redhat.com>
This commit is contained in:
commit
648f9e11a6
@ -154,7 +154,7 @@ class Ganesha(object):
|
||||
if RgwClient.admin_instance().is_service_online() and \
|
||||
RgwClient.admin_instance().is_system_user():
|
||||
result.append("RGW")
|
||||
except (NoCredentialsException, RequestException, LookupError):
|
||||
except (DashboardException, NoCredentialsException, RequestException, LookupError):
|
||||
pass
|
||||
return result
|
||||
|
||||
@ -212,9 +212,9 @@ class GaneshaConfParser(object):
|
||||
return block_name
|
||||
|
||||
def parse_block_or_section(self):
|
||||
if self.stream().startswith("%url "):
|
||||
if self.stream().startswith("%url"):
|
||||
# section line
|
||||
self.pos += 5
|
||||
self.pos += self.stream().find('rados://')
|
||||
idx = self.stream().find('\n')
|
||||
if idx == -1:
|
||||
value = self.stream()
|
||||
|
@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# pylint: disable=too-many-lines
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
@ -18,6 +19,38 @@ from . import KVStoreMockMixin # pylint: disable=no-name-in-module
|
||||
|
||||
|
||||
class GaneshaConfTest(unittest.TestCase, KVStoreMockMixin):
|
||||
daemon_raw_config = """
|
||||
NFS_CORE_PARAM {
|
||||
Enable_NLM = false;
|
||||
Enable_RQUOTA = false;
|
||||
Protocols = 4;
|
||||
NFS_Port = 14000;
|
||||
}
|
||||
|
||||
MDCACHE {
|
||||
Dir_Chunk = 0;
|
||||
}
|
||||
|
||||
NFSv4 {
|
||||
RecoveryBackend = rados_cluster;
|
||||
Minor_Versions = 1, 2;
|
||||
}
|
||||
|
||||
RADOS_KV {
|
||||
pool = nfs-ganesha;
|
||||
namespace = vstart;
|
||||
UserId = vstart;
|
||||
nodeid = a;
|
||||
}
|
||||
|
||||
RADOS_URLS {
|
||||
Userid = vstart;
|
||||
watch_url = 'rados://nfs-ganesha/vstart/conf-nfs.vstart';
|
||||
}
|
||||
|
||||
%url rados://nfs-ganesha/vstart/conf-nfs.vstart
|
||||
"""
|
||||
|
||||
export_1 = """
|
||||
EXPORT {
|
||||
Export_ID=1;
|
||||
@ -231,6 +264,44 @@ EXPORT
|
||||
ganesha.GaneshaConfOrchestrator._get_orch_nfs_instances = Mock(
|
||||
side_effect=_get_nfs_instances)
|
||||
|
||||
def test_parse_daemon_raw_config(self):
|
||||
expected_daemon_config = [
|
||||
{
|
||||
"block_name": "NFS_CORE_PARAM",
|
||||
"enable_nlm": False,
|
||||
"enable_rquota": False,
|
||||
"protocols": 4,
|
||||
"nfs_port": 14000
|
||||
},
|
||||
{
|
||||
"block_name": "MDCACHE",
|
||||
"dir_chunk": 0
|
||||
},
|
||||
{
|
||||
"block_name": "NFSV4",
|
||||
"recoverybackend": "rados_cluster",
|
||||
"minor_versions": [1, 2]
|
||||
},
|
||||
{
|
||||
"block_name": "RADOS_KV",
|
||||
"pool": "nfs-ganesha",
|
||||
"namespace": "vstart",
|
||||
"userid": "vstart",
|
||||
"nodeid": "a"
|
||||
},
|
||||
{
|
||||
"block_name": "RADOS_URLS",
|
||||
"userid": "vstart",
|
||||
"watch_url": "'rados://nfs-ganesha/vstart/conf-nfs.vstart'"
|
||||
},
|
||||
{
|
||||
"block_name": "%url",
|
||||
"value": "rados://nfs-ganesha/vstart/conf-nfs.vstart"
|
||||
}
|
||||
]
|
||||
daemon_config = GaneshaConfParser(self.daemon_raw_config).parse()
|
||||
self.assertEqual(daemon_config, expected_daemon_config)
|
||||
|
||||
def test_export_parser_1(self):
|
||||
blocks = GaneshaConfParser(self.export_1).parse()
|
||||
self.assertIsInstance(blocks, list)
|
||||
|
Loading…
Reference in New Issue
Block a user