hammer_cli_katello 0.0.3 → 0.0.4

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 (34) hide show
  1. checksums.yaml +8 -8
  2. data/lib/hammer_cli_katello.rb +26 -6
  3. data/lib/hammer_cli_katello/activation_key.rb +176 -0
  4. data/lib/hammer_cli_katello/associating_commands.rb +67 -0
  5. data/lib/hammer_cli_katello/capsule.rb +100 -0
  6. data/lib/hammer_cli_katello/commands.rb +55 -0
  7. data/lib/hammer_cli_katello/content_host.rb +90 -0
  8. data/lib/hammer_cli_katello/content_view.rb +193 -0
  9. data/lib/hammer_cli_katello/content_view_puppet_module.rb +74 -0
  10. data/lib/hammer_cli_katello/content_view_version.rb +81 -0
  11. data/lib/hammer_cli_katello/exception_handler.rb +40 -0
  12. data/lib/hammer_cli_katello/filter.rb +83 -0
  13. data/lib/hammer_cli_katello/filter_rule.rb +73 -0
  14. data/lib/hammer_cli_katello/gpg_key.rb +34 -56
  15. data/lib/hammer_cli_katello/host_collection.rb +91 -0
  16. data/lib/hammer_cli_katello/i18n.rb +24 -0
  17. data/lib/hammer_cli_katello/id_resolver.rb +39 -0
  18. data/lib/hammer_cli_katello/lifecycle_environment.rb +63 -45
  19. data/lib/hammer_cli_katello/organization.rb +27 -23
  20. data/lib/hammer_cli_katello/ping.rb +20 -23
  21. data/lib/hammer_cli_katello/product.rb +69 -62
  22. data/lib/hammer_cli_katello/puppet_module.rb +47 -0
  23. data/lib/hammer_cli_katello/repository.rb +147 -0
  24. data/lib/hammer_cli_katello/repository_set.rb +88 -0
  25. data/lib/hammer_cli_katello/subscription.rb +59 -12
  26. data/lib/hammer_cli_katello/sync_plan.rb +74 -0
  27. data/lib/hammer_cli_katello/version.rb +1 -1
  28. data/locale/hammer-cli-katello.pot +1215 -0
  29. data/locale/zanata.xml +29 -0
  30. metadata +28 -13
  31. data/lib/hammer_cli_katello/provider.rb +0 -68
  32. data/lib/hammer_cli_katello/resource.rb +0 -0
  33. data/lib/hammer_cli_katello/system.rb +0 -94
  34. data/lib/hammer_cli_katello/system_group.rb +0 -48
