hammer_cli_katello 0.0.26 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/activation_key.rb +23 -43
  3. data/lib/hammer_cli_katello/associating_commands.rb +3 -5
  4. data/lib/hammer_cli_katello/capsule.rb +1 -3
  5. data/lib/hammer_cli_katello/commands.rb +1 -7
  6. data/lib/hammer_cli_katello/content_view.rb +6 -3
  7. data/lib/hammer_cli_katello/content_view_name_resolvable.rb +21 -0
  8. data/lib/hammer_cli_katello/content_view_puppet_module.rb +11 -7
  9. data/lib/hammer_cli_katello/content_view_version.rb +30 -29
  10. data/lib/hammer_cli_katello/erratum.rb +0 -1
  11. data/lib/hammer_cli_katello/exception_handler.rb +0 -2
  12. data/lib/hammer_cli_katello/filter.rb +11 -3
  13. data/lib/hammer_cli_katello/filter_rule.rb +8 -2
  14. data/lib/hammer_cli_katello/foreman_search_options_creators.rb +71 -0
  15. data/lib/hammer_cli_katello/gpg_key.rb +0 -5
  16. data/lib/hammer_cli_katello/host.rb +1 -0
  17. data/lib/hammer_cli_katello/host_collection.rb +48 -16
  18. data/lib/hammer_cli_katello/host_errata.rb +0 -1
  19. data/lib/hammer_cli_katello/host_extensions.rb +56 -0
  20. data/lib/hammer_cli_katello/host_package.rb +0 -3
  21. data/lib/hammer_cli_katello/host_package_group.rb +0 -3
  22. data/lib/hammer_cli_katello/host_subscription.rb +67 -1
  23. data/lib/hammer_cli_katello/hostgroup.rb +2 -0
  24. data/lib/hammer_cli_katello/hostgroup_extensions.rb +48 -0
  25. data/lib/hammer_cli_katello/i18n.rb +0 -3
  26. data/lib/hammer_cli_katello/id_resolver.rb +25 -16
  27. data/lib/hammer_cli_katello/katello_environment_name_resolvable.rb +4 -3
  28. data/lib/hammer_cli_katello/lifecycle_environment.rb +0 -3
  29. data/lib/hammer_cli_katello/lifecycle_environment_name_resolvable.rb +4 -3
  30. data/lib/hammer_cli_katello/organization.rb +0 -3
  31. data/lib/hammer_cli_katello/organization_options.rb +12 -0
  32. data/lib/hammer_cli_katello/ostree_branch.rb +0 -1
  33. data/lib/hammer_cli_katello/output/fields.rb +0 -2
  34. data/lib/hammer_cli_katello/output/formatters.rb +0 -4
  35. data/lib/hammer_cli_katello/package.rb +0 -1
  36. data/lib/hammer_cli_katello/package_group.rb +0 -1
  37. data/lib/hammer_cli_katello/ping.rb +0 -6
  38. data/lib/hammer_cli_katello/product.rb +1 -7
  39. data/lib/hammer_cli_katello/puppet_module.rb +0 -1
  40. data/lib/hammer_cli_katello/repository.rb +36 -35
  41. data/lib/hammer_cli_katello/repository_scoped_to_product.rb +0 -4
  42. data/lib/hammer_cli_katello/repository_set.rb +0 -3
  43. data/lib/hammer_cli_katello/search_options_creators.rb +40 -18
  44. data/lib/hammer_cli_katello/subscription.rb +20 -13
  45. data/lib/hammer_cli_katello/sync_plan.rb +4 -8
  46. data/lib/hammer_cli_katello/version.rb +1 -1
  47. data/lib/hammer_cli_katello.rb +21 -26
  48. data/test/data/3.0/foreman_api.json +1 -1
  49. data/test/data/3.2/foreman_api.json +1 -0
  50. data/test/data/Readme.md +5 -0
  51. data/test/functional/activaton_key/add_host_collection_test.rb +62 -0
  52. data/test/functional/activaton_key/create_test.rb +33 -0
  53. data/test/functional/activaton_key/list_test.rb +15 -16
  54. data/test/functional/activaton_key/product_content_test.rb +23 -0
  55. data/test/functional/activaton_key/remove_host_collection_test.rb +62 -0
  56. data/test/functional/activaton_key/subscriptions_test.rb +57 -0
  57. data/test/functional/activaton_key/update_test.rb +26 -0
  58. data/test/functional/capsule/content/cancel_synchronization_test.rb +1 -1
  59. data/test/functional/capsule/content/capsule_content_helpers.rb +0 -2
  60. data/test/functional/content_view/add_content_view_version_test.rb +34 -0
  61. data/test/functional/content_view/add_repository_test.rb +20 -0
  62. data/test/functional/content_view/content_view_helpers.rb +0 -2
  63. data/test/functional/content_view/create_test.rb +3 -3
  64. data/test/functional/content_view/filter/create_test.rb +63 -0
  65. data/test/functional/content_view/list_test.rb +23 -20
  66. data/test/functional/content_view/publish_test.rb +23 -0
  67. data/test/functional/content_view/puppet_module/add_test.rb +23 -0
  68. data/test/functional/content_view/remove_content_view_version_test.rb +34 -0
  69. data/test/functional/content_view/version/incremental_update_test.rb +4 -4
  70. data/test/functional/content_view/version/list_test.rb +44 -0
  71. data/test/functional/content_view/version/promote_test.rb +35 -0
  72. data/test/functional/filter_rule/create_test.rb +20 -0
  73. data/test/functional/host/errata/apply_test.rb +5 -4
  74. data/test/functional/host/extensions/data/host.json +310 -0
  75. data/test/functional/host/extensions/data/host_list.json +115 -0
  76. data/test/functional/host/extensions/info_test.rb +27 -0
  77. data/test/functional/host/extensions/list_test.rb +21 -0
  78. data/test/functional/host/host_helpers.rb +0 -2
  79. data/test/functional/host/subscription/attach_test.rb +54 -0
  80. data/test/functional/host/subscription/auto_attach_test.rb +35 -0
  81. data/test/functional/host/subscription/register_test.rb +2 -2
  82. data/test/functional/host/subscription/remove_test.rb +52 -0
  83. data/test/functional/host_collection/add_host_test.rb +57 -0
  84. data/test/functional/host_collection/copy_test.rb +64 -0
  85. data/test/functional/host_collection/create_test.rb +43 -0
  86. data/test/functional/host_collection/delete_test.rb +57 -0
  87. data/test/functional/host_collection/hosts_test.rb +40 -0
  88. data/test/functional/host_collection/info_test.rb +57 -0
  89. data/test/functional/host_collection/list_test.rb +42 -0
  90. data/test/functional/host_collection/remove_host_test.rb +57 -0
  91. data/test/functional/host_collection/update_test.rb +57 -0
  92. data/test/functional/hostgroup/create_test.rb +55 -0
  93. data/test/functional/hostgroup/data/hostgroup.json +48 -0
  94. data/test/functional/hostgroup/info_test.rb +30 -0
  95. data/test/functional/hostgroup/update_test.rb +55 -0
  96. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -2
  97. data/test/functional/organization/organization_helpers.rb +0 -2
  98. data/test/functional/product/create_test.rb +54 -0
  99. data/test/functional/product/delete_test.rb +41 -0
  100. data/test/functional/product/info_test.rb +33 -0
  101. data/test/functional/product/list_test.rb +58 -0
  102. data/test/functional/product/product_helpers.rb +14 -0
  103. data/test/functional/product/remove_sync_plan_test.rb +35 -0
  104. data/test/functional/product/set_sync_plan_test.rb +49 -0
  105. data/test/functional/product/update_test.rb +46 -0
  106. data/test/functional/repository/info_test.rb +3 -3
  107. data/test/functional/repository/list_test.rb +14 -13
  108. data/test/functional/repository/remove_content_test.rb +18 -0
  109. data/test/functional/repository/repository_helpers.rb +9 -3
  110. data/test/functional/repository/synchronize_test.rb +3 -3
  111. data/test/functional/repository/upload_test.rb +17 -5
  112. data/test/functional/subscription/list_test.rb +92 -0
  113. data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
  114. data/test/test_helper.rb +3 -3
  115. data/test/unit/id_resolver_test.rb +17 -2
  116. data/test/unit/search_options_creators_test.rb +49 -12
  117. metadata +105 -7
  118. data/lib/hammer_cli_katello/content_host.rb +0 -111
