• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-installation / 8705582428

16 Apr 2024 12:27PM UTC coverage: 40.913% (-0.2%) from 41.105%
8705582428

Pull #1114

github

shundhammer
Version bump and change log
Pull Request #1114: WIP: Handle autoinst AND autoupgrade (bsc#1222153)

0 of 1 new or added line in 1 file covered. (0.0%)

95 existing lines in 13 files now uncovered.

4489 of 10972 relevant lines covered (40.91%)

6.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.58
/src/lib/installation/clients/ssh_import_auto.rb
1
require "yast"
1✔
2

3
require "installation/auto_client"
1✔
4
require "installation/ssh_importer"
1✔
5
require "installation/ssh_importer_presenter"
1✔
6

7
Yast.import "Progress"
1✔
8
Yast.import "Mode"
1✔
9
Yast.import "Popup"
1✔
10

11
module Installation
1✔
12
  # AutoYaST client for ssh_import
13
  class SSHImportAutoClient < ::Installation::AutoClient
1✔
14
    class << self
1✔
15
      attr_accessor :changed
1✔
16
    end
17

18
    def initialize
1✔
19
      super
14✔
20
      textdomain "installation"
14✔
21
    end
22

23
    def run
1✔
24
      progress_orig = Yast::Progress.set(false)
14✔
25
      ret = super
14✔
26
      Yast::Progress.set(progress_orig)
14✔
27

28
      ret
14✔
29
    end
30

31
    # Importing data from the AutoYaST configuration module
32
    # AutoYaST data format:
33
    #
34
    # <ssh_import>
35
    #   <import config:type="boolean">true</import>
36
    #   <copy_config config:type="boolean">true</copy_config>
37
    #   <device>/dev/sda4</device>
38
    # </ssh_import>
39
    #
40
    # @param data [Hash] AutoYaST specification.
41
    # @option data [Boolean] :import Import SSH keys
42
    # @option data [Boolean] :copy_config Import SSH server configuration
43
    #   in addition to keys.
44
    # @option data [Boolean] :device Device to import the keys/configuration from.
45
    def import(data)
1✔
46
      if !data["import"]
6✔
47
        log.info "Do not import ssh keys/configuration"
1✔
48
        ssh_importer.device = nil # do not copy ssh keys into the installed system
1✔
49
        return true
1✔
50
      end
51

52
      log.info "Importing AutoYaST data: #{data}"
5✔
53
      ssh_importer.copy_config = data["copy_config"] == true
5✔
54
      if data["device"] && !data["device"].empty?
5✔
55
        if ssh_importer.configurations.key?(data["device"])
2✔
56
          ssh_importer.device = data["device"]
1✔
57
        else
58
          Yast::Report.Warning(
1✔
59
            # TRANSLATORS: both %s are device names like /dev/sda0
60
            _(format("Device %s not found. Using data from %s.",
61
              data["device"], ssh_importer.device))
62
          )
63
        end
64
      end
65
      true
5✔
66
    end
67

68
    # Returns a human readable summary
69
    #
70
    # @see ::Installation::SshImporterPresenter
71
    def summary
1✔
72
      ::Installation::SshImporterPresenter.new(ssh_importer).summary
1✔
73
    end
74

75
    def modified?
1✔
76
      self.class.changed
4✔
77
    end
78

79
    def modified
1✔
80
      self.class.changed = true
2✔
81
    end
82

83
    def reset
1✔
84
      ssh_importer.reset
1✔
85
    end
86

87
    def change
1✔
88
      # If this module has been called and do not
89
      # depends on the installed system we would like to
90
      # have this section in the exported AutoYaST file
91
      # regardless if the entries have been changed nor not.
92
      modified
×
93

UNCOV
94
      begin
×
95
        args = {
×
96
          "enable_back" => false,
97
          "enable_next" => false,
98
          "going_back"  => false
99
        }
100
        Yast::Wizard.OpenAcceptDialog
×
101
        WFM.CallFunction("inst_ssh_import", [args])
×
102
      ensure
103
        Yast::Wizard.CloseDialog
×
104
      end
105
    end
106

107
    # Exporting data to the AutoYaST configuration module.
108
    # That's are default entries.
109
    def export
1✔
110
      ret = {}
2✔
111
      # Taking values from AutoYast configuration module, otherwise do not export (bsc#1172749)
112
      if Mode.config
2✔
113
        if ssh_importer.device && !ssh_importer.device.empty?
1✔
114
          ret["import"] = true
1✔
115
          ret["copy_config"] = ssh_importer.copy_config
1✔
116
          if !ssh_importer.device.empty? && ssh_importer.device != "default"
1✔
117
            ret["device"] =
1✔
118
              ssh_importer.device
119
          end
120
        else
121
          ret["import"] = false
×
122
          ret["copy_config"] = false
×
123
        end
124
      end
125
      ret
2✔
126
    end
127

128
    # Writes the SSH keys from the selected device (and also other
129
    # configuration files if #copy_config? is true) in the target
130
    # filesystem
131
    def write
1✔
132
      if Mode.config || Mode.normal # normal=configuration in an installed system
1✔
133
        Popup.Notify _("It makes no sense to write these settings to system.")
×
134
        true
×
135
      else
136
        ssh_importer.write(Yast::Installation.destdir)
1✔
137
      end
138
    end
139

140
    def read
1✔
141
      # It is a user decision only. Not depending on system
142
      true
×
143
    end
144

145
  protected
1✔
146

147
    # Helper method to access to the SshImporter
148
    #
149
    # @return [::Installation::SshImporter] SSH importer
150
    def ssh_importer
1✔
151
      @ssh_importer ||= ::Installation::SshImporter.instance
19✔
152
    end
153
  end
154
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc