Class: Installation::SSHImportAutoClient

Inherits:
AutoClient
  • Object
show all
Defined in:
src/lib/installation/clients/ssh_import_auto.rb

Overview

AutoYaST client for ssh_import

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSSHImportAutoClient

Returns a new instance of SSHImportAutoClient.



18
19
20
21
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 18

def initialize
  super
  textdomain "installation"
end

Class Attribute Details

.changedObject

Returns the value of attribute changed.



15
16
17
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 15

def changed
  @changed
end

Instance Method Details

#changeObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 87

def change
  # If this module has been called and do not
  # depends on the installed system we would like to
  # have this section in the exported AutoYaST file
  # regardless if the entries have been changed nor not.
  modified

  begin
    args = {
      "enable_back" => false,
      "enable_next" => false,
      "going_back"  => false
    }
    Yast::Wizard.OpenAcceptDialog
    WFM.CallFunction("inst_ssh_import", [args])
  ensure
    Yast::Wizard.CloseDialog
  end
end

#exportObject

Exporting data to the AutoYaST configuration module. That's are default entries.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 109

def export
  ret = {}
  # Taking values from AutoYast configuration module, otherwise do not export (bsc#1172749)
  if Mode.config
    if ssh_importer.device && !ssh_importer.device.empty?
      ret["import"] = true
      ret["copy_config"] = ssh_importer.copy_config
      if !ssh_importer.device.empty? && ssh_importer.device != "default"
        ret["device"] =
          ssh_importer.device
      end
    else
      ret["import"] = false
      ret["copy_config"] = false
    end
  end
  ret
end

#import(data) ⇒ Object

Importing data from the AutoYaST configuration module AutoYaST data format:

true true /dev/sda4

Parameters:

  • data (Hash)

    AutoYaST specification.

Options Hash (data):

  • :import (Boolean)

    Import SSH keys

  • :copy_config (Boolean)

    Import SSH server configuration in addition to keys.

  • :device (Boolean)

    Device to import the keys/configuration from.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 45

def import(data)
  if !data["import"]
    log.info "Do not import ssh keys/configuration"
    ssh_importer.device = nil # do not copy ssh keys into the installed system
    return true
  end

  log.info "Importing AutoYaST data: #{data}"
  ssh_importer.copy_config = data["copy_config"] == true
  if data["device"] && !data["device"].empty?
    if ssh_importer.configurations.key?(data["device"])
      ssh_importer.device = data["device"]
    else
      Yast::Report.Warning(
        # TRANSLATORS: both %s are device names like /dev/sda0
        _(format("Device %s not found. Using data from %s.",
          data["device"], ssh_importer.device))
      )
    end
  end
  true
end

#modifiedObject



79
80
81
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 79

def modified
  self.class.changed = true
end

#modified?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 75

def modified?
  self.class.changed
end

#readObject



140
141
142
143
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 140

def read
  # It is a user decision only. Not depending on system
  true
end

#resetObject



83
84
85
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 83

def reset
  ssh_importer.reset
end

#runObject



23
24
25
26
27
28
29
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 23

def run
  progress_orig = Yast::Progress.set(false)
  ret = super
  Yast::Progress.set(progress_orig)

  ret
end

#ssh_importer::Installation::SshImporter (protected)

Helper method to access to the SshImporter

Returns:



150
151
152
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 150

def ssh_importer
  @ssh_importer ||= ::Installation::SshImporter.instance
end

#summaryObject

Returns a human readable summary



71
72
73
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 71

def summary
  ::Installation::SshImporterPresenter.new(ssh_importer).summary
end

#writeObject

Writes the SSH keys from the selected device (and also other configuration files if #copy_config? is true) in the target filesystem



131
132
133
134
135
136
137
138
# File 'src/lib/installation/clients/ssh_import_auto.rb', line 131

def write
  if Mode.config || Mode.normal # normal=configuration in an installed system
    Popup.Notify _("It makes no sense to write these settings to system.")
    true
  else
    ssh_importer.write(Yast::Installation.destdir)
  end
end