hammer_cli_katello 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
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,83 @@
1
+ require 'hammer_cli_katello/filter_rule'
2
+
3
+ module HammerCLIKatello
4
+
5
+ class Filter < HammerCLIKatello::Command
6
+
7
+ resource :content_view_filters
8
+ command_name 'filter'
9
+ desc 'View and manage filters'
10
+
11
+ class ListCommand < HammerCLIKatello::ListCommand
12
+ output do
13
+ field :id, _("Filter ID")
14
+ field :name, _("Name")
15
+ field :type, _("Type")
16
+ field :inclusion, _("Inclusion")
17
+ end
18
+
19
+ build_options
20
+ end
21
+
22
+ class InfoCommand < HammerCLIKatello::InfoCommand
23
+ output do
24
+ field :id, _("Filter ID")
25
+ field :name, _("Name")
26
+ field :type, _("Type")
27
+ field :inclusion, _("Inclusion")
28
+
29
+ collection :repositories, _("Repositories") do
30
+ field :id, _("ID")
31
+ field :name, _("Name")
32
+ field :label, _("Label")
33
+ end
34
+
35
+ collection :rules, _("Rules") do
36
+ field :id, _("ID")
37
+ field :name, _("Name"), Fields::Field, :hide_blank => true
38
+ field :version, _("Version"), Fields::Field, :hide_blank => true
39
+ field :min_version, _("Minimum Version"), Fields::Field, :hide_blank => true
40
+ field :max_version, _("Maximum Version"), Fields::Field, :hide_blank => true
41
+ field :errata_id, _("Errata ID"), Fields::Field, :hide_blank => true
42
+ field :start_date, _("Start Date"), Fields::Field, :hide_blank => true
43
+ field :end_date, _("End Date"), Fields::Field, :hide_blank => true
44
+ field :types, _("Types"), Fields::List, :hide_blank => true
45
+ field :created_at, _("Created"), Fields::Date
46
+ field :updated_at, _("Updated"), Fields::Date
47
+ end
48
+ end
49
+
50
+ build_options :without => [:content_view_id]
51
+ end
52
+
53
+ class CreateCommand < HammerCLIKatello::CreateCommand
54
+ success_message _("Filter created")
55
+ failure_message _("Could not create the filter")
56
+
57
+ build_options
58
+ end
59
+
60
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
61
+ success_message _("Filter updated")
62
+ failure_message _("Could not update the filter")
63
+
64
+ build_options :without => [:content_view_id]
65
+ end
66
+
67
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
68
+ success_message _("Filter deleted")
69
+ failure_message _("Could not delete the filter")
70
+
71
+ build_options :without => [:content_view_id]
72
+ end
73
+
74
+ HammerCLIKatello::AssociatingCommands::Repository.extend_command(self)
75
+
76
+ autoload_subcommands
77
+
78
+ subcommand HammerCLIKatello::FilterRule.command_name,
79
+ HammerCLIKatello::FilterRule.desc,
80
+ HammerCLIKatello::FilterRule
81
+
82
+ end
83
+ end
@@ -0,0 +1,73 @@
1
+ module HammerCLIKatello
2
+
3
+ class FilterRule < HammerCLIKatello::Command
4
+
5
+ resource :content_view_filter_rules
6
+ command_name 'rule'
7
+ desc 'View and manage filter rules'
8
+
9
+ class ListCommand < HammerCLIKatello::ListCommand
10
+ output do
11
+ field :id, _("Rule ID")
12
+ field :content_view_filter_id, _("Filter ID")
13
+
14
+ field :name, _("Name")
15
+ field :version, _("Version")
16
+ field :min_version, _("Minimum Version")
17
+ field :max_version, _("Maximum Version")
18
+ field :errata_id, _("Errata ID")
19
+ field :start_date, _("Start Date")
20
+ field :end_date, _("End Date")
21
+ end
22
+
23
+ build_options
24
+ end
25
+
26
+ class InfoCommand < HammerCLIKatello::InfoCommand
27
+ output do
28
+ field :id, _("Rule ID")
29
+ field :content_view_filter_id, _("Filter ID")
30
+
31
+ field :name, _("Name"), Fields::Field, :hide_blank => true
32
+ field :version, _("Version"), Fields::Field, :hide_blank => true
33
+ field :min_version, _("Minimum Version"), Fields::Field, :hide_blank => true
34
+ field :max_version, _("Maximum Version"), Fields::Field, :hide_blank => true
35
+ field :errata_id, _("Errata ID"), Fields::Field, :hide_blank => true
36
+ field :start_date, _("Start Date"), Fields::Field, :hide_blank => true
37
+ field :end_date, _("End Date"), Fields::Field, :hide_blank => true
38
+ field :types, _("Types"), Fields::List, :hide_blank => true
39
+ field :created_at, _("Created"), Fields::Date
40
+ field :updated_at, _("Updated"), Fields::Date
41
+ end
42
+
43
+ build_options
44
+ end
45
+
46
+ class CreateCommand < HammerCLIKatello::CreateCommand
47
+ success_message _("Filter rule created")
48
+ failure_message _("Could not create the filter rule")
49
+
50
+ build_options
51
+ end
52
+
53
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
54
+ success_message _("Filter rule updated")
55
+ failure_message _("Could not update the filter rule")
56
+
57
+ build_options
58
+ end
59
+
60
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
61
+ success_message _("Filter rule deleted")
62
+ failure_message _("Could not delete the filter rule")
63
+
64
+ def request_params
65
+ super.merge(method_options)
66
+ end
67
+
68
+ build_options
69
+ end
70
+
71
+ autoload_subcommands
72
+ end
73
+ end
@@ -1,97 +1,75 @@
1
1
  module HammerCLIKatello