@@ -0,0 +1,47 @@
1
+ module HammerCLIKatello
2
+
3
+ class PuppetModule < HammerCLIKatello::Command
4
+ resource :puppet_modules
5
+
6
+ class ListCommand < HammerCLIKatello::ListCommand
7
+ output do
8
+ field :id, _("ID")
9
+ field :name, _("Name")
10
+ field :version, _("Version")
11
+ field :author, _("Author")
12
+ end
13
+
14
+ build_options
15
+ end
16
+
17
+ class InfoCommand < HammerCLIKatello::InfoCommand
18
+ output do
19
+ field :id, _("ID")
20
+ field :name, _("Name")
21
+ field :version, _("Version")
22
+ field :author, _("Author")
23
+
24
+ field :summary, _("Summary")
25
+ field :description, _("Description")
26
+ field :license, _("License")
27
+ field :project_page, _("Project Page")
28
+ field :source, _("Source")
29
+ field :dependencies, _("Dependencies"), Fields::List
30
+ field :checksums, _("Checksums"), Fields::List
31
+ field :tag_list, _("Tag List"), Fields::List
32
+ end
33
+
34
+ def request_params
35
+ super.merge(method_options)
36
+ end
37
+
38
+ build_options
39
+ end
40
+
41
+ autoload_subcommands
42
+ end
43
+ end
44
+
45
+ HammerCLI::MainCommand.subcommand "puppet-module",
46
+ "View Puppet Module details.",
47
+ HammerCLIKatello::PuppetModule
@@ -0,0 +1,147 @@
1
+ module HammerCLIKatello
2
+
3
+ class Repository < HammerCLIKatello::Command
4
+ resource :repositories
5
+
6
+ class ListCommand < HammerCLIKatello::ListCommand
7
+ output do
8
+ field :id, _("Id")
9
+ field :name, _("Name")
10
+ field :content_type, _("Content Type")
11
+ end
12
+
13
+ build_options
14
+ end
15
+
16
+ class InfoCommand < HammerCLIKatello::InfoCommand
17
+ output do
18
+ field :id, _("ID")
19
+ field :name, _("Name")
20
+ field :label, _("Label")
21
+ from :organization do
22
+ field :name, _("Organization")
23
+ end
24
+ field :_redhat_repo, _("Red Hat Repository")
25
+ field :content_type, _("Content Type")
26
+ field :url, _("URL")
27
+ field :_publish_via_http, _("Publish Via HTTP")
28
+ field :full_path, _("Published At")
29
+
30
+ label _("Product") do
31
+ from :product do
32
+ field :id, _("ID")
33
+ field :name, _("Name")
34
+ end
35
+ end
36
+
37
+ label _("GPG Key") do
38
+ from :gpg_key do
39
+ field :id, _("ID"), Fields::Field, :hide_blank => true
40
+ field :name, _("Name"), Fields::Field, :hide_blank => true
41
+ end
42
+ end
43
+
44
+ label _("Sync") do
45
+ field :_sync_state, _("Status")
46
+ field :last_sync, _("Last Sync Date"), Fields::Date, :hide_blank => true
47
+ end
48
+
49
+ field :created_at, _("Created"), Fields::Date
50
+ field :updated_at, _("Updated"), Fields::Date
51
+
52
+ label _("Content Counts") do
53
+ field :package_total, _("Packages"), Fields::Field, :hide_blank => true
54
+ field :package_group_total, _("Package Groups"), Fields::Field, :hide_blank => true
55
+ field :errata_total, _("Errata"), Fields::Field, :hide_blank => true
56
+ field :puppet_total, _("Puppet Modules"), Fields::Field, :hide_blank => true
57
+ end
58
+ end
59
+
60
+ def send_request
61
+ super.tap do |data|
62
+ data["_redhat_repo"] = data["product_type"] == "redhat" ? _("yes") : _("no")
63
+ data["_publish_via_http"] = data["unprotected"] ? _("yes") : _("no")
64
+ data["_sync_state"] = get_sync_status(data["sync_state"])
65
+ setup_content_counts(data)
66
+ end
67
+ end
68
+
69
+ def setup_content_counts(data)
70
+ if data["content_type"] == "yum"
71
+ if data["content_counts"]
72
+ data["package_total"] = data["content_counts"]["rpm"]
73
+ data["package_group_total"] = data["content_counts"]["package_group"]
74
+ data["errata_total"] = data["content_counts"]["erratum"]
75
+ end
76
+ data["gpg_key_name"] = data["gpg_key"]["name"] if data["gpg_key"]
77
+ else
78
+ data["puppet_total"] = data["content_counts"]["puppet_module"] if data["content_counts"]
79
+ end
80
+ end
81
+
82
+ # rubocop:disable MethodLength
83
+ def get_sync_status(state)
84
+ sync_states = {
85
+ "failed" => _("Failed"),
86
+ "success" => _("Success"),
87
+ "finished" => _("Finished"),
88
+ "error" => _("Error"),
89
+ "running" => _("Running"),
90
+ "waiting" => _("Waiting"),
91
+ "canceled" => _("Canceled"),
92
+ "not_synced" => _("Not Synced")
93
+ }
94
+ sync_states[state]
95
+ end
96
+
97
+ def request_params
98
+ super.merge(method_options)
99
+ end
100
+
101
+ build_options
102
+ end
103
+
104
+ class SyncCommand < HammerCLIForemanTasks::AsyncCommand
105
+ action :sync
106
+ command_name "synchronize"
107
+
108
+ success_message _("Repository is being synchronized in task %{id}")
109
+ failure_message _("Could not synchronize the repository")
110
+
111
+ build_options
112
+ end
113
+
114
+ class CreateCommand < HammerCLIKatello::CreateCommand
115
+ success_message _("Repository created")
116
+ failure_message _("Could not create the repository")
117
+
118
+ option "--publish-via-http", "ENABLE", _("Publish Via HTTP"),
119
+ :attribute_name => :option_unprotected,
120
+ :format => HammerCLI::Options::Normalizers::Bool.new
121
+
122
+ build_options :without => [:unprotected]
123
+ end
124
+
125
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
126
+ success_message _("Repository updated")
127
+ failure_message _("Could not update the repository")
128
+
129
+ build_options :without => [:unprotected]
130
+ option "--publish-via-http", "ENABLE", _("Publish Via HTTP"),
131
+ :attribute_name => :option_unprotected,
132
+ :format => HammerCLI::Options::Normalizers::Bool.new
133
+ end
134
+
135
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
136
+ success_message _("Repository deleted")
137
+ failure_message _("Could not delete the Repository")
138
+
139
+ build_options
140
+ end
141
+
142
+ autoload_subcommands
143
+ end
144
+ end
145
+
146
+ HammerCLI::MainCommand.subcommand "repository", _("Manipulate repositories"),
147
+ HammerCLIKatello::Repository
@@ -0,0 +1,88 @@
1
+ module HammerCLIKatello
2
+
3
+ class RepositorySetCommand < HammerCLI::AbstractCommand
4
+
5
+ class ListCommand < HammerCLIKatello::ListCommand
6
+ resource :repository_sets, :index
7
+
8
+ output do
9
+ field :id, _("ID")
10
+ field :type, _("Type")
11
+ field :name, _("Name"), nil, :max_width => 300
12
+ end
13
+
14
+ build_options
15
+ end
16
+
17
+ class InfoCommand < HammerCLIKatello::InfoCommand
18
+ resource :repository_sets, :show
19
+
20
+ output do
21
+ field :id, _("ID")
22
+ field :name, _("Name")
23
+ field :type, _("Type")
24
+ field :contentUrl, _("URL")
25
+ field :gpgUrl, _("GPG Key")
26
+ field :label, _("Label")
27
+
28
+ collection :repositories, _("Enabled Repositories") do
29
+ field :id, _("ID")
30
+ field :name, _("Name")
31
+ end
32
+ end
33
+
34
+ build_options
35
+ end
36
+
37
+ class AvailableRepositoriesCommand < HammerCLIKatello::ListCommand
38
+ resource :repository_sets, :available_repositories
39
+ command_name "available-repositories"
40
+
41
+ output do
42
+ field :repo_name, _("Name")
43
+ from :substitutions do
44
+ field :basearch, _("Arch")
45
+ field :releasever, _("Release")
46
+ end
47
+ field :enabled, _("Enabled"), Fields::Boolean
48
+ end
49
+
50
+ # We need to define +custom_option_builders+ and +request_params+ to
51
+ # be able to resolve the --name to --id for repository set
52
+ def self.custom_option_builders
53
+ super + [HammerCLIForeman::SearchablesOptionBuilder.new(resource, searchables)]
54
+ end
55
+
56
+ def request_params
57
+ super.update('id' => get_identifier)
58
+ end
59
+
60
+ build_options
61
+ end
62
+
63
+ class EnableCommand < HammerCLIKatello::UpdateCommand
64
+ resource :repository_sets, :enable
65
+ command_name "enable"
66
+
67
+ success_message _("Repository enabled")
68
+ failure_message _("Could not enable repository")
69
+
70
+ build_options
71
+ end
72
+
73
+ class DisableCommand < HammerCLIKatello::UpdateCommand
74
+ resource :repository_sets, :disable
75
+ command_name "disable"
76
+
77
+ success_message _("Repository disabled")
78
+ failure_message _("Could not disable repository")
79
+
80
+ build_options
81
+ end
82
+
83
+ autoload_subcommands
84
+ end
85
+
86
+ HammerCLI::MainCommand.subcommand("repository-set", _("manipulate repository sets on the server"),
87
+ HammerCLIKatello::RepositorySetCommand)
88
+ end
@@ -1,23 +1,37 @@
1
1
  require 'hammer_cli'
