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.

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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0062a1642130c282db9079a28b7cf5a72edf88d4
4
- data.tar.gz: 3e9aad851851ace099b2b14fbc546dfb7d82b5d3
3
+ metadata.gz: c8dbe72d7f0cdd60461bcb2ceedbdb241791e9ba
4
+ data.tar.gz: 7a93863b4b5dfa7e2318e8842df64ee23de005a1
5
5
  SHA512:
6
- metadata.gz: 5d382cb35adc5868503186f201644a7dede5b4ebd58831a65e5e89f616a5c4b6fb948826ebd5e8c0658bdbfe7a00c9061bff8094e50e85cacf2a83c3f91bc229
7
- data.tar.gz: 009d972e9d43f82be69c944e7da8555e58abd0a2bc40fdd5ccd962dc321b61dc7b8d2153266796603277fb2b3053e41753951bfcad81f5a752eb87b99015da86
6
+ metadata.gz: 645d647eec03ddee3afd4c4f61677fd1ecfa98b9981cf72d150ac8cb9d68f0adc7b5b1e88c30ad4da52d7fe3463a889a4ad6622b51716cb6ad315f3d3e61b1d3
7
+ data.tar.gz: f2c39dccfb3949685b4a77703274aa7bcf683953a25ee271fcff63d9152f285ed833dcc00ec4cc3c61064ac92d21145d45ac9d7eb667e38945370b0eb8430533
data/config/foreman.yml CHANGED
@@ -8,6 +8,7 @@
8
8
  # Credentials. You'll be asked for them interactively if you leave them blank here
9
9
  :username: 'admin'
10
10
  #:password: 'example'
11
+ :use_sessions: false
11
12
 
12
13
  # Check API documentation cache status on each request
13
14
  #:refresh_cache: false
data/doc/host_create.md CHANGED
@@ -164,7 +164,7 @@ Available keys for `--compute-attributes`:
164
164
  ```
165
165
  cpus # number of CPUs
166
166
  memory # string, amount of memory, value in bytes
167
- start # boolean, whether to start the machine or not
167
+ start # Must be a 1 or 0, whether to start the machine or not
168
168
  ```
169
169
 
170
170
  Available keys for `--interface`:
@@ -198,7 +198,7 @@ cluster
198
198
  template # hardware profile to use
199
199
  cores # int value, number of cores
200
200
  memory # amount of memory, int value in bytes
201
- start # boolean, whether to start the machine or not
201
+ start # Must be a 1 or 0, whether to start the machine or not
202
202
  ```
203
203
 
204
204
  Available keys for `--interface`:
@@ -233,7 +233,7 @@ path # path to folder
233
233
  guest_id # guest OS id form VMware
234
234
  scsi_controller_type # id of the controller from VMware
235
235
  hardware_version # hardware version id from VMware
236
- start # Must be a 1 or 0, whether to start the machine or not
236
+ start # Boolean, expressed as 0 or 1, whether to start the machine or not
237
237
  ```
238
238
 
239
239
  Available keys for `--interface`:
data/doc/release_notes.md CHANGED
@@ -1,5 +1,19 @@
1
1
  Release notes
2
2
  =============