2
2
 
3
- class GpgKeyCommand < HammerCLI::AbstractCommand
3
+ class GpgKeyCommand < HammerCLIForeman::Command
4
4
 
5
- class ListCommand < HammerCLIForeman::ListCommand
6
- resource KatelloApi::Resources::GpgKey, :index
5
+ resource :gpg_keys
6
+
7
+ class ListCommand < HammerCLIKatello::ListCommand
7
8
 
8
9
  output do
9
- field :id, "ID"
10
- field :name, "Name"
10
+ field :id, _("ID")
11
+ field :name, _("Name")
11
12
  end
12
13
 
13
- apipie_options
14
+ build_options
14
15
  end
15
16
 
16
- class InfoCommand < HammerCLIForeman::InfoCommand
17
- resource KatelloApi::Resources::GpgKey, :show
17
+ class InfoCommand < HammerCLIKatello::InfoCommand
18
+
18
19
  output do
19
- field :id, "ID"
20
- field :name, "Name"
20
+ field :id, _("ID")
21
+ field :name, _("Name")
21
22
  from :organization do
22
- field :name, "Organization"
23
+ field :name, _("Organization")
23
24
  end
24
25
 
25
26
  collection :repositories, "Repositories" do
26
- field :id, "ID"
27
- field :name, "Name"
28
- field :content_type, "Content Type"
27
+ field :id, _("ID")
28
+ field :name, _("Name")
29
+ field :content_type, _("Content Type")
29
30
  from :product do
30
- field :name, "Product"
31
+ field :name, _("Product")
31
32
  end
32
33
  end
33
34
 
34
- # TODO: Below!
35
- # Need a better way to say
36
- # Contents
37
- # <content>
38
-
39
- field "", "Content"
40
- field :content, nil
35
+ field :content, _("Content"), Fields::LongText
41
36
  end
42
37
 
43
- def request_params
44
- super.merge(method_options)
45
- end
46
-
47
- apipie_options
38
+ build_options
48
39
  end
49
40
 
50
- class CreateCommand < HammerCLIForeman::CreateCommand
51
- resource KatelloApi::Resources::GpgKey, :create
52
- success_message "GPG Key created"
53
- failure_message "Could not create GPG Key"
54
- apipie_options :without => [:content]
55
- option "--key", "GPG_KEY_FILE", "GPG Key file",
41
+ class CreateCommand < HammerCLIKatello::CreateCommand
42
+ success_message _("GPG Key created")
43
+ failure_message _("Could not create GPG Key")
44
+
45
+ build_options :without => [:content]
46
+ option "--key", "GPG_KEY_FILE", _("GPG Key file"),
56
47
  :attribute_name => :option_content,
57
48
  :required => true,
58
49
  :format => HammerCLI::Options::Normalizers::File.new
59
50
  end
60
51
 
61
- class UpdateCommand < HammerCLIForeman::UpdateCommand
62
- success_message "GPG Key updated"
63
- failure_message "Could not update GPG Key"
64
- resource KatelloApi::Resources::GpgKey, :update
52
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
53
+ success_message _("GPG Key updated")
54
+ failure_message _("Could not update GPG Key")
65
55
 
66
- identifiers :id
67
-
68
- def request_params
69
- super.merge(method_options)
70
- end
71
-
72
- apipie_options :without => [:content]
73
- option "--key", "GPG_KEY_FILE", "GPG Key file",
56
+ build_options :without => [:content]
57
+ option "--key", "GPG_KEY_FILE", _("GPG Key file"),
74
58
  :attribute_name => :option_content,
75
59
  :format => HammerCLI::Options::Normalizers::File.new
76
60
  end
77
61
 
78
- class DeleteCommand < HammerCLIForeman::DeleteCommand
79
- success_message "GPG Key deleted"
80
- failure_message "Could not delete the GPG Key"
81
- resource KatelloApi::Resources::GpgKey, :destroy
82
-
83
- identifiers :id
84
- def request_params
85
- super.merge(method_options)
86
- end
62
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
63
+ success_message _("GPG Key deleted")
64
+ failure_message _("Could not delete the GPG Key")
87
65
 
88
- apipie_options
66
+ build_options
89
67
  end
90
68
 
91
69
  autoload_subcommands
92
70
  end
93
71
 
