Class List Method List File List

# Module: Yast::RelocationServerComplexInclude

Defined in:
  ../../src/include/relocation-server/complex.rb

## Instance Method Summary (collapse)

- - (Object) AddEditPortDialog(current_port)
- - (Object) DeletePort(port)
- - (Object) HandleKVMConfigurationDialog(id, event)
- - (Object) HandleXendConfigurationDialog(id, event)
- - (Object) InitGlobalState
- - (Object) initialize_relocation_server_complex(include_target)
- - (Object) InitKVMConfigurationDialog(id)
- - (Object) InitKVMFireWall
- - (Object) InitLibvirtdPortsTable
- - (Object) InitServerState
- - (Object) InitSSLServerState
- - (Object) InitXendConfigurationDialog(id)
- - (Object) ReadDialog

  Read settings dialog.

- - (Object) ReallyExit
- - (Object) StoreKVMConfigurationDialog(id, event)
- - (Object) StoreXendConfigurationDialog(id, event)
- - (Object) WriteDialog

  Write settings dialog.

## Instance Method Details

### - (`Object`) AddEditPortDialog(current_port)

    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
    # File '../../src/include/relocation-server/complex.rb', line 292

    def AddEditPortDialog(current_port)
      UI.OpenDialog(
        Opt(:decorated),
        VBox(
          MinWidth(
            30,
            HBox(
              HSpacing(1),
              Frame(
                current_port == nil ?
                  # A popup dialog caption
                  _("Add New Port") :
                  # A popup dialog caption
                  _("Edit Current Port"),
                # A text entry
                TextEntry(
                  Id("port_number"),
                  _("&Port"),
                  current_port == nil ? "" : current_port
                )
              ),
              HSpacing(1)
            )
          ),
          VSpacing(1),
          ButtonBox(
            PushButton(Id(:ok), Label.OKButton),
            PushButton(Id(:cancel), Label.CancelButton)
          )
        )
      )

      UI.ChangeWidget(Id("port_number"), :ValidChars, "0123456789")

      ret = nil
      while true
        ret = UI.UserInput
        if ret == :ok
          new_port = Convert.to_string(
            UI.QueryWidget(Id("port_number"), :Value)
          )

          if new_port == ""
            UI.SetFocus(Id("port_number"))
            Report.Error(_("Port number must not be empty."))
            next
          end

          if Ops.greater_than(Builtins.tointeger(new_port), 65535) ||
              Ops.less_than(Builtins.tointeger(new_port), 1)
            UI.SetFocus(Id("port_number"))
            Report.Error(_("Port number out of range."))
            next
          end

          ports = RelocationServer.GetLibVirtdPorts
          if Builtins.contains(ports, new_port)
            UI.SetFocus(Id("port_number"))
            Report.Error(_("Port number already exists."))
            next
          end
          ports = Builtins.add(ports, new_port)
          RelocationServer.SetLibvirtdPorts(ports)

          DeletePort(current_port) if current_port != nil
        end

        break
      end

      UI.CloseDialog

      nil
    end

### - (`Object`) DeletePort(port)

    284
    285
    286
    287
    288
    289
    290
    # File '../../src/include/relocation-server/complex.rb', line 284

    def DeletePort(port)
      ports = RelocationServer.GetLibVirtdPorts
      ports = Builtins.filter(ports) { |s| s != port }
      RelocationServer.SetLibvirtdPorts(ports)

      nil
    end

### - (`Object`) HandleKVMConfigurationDialog(id, event)

    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    # File '../../src/include/relocation-server/complex.rb', line 367

    def HandleKVMConfigurationDialog(id, event)
      event = deep_copy(event)
      action = Ops.get(event, "ID")
      selected_port = Convert.to_string(
        UI.QueryWidget(Id("Port"), :CurrentItem)
      )

      # Adding a new port
      if action == "add_port"
        AddEditPortDialog(nil)
        # Editing current port
      elsif action == "edit_port"
        AddEditPortDialog(selected_port)
        # Deleting current port
      elsif action == "delete_port"
        DeletePort(selected_port) if Confirm.DeleteSelected
      elsif action == "tunneled_migration" || action == "plain_migration"
        InitKVMFireWall()
      end

      InitLibvirtdPortsTable()
      nil
    end

### - (`Object`) HandleXendConfigurationDialog(id, event)

    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    # File '../../src/include/relocation-server/complex.rb', line 161

    def HandleXendConfigurationDialog(id, event)
      event = deep_copy(event)
      action = Ops.get(event, "ID")

      if action == "browse_ssl_key_file"
        new_filename = UI.AskForExistingFile("", "", _("Select SSL Key File"))
        if new_filename != nil && new_filename != ""
          UI.ChangeWidget(
            Id("xend-relocation-server-ssl-key-file"),
            :Value,
            new_filename
          )
        end
      elsif action == "browse_ssl_cert_file"
        new_filename = UI.AskForExistingFile("", "", _("Select SSL Cert File"))
        if new_filename != nil && new_filename != ""
          UI.ChangeWidget(
            Id("xend-relocation-server-ssl-cert-file"),
            :Value,
            new_filename
          )
        end
      elsif action == "xend-relocation-server"
        InitServerState()
      elsif action == "xend-relocation-ssl-server"
        InitSSLServerState()
      end
      nil
    end

