Class: Yast::NfsServerClass
- Inherits:
-
Module
- Object
- Module
- Yast::NfsServerClass
- Defined in:
- ../../src/modules/NfsServer.rb
Instance Method Summary (collapse)
-
- (Hash) AutoPackages
Return required packages for auto-installation.
-
- (Object) Export
Dump the NFS settings to a map, for autoinstallation use.
-
- (Boolean) GetModified
Functions which returns if the settings were modified.
-
- (Object) Import(settings)
Get all NFS server configuration from a map.
- - (Object) main
-
- (Object) Portmapper
Get the used port mapper: since SLE11A3 we have rpcbind instead of portmap as the default (bnc#423026).
-
- (Object) Read
Reads NFS settings from the SCR (.etc.exports), from SCR (.sysnconfig.nfs) and SCR (.etc.idmapd_conf),if necessary.
-
- (Object) Set(settings)
Set the variables just as is and without complaining.
-
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
- (Object) Summary
A summary for autoyast.
-
- (Object) Write
Saves NFS server configuration.
-
- (Object) WriteExports
Saves /etc/exports and creates missing directories.
Instance Method Details
- (Hash) AutoPackages
Return required packages for auto-installation
438 439 440 |
# File '../../src/modules/NfsServer.rb', line 438 def AutoPackages { "install" => @required_packages, "remove" => [] } end |
- (Object) Export
Dump the NFS settings to a map, for autoinstallation use.
136 137 138 |
# File '../../src/modules/NfsServer.rb', line 136 def Export { "start_nfsserver" => @start, "nfs_exports" => @exports } end |
- (Boolean) GetModified
Functions which returns if the settings were modified
92 93 94 |
# File '../../src/modules/NfsServer.rb', line 92 def GetModified @modified end |
- (Object) Import(settings)
Get all NFS server configuration from a map. When called by nfs_server_auto (preparing autoinstallation data) the map may be empty.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File '../../src/modules/NfsServer.rb', line 102 def Import(settings) settings = deep_copy(settings) # if (size (settings) == 0) # { # // Reset - just continue with Set (#24544). # } # To avoid enabling nfslock if it does not exist during autoinstall @have_nfslock = Convert.to_boolean( SCR.Read(path(".init.scripts.exists"), "nfslock") ) Set(settings) true end |
- (Object) main
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File '../../src/modules/NfsServer.rb', line 21 def main textdomain "nfs_server" Yast.import "Progress" Yast.import "Report" Yast.import "Service" Yast.import "Summary" Yast.import "SuSEFirewall" Yast.import "Wizard" # default value of settings modified @modified = false # Required packages for this module to operate # @required_packages = ["nfs-kernel-server"] # Write only, used during autoinstallation. # Don't run services and SuSEconfig, it's all done at one place. @write_only = false # Enable nfsv4 @enable_nfsv4 = true # GSS Security ? @nfs_security = false # Domain name to be used for nfsv4 (idmapd.conf) @domain = "" # Should the server be started? # New since 9.0: Exports are independent of this setting. @start = false # @example # [ # $[ # "mountpoint": "/projects", # "allowed": [ "*.local.domain(ro)", "@trusted(rw)"] # ], # $[ ... ], # ... # ] # @exports = [] # Do we have nfslock? (nfs-utils: yes, nfs-server: no) # FIXME: check nfs-kernel-server @have_nfslock = true @portmapper = nil end |
- (Object) Portmapper
Get the used port mapper: since SLE11A3 we have rpcbind instead of portmap as the default (bnc#423026)
207 208 209 210 211 212 213 214 215 216 |
# File '../../src/modules/NfsServer.rb', line 207 def Portmapper if @portmapper == nil @portmapper = Service.Find(["rpcbind", "portmap"]) if @portmapper == "" Builtins.y2error("No portmapper found") @portmapper = "rpcbind" end end @portmapper end |
- (Object) Read
Reads NFS settings from the SCR (.etc.exports), from SCR (.sysnconfig.nfs) and SCR (.etc.idmapd_conf),if necessary.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File '../../src/modules/NfsServer.rb', line 143 def Read @start = Service.Enabled("nfsserver") @exports = Convert.convert( SCR.Read(path(".etc.exports")), :from => "any", :to => "list <map <string, any>>" ) @have_nfslock = Convert.to_boolean( SCR.Read(path(".init.scripts.exists"), "nfslock") ) @enable_nfsv4 = SCR.Read(path(".sysconfig.nfs.NFS4_SUPPORT")) == "yes" @nfs_security = SCR.Read(path(".sysconfig.nfs.NFS_SECURITY_GSS")) == "yes" if @enable_nfsv4 @domain = Convert.to_string( SCR.Read(path(".etc.idmapd_conf.value.General.Domain")) ) end progress_orig = Progress.set(false) SuSEFirewall.Read Progress.set(progress_orig) @exports != nil end |
- (Object) Set(settings)
Set the variables just as is and without complaining
119 120 121 122 123 124 125 126 127 128 129 130 |
# File '../../src/modules/NfsServer.rb', line 119 def Set(settings) settings = deep_copy(settings) @start = Ops.get_boolean(settings, "start_nfsserver", false) @exports = Ops.get_list(settings, "nfs_exports", []) # #260723, #287338: fix wrongly initialized variables # but do not extend the schema yet @enable_nfsv4 = false @domain = "" @nfs_security = false nil end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to "true"
84 85 86 87 88 |
# File '../../src/modules/NfsServer.rb', line 84 def SetModified @modified = true nil end |
- (Object) Summary
Returns A summary for autoyast
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File '../../src/modules/NfsServer.rb', line 396 def Summary summary = "" # summary header; directories exported by NFS summary = Summary.AddHeader(summary, _("NFS Exports")) if Ops.greater_than(Builtins.size(@exports), 0) Builtins.foreach(@exports) do |e| summary = Summary.OpenList(summary) summary = Summary.AddListItem( summary, Ops.get_string(e, "mountpoint", "") ) summary = Summary.CloseList(summary) end else summary = Summary.AddLine(summary, Summary.NotConfigured) end # add information reg NFSv4 support, domain and security if @enable_nfsv4 summary = Summary.AddLine(summary, "NFSv4 support is enabled.") summary = Summary.AddLine( summary, Builtins.sformat(_("The NFSv4 domain for idmapping is %1."), @domain) ) else summary = Summary.AddLine(summary, "NFSv4 support is disabled.") end if @nfs_security summary = Summary.AddLine(summary, "NFS Security using GSS is enabled.") else summary = Summary.AddLine( summary, "NFS Security using GSS is disabled." ) end summary end |
- (Object) Write
Saves NFS server configuration. (exports(5)) Creates any missing directories.
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File '../../src/modules/NfsServer.rb', line 221 def Write # if there is still work to do, don't return false immediately # but remember the error ok = true # dialog label Progress.New( _("Writing NFS Server Configuration"), " ", 2, [ # progress stage label _("Save /etc/exports"), # progress stage label _("Restart services") ], [ # progress step label _("Saving /etc/exports..."), # progress step label _("Restarting services..."), # final progress step label _("Finished") ], "" ) # help text if !@write_only # help text Wizard.RestoreHelp(_("Writing NFS server settings. Please wait...")) end Progress.NextStage # Independent of @ref start because of Heartbeat (#27001). if !WriteExports() Progress.Finish return false end if @enable_nfsv4 SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "yes") if !SCR.Write(path(".etc.idmapd_conf.value.General.Domain"), @domain) || !SCR.Write(path(".etc.idmapd_conf"), nil) Report.Error(_("Unable to write to idmapd.conf.")) end else SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "no") end if @nfs_security SCR.Write(path(".sysconfig.nfs.NFS_SECURITY_GSS"), "yes") else SCR.Write(path(".sysconfig.nfs.NFS_SECURITY_GSS"), "no") end SCR.Write(path(".sysconfig.nfs"), nil) Progress.NextStage if !@start Service.Stop("nfsserver") if !@write_only if !Service.Disable("nfsserver") Report.Error(Service.Error) ok = false end if @have_nfslock Service.Stop("nfslock") if !@write_only if !Service.Disable("nfslock") Report.Error(Service.Error) ok = false end end else if !Service.Enable(Portmapper()) Report.Error(Service.Error) ok = false end if @have_nfslock if !Service.Enable("nfslock") Report.Error(Service.Error) ok = false end end if !Service.Enable("nfsserver") Report.Error(Service.Error) ok = false end if @enable_nfsv4 if Service.Status("idmapd") == 3 if !Service.Start("idmapd") Report.Error( _("Unable to start idmapd. Check your domain setting.") ) ok = false end end if Service.Status("idmapd") == 0 if !Service.Restart("idmapd") Report.Error(_("Unable to restart idmapd.")) ok = false end end else if Service.Status("idmapd") == 3 if !Service.Stop("idmapd") Report.Error(_("Unable to stop idmapd.")) ok = false end end end if @nfs_security if Service.Status("svcgssd") == 3 if !Service.Start("svcgssd") # FIXME svcgssd is gone! (only nfsserver is left) Report.Error( _( "Unable to start svcgssd. Ensure your kerberos and gssapi (nfs-utils) setup is correct." ) ) ok = false end end if Service.Status("svcgssd") == 0 if !Service.Restart("svcgssd") Report.Error( _("'svcgssd' is already running. Unable to restart it.") ) ok = false end end else if Service.Status("svcgssd") == 0 if !Service.Stop("svcgssd") Report.Error(_("'svcgssd' is running. Unable to stop it.")) ok = false end end end if !@write_only if Service.Status(Portmapper()) != 0 # portmap must not be started if it is running already (see bug # 9999) Service.Start(Portmapper()) end Service.Stop("nfsserver") Service.Restart("nfslock") if @have_nfslock Service.Start("nfsserver") if Service.Status("nfsserver") != 0 # error popup message Report.Error( _( "Unable to restart the NFS server.\nYour changes will be active after reboot.\n" ) ) ok = false end end end progress_orig = Progress.set(false) SuSEFirewall.WriteOnly SuSEFirewall.ActivateConfiguration if !@write_only Progress.set(progress_orig) Progress.NextStage ok end |
- (Object) WriteExports
Saves /etc/exports and creates missing directories.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File '../../src/modules/NfsServer.rb', line 172 def WriteExports # create missing directories. Builtins.foreach(@exports) do |entry| directory = Ops.get_string(entry, "mountpoint") if SCR.Read(path(".target.dir"), directory) == nil if !Convert.to_boolean(SCR.Execute(path(".target.mkdir"), directory)) # not fatal - write other dirs. Report.Warning( Builtins.sformat( _("Unable to create a missing directory:\n%1"), directory ) ) end end end # (the backup is now done by the agent) if !SCR.Write(path(".etc.exports"), @exports) # error popup message Report.Error( _( "Unable to write to /etc/exports.\n" + "No changes will be made to the\n" + "exported directories.\n" ) ) return false end true end |