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) 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
360 361 362 |
# File '../../src/modules/NfsServer.rb', line 360 def AutoPackages { "install" => @required_packages, "remove" => [] } end |
- (Object) Export
Dump the NFS settings to a map, for autoinstallation use.
116 117 118 |
# File '../../src/modules/NfsServer.rb', line 116 def Export { "start_nfsserver" => @start, "nfs_exports" => @exports } end |
- (Boolean) GetModified
Functions which returns if the settings were modified
81 82 83 |
# File '../../src/modules/NfsServer.rb', line 81 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.
91 92 93 94 95 |
# File '../../src/modules/NfsServer.rb', line 91 def Import(settings) settings = deep_copy(settings) 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 |
# 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? # Exports are independent of this setting. @start = false # @example # [ # $[ # "mountpoint": "/projects", # "allowed": [ "*.local.domain(ro)", "@trusted(rw)"] # ], # $[ ... ], # ... # ] # @exports = [] # Since SLE 11, there's no portmapper, but rpcbind @portmapper = "rpcbind" end |
- (Object) Read
Reads NFS settings from the SCR (.etc.exports), from SCR (.sysnconfig.nfs) and SCR (.etc.idmapd_conf),if necessary.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File '../../src/modules/NfsServer.rb', line 123 def Read @start = Service.Enabled("nfsserver") @exports = Convert.convert( SCR.Read(path(".etc.exports")), :from => "any", :to => "list <map <string, any>>" ) @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
99 100 101 102 103 104 105 106 107 108 109 110 |
# File '../../src/modules/NfsServer.rb', line 99 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”
73 74 75 76 77 |
# File '../../src/modules/NfsServer.rb', line 73 def SetModified @modified = true nil end |
- (Object) Summary
Returns A summary for autoyast
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 |
# File '../../src/modules/NfsServer.rb', line 319 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.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 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 |
# File '../../src/modules/NfsServer.rb', line 185 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 else if !Service.Enable(@portmapper) Report.Error(Service.Error) ok = false end if !Service.Enable("nfsserver") Report.Error(Service.Error) ok = false end if @nfs_security if !Service.active?("svcgssd") unless 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 else unless Service.Restart("svcgssd") Report.Error( _("Unable to restart 'svcgssd' service.") ) ok = false end end else if Service.active?("svcgssd") unless Service.Stop("svcgssd") Report.Error(_("'svcgssd' is running. Unable to stop it.")) ok = false end end end if !@write_only unless Service.active?(@portmapper) Service.Start(@portmapper) end Service.Restart("nfsserver") unless Service.active?("nfsserver") # 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.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File '../../src/modules/NfsServer.rb', line 149 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 |