Class: Yast::SlpServerClass
- Inherits:
-
Module
- Object
- Module
- Yast::SlpServerClass
- Defined in:
- ../../src/modules/SlpServer.rb
Instance Method Summary (collapse)
-
- (Boolean) Abort
Abort function.
-
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
-
- (Hash) Export
Dump the slp-server settings to a single map (For use by autoinstallation.).
- - (Object) GetStartService
-
- (Boolean) Import(settings)
Get all slp-server settings from the first parameter (For use by autoinstallation.).
-
- (Object) installed_packages
check for package openslp-server installed.
- - (Object) main
-
- (Object) Modified
Data was modified?.
-
- (Object) Overview
Create an overview table with all configured cards.
-
- (Object) Read
Read all slp-server settings.
-
- (Object) ReadGlobalConfig
read global configuration file /etc/slp.conf.
- - (Object) SetStartService(status)
-
- (Object) Summary
Create a textual summary and a list of unconfigured cards.
-
- (Object) Write
Write all slp-server settings.
-
- (Object) WriteGlobalConfig
write global configuration file /etc/slp.conf.
Instance Method Details
- (Boolean) Abort
Abort function
78 79 80 81 |
# File '../../src/modules/SlpServer.rb', line 78 def Abort return @AbortFunction.call == true if @AbortFunction != nil false end |
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
398 399 400 401 |
# File '../../src/modules/SlpServer.rb', line 398 def AutoPackages # TODO FIXME: your code here... { "install" => [], "remove" => [] } end |
- (Hash) Export
Dump the slp-server settings to a single map (For use by autoinstallation.)
363 364 365 366 367 368 369 370 371 372 373 |
# File '../../src/modules/SlpServer.rb', line 363 def Export result = { "version" => "1.0", "service" => @serviceStatus, "config" => @slp_config, "files" => @reg_files } @configured = true deep_copy(result) end |
- (Object) GetStartService
403 404 405 406 407 |
# File '../../src/modules/SlpServer.rb', line 403 def GetStartService @serviceStatus = Service.Enabled("slpd") Builtins.y2milestone("Status of slpd service %1", @serviceStatus) @serviceStatus end |
- (Boolean) Import(settings)
Get all slp-server settings from the first parameter (For use by autoinstallation.)
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File '../../src/modules/SlpServer.rb', line 337 def Import(settings) settings = deep_copy(settings) Builtins.foreach( Convert.convert(settings, :from => "map", :to => "map <string, any>") ) do |key, value| case key when "service" @serviceStatus = Convert.to_boolean(value) when "config" Builtins.foreach( Convert.convert(value, :from => "any", :to => "map <string, any>") ) { |k, v| Ops.set(@slp_config, k, v) } when "files" @reg_files = Convert.convert( value, :from => "any", :to => "list <map <string, any>>" ) end end true end |
- (Object) installed_packages
check for package openslp-server installed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File '../../src/modules/SlpServer.rb', line 176 def installed_packages Builtins.y2milestone("check for installed package") ret = false if !Package.InstallMsg( "openslp-server", _( "<p>To configure the SLP server, the <b>%1</b> package must be installed.</p>" ) + _("<p>Do you want to install it now?</p>") ) Popup.Error(Message.CannotContinueWithoutPackagesInstalled) else ret = true end ret end |
- (Object) main
16 17 18 19 20 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 |
# File '../../src/modules/SlpServer.rb', line 16 def main textdomain "slp-server" Yast.import "Progress" Yast.import "Report" Yast.import "Summary" Yast.import "Message" Yast.import "Service" Yast.import "SuSEFirewall" Yast.import "Package" Yast.import "Popup" Yast.import "Confirm" Yast.import "Map" Yast.import "NetworkService" Yast.include self, "slp-server/helps.rb" # Data was modified? @modified = false @configured = false @serviceStatus = false @proposal_valid = false # Write only, used during autoinstallation. # Don't run services and SuSEconfig, it's all done at one place. @write_only = false # Abort function # return boolean return true if abort @AbortFunction = fun_ref(method(:Modified), "boolean ()") # Settings: Define all variables needed for configuration of slp-server # TODO FIXME: Define all the variables necessary to hold # TODO FIXME: the configuration here (with the appropriate # TODO FIXME: description) # TODO FIXME: For example: # /** # * List of the configured cards. # */ # list cards = []; # # /** # * Some additional parameter needed for the configuration. # */ # boolean additional_parameter = true; @SETTINGS = {} @slp_config = { "net.slp.useScopes" => "DEFAULT", "net.slp.isDA" => "false", "net.slp.isBroadcastOnly" => "false", "net.slp.DAHeartBeat" => nil } @REGFILES = {} @reg_files = [] end |
- (Object) Modified
Data was modified?
85 86 87 88 |
# File '../../src/modules/SlpServer.rb', line 85 def Modified Builtins.y2debug("modified=%1", @modified) @modified end |
- (Object) Overview
Create an overview table with all configured cards
389 390 391 392 |
# File '../../src/modules/SlpServer.rb', line 389 def Overview # TODO FIXME: your code here... [] end |
- (Object) Read
Read all slp-server settings
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 |
# File '../../src/modules/SlpServer.rb', line 197 def Read # SlpServer read dialog caption caption = _("Initializing SLP Server Configuration") # TODO FIXME Set the right number of stages steps = 4 sl = 500 Builtins.sleep(sl) # TODO FIXME Names of real stages # We do not set help text here, because it was set outside Progress.New( caption, " ", steps, [ # Progress stage 1/3 _("Read the database"), # Progress stage 2/3 _("Read the previous settings"), # Progress stage 3/3 _("Detect the devices") ], [ # Progress step 1/3 _("Reading the database..."), # Progress step 2/3 _("Reading the previous settings..."), # Progress step 3/3 _("Detecting the devices..."), # Progress finished _("Finished") ], "" ) # check if user is root return false if !Confirm.MustBeRoot return false if !NetworkService.RunningNetworkPopup Progress.NextStage return false if false Builtins.sleep(sl) Progress.set(false) SuSEFirewall.Read Progress.set(true) # read database # if(Abort()) return false; Progress.NextStage Report.Error(Message.CannotReadCurrentSettings) if !ReadGlobalConfig() # read another database return false if Abort() Progress.NextStep Report.Error(_("Cannot read database2.")) if false Builtins.sleep(sl) # detect devices return false if Abort() Progress.NextStage return false if !installed_packages Builtins.sleep(sl) return false if Abort() Progress.NextStage Builtins.sleep(sl) return false if Abort() @modified = false @configured = true true end |
- (Object) ReadGlobalConfig
read global configuration file /etc/slp.conf
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File '../../src/modules/SlpServer.rb', line 91 def ReadGlobalConfig @SETTINGS = Convert.convert( SCR.Read(path(".etc.slp.all")), :from => "any", :to => "map <string, any>" ) @REGFILES = Convert.convert( SCR.Read(path(".etc.slp.reg.all")), :from => "any", :to => "map <string, any>" ) Builtins.foreach(@SETTINGS) do |k1, v1| if k1 == "value" Builtins.foreach( Convert.convert( v1, :from => "any", :to => "list <map <string, any>>" ) ) do |v2| if Ops.get(v2, "type") == 1 Ops.set( @slp_config, Ops.get_string(v2, "name", ""), Ops.get_string(v2, "value", "") ) end end end end Builtins.y2milestone("Values from /etc/slp.conf : %1", @slp_config) @reg_files = Ops.get_list(@REGFILES, "value", []) Builtins.y2milestone("values from /etc/slp.reg.d : %1", @reg_files) true end |
- (Object) SetStartService(status)
409 410 411 412 413 414 415 416 417 418 419 |
# File '../../src/modules/SlpServer.rb', line 409 def SetStartService(status) Builtins.y2milestone("Set service status %1", status) if status == true Service.Enable("slpd") else Service.Disable("slpd") end @serviceStatus = status nil end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
377 378 379 380 381 382 383 384 385 |
# File '../../src/modules/SlpServer.rb', line 377 def Summary summary = _("Configuration summary...") if @configured else summary = Summary.NotConfigured end [summary, []] end |
- (Object) Write
Write all slp-server settings
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 |
# File '../../src/modules/SlpServer.rb', line 274 def Write # SlpServer read dialog caption caption = _("Saving SLP Server Configuration") # TODO FIXME And set the right number of stages steps = 2 sl = 500 Builtins.sleep(sl) # TODO FIXME Names of real stages # We do not set help text here, because it was set outside Progress.New( caption, " ", steps, [ # Progress stage 1/2 _("Write the settings"), # Progress stage 2/2 _("Run SuSEconfig") ], [ # Progress step 1/2 _("Writing the settings..."), # Progress step 2/2 _("Running SuSEconfig..."), # Progress finished _("Finished") ], "" ) Progress.set(false) SuSEFirewall.Write Progress.set(true) Progress.NextStage # Error message Report.Error(_("Cannot write settings.")) if !WriteGlobalConfig() Builtins.sleep(sl) # run SuSEconfig return false if Abort() Progress.NextStage # Error message return false if false Builtins.sleep(sl) return false if Abort() # Progress finished Progress.NextStage Builtins.sleep(sl) return false if Abort() @configured = true true end |
- (Object) WriteGlobalConfig
write global configuration file /etc/slp.conf
129 130 131 132 133 134 135 136 137 138 139 140 141 142 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 168 169 170 171 172 173 |
# File '../../src/modules/SlpServer.rb', line 129 def WriteGlobalConfig Builtins.foreach(@slp_config) do |k1, v1| found = false Ops.set( @SETTINGS, "value", Builtins.maplist(Ops.get_list(@SETTINGS, "value", [])) do |v2| if k1 == Ops.get_string(v2, "name", "") Ops.set(v2, "type", v1 == nil ? 0 : 1) Ops.set(v2, "value", v1) found = true end deep_copy(v2) end ) if !found Ops.set( @SETTINGS, "value", Builtins.add( Ops.get_list(@SETTINGS, "value", []), { "name" => k1, "type" => v1 == nil ? 0 : 1, "kind" => "value", "comment" => "", "value" => v1 } ) ) end end Builtins.y2milestone("slp_config %1", @slp_config) Builtins.y2milestone("SETTINGS %1", @SETTINGS) Ops.set(@REGFILES, "value", @reg_files) Builtins.y2debug("write reg_files %1", @reg_files) Builtins.y2debug("write REGFILES %1", @REGFILES) SCR.Write(path(".etc.slp.all"), @SETTINGS) SCR.Write(path(".etc.slp.reg.all"), @REGFILES) true end |