94
72
  HammerCLI::MainCommand.subcommand("gpg",
95
- "manipulate GPG Key actions on the server",
73
+ _("manipulate GPG Key actions on the server"),
96
74
  HammerCLIKatello::GpgKeyCommand)
97
75
  end
@@ -0,0 +1,91 @@
1
+ module HammerCLIKatello
2
+
3
+ class HostCollection < HammerCLIKatello::Command
4
+ resource :host_collections
5
+
6
+ class ListCommand < HammerCLIKatello::ListCommand
7
+ resource :host_collections, :index
8
+
9
+ output do
10
+ field :id, _("ID")
11
+ field :name, _("Name")
12
+ field :max_content_hosts, _("Limit")
13
+ field :description, _("Description")
14
+ end
15
+
16
+ build_options
17
+ end
18
+
19
+ class CreateCommand < HammerCLIKatello::CreateCommand
20
+ resource :host_collections, :create
21
+
22
+ success_message _("Host collection created")
23
+ failure_message _("Could not create the host collection")
24
+
25
+ build_options
26
+ end
27
+
28
+ class InfoCommand < HammerCLIKatello::InfoCommand
29
+ resource :host_collections, :show
30
+
31
+ output ListCommand.output_definition do
32
+ field :total_content_hosts, _("Total Content Hosts")
33
+ field :max_content_hosts, _("Max Content Hosts")
34
+ end
35
+
36
+ build_options
37
+ end
38
+
39
+ class ContentHostsCommand < HammerCLIKatello::ListCommand
40
+ resource :host_collections, :systems
41
+ command_name "content-hosts"
42
+
43
+ output do
44
+ field :id, _("ID")
45
+ field :uuid, _("UUID")
46
+ field :name, _("Name")
47
+ end
48
+
49
+ build_options
50
+ end
51
+
52
+ class CopyCommand < HammerCLIKatello::CreateCommand
53
+ resource :host_collections, :copy
54
+
55
+ action :copy
56
+ command_name "copy"
57
+
58
+ success_message _("Host collection created")
59
+ failure_message _("Could not create the host collection")
60
+
61
+ validate_options do
62
+ all(:option_name).required unless option(:option_id).exist?
63
+ end
64
+
65
+ build_options
66
+ end
67
+
68
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
69
+ success_message _("Host collection updated")
70
+ failure_message _("Could not update the the host collection")
71
+
72
+ build_options
73
+ end
74
+
75
+ class DeleteCommand < HammerCLIKatello::DeleteCommand
76
+ resource :host_collections, :destroy
77
+
78
+ success_message _("Host collection deleted")
79
+ failure_message _("Could not delete the host collection")
80
+
81
+ build_options
82
+ end
83
+
84
+ HammerCLIKatello::AssociatingCommands::ContentHost.extend_command(self)
85
+
86
+ autoload_subcommands
87
+ end
88
+ end
89
+
90
+ HammerCLI::MainCommand.subcommand 'host-collection', _("Manipulate host collections"),
91
+ HammerCLIKatello::HostCollection
@@ -0,0 +1,24 @@
1
+ require 'hammer_cli/i18n'
2
+
3
+ module HammerCLIKatello
4
+ module I18n
5
+
6
+ class LocaleDomain < HammerCLI::I18n::LocaleDomain
7
+
8
+ def translated_files
9
+ Dir.glob(File.join(File.dirname(__FILE__), '../**/*.rb'))
10
+ end
11
+
12
+ def locale_dir
13
+ File.join(File.dirname(__FILE__), '../../locale')
14
+ end
15
+
16
+ def domain_name
17
+ 'hammer-cli-katello'
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ HammerCLI::I18n.add_domain(HammerCLIKatello::I18n::LocaleDomain.new)
@@ -0,0 +1,39 @@
1
+ module HammerCLIKatello
2
+
3
+ class Searchables
4
+
5
+ SEARCHABLES = {
6
+ :organization => [
7
+ HammerCLIForeman::Searchable.new("name", _("Name to search by")),
8
+ HammerCLIForeman::Searchable.new("label", _("Label to search by"), :editable => false)
9
+ ]
10
+ }
11
+
12
+ DEFAULT_SEARCHABLES = [HammerCLIForeman::Searchable.new("name", _("Name to search by"))]
13
+
14
+ def for(resource)
15
+ SEARCHABLES[resource.singular_name.to_sym] || DEFAULT_SEARCHABLES
16
+ end
17
+
18
+ end
19
+
20
+ class IdResolver < HammerCLIForeman::IdResolver
21
+
22
+ def system_id(options)
23
+ options[HammerCLI.option_accessor_name("id")] || find_resource(:systems, options)['uuid']
24
+ end
25
+
26
+ def create_search_options(options, resource)
27
+ return super if resource.name == :organizations
28
+
29
+ searchables(resource).each do |s|
30
+ value = options[HammerCLI.option_accessor_name(s.name.to_s)]
31
+ if value
32
+ return {"#{s.name}" => "#{value}"}
33
+ end
34
+ end
35
+ {}
36
+ end
37
+
38
+ end
39
+ end