@@ -1,5 +1,4 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class HostCollection < HammerCLIKatello::Command
4
3
  resource :host_collections
5
4
 
@@ -48,42 +47,76 @@ module HammerCLIKatello
48
47
  field :total_hosts, _("Total Hosts")
49
48
  end
50
49
 
51
- build_options
50
+ build_options { |o| o.expand(:all).including(:organizations) }
52
51
  end
53
52
 
54
53
  class HostsCommand < HammerCLIKatello::ListCommand
55
- resource :host_collections, :hosts
54
+ resource :hosts, :index
56
55
  command_name "hosts"
57
56
 
57
+ option "--id", "HOST_COLLECTION_ID", _("Host Collection ID"),
58
+ :attribute_name => :option_host_collection_id
59
+ option "--name", "HOST_COLLECTION_NAME", _("Host Collection Name"),
60
+ :attribute_name => :option_host_collection_name
61
+
62
+ validate_options do
63
+ host_collection_options = [:option_host_collection_id, :option_host_collection_name]
64
+ any(*host_collection_options).required
65
+ end
66
+
67
+ def host_collection_options
68
+ {
69
+ "option_name" => option_host_collection_name,
70
+ "option_organization_name" => option_organization_name,
71
+ "option_organization_id" => option_organization_id,
72
+ "option_organization_label" => option_organization_label
73
+ }
74
+ end
75
+
76
+ def request_params
77
+ params = super
78
+ host_collection_id = option_host_collection_id
79
+ unless option_host_collection_name.nil?
80
+ host_collection_id = resolver.host_collection_id(
81
+ options.merge(resolver.scoped_options("host_collection", options)))
82
+ end
83
+ params['search'] = "host_collection_id=#{host_collection_id}"
84
+ params
85
+ end
86
+
58
87
  output do
59
88
  field :id, _("ID")
60
89
  field :name, _("Name")
61
90
  end
62
91
 
63
- build_options
92
+ build_options { |o| o.expand(:all).including(:organizations) }
64
93
  end
65
94
 
66
95
  class CopyCommand < HammerCLIKatello::CreateCommand
67
- resource :host_collections, :copy
68
-
69
96
  action :copy
70
97
  command_name "copy"
98
+ desc _("Copy a host collection")
71
99
 
72
- success_message _("Host collection created")
73
- failure_message _("Could not create the host collection")
100
+ option "--new-name", "NEW_NAME", _("New host collection name"), required: true
74
101
 
75
- validate_options do
76
- all(:option_name).required unless option(:option_id).exist?
102
+ success_message _("New host collection created")
103
+ failure_message _("Could not create the new host collection")
104
+
105
+ def request_params
106
+ params = super
107
+ # This is a hack to keep Hammer consistent without changing the inconsistent API V2
108
+ params['name'] = options[HammerCLI.option_accessor_name('new_name')] if params['id']
109
+ params
77
110
  end
78
111
 
79
- build_options
112
+ build_options { |o| o.expand(:all).including(:organizations) }
80
113
  end
81
114
 
82
115
  class UpdateCommand < HammerCLIKatello::UpdateCommand
83
116
  success_message _("Host collection updated")
84
117
  failure_message _("Could not update the the host collection")
85
118
 
86
- build_options
119
+ build_options { |o| o.expand(:all).including(:organizations) }
87
120
  end
88
121
 
89
122
  class DeleteCommand < HammerCLIKatello::DeleteCommand
@@ -92,7 +125,7 @@ module HammerCLIKatello
92
125
  success_message _("Host collection deleted")
93
126
  failure_message _("Could not delete the host collection")
94
127
 
95
- build_options
128
+ build_options { |o| o.expand(:all).including(:organizations) }
96
129
  end
97
130
 
98
131
  class AddHostCommand < HammerCLIKatello::SingleResourceCommand
@@ -102,7 +135,7 @@ module HammerCLIKatello
102
135
  success_message _("The host(s) has been added")
103
136
  failure_message _("Could not add host(s)")
104
137
 
105
- build_options
138
+ build_options { |o| o.expand(:all).including(:organizations) }
106
139
  end