### - (`Object`) InitGlobalState

    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    # File '../../src/include/relocation-server/complex.rb', line 72

    def InitGlobalState
      server_stat = Convert.to_boolean(
        UI.QueryWidget(Id("xend-relocation-server"), :Value)
      )
      ssl_server_stat = Convert.to_boolean(
        UI.QueryWidget(Id("xend-relocation-ssl-server"), :Value)
      )
      stat = server_stat || ssl_server_stat
      UI.ChangeWidget(Id("xend-relocation-address"), :Enabled, stat)
      UI.ChangeWidget(Id("xend-relocation-hosts-allow"), :Enabled, stat)
      if stat
        CWMFirewallInterfaces.EnableOpenFirewallWidget
      else
        CWMFirewallInterfaces.DisableOpenFirewallWidget
      end
      stat = server_stat && ssl_server_stat
      UI.ChangeWidget(Id("xend-relocation-ssl"), :Enabled, stat)

      nil
    end

### - (`Object`) initialize_relocation_server_complex(include_target)

    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    # File '../../src/include/relocation-server/complex.rb', line 32

    def initialize_relocation_server_complex(include_target)
      textdomain "relocation-server"

      Yast.import "Label"
      Yast.import "Popup"
      Yast.import "Wizard"
      Yast.import "Confirm"
      Yast.import "CWMFirewallInterfaces"
      Yast.import "RelocationServer"

      Yast.include include_target, "relocation-server/helps.rb"
    end

### - (`Object`) InitKVMConfigurationDialog(id)

    274
    275
    276
    277
    278
    279
    280
    281
    282
    # File '../../src/include/relocation-server/complex.rb', line 274

    def InitKVMConfigurationDialog(id)
      UI.ChangeWidget(Id("tunneled_migration"), :Value, false)
      UI.ChangeWidget(Id("plain_migration"), :Value, false)
      UI.ChangeWidget(Id("default_port_range"), :Value, true)
      InitLibvirtdPortsTable()
      InitKVMFireWall()

      nil
    end

### - (`Object`) InitKVMFireWall

    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    # File '../../src/include/relocation-server/complex.rb', line 230

    def InitKVMFireWall
      tunneled_migration = Convert.to_boolean(
        UI.QueryWidget(Id("tunneled_migration"), :Value)
      )
      plain_migration = Convert.to_boolean(
        UI.QueryWidget(Id("plain_migration"), :Value)
      )
      if tunneled_migration || plain_migration
        CWMFirewallInterfaces.EnableOpenFirewallWidget
      else
        CWMFirewallInterfaces.DisableOpenFirewallWidget
      end

      nil
    end

### - (`Object`) InitLibvirtdPortsTable

    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
    # File '../../src/include/relocation-server/complex.rb', line 246

    def InitLibvirtdPortsTable
      ports = RelocationServer.GetLibVirtdPorts
      stat = Convert.to_boolean(UI.QueryWidget(Id("plain_migration"), :Value))

      if ports != nil && ports != []
        items = []
        Builtins.foreach(ports) do |port|
          items = Builtins.add(items, Item(Id(port), port))
        end

        # Redraw table of ports and enable modification buttons
        UI.ChangeWidget(Id("Port"), :Items, items)
        UI.ChangeWidget(Id("edit_port"), :Enabled, true && stat)
        UI.ChangeWidget(Id("delete_port"), :Enabled, true && stat)
      else
        # Redraw table of ports and disable modification buttons
        UI.ChangeWidget(Id("Port"), :Items, [])
        UI.ChangeWidget(Id("edit_port"), :Enabled, false)
        UI.ChangeWidget(Id("delete_port"), :Enabled, false)
      end

      UI.ChangeWidget(Id("Port"), :Enabled, stat)
      UI.ChangeWidget(Id("add_port"), :Enabled, stat)
      UI.ChangeWidget(Id("default_port_range"), :Enabled, stat)

      nil
    end

### - (`Object`) InitServerState

    93
    94
    95
    96
    97
    98
    99
    100
    101
    # File '../../src/include/relocation-server/complex.rb', line 93

    def InitServerState
      stat = Convert.to_boolean(
        UI.QueryWidget(Id("xend-relocation-server"), :Value)
      )
      UI.ChangeWidget(Id("xend-relocation-port"), :Enabled, stat)
      InitGlobalState()

      nil
    end

