Skip to content

Commit fc8514f

Browse files
committed
ncm-metaconfig/ganesha: Use choice type where possible
Also use built-in validation for the long "ganesha_nfs_protocol".
1 parent ca08171 commit fc8514f

File tree

2 files changed

+56
-20
lines changed

2 files changed

+56
-20
lines changed

ncm-metaconfig/src/main/metaconfig/ganesha/pan/schema.pan

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ declaration template metaconfig/ganesha/schema;
22

33
# the defaults are based on the GPFS FSAL
44

5-
type ganesha_nfs_protocol = long with SELF == 2 || SELF == 3 || SELF == 4;
6-
type ganesha_transport_protocol = string with SELF == 'TCP' || SELF == 'UDP';
7-
type ganesha_sec_type = string with SELF == 'sys' || SELF == 'krb5' || SELF == 'krb5i' || SELF == 'krb5p';
5+
type ganesha_nfs_protocol = long(2..4);
6+
type ganesha_transport_protocol = choice('TCP', 'UDP');
7+
type ganesha_sec_type = choice('sys', 'krb5', 'krb5i', 'krb5p');
88

99
type ganesha_export_client = {
1010
"Root_Access" ? string[] # Grant root access to thoses nodes, networks and @netgroups. A hostname can contain wildcards (*?).

ncm-metaconfig/src/main/metaconfig/ganesha/pan/schema_v2.pan

+53-17
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type ganesha_v2_export_FSAL = {
5757
#"FSAL" ? ganesha_v2_export_FSAL
5858
#FSAL_VFS
5959
"pnfs" ? boolean = false
60-
"fsid_type" ? string with match(SELF, '^(None|One64|Major64|Two64|uuid|Two32|Dev|Device)$')
60+
"fsid_type" ? choice('None', 'One64', 'Major64', 'Two64', 'uuid', 'Two32', 'Dev', 'Device')
6161
#FSAL_GLUSTER
6262
"glfs_log" ? string = "/tmp/gfapi.log"
6363
"hostname" ? string # Mandatory
@@ -71,26 +71,40 @@ type ganesha_v2_export_FSAL = {
7171
"PNFS" ? ganesha_v2_export_FSAL_PNFS
7272
};
7373

74-
type ganesha_v2_protocol = string with match(SELF, '^((NFS)?[vV]?[34]|9P)$');
75-
type ganesha_v2_SecType = string with match(SELF, '^(none|sys|krb5[ip]?)$');
76-
type ganesha_v2_Transports = string with match(SELF, '^(UDP|TCP)$');
74+
type ganesha_v2_protocol = choice('3', '4', 'NFS3', 'NFS4', 'V3', 'V4', 'NFSv3', 'NFSv4', '9P');
75+
type ganesha_v2_SecType = choice('none', 'sys', 'krb5', 'krb5i', 'krb5p');
76+
type ganesha_v2_Transports = choice('UDP', 'TCP');
77+
type ganesha_v2_delegations = choice('None', 'read', 'write', 'readwrite', 'r', 'w', 'rw');
7778

7879
@{ Ganesha Export Permissions for EXPORT_DEFAULLTS, EXPORT and CLIENT sections @}
7980
type ganesha_v2_export_permissions = {
80-
"Access_Type" ? string = 'None' with match(SELF, '^(None|RW|RO|MDONLY|MDONLY_RO)$')
81+
"Access_Type" ? choice('None', 'RW', 'RO', 'MDONLY', 'MDONLY_RO') = 'None'
8182
"Anonymous_gid" ? long = -2
8283
"Anonymous_uid" ? long = -2
83-
"Delegations" ? string with match(SELF, '^(None|read|write|readwrite|r|w|rw)$')
84+
"Delegations" ? ganesha_v2_delegations
8485
"Disable_ACL" ? boolean = false
8586
"DisableReaddirPlus" ? boolean = false
8687
"Manage_Gids" ? boolean = false
8788
"NFS_Commit" ? boolean = false
8889
"PrivilegedPort" ? boolean = false
8990
"Protocols" ? ganesha_v2_protocol[] = list('3', '4', '9P')
9091
"SecType" ? ganesha_v2_SecType[] = list('none', 'sys')
91-
"Squash" ? string = "root_squash" with match(SELF,
92-
'^((root|all)(_?squash)?|no_root_squash|none|noidsquash)$'
93-
)
92+
"Squash" ? choice(
93+
'root',
94+
'root_squash',
95+
'rootsquash',
96+
'rootid',
97+
'root_id_squash',
98+
'rootidsquash',
99+
'all',
100+
'all_squash',
101+
'allsquash',
102+
'all_anomnymous',
103+
'allanonymous',
104+
'no_root_squash',
105+
'none',
106+
'noidsquash'
107+
) = "root_squash"
94108
"Transports" ? ganesha_v2_Transports[] = list('UDP', 'TCP')
95109
"Trust_Readdir_Negative_Cache" ? boolean = false
96110
};
@@ -130,8 +144,19 @@ type ganesha_v2_exports = {
130144
"UseCookieVerifier" ? boolean = true
131145
};
132146

133-
type ganesha_v2_log_level = string with match(SELF,
134-
'^(NULL|FATAL|MAJ|CRIT|WARN|EVENT|INFO|DEBUG|MID_DEBUG|M_DBG|FULL_DEBUG|F_DBG)$'
147+
type ganesha_v2_log_level = choice(
148+
'NULL',
149+
'FATAL',
150+
'MAJ',
151+
'CRIT',
152+
'WARN',
153+
'EVENT',
154+
'INFO',
155+
'DEBUG',
156+
'MID_DEBUG',
157+
'M_DBG',
158+
'FULL_DEBUG',
159+
'F_DBG'
135160
);
136161

137162
@{ Check for valid Ganesha Log Component names @}
@@ -146,8 +171,19 @@ function is_ganesha_v2_log_Components = {
146171
};
147172
type ganesha_v2_log_Components = ganesha_v2_log_level{} with is_ganesha_v2_log_Components(SELF);
148173

149-
type ganesha_v2_log_time_format = string with match(SELF,
150-
'^(ganesha|true|local|8601|ISO-8601|ISO 8601|ISO|syslog|syslog_usec|false|none|user_defined)$'
174+
type ganesha_v2_log_time_format = choice(
175+
'ganesha',
176+
'true',
177+
'local',
178+
'8601',
179+
'ISO-8601',
180+
'ISO 8601',
181+
'ISO',
182+
'syslog',
183+
'syslog_usec',
184+
'false',
185+
'none',
186+
'user_defined'
151187
);
152188

153189
@{ Ganesha Log Format subsection @}
@@ -173,8 +209,8 @@ type ganesha_v2_log_Format = {
173209
@{ Ganesha Log Facility subsection @}
174210
type ganesha_v2_log_Facility = {
175211
"destination" : string
176-
"enable" ? string = 'idle' with match(SELF, '^(idle|active|default)$')
177-
"headers" ? string = 'all' with match(SELF, '^(none|component|all)$')
212+
"enable" ? choice('idle', 'active', 'default') = 'idle'
213+
"headers" ? choice('none', 'component', 'all') = 'all'
178214
"max_level" ? ganesha_v2_log_level = 'FULL_DEBUG'
179215
"name" ? string
180216
};
@@ -283,7 +319,7 @@ type ganesha_v2_proxy_remote_server = {
283319
"RPC_Client_Timeout" ? long(0..) = 60
284320
"Remote_PrincipalName" ? string
285321
"Retry_SleepTime" ? long(0..) = 10
286-
"Sec_Type" ? string = 'krb5' with match(SELF, '^krb5[ip]?$')
322+
"Sec_Type" ? choice('none', 'krb5', 'krb5i', 'krb5p') = 'krb5'
287323
"Srv_Addr" ? type_ip = "127.0.0.1"
288324
"Use_Privileged_Client_Port" ? boolean = false
289325
};
@@ -314,7 +350,7 @@ type ganesha_v2_proxy = {
314350
@{ Ganesha GPFS section @}
315351
type ganesha_v2_GPFS = {
316352
include ganesha_v2_fsalsettings_all
317-
"Delegations" ? string with match(SELF, '^(None|read|write|readwrite|r|w|rw)$')
353+
"Delegations" ? ganesha_v2_delegations
318354
"fsal_grace" ? boolean = false
319355
"fsal_trace" ? boolean = true
320356
"pnfs_file" ? boolean = false

0 commit comments

Comments
 (0)