107
140
 
108
141
  class RemoveHostCommand < HammerCLIKatello::SingleResourceCommand
@@ -112,7 +145,7 @@ module HammerCLIKatello
112
145
  success_message _("The host(s) has been removed")
113
146
  failure_message _("Could not remove host(s)")
114
147
 
115
- build_options
148
+ build_options { |o| o.expand(:all).including(:organizations) }
116
149
  end
117
150
 
118
151
  autoload_subcommands
@@ -174,5 +207,4 @@ module HammerCLIKatello
174
207
  HammerCLIKatello::HostCollectionErratumCommand.desc,
175
208
  HammerCLIKatello::HostCollectionErratumCommand
176
209
  end
177
-
178
210
  end
@@ -1,6 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  class HostErrata < HammerCLIKatello::Command
3
-
4
3
  desc "Manage errata on your hosts"
5
4
 
6
5
  class ApplyCommand < HammerCLIKatello::SingleResourceCommand
@@ -0,0 +1,56 @@
1
+ require 'hammer_cli_foreman/host'
2
+ require 'hammer_cli_katello/host_errata'
3
+ require 'hammer_cli_katello/host_subscription'
4
+ require 'hammer_cli_katello/host_package'
5
+ require 'hammer_cli_katello/host_package_group'
6
+
7
+ module HammerCLIKatello
8
+ module HostExtensions
9
+ ::HammerCLIForeman::Host::ListCommand.instance_eval do
10
+ output do
11
+ from :content_facet_attributes do
12
+ field :content_view_name, _('Content View')
13
+ field :lifecycle_environment_name, _('Lifecycle Environment')
14
+ end
15
+ end
16
+ end
17
+
18
+ ::HammerCLIForeman::Host::InfoCommand.instance_eval do
19
+ output do
20
+ label _('Content Information') do
21
+ from :content_facet_attributes do
22
+ field :content_view_name, _('Content View')
23
+ field :lifecycle_environment_name, _('Lifecycle Environment')
24
+
25
+ label _('Applicable Errata') do
26
+ from :errata_counts do
27
+ field :enhancement, _('Enhancement')
28
+ field :bugfix, _('Bug Fix')
29
+ field :security, _('Security')
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ label _('Subscription Information') do
36
+ from :subscription_facet_attributes do
37
+ field :uuid, _('UUID')
38
+ field :last_checkin, _('Last Checkin')
39
+ field :service_level, _('Service Level')
40
+ field :release_version, _('Release Version')
41
+ field :autoheal, _('Autoheal')
42
+ field :registered_at, _('Registered At')
43
+ collection :activation_keys, _('Registered by Activation Keys'), :hide_blank => true do
44
+ custom_field Fields::Reference
45
+ end
46
+ end
47
+ end
48
+
49
+ collection :host_collections, _('Host Collections') do
50
+ field :id, _('Id')
51
+ field :name, _('Name')
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,7 +1,5 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class HostPackage < HammerCLIKatello::Command
4
-
5
3
  desc "Manage packages on your hosts"
6
4
 
7
5
  class ListCommand < HammerCLIKatello::ListCommand
@@ -64,5 +62,4 @@ module HammerCLIKatello
64
62
 
65
63
  autoload_subcommands
66
64
  end
67
-
68
65
  end
@@ -1,7 +1,5 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class HostPackageGroup < HammerCLIKatello::Command
4
-
5
3
  desc "Manage package-groups on your hosts"
6
4
 
7
5
  class InstallCommand < HammerCLIKatello::SingleResourceCommand
@@ -34,5 +32,4 @@ module HammerCLIKatello
34
32
 
35
33
  autoload_subcommands
36
34
  end
37
-
38
35
  end
@@ -1,6 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  class HostSubscription < HammerCLIKatello::Command
3
-
4
3
  desc "Manage subscription information on your hosts"
5
4
 
6
5
  class DeleteCommand < HammerCLIKatello::DeleteCommand
@@ -15,6 +14,8 @@ module HammerCLIKatello
15
14
 
16
15
  class CreateCommand < HammerCLIKatello::SingleResourceCommand
17
16
  include LifecycleEnvironmentNameResolvable
