hammer_cli_foreman 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/config/foreman.yml +1 -0
  3. data/doc/host_create.md +3 -3
  4. data/doc/release_notes.md +14 -0
  5. data/lib/hammer_cli_foreman.rb +0 -1
  6. data/lib/hammer_cli_foreman/api.rb +3 -0
  7. data/lib/hammer_cli_foreman/api/connection.rb +75 -0
  8. data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +49 -0
  9. data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +120 -0
  10. data/lib/hammer_cli_foreman/auth.rb +16 -12
  11. data/lib/hammer_cli_foreman/commands.rb +4 -36
  12. data/lib/hammer_cli_foreman/compute_resource.rb +6 -6
  13. data/lib/hammer_cli_foreman/compute_resources/all.rb +7 -0
  14. data/lib/hammer_cli_foreman/compute_resources/ec2.rb +9 -0
  15. data/lib/hammer_cli_foreman/compute_resources/ec2/host_help_extenstion.rb +23 -0
  16. data/lib/hammer_cli_foreman/compute_resources/gce.rb +9 -0
  17. data/lib/hammer_cli_foreman/compute_resources/gce/host_help_extenstion.rb +22 -0
  18. data/lib/hammer_cli_foreman/compute_resources/libvirt.rb +9 -0
  19. data/lib/hammer_cli_foreman/compute_resources/libvirt/host_help_extenstion.rb +35 -0
  20. data/lib/hammer_cli_foreman/compute_resources/openstack.rb +9 -0
  21. data/lib/hammer_cli_foreman/compute_resources/openstack/host_help_extenstion.rb +23 -0
  22. data/lib/hammer_cli_foreman/compute_resources/ovirt.rb +9 -0
  23. data/lib/hammer_cli_foreman/compute_resources/ovirt/host_help_extenstion.rb +36 -0
  24. data/lib/hammer_cli_foreman/compute_resources/rackspace.rb +9 -0
  25. data/lib/hammer_cli_foreman/compute_resources/rackspace/host_help_extenstion.rb +20 -0
  26. data/lib/hammer_cli_foreman/compute_resources/vmware.rb +9 -0
  27. data/lib/hammer_cli_foreman/compute_resources/vmware/host_help_extenstion.rb +62 -0
  28. data/lib/hammer_cli_foreman/filter.rb +1 -0
  29. data/lib/hammer_cli_foreman/host.rb +15 -140
  30. data/lib/hammer_cli_foreman/hosts/common_update_help.rb +53 -0
  31. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +141 -0
  32. data/lib/hammer_cli_foreman/references.rb +13 -2
  33. data/lib/hammer_cli_foreman/role.rb +3 -7
  34. data/lib/hammer_cli_foreman/smart_class_parameter.rb +2 -2
  35. data/lib/hammer_cli_foreman/smart_variable.rb +1 -2
  36. data/lib/hammer_cli_foreman/user.rb +2 -0
  37. data/lib/hammer_cli_foreman/version.rb +1 -1
  38. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/ca/hammer-cli-foreman.edit.po +520 -318
  40. data/locale/ca/hammer-cli-foreman.po +253 -175
  41. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/de/hammer-cli-foreman.edit.po +568 -358
  43. data/locale/de/hammer-cli-foreman.po +255 -177
  44. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  45. data/locale/en/hammer-cli-foreman.edit.po +446 -228
  46. data/locale/en/hammer-cli-foreman.po +208 -41
  47. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  48. data/locale/en_GB/hammer-cli-foreman.edit.po +498 -307
  49. data/locale/en_GB/hammer-cli-foreman.po +254 -176
  50. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  51. data/locale/es/hammer-cli-foreman.edit.po +594 -388
  52. data/locale/es/hammer-cli-foreman.po +254 -176
  53. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  54. data/locale/fr/hammer-cli-foreman.edit.po +542 -342
  55. data/locale/fr/hammer-cli-foreman.po +254 -176
  56. data/locale/hammer-cli-foreman.pot +503 -241
  57. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  58. data/locale/it/hammer-cli-foreman.edit.po +510 -295
  59. data/locale/it/hammer-cli-foreman.po +254 -176
  60. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  61. data/locale/ja/hammer-cli-foreman.edit.po +590 -365
  62. data/locale/ja/hammer-cli-foreman.po +254 -176
  63. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  64. data/locale/ko/hammer-cli-foreman.edit.po +591 -366
  65. data/locale/ko/hammer-cli-foreman.po +254 -176
  66. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  67. data/locale/pt_BR/hammer-cli-foreman.edit.po +588 -388
  68. data/locale/pt_BR/hammer-cli-foreman.po +254 -176
  69. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  70. data/locale/ru/hammer-cli-foreman.edit.po +549 -336
  71. data/locale/ru/hammer-cli-foreman.po +254 -176
  72. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  73. data/locale/zh_CN/hammer-cli-foreman.edit.po +598 -373
  74. data/locale/zh_CN/hammer-cli-foreman.po +254 -176
  75. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  76. data/locale/zh_TW/hammer-cli-foreman.edit.po +592 -367
  77. data/locale/zh_TW/hammer-cli-foreman.po +254 -176
  78. data/test/test_helper.rb +7 -5
  79. data/test/unit/api/interactive_basic_auth_test.rb +87 -0
  80. data/test/unit/api/session_authenticator_wrapper_test.rb +263 -0
  81. data/test/unit/exception_handler_test.rb +1 -1
  82. data/test/unit/host_test.rb +2 -2
  83. metadata +314 -292
  84. data/lib/hammer_cli_foreman/credentials.rb +0 -67
  85. 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