-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Review] Request from 'schubi2' @ 'yast/yast-installation/review_1605…
…24_autoyast_support' (#380) * autoyast support * syntax * fixed errors * fixed makefile pathes * typo * typo * setting global variables corretly * fixes in exporting settings * packaging * autoyast ui for ssh_import * Add unit tests for SSHImportAutoClient * removed auto_ssh_import due Knut's nice UI changes * Move client logic from SshImporter to SSHImportAutoClient * Updates from code review * additional changes for the UI * take setting from module * added description * Fix ssh_import_auto test * Move the debugger invocation to ruby-bindings (FATE#318421) (#386) * Move the debugger invocation to ruby-bindings (FATE#318421) ... to use the same implementation at run time. - 3.1.190 * revert also the dependency * cleanup * we are taking the second one suggestion :-) * Revert SshImportProposalClient#make_proposal * Updates from code review * Move SshImporter presentation responsability to a new class * Make rubocop happy * ssh_importer_presenter added * missing \ * added SshImporter * added logging * added more logging * making rubokop happy * normal mode is a configuration mode too * rubocop * rubocop * Updates from code review * removed back stuff * moving config to copy_config * moving config to copy_config * added logging
- Loading branch information
Showing
19 changed files
with
577 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[Desktop Entry] | ||
Type=Application | ||
Categories=Settings;System;Qt;X-SuSE-YaST;X-SuSE-YaST-Misc; | ||
|
||
X-KDE-ModuleType=Library | ||
X-KDE-HasReadOnlyMode=false | ||
X-SuSE-YaST-Call=ssh_import | ||
|
||
X-SuSE-YaST-Group=Security | ||
X-SuSE-YaST-Argument= | ||
X-SuSE-YaST-RootOnly=true | ||
X-SuSE-YaST-AutoInst=configure | ||
X-SuSE-YaST-Geometry= | ||
X-SuSE-YaST-SortKey= | ||
X-SuSE-YaST-AutoInstResource= | ||
X-SuSE-YaST-AutoInstPath=install | ||
X-SuSE-YaST-AutoInstSchema=ssh_import.rnc | ||
X-SuSE-YaST-AutoInstClonable=true | ||
|
||
Icon=yast-ssh_import | ||
Exec= | ||
|
||
Name=SSH Key Import | ||
GenericName=Importing SSH keys from a previous installation | ||
|
||
StartupNotify=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "installation/clients/ssh_import_auto" | ||
|
||
::Installation::SSHImportAutoClient.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
require "yast" | ||
|
||
require "installation/auto_client" | ||
require "installation/ssh_importer" | ||
require "installation/ssh_importer_presenter" | ||
|
||
Yast.import "Progress" | ||
Yast.import "Mode" | ||
Yast.import "Popup" | ||
|
||
module Installation | ||
# AutoYaST client for ssh_import | ||
class SSHImportAutoClient < ::Installation::AutoClient | ||
class << self | ||
attr_accessor :changed | ||
end | ||
|
||
def run | ||
progress_orig = Yast::Progress.set(false) | ||
ret = super | ||
Yast::Progress.set(progress_orig) | ||
|
||
ret | ||
end | ||
|
||
# Importing data from the AutoYaST configuration module | ||
# AutoYaST data format: | ||
# | ||
# <ssh_import> | ||
# <import config:type="boolean">true</import> | ||
# <copy_config config:type="boolean">true</copy_config> | ||
# <device>/dev/sda4</device> | ||
# </ssh_import> | ||
# | ||
# @param data [Hash] AutoYaST specification. | ||
# @option data [Boolean] :import Import SSH keys | ||
# @option data [Boolean] :copy_config Import SSH server configuration | ||
# in addition to keys. | ||
# @option data [Boolean] :device Device to import the keys/configuration from. | ||
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 | ||
|
||
# Returns a human readable summary | ||
# | ||
# @see ::Installation::SshImporterPresenter | ||
def summary | ||
::Installation::SshImporterPresenter.new(ssh_importer).summary | ||
end | ||
|
||
def modified? | ||
self.class.changed | ||
end | ||
|
||
def modified | ||
self.class.changed = true | ||
end | ||
|
||
def reset | ||
ssh_importer.reset | ||
end | ||
|
||
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 | ||
|
||
# Exporting data to the AutoYaST configuration module. | ||
# That's are default entries. | ||
def export | ||
ret = {} | ||
if Mode.config | ||
# Taking values from AutoYast configuration module | ||
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 | ||
else | ||
# Taking default values | ||
ret = { "import" => true, "copy_config" => false } | ||
# Device will not be set because it is optional and the | ||
# most-recently-accessed device (biggest keys_atime) | ||
# will be used for. | ||
# ret["device"] = device | ||
end | ||
ret | ||
end | ||
|
||
# Writes the SSH keys from the selected device (and also other | ||
# configuration files if #copy_config? is true) in the target | ||
# filesystem | ||
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(::Installation.destdir) | ||
end | ||
end | ||
|
||
def read | ||
# It is a user decision only. Not depending on system | ||
true | ||
end | ||
|
||
protected | ||
|
||
# Helper method to access to the SshImporter | ||
# | ||
# @return [::Installation::SshImporter] SSH importer | ||
def ssh_importer | ||
@ssh_importer ||= ::Installation::SshImporter.instance | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.