### - (`Object`) InitSSLServerState

    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    # File '../../src/include/relocation-server/complex.rb', line 103

    def InitSSLServerState
      stat = Convert.to_boolean(
        UI.QueryWidget(Id("xend-relocation-ssl-server"), :Value)
      )
      UI.ChangeWidget(Id("xend-relocation-ssl-port"), :Enabled, stat)
      UI.ChangeWidget(Id("xend-relocation-server-ssl-key-file"), :Enabled, stat)
      UI.ChangeWidget(
        Id("xend-relocation-server-ssl-cert-file"),
        :Enabled,
        stat
      )
      UI.ChangeWidget(Id("browse_ssl_key_file"), :Enabled, stat)
      UI.ChangeWidget(Id("browse_ssl_cert_file"), :Enabled, stat)
      InitGlobalState()

      nil
    end

### - (`Object`) InitXendConfigurationDialog(id)

    121
    122
    123
    124
    125
    126
    127
    128
    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
    # File '../../src/include/relocation-server/complex.rb', line 121

    def InitXendConfigurationDialog(id)
      Builtins.foreach(
        [
          "xend-relocation-server",
          "xend-relocation-ssl-server",
          "xend-relocation-ssl"
        ]
      ) do |key|
        UI.ChangeWidget(
          Id(key),
          :Value,
          RelocationServer.GetXendOption(key) == "yes"
        )
      end

      Builtins.foreach(
        [
          "xend-relocation-server-ssl-key-file",
          "xend-relocation-server-ssl-cert-file",
          "xend-relocation-address",
          "xend-relocation-hosts-allow"
        ]
      ) do |key|
        UI.ChangeWidget(Id(key), :Value, RelocationServer.GetXendOption(key))
      end

      Builtins.foreach(["xend-relocation-port", "xend-relocation-ssl-port"]) do |key|
        UI.ChangeWidget(
          Id(key),
          :Value,
          Builtins.tointeger(RelocationServer.GetXendOption(key))
        )
      end

      InitServerState()
      InitSSLServerState()

      nil
    end

### - (`Object`) ReadDialog

Read settings dialog

Returns:

- `abort if aborted and`next otherwise

    53
    54
    55
    56
    57
    58
    59
    60
    # File '../../src/include/relocation-server/complex.rb', line 53

    def ReadDialog
      Wizard.RestoreHelp(Ops.get_string(@HELPS, "read", ""))
      Wizard.SetTitleIcon("yast-vm-install")
      # RelocationServer::SetAbortFunction(PollAbort);
      return :abort if !Confirm.MustBeRoot
      ret = RelocationServer.Read
      ret ? :next : :abort
    end

### - (`Object`) ReallyExit

    46
    47
    48
    49
    # File '../../src/include/relocation-server/complex.rb', line 46

    def ReallyExit
      # yes-no popup
      Popup.YesNo(_("Really exit?\nAll changes will be lost."))
    end

### - (`Object`) StoreKVMConfigurationDialog(id, event)

    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    # File '../../src/include/relocation-server/complex.rb', line 392

    def StoreKVMConfigurationDialog(id, event)
      event = deep_copy(event)
      RelocationServer.SetModified

      Builtins.foreach(
        ["tunneled_migration", "plain_migration", "default_port_range"]
      ) do |key|
        value = Convert.to_boolean(UI.QueryWidget(Id(key), :Value))
        RelocationServer.SetLibvirtdOption(key, value)
      end

      nil
    end

### - (`Object`) StoreXendConfigurationDialog(id, event)

    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
    # File '../../src/include/relocation-server/complex.rb', line 191

    def StoreXendConfigurationDialog(id, event)
      event = deep_copy(event)
      RelocationServer.SetModified

      Builtins.foreach(
        [
          "xend-relocation-server",
          "xend-relocation-ssl-server",
          "xend-relocation-ssl"
        ]
      ) do |key|
        value = Convert.to_boolean(UI.QueryWidget(Id(key), :Value)) == true ? "yes" : "no"
        if value != RelocationServer.GetXendOption(key)
          RelocationServer.SetXendOption(key, value)
        end
      end

      Builtins.foreach(
        [
          "xend-relocation-server-ssl-key-file",
          "xend-relocation-server-ssl-cert-file",
          "xend-relocation-address",
          "xend-relocation-hosts-allow",
          "xend-relocation-port",
          "xend-relocation-ssl-port"
        ]
      ) do |key|
        value = Builtins.tostring(UI.QueryWidget(Id(key), :Value))
        if value != RelocationServer.GetXendOption(key)
          RelocationServer.SetXendOption(
            key,
            Builtins.tostring(UI.QueryWidget(Id(key), :Value))
          )
        end
      end

      nil
    end

### - (`Object`) WriteDialog

Write settings dialog

Returns:

- `abort if aborted and`next otherwise

    64
    65
    66
    67
    68
    69
    70
    # File '../../src/include/relocation-server/complex.rb', line 64

    def WriteDialog
      Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
      Wizard.SetTitleIcon("yast-vm-install")
      # RelocationServer::SetAbortFunction(PollAbort);
      ret = RelocationServer.Write
      ret ? :next : :abort
    end