Skip to content
This repository was archived by the owner on Apr 24, 2026. It is now read-only.

Commit 5752f74

Browse files
committed
Add refresh-config feature to NFS-Ganesha
1 parent 515a319 commit 5752f74

14 files changed

Lines changed: 172 additions & 14 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add a client block and run-refresh config
2+
# config-block: is the variable containing lines (| separated) which will be
3+
# added to the client block.
4+
#
5+
# The client block will look something like:
6+
# client {
7+
# clients = 10.0.0.1;
8+
# allow_root_access = true;
9+
# access_type = "RO";
10+
# Protocols = "3";
11+
# anonymous_uid = 1440;
12+
# anonymous_gid = 72;
13+
# }
14+
#
15+
16+
[hosts]
17+
dhcp37-102.lab.eng.blr.redhat.com
18+
dhcp37-103.lab.eng.blr.redhat.com
19+
20+
[nfs-ganesha]
21+
action=refresh-config
22+
# Default block name is `client'
23+
# block-name=client
24+
config-block=clients = 10.0.0.1;|allow_root_access = true;|access_type = "RO";|Protocols = "2", "3";|anonymous_uid = 1440;|anonymous_gid = 72;
25+
volname=ganesha
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[hosts]
2+
dhcp37-102.lab.eng.blr.redhat.com
3+
dhcp37-103.lab.eng.blr.redhat.com
4+
5+
[nfs-ganesha]
6+
action=refresh-config
7+
add-config-lines=clients = 10.0.0.1;|anonymous_gid = 72;
8+
volname=ganesha
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[hosts]
2+
dhcp37-102.lab.eng.blr.redhat.com
3+
dhcp37-103.lab.eng.blr.redhat.com
4+
5+
[nfs-ganesha]
6+
action=refresh-config
7+
# This is a regular expression, lines containing clients will be removed to
8+
# delete more than one line separate the values by |
9+
del-config-lines=clients
10+
block-name=client
11+
config-block=clients = 10.0.0.1;|allow_root_access = true;|access_type = "RO";|Protocols = "3";|anonymous_uid = 1440;|anonymous_gid = 72;
12+
volname=ganesha
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[hosts]
2+
dhcp37-102.lab.eng.blr.redhat.com
3+
dhcp37-103.lab.eng.blr.redhat.com
4+
5+
[nfs-ganesha]
6+
action=refresh-config
7+
del-config-lines=client
8+
volname=ganesha

examples/gluster.conf.sample

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,16 +1241,6 @@ client_mount_points=/mnt/gluster{1,3}
12411241
# `ctdb_nodes' variable in the above example is optional, if it is removed the
12421242
# nodes used to create volume are used as ctdb nodes.
12431243
#
1244-
# Other supported variables include:
1245-
# CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
1246-
# CTDB_NODES=/etc/ctdb/nodes
1247-
# CTDB_MANAGES_SAMBA=no
1248-
# CTDB_SET_DeterministicIPs=1
1249-
# CTDB_SET_RecoveryBanPeriod=120
1250-
# CTDB_SET_KeepaliveInterval=5
1251-
# CTDB_SET_KeepaliveLimit=5
1252-
# CTDB_SET_MonitorInterval=15
1253-
# CTDB_RECOVERY_LOCK=/mnt/lock/reclock
12541244
#
12551245
# NOTE: Expect the user to specify nodes in the cluster under section
12561246
# 'hosts'
@@ -1288,7 +1278,7 @@ client_mount_points=/mnt/gluster{1,3}
12881278
# action=setup
12891279
# public_address=10.70.37.6/24 eth0,10.70.37.8/24 eth0
12901280
# volname=ctdb
1291-
#
1281+
#
12921282
#-----------------------------------
12931283

12941284

examples/refresh-config.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[hosts]
2+
dhcp37-102.lab.eng.blr.redhat.com
3+
dhcp37-103.lab.eng.blr.redhat.com
4+
5+
[nfs-ganesha]
6+
action=refresh-config
7+
volname=ganesha

gdeployfeatures/clients/clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def clients_mount(section_dict):
4141
def nfs_mount(mnt, host, section_dict):
4242
global client_mounts, helpers
4343
options = section_dict.pop('options')
44-
if type(options) != list:
44+
if type(options) is not list:
4545
options = [options]
4646
section_dict['opts'] = ",".join(options)
4747
client_mounts[host].append({'mountpoint': mnt, 'fstype': 'nfs'})

gdeployfeatures/nfs_ganesha/nfs_ganesha.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,32 @@
6464
"required": "true"
6565
}
6666
]
67+
},
68+
"refresh-config": {
69+
"options": [
70+
{
71+
"required": "false",
72+
"name": "del-config-lines"
73+
},
74+
{
75+
"name": "add-config-lines",
76+
"required": "false"
77+
},
78+
{
79+
"name": "block-name",
80+
"required": "false",
81+
"default": "client"
82+
},
83+
{
84+
"name": "volname",
85+
"required": "true"
86+
},
87+
{
88+
"name": "ha-conf-dir",
89+
"required": "false",
90+
"default": "/etc/ganesha"
91+
}
92+
]
6793
}
6894
}
6995
}

gdeployfeatures/nfs_ganesha/nfs_ganesha.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,29 @@ def nfs_ganesha_unexport_volume(section_dict):
6060
section_dict = get_base_dir(section_dict)
6161
return section_dict, defaults.GANESHA_VOL_EXPORT
6262

63+
def nfs_ganesha_refresh_config(section_dict):
64+
del_lines = list_to_string(section_dict.get('del-config-lines'))
65+
# Split the string which is `|' delimited. Escaped `|' is handled gracefully
66+
section_dict['del-config-lines'] = helpers.split_string(del_lines, '|')
67+
68+
add_lines = list_to_string(section_dict.get('add-config-lines'))
69+
section_dict['add-config-lines'] = helpers.split_string(add_lines, '|')
70+
71+
block_name = section_dict.get('block-name')
72+
section_dict['block-name'] = block_name
73+
74+
config_block = list_to_string(section_dict.get('config-block'))
75+
section_dict['config-block'] = helpers.split_string(config_block, '|')
76+
77+
section_dict['ha-conf-dir'] = section_dict.get('ha-conf-dir')
78+
section_dict = get_base_dir(section_dict)
79+
80+
if config_block:
81+
section_dict['config-block'].insert(0, '%s {'%block_name)
82+
section_dict['config-block'].append('}\n')
83+
84+
return section_dict, defaults.GANESHA_REFRESH_CONFIG
85+
6386
def get_cluster_nodes(section_dict):
6487
global helpers
6588
cluster_nodes = section_dict.get('cluster-nodes')
@@ -93,3 +116,11 @@ def get_base_dir(section_dict):
93116
section_dict['base_dir'] = Global.base_dir
94117
section_dict['ha_base_dir'] = '/etc/ganesha'
95118
return section_dict
119+
120+
def list_to_string(l):
121+
# If l is a list of lines, join and return string
122+
if type(l) is list:
123+
return ",".join(l)
124+
else:
125+
# Return the string
126+
return l

gdeployfeatures/yum/yum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def yum_remove(section_dict):
3333

3434
def get_common_data(section_dict):
3535
packages = section_dict.pop('packages')
36-
if type(packages) != list:
36+
if type(packages) is not list:
3737
packages = [packages]
3838
section_dict['name'] = ','.join(packages)
3939
return section_dict, defaults.YUM_OP

0 commit comments

Comments
 (0)