17
+ include OrganizationOptions
18
+
18
19
  resource :host_subscriptions, :create
19
20
  command_name "register"
20
21
  success_message _("Host successfully registered")
@@ -26,6 +27,71 @@ module HammerCLIKatello
26
27
  end
27
28
  end
28
29
 
30
+ class AddSubscriptions < HammerCLIKatello::SingleResourceCommand
31
+ resource :host_subscriptions, :add_subscriptions
32
+ command_name "attach"
33
+ success_message _("Subscription attached to the host successfully")
34
+ failure_message _("Failed to attach subscriptions to the host")
35
+
36
+ option "--subscription-id", "SUBSCRIPTION_ID", _("ID of subscription"),
37
+ :attribute_name => :option_subscription_id, :required => true
38
+
39
+ option "--quantity", "Quantity", _("Quantity of this subscriptions to add. Defaults to 1"),
40
+ :attribute_name => :option_quantity, :required => false
41
+
42
+ def request_params
43
+ params = super
44
+ params[:subscriptions] = [
45
+ {
46
+ :id => option_subscription_id,
47
+ :quantity => option_quantity || 1
48
+ }
49
+ ]
50
+ params
51
+ end
52
+
53
+ build_options do |o|
54
+ o.expand.except(:subscriptions)
55
+ o.without(:subscriptions)
56
+ end
57
+ end
58
+
59
+ class AutoAttachSubscriptions < HammerCLIKatello::SingleResourceCommand
60
+ resource :host_subscriptions, :auto_attach
61
+ command_name "auto-attach"
62
+ success_message _("Auto attached subscriptions to the host successfully")
63
+ failure_message _("Failed to auto attach subscriptions to the host")
64
+
65
+ build_options
66
+ end
67
+
68
+ class RemoveSubscriptions < HammerCLIKatello::SingleResourceCommand
69
+ resource :host_subscriptions, :remove_subscriptions
70
+ command_name "remove"
71
+ success_message _("Subscription removed from the host successfully")
72
+ failure_message _("Failed to remove subscriptions from the host")
73
+
74
+ option "--subscription-id", "SUBSCRIPTION_ID", _("ID of subscription"),
75
+ :attribute_name => :option_subscription_id, :required => true
76
+
77
+ option "--quantity", "Quantity",
78
+ _("Remove the first instance of a subscription with matching id and quantity"),
79
+ :attribute_name => :option_quantity, :required => false
80
+
81
+ def request_params
82
+ params = super
83
+ subs = { :id => option_subscription_id }
84
+ subs[:quantity] = option_quantity if option_quantity
85
+ params[:subscriptions] = [subs]
86
+ params
87
+ end
88
+
89
+ build_options do |o|
90
+ o.expand.except(:subscriptions)
91
+ o.without(:subscriptions)
92
+ end
93
+ end
94
+
29
95
  autoload_subcommands
30
96
  end
31
97
  end
@@ -0,0 +1,2 @@
1
+ require 'hammer_cli_foreman/hostgroup'
2
+ require 'hammer_cli_katello/hostgroup_extensions'
@@ -0,0 +1,48 @@
1
+ require 'hammer_cli_foreman/hostgroup'
2
+
3
+ module HammerCLIKatello
4
+ module PuppetEnvironmentNameResolvable
5
+ def all_options
6
+ options = super
7
+ if options['option_environment_name']
8
+ options['option_environment_id'] ||= resolver.puppet_environment_id(
9
+ resolver.scoped_options('environment', options))
10
+ end
11
+ options
12
+ end
13
+ end
14
+
15
+ module QueryOrganizationOptions
16
+ def self.included(base)
17
+ base.option '--query-organization-id', 'ORGANIZATION_ID',
18
+ _('Organization ID to search by'), attribute_name: :option_organization_id
19
+ base.option '--query-organization', 'ORGANIZATION_NAME',
20
+ _('Organization name to search by'), attribute_name: :option_organization_name
21
+ base.option '--query-organization-label', 'ORGANIZATION_LABEL',
22
+ _('Organization label to search by'), attribute_name: :option_organization_label
23
+ end
24
+ end
25
+
26
+ module HostgroupExtensions
27
+ ::HammerCLIForeman::Hostgroup::CreateCommand.instance_eval do
28
+ include HammerCLIKatello::ResolverCommons
29
+ include HammerCLIKatello::PuppetEnvironmentNameResolvable
30
+ include HammerCLIKatello::ContentViewNameResolvable
31
+ include HammerCLIKatello::QueryOrganizationOptions
32
+ end
33
+
34
+ ::HammerCLIForeman::Hostgroup::UpdateCommand.instance_eval do
35
+ include HammerCLIKatello::ResolverCommons
36
+ include HammerCLIKatello::PuppetEnvironmentNameResolvable
37
+ include HammerCLIKatello::ContentViewNameResolvable
38
+ include HammerCLIKatello::QueryOrganizationOptions
39
+ end
40
+
41
+ ::HammerCLIForeman::Hostgroup::InfoCommand.instance_eval do
42
+ output do
43
+ field :content_view_name, _('Content View')
44
+ field :lifecycle_environment_name, _('Lifecycle Environment')
45
+ end
46
+ end
47
+ end
48
+ end
@@ -2,9 +2,7 @@ require 'hammer_cli/i18n'
2
2
 
