Class: Yast::IscsiLioServerClass
- Inherits:
-
Module
- Object
- Module
- Yast::IscsiLioServerClass
- Defined in:
- ../../src/modules/IscsiLioServer.rb
Instance Method Summary (collapse)
-
- (Boolean) Abort
Abort function.
- - (Object) activateIetdConfig(ietd)
-
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
-
- (Hash) Export
Dump the iscsi-lio-server settings to a single map (For use by autoinstallation.).
- - (Object) getLunDesc(lun)
-
- (Object) getServiceStatus
check status of target service if not enabled, start it manually.
-
- (Object) GetStartService
get/set service accessors for CWMService component.
-
- (Boolean) Import(settings)
Get all iscsi-lio-server settings from the first parameter (For use by autoinstallation.).
-
- (Object) installed_packages
test if required package (“lio-utils”) is installed.
- - (Object) main
-
- (Object) Modified
Data was modified?.
-
- (Object) Overview
Create an overview table with all configured cards.
-
- (Object) Read
Read all iscsi-lio-server settings.
-
- (Object) readConfig
read configuration file /etc/ietd.conf.
-
- (Object) readIetdConfig
read configuration file /etc/ietd.conf.
- - (Object) SetStartService(status)
-
- (Object) Summary
Create a textual summary and a list of unconfigured cards.
-
- (Object) Write
Write all iscsi-lio-server settings.
-
- (Object) writeConfig
dummy function since LIO has no config file.
Instance Method Details
- (Boolean) Abort
Abort function
76 77 78 79 |
# File '../../src/modules/IscsiLioServer.rb', line 76 def Abort return @AbortFunction.call == true if @AbortFunction != nil false end |
- (Object) activateIetdConfig(ietd)
119 120 121 122 |
# File '../../src/modules/IscsiLioServer.rb', line 119 def activateIetdConfig(ietd) ietd = deep_copy(ietd) IscsiLioData.ActivateConfigIetd(ietd) end |
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
477 478 479 480 |
# File '../../src/modules/IscsiLioServer.rb', line 477 def AutoPackages # TODO FIXME: your code here... { "install" => [], "remove" => [] } end |
- (Hash) Export
Dump the iscsi-lio-server settings to a single map (For use by autoinstallation.)
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File '../../src/modules/IscsiLioServer.rb', line 396 def Export targets = [] Builtins.foreach(IscsiLioData.GetExportTargets) do |k, v| targets = Builtins.add(targets, v) end result = { "version" => "1.0", "service" => @serviceStatus, "auth" => IscsiLioData.GetExportAuth("", 0), "targets" => targets } @configured = true deep_copy(result) end |
- (Object) getLunDesc(lun)
412 413 414 415 416 417 418 419 420 |
# File '../../src/modules/IscsiLioServer.rb', line 412 def getLunDesc(lun) lun = deep_copy(lun) ret = "" Builtins.foreach(lun) do |l, m| ret = Ops.add(ret, ", ") if Ops.greater_than(Builtins.size(ret), 0) ret = Ops.add(ret, IscsiLioData.GetExportLun(l, m)) end ret end |
- (Object) getServiceStatus
check status of target service if not enabled, start it manually
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File '../../src/modules/IscsiLioServer.rb', line 166 def getServiceStatus ret = true if Service.Status("target") == 0 @statusOnStart = true @serviceStatus = true end Builtins.y2milestone("Service status = %1", @statusOnStart) if !@statusOnStart if !Service.Start("target") # to translator: %1 is replaced by pathname e.g. /etc/init.d/target txt = Builtins.sformat( _("Could not start service \"%1\""), "/etc/init.d/target" ) Popup.Error(txt) end end ret end |
- (Object) GetStartService
get/set service accessors for CWMService component
484 485 486 487 488 |
# File '../../src/modules/IscsiLioServer.rb', line 484 def GetStartService status = Service.Enabled("target") Builtins.y2milestone("target service status %1", status) status end |
- (Boolean) Import(settings)
Get all iscsi-lio-server settings from the first parameter (For use by autoinstallation.)
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 |
# File '../../src/modules/IscsiLioServer.rb', line 326 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 "auth" @incom = [] @outgoin = "" Builtins.foreach( Convert.convert( value, :from => "any", :to => "list <map <string, any>>" ) ) do |row| if Ops.get_string(row, "KEY", "") == "IncomingUser" @incom = Builtins.add(@incom, Ops.get_string(row, "VALUE", "")) else @outgoin = Ops.get_string(row, "VALUE", "") end end IscsiLioData.SetIetdAuth("", 0, @incom, @outgoin) when "targets" @name = "" @lun = [] @inc = [] @out = "" Builtins.foreach( Convert.convert( value, :from => "any", :to => "list <list <map <string, any>>>" ) ) do |val| @name = "" @lun = [] @inc = [] @out = "" tpg = 1 Builtins.foreach(val) do |row| case Ops.get_string(row, "KEY", "") when "Target" @name = Ops.get_string(row, "VALUE", "") when "Tpg" tpg = Builtins.tointeger(Ops.get_string(row, "VALUE", "1")) tpg = 1 if tpg == nil when "Lun" @lun = Builtins.add(@lun, Ops.get_string(row, "VALUE", "")) when "IncomingUser" @inc = Builtins.add(@inc, Ops.get_string(row, "VALUE", "")) when "OutgoingUser" @out = Ops.get_string(row, "VALUE", "") end end IscsiLioData.AddNewTarget(@name, tpg, @lun) IscsiLioData.SetIetdAuth(@name, tpg, @inc, @out) end end end @configured = true true end |
- (Object) installed_packages
test if required package (“lio-utils”) is installed
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 |
# File '../../src/modules/IscsiLioServer.rb', line 131 def installed_packages if !PackageSystem.PackageInstalled("lio-utils") Builtins.y2milestone("Not installed, will install") confirm = Popup.AnyQuestionRichText( "", _("Can't continue without installing lio-utils package"), 40, 10, Label.InstallButton, Label.CancelButton, :focus_yes ) if confirm service = "tgtd" Service.Stop(service) if Service.Status(service) == 0 Service.Disable(service) service = "iscsitarget" Service.Stop(service) if Service.Status(service) == 0 Service.Disable(service) PackageSystem.DoInstall(["lio-utils"]) if PackageSystem.PackageInstalled("lio-utils") return true else return false end end return false else return true end end |
- (Object) main
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 |
# File '../../src/modules/IscsiLioServer.rb', line 37 def main textdomain "iscsi-lio-server" Yast.import "Progress" Yast.import "Report" Yast.import "Summary" Yast.import "Message" Yast.import "Service" Yast.import "Package" Yast.import "Popup" Yast.import "SuSEFirewall" Yast.import "Confirm" Yast.import "IscsiLioData" Yast.import "Mode" Yast.import "NetworkService" Yast.import "PackageSystem" Yast.import "Label" @serviceStatus = false @statusOnStart = false # Data was modified? @modified = false @configured = 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 ()") end |
- (Object) Modified
Data was modified?
83 84 85 86 |
# File '../../src/modules/IscsiLioServer.rb', line 83 def Modified Builtins.y2debug("modified=%1", @modified) @modified end |
- (Object) Overview
Create an overview table with all configured cards
468 469 470 471 |
# File '../../src/modules/IscsiLioServer.rb', line 468 def Overview # TODO FIXME: your code here... [] end |
- (Object) Read
Read all iscsi-lio-server settings
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 |
# File '../../src/modules/IscsiLioServer.rb', line 188 def Read # IscsiLioServer read dialog caption caption = _("Initializing iSCSI LIO Target 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 # check if required packages ("lio-utils") are installed return false if !installed_packages Builtins.sleep(sl) return false if Abort() Progress.NextStep # get status of target init script return false if !getServiceStatus Builtins.sleep(sl) return false if Abort() Progress.NextStage # read configuration (/etc/ietd.conf) readConfig if Builtins.size(IscsiLioData.GetTargets) == 0 ietd = readIetdConfig msg = _( "You have currently no active LIO targets but there seems \n" + "to be a valid config in /etc/ietd.conf. Should the module \n" + "try to import setting from /etc/ietd.conf into LIO?" ) if Ops.greater_than(Builtins.size(Ops.get_map(ietd, "tgt", {})), 0) && Ops.get_boolean(Report., "show", true) && Popup.YesNo(msg) if !activateIetdConfig(ietd) err = _("Errors during import. Check LIO state!") Report.Error(err) end end end Builtins.sleep(sl) # detect devices Progress.set(false) SuSEFirewall.Read Progress.set(true) Progress.NextStage # Error message return false if false Builtins.sleep(sl) return false if Abort() @modified = false @configured = true true end |
- (Object) readConfig
read configuration file /etc/ietd.conf
104 105 106 107 |
# File '../../src/modules/IscsiLioServer.rb', line 104 def readConfig IscsiLioData.SetData(IscsiLioData.ParseConfigLio) true end |
- (Object) readIetdConfig
read configuration file /etc/ietd.conf
110 111 112 113 114 115 116 117 |
# File '../../src/modules/IscsiLioServer.rb', line 110 def readIetdConfig read_values = Convert.convert( SCR.Read(path(".etc.ietd.all")), :from => "any", :to => "map <string, any>" ) IscsiLioData.ParseConfigIetd(read_values) end |
- (Object) SetStartService(status)
490 491 492 493 494 495 496 497 498 499 500 |
# File '../../src/modules/IscsiLioServer.rb', line 490 def SetStartService(status) Builtins.y2milestone("Set service status %1", status) @serviceStatus = status if status == true Service.Enable("target") else Service.Disable("target") end nil end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
# File '../../src/modules/IscsiLioServer.rb', line 424 def Summary summary = _("Configuration summary...") if @configured summary = Summary.AddHeader("", _("Global")) if @serviceStatus summary = Summary.AddLine(summary, _("When Booting")) else summary = Summary.AddLine(summary, _("Manually")) end if !IscsiLioData.HasAuth("", 0, "") summary = Summary.AddLine(summary, _("No Authentication")) else if IscsiLioData.HasIncomingAuth("", 0, "") summary = Summary.AddLine(summary, _("Incoming Authentication")) end if IscsiLioData.HasOutgoingAuth("", 0, "") summary = Summary.AddLine(summary, _("Outgoing Authentication")) end end summary = Summary.AddHeader(summary, _("Targets")) summary = Summary.OpenList(summary) Builtins.foreach(IscsiLioData.GetTargets) do |keys| summary = Summary.AddListItem(summary, Ops.get_string(keys, 0, "")) summary = Summary.AddLine( summary, getLunDesc( IscsiLioData.GetLun( Ops.get_string(keys, 0, ""), Ops.get_integer(keys, 1, 1) ) ) ) end summary = Summary.CloseList(summary) else summary = Summary.NotConfigured end # TODO FIXME: your code here... # Configuration summary text for autoyast [summary, []] end |
- (Object) Write
Write all iscsi-lio-server settings
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 |
# File '../../src/modules/IscsiLioServer.rb', line 279 def Write # IscsiLioServer write dialog caption caption = _("Saving iSCSI LIO Target Configuration") # number of stages steps = 2 sl = 500 Builtins.sleep(sl) # We do not set help text here, because it was set outside Progress.New( caption, " ", steps, [ # Progress stage 1/2 _("Write firewall settings"), # Progress stage 2/2 _("Write lio configuration") ], [ # Progress step 1/2 _("Writing the firewall settings..."), # Progress step 2/2 _("Writing lio configuration..."), # Progress finished _("Finished") ], "" ) Progress.set(false) SuSEFirewall.Write Progress.set(true) Progress.NextStage IscsiLioData.SaveSettings Builtins.sleep(sl) true end |
- (Object) writeConfig
dummy function since LIO has no config file
126 127 128 |
# File '../../src/modules/IscsiLioServer.rb', line 126 def writeConfig true end |