Module: Yast::LdapServerComplexInclude

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) DisplayError(error)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File '../../src/include/ldap-server/complex.rb', line 26

def DisplayError(error)
  error = deep_copy(error)
  if Ops.get(error, "msg") != nil
    if Ops.get(error, "details") != nil
      Popup.ErrorDetails(
        Ops.get(error, "msg", ""),
        Ops.get(error, "details", "")
      )
    else
      Popup.Error(Ops.get(error, "msg", ""))
    end
  end

  nil
end

- (Object) DoMigration



193
194
195
196
197
198
199
200
201
202
# File '../../src/include/ldap-server/complex.rb', line 193

def DoMigration
  LdapServer.UseLdapiForConfig(true)
  if !LdapServer.MigrateSlapdConf
    Builtins.y2milestone("LdapServer::MigrateSlapdConf failed")
    DisplayError(LdapServer.ReadError)
    return :abort
  end
  LdapServer.Read
  :next
end

- (Object) initialize_ldap_server_complex(include_target)



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File '../../src/include/ldap-server/complex.rb', line 11

def initialize_ldap_server_complex(include_target)
  Yast.import "UI"

  textdomain "ldap-server"

  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "Wizard"
  Yast.import "LdapServer"
  Yast.import "Package"
  Yast.import "Service"

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

- (Object) MigrationMainDialog



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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File '../../src/include/ldap-server/complex.rb', line 131

def MigrationMainDialog
  caption = "Migrate existing Configuration"
  summary = _(
    "Your system is currently configured to use the configuration file\n" +
      "/etc/openldap/slapd.conf. YaST only supports the dynamic configuration\n" +
      "database of OpenLDAP (back-config). Do you want to migrate your existing\n" +
      "configuration to the configuration database?\n"
  )
  contents = VBox(
    HSquash(
      RadioButtonGroup(
        Id(:rb),
        VBox(
          Label(summary),
          Left(
            RadioButton(Id(0), _("Migrate existing configuration"), true)
          ),
          Left(
            RadioButton(Id(1), _("Create a new configuration from scratch"))
          )
        )
      )
    )
  )

  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "summary", ""),
    Label.BackButton,
    Label.NextButton
  )
  ret = :next
  while true
    ret = Convert.to_symbol(UI.UserInput)

    # abort?
    if ret == :abort || ret == :cancel
      if Popup.ReallyAbort(true)
        break
      else
        next
      end
    elsif ret == :next
      current = Convert.to_integer(UI.QueryWidget(Id(:rb), :CurrentButton))
      if current == 0
        ret = :next
      else
        ret = :initial
      end
      break
    elsif ret == :back
      break
    else
      Builtins.y2error("unexpected retcode: %1", ret)
      next
    end
  end

  ret
end

- (Object) ReadDialog

Read settings dialog

Returns:

  • abort if aborted andnext otherwise



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
81
82
83
84
85
86
87
88
89
90
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
127
128
129
# File '../../src/include/ldap-server/complex.rb', line 44

def ReadDialog
  Wizard.RestoreHelp(Ops.get_string(@HELPS, "read", ""))

  # ensure openldap2 package is installed
  if !Package.Install("openldap2")
    if !Package.Available("openldap2")
      # translators: error popup before aborting the module
      Popup.Error(
        Builtins.sformat(
          _(
            "The package '%1' is not available.\n" +
              "YaST2 cannot continue the configuration\n" +
              "without installing the package."
          ),
          "openldap2"
        )
      )
    else
      # translators: error popup before aborting the module
      Popup.Error(
        _(
          "YaST2 cannot continue the configuration\nwithout installing the required packages."
        )
      )
    end
    return :abort
  end

  ret = LdapServer.Read
  if !ret
    DisplayError(LdapServer.ReadError)
    return :abort
  end
  hasBackconfig = LdapServer.IsUsingBackconfig
  configModified = LdapServer.SlapdConfChanged #original shipped slapd.conf?

  serviceEnabled = LdapServer.ReadServiceEnabled
  serviceRunning = LdapServer.ReadServiceRunning
  switchToBackConfig = false
  convert = false

  #y2milestone("OpenLDAP running: %1", isRunning);
  Builtins.y2milestone("OpenLDAP using backConfig: %1", hasBackconfig)
  Builtins.y2milestone("OpenLDAP modifed config: %1", configModified)
  configFile = "/etc/openldap/slapd.conf"
  if !hasBackconfig
    if configModified
      return :migrate
    else
      # Start new config wizward
      LdapServer.InitDbDefaults
      return :initial
    end
  else
    if !configModified
      # Start new config wizward
      LdapServer.InitDbDefaults
      return :initial
    elsif !serviceRunning
      ret2 = Popup.AnyQuestion3(
        _("Existing configuration detected."),
        _(
          "You have an existing configuration, but the LDAP server is currently not running.\n" +
            "Do you want to start the server now and re-read its configuration data or do you \n" +
            "want to create a new configuration from scratch?"
        ),
        _("Restart"),
        Label.CancelButton,
        _("New Configuration"),
        :focus_yes
      )
      if ret2 == :yes
        LdapServer.WriteRestartRequired(true)
        return :reread
      elsif ret2 == :no
        return :abort
      elsif ret2 == :retry
        # Start new config wizward
        LdapServer.InitDbDefaults
        return :initial
      end
    end
  end

  :next
end

- (Object) SummaryDialog

Summary dialog

Returns:

  • dialog result



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

def SummaryDialog
  # LdapServer summary dialog caption
  caption = _("LDAP Server Configuration Summary")

  summary = LdapServer.Summary

  # Frame label
  contents = VBox(
    RichText(summary) #,
    #`Right(
    #    `PushButton( `id(`pb_advanced), _("Advanced Configuration") )
    #)
  )

  Wizard.SetContentsButtons(
    caption,
    contents,
    Ops.get_string(@HELPS, "summary", ""),
    Label.BackButton,
    Label.FinishButton
  )

  ret = nil
  while true
    ret = UI.UserInput

    # abort?
    if ret == :abort || ret == :cancel
      if Popup.ReallyAbort(true)
        break
      else
        next
      end
    elsif ret == :pb_advanced
      Popup.Error("Not there yet")
      LdapServer.ReadFromDefaults
      ret = :advanced
      break
    elsif ret == :next
      if !LdapServer.ReadFromDefaults
        DisplayError(LdapServer.ReadError)
        ret = :abort
      end
      break
    elsif ret == :back
      break
    else
      Builtins.y2error("unexpected retcode: %1", ret)
      next
    end
  end

  deep_copy(ret)
end

- (Object) WriteDialog

Write settings dialog

Returns:

  • abort if aborted andnext otherwise



215
216
217
218
219
220
221
222
223
224
# File '../../src/include/ldap-server/complex.rb', line 215

def WriteDialog
  Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
  ret = LdapServer.Write
  if !ret
    DisplayError(LdapServer.ReadError)
    return :abort
  end
  #    ret = LdapServer::WritePPolicyObjects();
  ret ? :next : :abort
end

- (Object) WriteServiceDialog

Write service settings dialog. This dialog writes only the service settings (sysconfig and init.d stuff)

Returns:

  • reread if configuration needs to be reread andnext otherwise



207
208
209
210
211
# File '../../src/include/ldap-server/complex.rb', line 207

def WriteServiceDialog
  Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", ""))
  ret = LdapServer.WriteServiceSettings
  ret ? :next : :reread
end