2
- require 'katello_api'
3
2
  require 'hammer_cli_foreman'
4
3
  require 'hammer_cli_foreman/commands'
5
4
 
6
5
  module HammerCLIKatello
7
6
 
8
7
  class SubscriptionCommand < HammerCLI::AbstractCommand
9
- class ListCommand < HammerCLIForeman::ListCommand
10
- resource KatelloApi::Resources::Subscription, 'index'
8
+ class ListCommand < HammerCLIKatello::ListCommand
9
+ resource :subscriptions, :index
11
10
 
12
11
  output do
13
- field :id, "ID"
12
+ field :product_name, _("Name")
13
+ field :contract_number, _("Contract")
14
+ field :account_number, _("Account")
15
+ field :support_level, _("Support")
16
+ field :quantity, _("Quantity")
17
+ field :consumed, _("Consumed")
18
+ field :end_date, _("End Date")
19
+ field :id, _("ID")
20
+ field :product_name, _("Product")
21
+ field :format_quantity, _("Quantity")
22
+ field :consumed, _("Attached")
14
23
  end
15
24
 
16
- apipie_options
25
+ def extend_data(data)
26
+ data["format_quantity"] = data["quantity"] == -1 ? _("Unlimited") : data["quantity"]
27
+ data
28
+ end
29
+
30
+ build_options
17
31
  end
18
32
 
19
- class UploadCommand < HammerCLIForeman::WriteCommand
20
- resource KatelloApi::Resources::Subscription, 'upload'
33
+ class UploadCommand < HammerCLIForemanTasks::AsyncCommand
34
+ resource :subscriptions, :upload
21
35
  command_name "upload"
22
36
 
23
37
  class BinaryFile < HammerCLI::Options::Normalizers::File
@@ -30,18 +44,51 @@ module HammerCLIKatello
30
44
  {:content_type => 'multipart/form-data', :multipart => true}
31
45
  end