3
3
  module HammerCLIKatello
4
4
  module I18n
5
-
6
5
  class LocaleDomain < HammerCLI::I18n::LocaleDomain
7
-
8
6
  def translated_files
9
7
  Dir.glob(File.join(File.dirname(__FILE__), '../**/*.rb'))
10
8
  end
@@ -17,7 +15,6 @@ module HammerCLIKatello
17
15
  'hammer-cli-katello'
18
16
  end
19
17
  end
20
-
21
18
  end
22
19
  end
23
20
 
@@ -1,13 +1,10 @@
1
1
  require 'hammer_cli_katello/search_options_creators'
2
2
 
3
3
  module HammerCLIKatello
4
-
5
4
  class Searchables < HammerCLIForeman::Searchables
6
-
7
5
  SEARCHABLES = {
8
6
  :activation_key => [s_name(_("Activation key name to search by"))],
9
7
  :capsule => [s_name(_("Capsule name to search by"))],
10
- :content_host => [s_name(_("Content host name to search by"))],
11
8
  :content_view => [s_name(_("Content view name to search by"))],
12
9
  :gpg => [s_name(_("Gpg key name to search by"))],
13
10
  :host_collection => [s_name(_("Host collection name to search by"))],
@@ -17,6 +14,7 @@ module HammerCLIKatello
17
14
  :editable => false)
18
15
  ],
19
16
  :product => [s_name(_("Product name to search by"))],
17
+ :operatingsystem => [s("title", _("Operating system title"), :editable => false)],
20
18
  :repository => [s_name(_("Repository name to search by"))],
21
19
  :repository_set => [s_name(_("Repository set name to search by"))],
22
20
  :subscription => [s_name(_("Subscription name to search by"))],
@@ -28,18 +26,19 @@ module HammerCLIKatello
28
26
  s("author", _("Puppet module's author to search by")),
29
27
  s("uuid", _("Puppet module's UUID to search by"))
30
28
  ],
31
- :content_view_version => [s("version", _("Content view version number"))]
32
- }
29
+ :content_view_version => [
30
+ s("version", _("Content view version number")),
31
+ s("content_view_id", _("Content view to search by"))
32
+ ]
33
+ }.freeze
33
34
 
34
- DEFAULT_SEARCHABLES = [s_name(_("Name to search by"))]
35
+ DEFAULT_SEARCHABLES = [s_name(_("Name to search by"))].freeze
35
36
 
36
37
  def for(resource)
37
38
  SEARCHABLES[resource.singular_name.to_sym] || DEFAULT_SEARCHABLES
38
39
  end
39
-
40
40
  end
41
41
 
42
- # rubocop:disable ClassLength
43
42
  class IdResolver < HammerCLIForeman::IdResolver
44
43
  include HammerCLIKatello::SearchOptionsCreators
45
44
 
@@ -51,8 +50,8 @@ module HammerCLIKatello
51
50
  smart_proxy_id(options)
52
51
  end
53
52
 
54
- def system_id(options)
55
- options[HammerCLI.option_accessor_name("id")] || find_resource(:systems, options)['uuid']
53
+ def puppet_environment_id(options)
54
+ get_id(:environments, options)
56
55
  end