3
+ ### 0.9.0 (2016-12-15)
4
+ * Auth overrides only unauthorized exception ([PR #271](https://github.com/theforeman/hammer-cli-foreman/pull/271)) ([#17650](http://projects.theforeman.org/issues/17650))
5
+ * Session auth in hammer ([PR #269](https://github.com/theforeman/hammer-cli-foreman/pull/269)) ([#8016](http://projects.theforeman.org/issues/8016))
6
+ * Display override value order as long text ([#17355](http://projects.theforeman.org/issues/17355))
7
+ * Showing roles inherited from usergroups ([#16016](http://projects.theforeman.org/issues/16016))
8
+ * The 'start' key always needs a 1 or 0 ([#17393](http://projects.theforeman.org/issues/17393))
9
+ * Compute resource specific details in host help ([PR #263](https://github.com/theforeman/hammer-cli-foreman/pull/263)) ([#12472](http://projects.theforeman.org/issues/12472))
10
+ * Fix compute-resource info ([#17077](http://projects.theforeman.org/issues/17077))
11
+ * List override in filter output ([#17109](http://projects.theforeman.org/issues/17109))
12
+ * Added description field to User in hammer ([#16772](http://projects.theforeman.org/issues/16772))
13
+ * Added description field to Roles in hammer ([#16771](http://projects.theforeman.org/issues/16771))
14
+ * add taxonomies to role info ([#16799](http://projects.theforeman.org/issues/16799))
15
+ * Adds 'builtin' attribute to Role list ([#16406](http://projects.theforeman.org/issues/16406))
16
+
3
17
  ### 0.8.0 (2016-09-01)
4
18
  * add realm commands to hammer ([PR #240](https://github.com/theforeman/hammer-cli-foreman/pull/240)) ([#4918](http://projects.theforeman.org/issues/4918))
5
19
  * Renamed name to variable for smart_variables ([#16119](http://projects.theforeman.org/issues/16119))
@@ -13,7 +13,6 @@ module HammerCLIForeman
13
13
  require 'hammer_cli_foreman/version'
14
14
  require 'hammer_cli_foreman/output'
15
15
  require 'hammer_cli_foreman/output/fields'
16
- require 'hammer_cli_foreman/credentials'
17
16
  require 'hammer_cli_foreman/exception_handler'
18
17
  require 'hammer_cli_foreman/option_builders'
19
18
  require 'hammer_cli_foreman/param_filters'
@@ -0,0 +1,3 @@
1
+ require 'hammer_cli_foreman/api/connection'
2
+
3
+ HammerCLIForeman.init_api_connection
@@ -0,0 +1,75 @@
1
+ require 'hammer_cli_foreman/api/session_authenticator_wrapper'
2
+ require 'hammer_cli_foreman/api/interactive_basic_auth'
3
+
4
+ module HammerCLIForeman
5
+ module Api
6
+ class Connection < HammerCLI::Apipie::ApiConnection
7
+ attr_reader :authenticator
8
+
9
+ def initialize(settings, logger = nil, locale = nil)
10
+ default_params = build_default_params(settings, logger, locale)
11
+ super(default_params,
12
+ :logger => logger,
13
+ :reload_cache => settings.get(:_params, :reload_cache) || settings.get(:reload_cache)
14
+ )
15
+ end
16
+
17
+ def login
18
+ # Call some api entry point to trigger the
19
+ @api.resource(:home).action(:status).call
20
+ end
21
+
22
+ def logout
23
+ @authenticator.clear if @authenticator.respond_to?(:clear)
24
+ end
25
+
26
+ def login_status
27
+ @authenticator.status
28
+ end
29
+
30
+ protected
31
+
32
+ def create_authenticator(uri, settings)
33
+ return @authenticator unless @authenticator.nil?
34
+
35
+ @authenticator = InteractiveBasicAuth.new(
36
+ settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || settings.get(:foreman, :username),
37
+ settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || settings.get(:foreman, :password)
38
+ )
39
+ @authenticator = SessionAuthenticatorWrapper.new(@authenticator, uri) if settings.get(:foreman, :use_sessions)
40
+ @authenticator
41
+ end
42
+
43
+ def build_default_params(settings, logger, locale)
44
+ config = {}
45
+ config[:uri] = settings.get(:_params, :host) || settings.get(:foreman, :host)
46
+ config[:logger] = logger unless logger.nil?
47
+ config[:api_version] = 2
48
+ config[:follow_redirects] = settings.get(:foreman, :follow_redirects) || :never
49
+ config[:aggressive_cache_checking] = settings.get(:foreman, :refresh_cache) || false
50
+ unless locale.nil?
51
+ config[:headers] = { "Accept-Language" => locale }
52
+ config[:language] = locale
53
+ end
54
+ config[:timeout] = settings.get(:foreman, :request_timeout)
55
+ config[:timeout] = -1 if (config[:timeout] && config[:timeout].to_i < 0)
56
+ config[:apidoc_authenticated] = false
57
+ config[:authenticator] = create_authenticator(config[:uri], settings)
58
+ config
59
+ end
60
+ end
61
+ end
62
+
63
+ CONNECTION_NAME = 'foreman'
64
+
65
+ def self.foreman_api_connection
66
+ HammerCLI.context[:api_connection].create(CONNECTION_NAME) do
67
+ HammerCLIForeman::Api::Connection.new(HammerCLI::Settings, Logging.logger['API'], HammerCLI::I18n.locale)
68
+ end
69
+ end
70
+
71
+ def self.init_api_connection
72
+ foreman_api_connection
73
+ end
74
+ end
75
+
@@ -0,0 +1,49 @@
1
+ require 'highline/import'
2
+
3
+ module HammerCLIForeman
4
+ module Api
5
+ class InteractiveBasicAuth < ApipieBindings::Authenticators::BasicAuth
6
+ def authenticate(request, args)
7
+ if HammerCLI.interactive?
8
+ get_user
9
+ get_password
10
+ end
11
+ super
12
+ end
13
+
14
+ def error(ex)
15
+ ex.message = _("Invalid username or password") if ex.is_a?(RestClient::Unauthorized)
16
+ end
17
+
18
+ def status
19
+ unless @user.nil? || @password.nil?
20
+ _("You are logged in as '%s'") % @user
21
+ else
22
+ _("You are currently not logged in")
23
+ end
24
+ end
25
+
26
+ def user
27
+ get_user
28
+ end
29
+
30
+ private
31
+
32
+ def get_user
33
+ @user ||= ask_user(_("[Foreman] Username: "))
34
+ end
35
+
36
+ def get_password
37
+ @password ||= ask_user(_("[Foreman] Password for %s: ") % @user, true)
38
+ end
39
+
40
+ def ask_user(prompt, silent=false)
41
+ if silent
42
+ ask(prompt) {|q| q.echo = false}
43
+ else
44
+ ask(prompt)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,120 @@
1
+ require 'uri'
2
+
3
+ module HammerCLIForeman
4
+ module Api
5
+ class SessionAuthenticatorWrapper < ApipieBindings::Authenticators::Base
6
+ SESSION_STORAGE = '~/.hammer/sessions/'
7
+
8
+ def initialize(authenticator, url, storage_dir = nil)
9
+ @authenticator = authenticator
10
+ @url = url
11
+
12
+ uri = URI.parse(url)
13
+ @session_file = "#{uri.scheme}_#{uri.host}"
14
+ @storage_dir = storage_dir || File.expand_path(SESSION_STORAGE)
15
+
16
+ @permissions_ok = check_storage_permissions
17
+ warn _("Can't use session auth due to invalid permissions on session files.") unless @permissions_ok
18
+ end
19
+
20
+ def clear
21
+ destroy_session
22
+ end
23
+
24
+ def status
25
+ if load_session
26
+ _("Session exist, currently logged in as '%s'") % @user
27
+ else
28
+ _("You are currently not logged in")
29
+ end
30
+ end
31
+
32
+ def authenticate(request, args)
33
+ load_session
34
+
35
+ destroy_session if (@authenticator.user != @user)
36
+
37
+ if @permissions_ok && @session_id
38
+ jar = HTTP::CookieJar.new
39
+ jar.add(HTTP::Cookie.new('_session_id', @session_id, domain: request.uri.hostname.downcase, path: '/', for_domain: true))
40
+ request['Cookie'] = HTTP::Cookie.cookie_value(jar.cookies)
41
+ request
42
+ else
43
+ @authenticator.authenticate(request, args)
44
+ end
45
+ end
46
+
47
+ def error(ex)
48
+ load_session
49
+ if ex.is_a?(RestClient::Unauthorized) && !@session_id.nil?
50
+ destroy_session
51
+ ex.message = _("Session has expired")
52
+ else
53
+ @authenticator.error(ex)
54
+ end
55
+ end
56
+
57
+ def response(r)
58
+ @session_id = r.cookies['_session_id']
59
+ if (@session_id && r.code != 401)
60
+ save_session(@session_id, @authenticator.user)
61
+ end
62
+ @authenticator.response(r)
63
+ end
64
+
65
+ protected
66
+
67
+ def session_storage
68
+ "#{@storage_dir}/#{@session_file}"
69
+ end
70
+
71
+ def load_session
72
+ if File.exist?(session_storage)
73
+ session_data = JSON.parse(File.read(session_storage))
74
+ @user = session_data['user_name']
75
+ @session_id = session_data['session_id']
76
+ end
77
+ rescue JSON::ParserError
78
+ warn _('Invalid session file format')
79
+ nil
80
+ end
81
+
82
+ def save_session(session_id, user_name)
83
+ File.open(session_storage, 'w', 0600) do |f|
84
+ session = JSON.generate({
85
+ :session_id => session_id,
86
+ :user_name => user_name
87
+ })
88
+ f.write(session)
89
+ end
90
+ end
91
+
92
+ def destroy_session
93
+ @user = @session_id = nil
94
+ File.delete(session_storage) if File.exist?(session_storage)
95
+ end
96
+
97
+ def check_storage_permissions
98
+ Dir.mkdir(@storage_dir, 0700) unless File.exist?(@storage_dir)
99
+ ensure_mode(@storage_dir, '40700') && ensure_mode(session_storage, '100600')
100
+ end
101
+
102
+ def ensure_mode(file, expected_mode)
103
+ return true unless File.exist?(file)
104
+ mode = File.stat(file).mode.to_s(8)
105
+ if mode != expected_mode
106
+ warn _("Invalid permissions for %{file}: %{mode}, expected %{expected_mode}") % {
107
+ :mode => mode,
108
+ :expected_mode => expected_mode,
109
+ :file => file
110
+ }
111
+ false
112
+ else
113
+ true
114
+ end
115
+ end
116
+
117
+ end
118
+ end
119
+ end
120
+
@@ -6,11 +6,20 @@ module HammerCLIForeman
6
6
  command_name "login"
7
7
  desc _("Set credentials")
8
8
 
9
+ option ["-u", "--username"], "USERNAME", _("username to access the remote system")
10
+ option ["-p", "--password"], "PASSWORD", _("password to access the remote system")
11
+
9
12
  def execute
10
- HammerCLIForeman.credentials.clear
11
- HammerCLI::Connection.drop_all
12
- HammerCLIForeman.credentials.username
13
- HammerCLIForeman.credentials.password
13
+ HammerCLIForeman.foreman_api_connection.logout
14
+ context[:api_connection].drop_all
15
+ HammerCLI::Settings.load({
16
+ :_params => {
17
+ :username => option_username,
18
+ :password => option_password
19
+ }
20
+ })
21
+ HammerCLIForeman.foreman_api_connection.login
22
+ print_message(_("Successfully logged in."))
14
23
  HammerCLI::EX_OK
15
24
  end
16
25
  end
@@ -20,9 +29,8 @@ module HammerCLIForeman
20
29
  desc _("Wipe your credentials")
21
30
 
22
31
  def execute
23
- #NOTE: we will change that to drop(:foreman) once dynamic bindings are implemented
24
- HammerCLIForeman.credentials.clear
25
- HammerCLI::Connection.drop_all
32
+ HammerCLIForeman.foreman_api_connection.logout
33
+ context[:api_connection].drop_all
26
34
  print_message(_("Credentials deleted."))
27
35
  HammerCLI::EX_OK
28
36
  end
@@ -33,11 +41,7 @@ module HammerCLIForeman
33
41
  desc _("Information about current connections")
34
42
 
35
43
  def execute
36
- unless HammerCLIForeman.credentials.empty?
37
- print_message(_("You are logged in as '%s'") % HammerCLIForeman.credentials.username)
38
- else
39
- print_message(_("You are currently not logged in to any service.\nUse the service to set credentials."))
40
- end
44
+ print_message(HammerCLIForeman.foreman_api_connection.login_status)
41
45
  HammerCLI::EX_OK
42
46
  end
43
47
  end
@@ -1,6 +1,6 @@
1
- module HammerCLIForeman
1
+ require 'hammer_cli_foreman/api'
2
2
 
3
- CONNECTION_NAME = 'foreman'
3
+ module HammerCLIForeman
4
4
 
5
5
  RESOURCE_NAME_MAPPING = {
6
6
  :usergroup => :user_group,
@@ -11,40 +11,8 @@ module HammerCLIForeman
11
11
  :puppetclasses => :puppet_classes
12
12
  }
13
13
 
14
- def self.credentials
15
- @credentials ||= BasicCredentials.new(
16
- :username => (HammerCLI::Settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || HammerCLI::Settings.get(:foreman, :username)),
17
- :password => (HammerCLI::Settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || HammerCLI::Settings.get(:foreman, :password))
18
- )
19
- @credentials
20
- end
21
-
22
- def self.resource_config
23
- config = {}
24
- config[:uri] = HammerCLI::Settings.get(:_params, :host) || HammerCLI::Settings.get(:foreman, :host)
25
- config[:credentials] = credentials
26
- config[:logger] = Logging.logger['API']
27
- config[:api_version] = 2
28
- config[:follow_redirects] = HammerCLI::Settings.get(:foreman, :follow_redirects) || :never
29
- config[:aggressive_cache_checking] = HammerCLI::Settings.get(:foreman, :refresh_cache) || false
30
- config[:headers] = { "Accept-Language" => HammerCLI::I18n.locale }
31
- config[:language] = HammerCLI::I18n.locale
32
- config[:timeout] = HammerCLI::Settings.get(:foreman, :request_timeout)
33
- config[:timeout] = -1 if (config[:timeout] && config[:timeout].to_i < 0)
34
- config[:apidoc_authenticated] = false
35
- config
36
- end
37
-
38
- def self.foreman_api_connection
39
- HammerCLI::Connection.create(
40
- CONNECTION_NAME,
41
- HammerCLI::Apipie::Command.resource_config.merge(resource_config),
42
- HammerCLI::Apipie::Command.connection_options
43
- )
44
- end
45
-
46
14
  def self.foreman_api
47
- foreman_api_connection.api
15
+ foreman_api_connection
48
16
  end
49
17
 
50
18
  def self.foreman_resource!(resource_name, options={})
@@ -173,7 +141,7 @@ module HammerCLIForeman
173
141
  end
174
142
 
175
143
  def self.resolver
176
- api = HammerCLI::Connection.get("foreman").api
144
+ api = HammerCLI.context[:api_connection].get("foreman")
177
145
  HammerCLIForeman::IdResolver.new(api, HammerCLIForeman::Searchables.new)
178
146
  end
179
147
 
@@ -31,20 +31,20 @@ module HammerCLIForeman
31
31
 
32
32
  PROVIDER_SPECIFIC_FIELDS = {
33
33
  'ovirt' => [
34
- Fields::Field.new(:label => _('UUID'), :path => ["compute_resource", "uuid"])
34
+ Fields::Field.new(:label => _('Datacenter'), :path => [:datacenter])
35
35
  ],
36
36
  'ec2' => [
37
- Fields::Field.new(:label => _('Region'), :path => ["compute_resource", "region"])
37
+ Fields::Field.new(:label => _('Region'), :path => [:region])
38
38
  ],
39
39
  'vmware' => [
40
- Fields::Field.new(:label => _('UUID'), :path => ["compute_resource", "uuid"]),
41
- Fields::Field.new(:label => _('Server'), :path => ["compute_resource", "server"])
40
+ Fields::Field.new(:label => _('Datacenter'), :path => [:datacenter]),
41
+ Fields::Field.new(:label => _('Server'), :path => [:server])
42
42
  ],
43
43
  'openstack' => [
44
- Fields::Field.new(:label => _('Tenant'), :path => ["compute_resource", "tenant"])
44
+ Fields::Field.new(:label => _('Tenant'), :path => [:tenant])
45
45
  ],
46
46
  'rackspace' => [
47
- Fields::Field.new(:label => _('Region'), :path => ["compute_resource", "region"])
47
+ Fields::Field.new(:label => _('Region'), :path => [:region])
48
48
  ],
49
49
  'libvirt' => [
50
50
  ]