32
46
 
33
- success_message "Manifest is being uploaded"
34
- failure_message "Manifest upload failed"
47
+ success_message _("Manifest is being uploaded in task %{id}")
48
+ failure_message _("Manifest upload failed")
35
49
 
36
- apipie_options
37
- option "--file", "MANIFEST", "Subscription manifest file",
50
+ build_options :without => [:content]
51
+ option "--file", "MANIFEST", _("Subscription manifest file"),
38
52
  :attribute_name => :option_content,
39
53
  :required => true, :format => BinaryFile.new
40
54
  end
41
55
 
56
+ class DeleteManfiestCommand < HammerCLIForemanTasks::AsyncCommand
57
+ resource :subscriptions, :delete_manifest
58
+ command_name "delete-manifest"
59
+
60
+ success_message _("Manifest is being deleted in task %{id}")
61
+ failure_message _("Manifest deletion failed")
62
+
63
+ build_options
64
+ end
65
+
66
+ class RefreshManfiestCommand < HammerCLIForemanTasks::AsyncCommand
67
+ resource :subscriptions, :refresh_manifest
68
+ command_name "refresh-manifest"
69
+
70
+ success_message _("Manifest is being refreshed in task %{id}")
71
+ failure_message _("Manifest refresh failed")
72
+
73
+ build_options
74
+ end
75
+
76
+ class ManifestHistoryCommand < HammerCLIKatello::ListCommand
77
+ command_name "manifest-history"
78
+ resource :subscriptions, :manifest_history
79
+
80
+ output do
81
+ field :status, _("Status")
82
+ field :statusMessage, _("Status Message")
83
+ field :created, _("Time"), Fields::Date
84
+ end
85
+
86
+ build_options
87
+ end
88
+
42
89
  autoload_subcommands
43
90
  end
44
91
  end
45
92
 
46
- HammerCLI::MainCommand.subcommand("subscription", "Manipulate subscriptions.",
93
+ HammerCLI::MainCommand.subcommand("subscription", _("Manipulate subscriptions."),
47
94
  HammerCLIKatello::SubscriptionCommand)
@@ -0,0 +1,74 @@
1
+ module HammerCLIKatello
2
+ class SyncPlan < HammerCLIKatello::Command
3
+ resource :sync_plans
4
+
5
+ class ListCommand < HammerCLIKatello::ListCommand
6
+
7
+ output do
8
+ field :id, _("ID")
9
+ field :name, _("Name")
10
+ field :sync_date, _("Start Date"), Fields::Date
11
+ field :interval, _("Interval")
12
+ end
13
+
14
+ build_options
15
+ end
16
+
17
+ class InfoCommand < HammerCLIKatello::InfoCommand
18
+
19
+ output ListCommand.output_definition do
20
+ field :description, _("Description")
21
+ field :created_at, _("Created at"), Fields::Date
22
+ field :updated_at, _("Updated at"), Fields::Date
23
+ end
24
+
25
+ build_options
26
+ end
27
+
28
+ class CreateCommand < HammerCLIKatello::CreateCommand
29
+
30
+ option "--interval", "INTERVAL", _("how often synchronization should run"),
31
+ :default => 'none',
32
+ :format => HammerCLI::Options::Normalizers::Enum.new(
33
+ %w(none hourly daily weekly)
34
+ )
35
+
36
+ option "--sync-date", "SYNC_DATE",
37
+ _("start date and time of the synchronization defaults to now"),
38
+ :format => HammerCLI::Options::Normalizers::DateTime.new,
39
+ :default => DateTime.now.strftime("%F %T")
40
+
41
+ success_message _("Sync plan created")
42
+ failure_message _("Could not create the sync plan")
43
+
44
+ build_options :without => [:interval, :sync_date]
45
+ end
46
+
47
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
48
+
49
+ option "--interval", "INTERVAL", _("how often synchronization should run"),
50
+ :format => HammerCLI::Options::Normalizers::Enum.new(
51
+ %w(none hourly daily weekly)
52
+ )
53
+ option "--sync-date", "SYNC_DATE", _("start date and time of the synchronization"),
54
+ :format => HammerCLI::Options::Normalizers::DateTime.new
55
+
56
+ success_message _("Sync plan updated")
57
+ failure_message _("Could not update the sync plan")
58
+
59
+ build_options :without => [:interval, :sync_date]
60
+ end
61
+
62
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
63
+ success_message _("Sync plan destroyed")
64
+ failure_message _("Could not destroy the sync plan")
65
+
66
+ build_options
67
+ end
68
+
69
+ autoload_subcommands
70
+ end
71
+ end
72
+
73
+ HammerCLI::MainCommand.subcommand 'sync-plan', _("Manipulate sync plans"),
74
+ HammerCLIKatello::SyncPlan