57
56
 
58
57
  def environment_id(options)
@@ -66,7 +65,7 @@ module HammerCLIKatello
66
65
 
67
66
  key_names = HammerCLI.option_accessor_name 'lifecycle_environment_names'
68
67
  key_organization_id = HammerCLI.option_accessor_name 'organization_id'
69
- options[key_organization_id] ||= organization_id(scoped_options 'organization', options)
68
+ options[key_organization_id] ||= organization_id(scoped_options('organization', options))
70
69
 
71
70
  find_resources(:lifecycle_environments, options)
72
71
  .select { |repo| options[key_names].include? repo['name'] }.map { |repo| repo['id'] }
@@ -75,10 +74,14 @@ module HammerCLIKatello
75
74
  def repository_id(options)
76
75
  key_id = HammerCLI.option_accessor_name("id")
77
76
  key_product_id = HammerCLI.option_accessor_name("product_id")
77
+ key_product_name = HammerCLI.option_accessor_name("product_name")
78
78
 
79
79
  return options[key_id] if options[key_id]
80
80
 
81
- options[key_product_id] ||= product_id(scoped_options("product", options))
81
+ unless options[key_product_name].nil?
82
+ options[key_product_id] ||= product_id(scoped_options("product", options))
83
+ end
84
+
82
85
  find_resource(:repositories, options)['id']
83
86
  end
84
87
 
@@ -87,11 +90,17 @@ module HammerCLIKatello
87
90
 
88
91
  key_names = HammerCLI.option_accessor_name 'names'
89
92
  key_product_id = HammerCLI.option_accessor_name 'product_id'
93
+
94
+ options[key_names] ||= []
95
+
90
96
  unless options['option_product_name'].nil?
91
- options[key_product_id] ||= product_id(scoped_options 'product', options)
97
+ options[key_product_id] ||= product_id(scoped_options('product', options))
98
+ end
99
+
100
+ if options[key_names].any?
101
+ find_resources(:repositories, options)
102
+ .select { |repo| options[key_names].include? repo['name'] }.map { |repo| repo['id'] }
92
103
  end
93
- find_resources(:repositories, options)
94
- .select { |repo| options[key_names].include? repo['name'] }.map { |repo| repo['id'] }
95
104
  end
96
105
 
97
106
  def content_view_version_id(options)
@@ -113,7 +122,7 @@ module HammerCLIKatello
113
122
  options[from_environment_id] ||= from_lifecycle_environment_id(options)
114
123
 
115
124
  if results.size > 1 && options[from_environment_id]
116
- results_in_from_environment = results.select do |version|
125
+ results_in_from_environment = results.select do |version|
117
126
  member_of_environment_ids = version['environments'].map { |env| env['id'].to_s }
118
127
  member_of_environment_ids.include? options[from_environment_id].to_s
119
128
  end
@@ -23,9 +23,10 @@ module HammerCLIKatello
23
23
 
24
24
  def all_options
25
25
  result = super.clone
26
- if result['option_environment_name']
27
- result['option_environment_id'] = resolver.lifecycle_environment_id(
28
- lifecycle_environment_resolve_options(result))
26
+ if result['option_environment_name'] && result['option_environment_id'].nil?
27
+ result['option_environment_id'] = resolver.lifecycle_environment_id(
28
+ lifecycle_environment_resolve_options(result))
29
+ @all_options = result
29
30
  end
30
31
  result
31
32
  end
@@ -1,10 +1,8 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class LifecycleEnvironmentCommand < HammerCLIKatello::Command
4
3
  resource :lifecycle_environments
5
4
 
6
5
  module PriorIdResolvable
7
-
8
6
  def self.included(base)
