-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #22739, #21740 - Maintain hammer configuration
- Loading branch information
Showing
26 changed files
with
450 additions
and
239 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
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 |
---|---|---|
@@ -1,50 +1,15 @@ | ||
class Procedures::HammerSetup < ForemanMaintain::Procedure | ||
metadata do | ||
description 'Setup hammer' | ||
for_feature :hammer | ||
end | ||
|
||
def run | ||
setup_from_default || setup_from_answers | ||
puts "New settings saved into #{hammer.config_file}" | ||
hammer.run_command('architecture list') # if not setup properly, an error will be risen | ||
result = feature(:hammer).setup_admin_access | ||
logger.info 'Hammer was configured successfully.' if result | ||
end | ||
|
||
def necessary? | ||
!hammer.ready? | ||
end | ||
|
||
private | ||
|
||
def setup_from_default | ||
used_default_file = hammer.setup_from_default | ||
if used_default_file | ||
puts "Using defaults from #{used_default_file}" | ||
true | ||
end | ||
end | ||
|
||
def setup_from_answers | ||
loop do | ||
username, password = ask_for_credentials | ||
break if username.nil? | ||
if hammer.setup_from_answers(username, password) | ||
return true | ||
else | ||
puts 'Invalid credentials' | ||
end | ||
end | ||
end | ||
|
||
def ask_for_credentials | ||
username = ask('Hammer username [admin]:') | ||
return if username.nil? | ||
username = 'admin' if username.empty? | ||
password = ask('Hammer password:', :password => true) | ||
return if password.nil? | ||
[username.strip, password.strip] | ||
end | ||
|
||
def hammer | ||
ForemanMaintain::Utils::Hammer.instance | ||
!feature(:hammer).check_connection | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module ForemanMaintain | ||
module Concerns | ||
module Reporter | ||
extend Forwardable | ||
def_delegators :reporter, :with_spinner, :puts, :print, :ask, :assumeyes? | ||
|
||
def reporter | ||
ForemanMaintain.reporter | ||
end | ||
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
Oops, something went wrong.