hammer_cli_foreman 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of hammer_cli_foreman might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/config/foreman.yml +1 -0
- data/doc/host_create.md +3 -3
- data/doc/release_notes.md +14 -0
- data/lib/hammer_cli_foreman.rb +0 -1
- data/lib/hammer_cli_foreman/api.rb +3 -0
- data/lib/hammer_cli_foreman/api/connection.rb +75 -0
- data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +49 -0
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +120 -0
- data/lib/hammer_cli_foreman/auth.rb +16 -12
- data/lib/hammer_cli_foreman/commands.rb +4 -36
- data/lib/hammer_cli_foreman/compute_resource.rb +6 -6
- data/lib/hammer_cli_foreman/compute_resources/all.rb +7 -0
- data/lib/hammer_cli_foreman/compute_resources/ec2.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/ec2/host_help_extenstion.rb +23 -0
- data/lib/hammer_cli_foreman/compute_resources/gce.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/gce/host_help_extenstion.rb +22 -0
- data/lib/hammer_cli_foreman/compute_resources/libvirt.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/libvirt/host_help_extenstion.rb +35 -0
- data/lib/hammer_cli_foreman/compute_resources/openstack.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/openstack/host_help_extenstion.rb +23 -0
- data/lib/hammer_cli_foreman/compute_resources/ovirt.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/ovirt/host_help_extenstion.rb +36 -0
- data/lib/hammer_cli_foreman/compute_resources/rackspace.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/rackspace/host_help_extenstion.rb +20 -0
- data/lib/hammer_cli_foreman/compute_resources/vmware.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resources/vmware/host_help_extenstion.rb +62 -0
- data/lib/hammer_cli_foreman/filter.rb +1 -0
- data/lib/hammer_cli_foreman/host.rb +15 -140
- data/lib/hammer_cli_foreman/hosts/common_update_help.rb +53 -0
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +141 -0
- data/lib/hammer_cli_foreman/references.rb +13 -2
- data/lib/hammer_cli_foreman/role.rb +3 -7
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +2 -2
- data/lib/hammer_cli_foreman/smart_variable.rb +1 -2
- data/lib/hammer_cli_foreman/user.rb +2 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ca/hammer-cli-foreman.edit.po +520 -318
- data/locale/ca/hammer-cli-foreman.po +253 -175
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/hammer-cli-foreman.edit.po +568 -358
- data/locale/de/hammer-cli-foreman.po +255 -177
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/hammer-cli-foreman.edit.po +446 -228
- data/locale/en/hammer-cli-foreman.po +208 -41
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/hammer-cli-foreman.edit.po +498 -307
- data/locale/en_GB/hammer-cli-foreman.po +254 -176
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/hammer-cli-foreman.edit.po +594 -388
- data/locale/es/hammer-cli-foreman.po +254 -176
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/hammer-cli-foreman.edit.po +542 -342
- data/locale/fr/hammer-cli-foreman.po +254 -176
- data/locale/hammer-cli-foreman.pot +503 -241
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/hammer-cli-foreman.edit.po +510 -295
- data/locale/it/hammer-cli-foreman.po +254 -176
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/hammer-cli-foreman.edit.po +590 -365
- data/locale/ja/hammer-cli-foreman.po +254 -176
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/hammer-cli-foreman.edit.po +591 -366
- data/locale/ko/hammer-cli-foreman.po +254 -176
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/hammer-cli-foreman.edit.po +588 -388
- data/locale/pt_BR/hammer-cli-foreman.po +254 -176
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/hammer-cli-foreman.edit.po +549 -336
- data/locale/ru/hammer-cli-foreman.po +254 -176
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/hammer-cli-foreman.edit.po +598 -373
- data/locale/zh_CN/hammer-cli-foreman.po +254 -176
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/hammer-cli-foreman.edit.po +592 -367
- data/locale/zh_TW/hammer-cli-foreman.po +254 -176
- data/test/test_helper.rb +7 -5
- data/test/unit/api/interactive_basic_auth_test.rb +87 -0
- data/test/unit/api/session_authenticator_wrapper_test.rb +263 -0
- data/test/unit/exception_handler_test.rb +1 -1
- data/test/unit/host_test.rb +2 -2
- metadata +314 -292
- data/lib/hammer_cli_foreman/credentials.rb +0 -67
- data/test/unit/credentials_test.rb +0 -59
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'highline/import'
|
2
|
-
module HammerCLIForeman
|
3
|
-
class BasicCredentials < ApipieBindings::AbstractCredentials
|
4
|
-
|
5
|
-
# Can keep username and passwords credentials and prompt for them when necessary
|
6
|
-
# @param [Hash] params
|
7
|
-
# @option params [String] :username when nil, user is prompted when the attribute is accessed
|
8
|
-
# @option params [String] :password when nil, user is prompted when the attribute is accessed
|
9
|
-
# @example use container with prompt
|
10
|
-
# c = HammerCLIForeman::BasicCredentials.new()
|
11
|
-
# c.username
|
12
|
-
# > [Foreman] Username: admin
|
13
|
-
# => "admin"
|
14
|
-
# @example use container with preset value
|
15
|
-
# c = HammerCLIForeman::BasicCredentials.new(:username => 'admin')
|
16
|
-
# c.username
|
17
|
-
# => "admin"
|
18
|
-
def initialize(params={})
|
19
|
-
@username = params[:username]
|
20
|
-
@password = params[:password]
|
21
|
-
end
|
22
|
-
|
23
|
-
# Get username. Prompt for it when not set
|
24
|
-
# @return [String]
|
25
|
-
def username
|
26
|
-
@username ||= ask_user(_("[Foreman] Username: ")) if HammerCLI.interactive?
|
27
|
-
@username
|
28
|
-
end
|
29
|
-
|
30
|
-
# Get password. Prompt for it when not set. Password characters are replaced with asterisks on the screen.
|
31
|
-
# @return [String]
|
32
|
-
def password
|
33
|
-
@password ||= ask_user(_("[Foreman] Password for %s: ") % username, true) if HammerCLI.interactive?
|
34
|
-
@password
|
35
|
-
end
|
36
|
-
|
37
|
-
def empty?
|
38
|
-
!@username && !@password
|
39
|
-
end
|
40
|
-
|
41
|
-
def clear
|
42
|
-
super
|
43
|
-
@username = nil
|
44
|
-
@password = nil
|
45
|
-
end
|
46
|
-
|
47
|
-
# Convert credentials to hash usable for merging to RestClient configuration.
|
48
|
-
# @return [Hash]
|
49
|
-
def to_params
|
50
|
-
{
|
51
|
-
:user => username,
|
52
|
-
:password => password
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def ask_user(prompt, silent=false)
|
59
|
-
if silent
|
60
|
-
ask(prompt) {|q| q.echo = false}
|
61
|
-
else
|
62
|
-
ask(prompt)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
-
|
3
|
-
describe HammerCLIForeman::BasicCredentials do
|
4
|
-
|
5
|
-
context "interactive mode" do
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
HammerCLI.stubs(:interactive?).returns true
|
9
|
-
end
|
10
|
-
|
11
|
-
after :each do
|
12
|
-
HammerCLI.stubs(:interactive?).returns false
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should ask for username when not provided" do
|
16
|
-
creds = HammerCLIForeman::BasicCredentials.new()
|
17
|
-
creds.stubs(:ask_user).returns('user')
|
18
|
-
creds.username.must_equal 'user'
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should not ask the username when provided" do
|
22
|
-
creds = HammerCLIForeman::BasicCredentials.new({ :username => 'user'})
|
23
|
-
creds.stubs(:ask_user).returns('other_user')
|
24
|
-
creds.username.must_equal 'user'
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should ask for password when not provided" do
|
28
|
-
creds = HammerCLIForeman::BasicCredentials.new()
|
29
|
-
creds.stubs(:ask_user).returns('pass')
|
30
|
-
creds.password.must_equal 'pass'
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should not ask the password when provided" do
|
34
|
-
creds = HammerCLIForeman::BasicCredentials.new({ :password => 'pass'})
|
35
|
-
creds.stubs(:ask_user).returns('other_pass')
|
36
|
-
creds.password.must_equal 'pass'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should export the credentials" do
|
40
|
-
creds = HammerCLIForeman::BasicCredentials.new()
|
41
|
-
creds.stubs(:ask_user).returns('user','pass')
|
42
|
-
creds.to_params.must_equal({ :user => 'user', :password => 'pass' })
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "non-interactive mode" do
|
47
|
-
|
48
|
-
it "should not ask for username when not provided" do
|
49
|
-
creds = HammerCLIForeman::BasicCredentials.new()
|
50
|
-
creds.username.must_be_nil
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should not ask for password when not provided" do
|
54
|
-
creds = HammerCLIForeman::BasicCredentials.new()
|
55
|
-
creds.password.must_be_nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|