9
7
  base.option(
10
8
  "--prior",
@@ -100,5 +98,4 @@ module HammerCLIKatello
100
98
 
101
99
  autoload_subcommands
102
100
  end
103
-
104
101
  end
@@ -11,9 +11,10 @@ module HammerCLIKatello
11
11
 
12
12
  def all_options
13
13
  result = super.clone
14
- if result['option_environment_name']
15
- result['option_environment_id'] = resolver.lifecycle_environment_id(
16
- lifecycle_environment_resolve_options(result))
14
+ if result['option_environment_name'] && result['option_environment_id'].nil?
15
+ result['option_environment_id'] = resolver.lifecycle_environment_id(
16
+ lifecycle_environment_resolve_options(result))
17
+ @all_options = result
17
18
  end
18
19
  result
19
20
  end
@@ -1,9 +1,7 @@
1
1
  require 'hammer_cli_foreman/organization'
2
2
 
3
3
  module HammerCLIKatello
4
-
5
4
  class Organization < HammerCLIForeman::Organization
6
-
7
5
  class ListCommand < HammerCLIForeman::Organization::ListCommand
8
6
  include HammerCLIKatello::ResolverCommons
9
7
  resource :organizations, :index
@@ -61,5 +59,4 @@ module HammerCLIKatello
61
59
 
62
60
  autoload_subcommands
63
61
  end
64
-
65
62
  end
@@ -0,0 +1,12 @@
1
+ module HammerCLIKatello
2
+ module OrganizationOptions
3
+ def self.included(base)
4
+ base.option '--organization-id', 'ORGANIZATION_ID',
5
+ _('Organization ID to search by'), attribute_name: :option_organization_id
6
+ base.option '--organization', 'ORGANIZATION_NAME',
7
+ _('Organization name to search by'), attribute_name: :option_organization_name
8
+ base.option '--organization-label', 'ORGANIZATION_LABEL',
9
+ _('Organization label to search by'), attribute_name: :option_organization_label
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,4 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class OstreeBranchCommand < HammerCLIKatello::Command
4
3
  resource :ostree_branches
5
4
 
@@ -3,13 +3,11 @@ require 'hammer_cli'
3
3
  module HammerCLIKatello
4
4
  module Output
5
5
  module Fields
6
-
7
6
  class ChecksumFilePair < ::Fields::Field
8
7
  end
9
8
 
10
9
  class Dependency < ::Fields::Field
11
10
  end
12
-
13
11
  end
14
12
  end
15
13
  end
@@ -1,9 +1,7 @@
1
1
  module HammerCLIKatello
2
2
  module Output
3
3
  module Formatters
4
-
5
4
  class ChecksumFormatter < HammerCLI::Output::Formatters::FieldFormatter
6
-
7
5
  def tags
8
6
  [:screen]
9
7
  end
@@ -14,7 +12,6 @@ module HammerCLIKatello
14
12
  end
15
13
 
16
14
  class DependencyFormatter < HammerCLI::Output::Formatters::FieldFormatter
17
-
18
15
  def format(dependency, _ = {})
19
16
  name = dependency[:name] || dependency['name']
20
17
  version = dependency[:version_requirement] || dependency['version_requirement']
@@ -28,7 +25,6 @@ module HammerCLIKatello
28
25
 
29
26
  HammerCLI::Output::Output.register_formatter(ChecksumFormatter.new, :ChecksumFilePair)
30
27
  HammerCLI::Output::Output.register_formatter(DependencyFormatter.new, :Dependency)
31
-
32
28
  end
33
29
  end
34
30
  end
@@ -1,5 +1,4 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class PackageCommand < HammerCLIKatello::Command
4
3
  resource :packages
5
4
 
@@ -1,5 +1,4 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class PackageGroupCommand < HammerCLIKatello::Command
4
3
  resource :package_groups
5
4
 
@@ -1,12 +1,9 @@
1
1
  module HammerCLIKatello
2
-
3
2
  class PingCommand < HammerCLIKatello::Command
4
-
5
3
  resource :ping, :index
6
4
 
7
5
  output do
8
6
  from "services" do
9
-
10
7
  label "candlepin" do
11
8
  from "candlepin" do
12
9
  field "status", _("Status")
@@ -41,7 +38,6 @@ module HammerCLIKatello
41
38
  field "_response", _("Server Response")
42
39
  end
43
40
  end
44
-
45
41
  end # from "services"
46
42
  end # output do
47
43
 
@@ -72,7 +68,5 @@ module HammerCLIKatello
72
68
  def request_options
73
69
  { with_authentication: false }
74
70
  end
75
-
76
71
  end # class PingCommand
77
-
78
72
  end # module HammerCLIKatello