hammer_cli_foreman 0.0.18 → 0.1.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.

Potentially problematic release.


This version of hammer_cli_foreman might be problematic. Click here for more details.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_foreman.rb +39 -27
  3. data/lib/hammer_cli_foreman/architecture.rb +14 -14
  4. data/lib/hammer_cli_foreman/associating_commands.rb +46 -40
  5. data/lib/hammer_cli_foreman/auth.rb +49 -0
  6. data/lib/hammer_cli_foreman/commands.rb +82 -29
  7. data/lib/hammer_cli_foreman/common_parameter.rb +13 -17
  8. data/lib/hammer_cli_foreman/compute_resource.rb +23 -23
  9. data/lib/hammer_cli_foreman/credentials.rb +36 -0
  10. data/lib/hammer_cli_foreman/domain.rb +32 -35
  11. data/lib/hammer_cli_foreman/environment.rb +14 -19
  12. data/lib/hammer_cli_foreman/exception_handler.rb +30 -8
  13. data/lib/hammer_cli_foreman/fact.rb +5 -5
  14. data/lib/hammer_cli_foreman/host.rb +178 -105
  15. data/lib/hammer_cli_foreman/hostgroup.rb +59 -37
  16. data/lib/hammer_cli_foreman/i18n.rb +24 -0
  17. data/lib/hammer_cli_foreman/image.rb +24 -24
  18. data/lib/hammer_cli_foreman/location.rb +13 -13
  19. data/lib/hammer_cli_foreman/media.rb +21 -16
  20. data/lib/hammer_cli_foreman/model.rb +16 -16
  21. data/lib/hammer_cli_foreman/operating_system.rb +39 -39
  22. data/lib/hammer_cli_foreman/organization.rb +13 -13
  23. data/lib/hammer_cli_foreman/output/fields.rb +2 -2
  24. data/lib/hammer_cli_foreman/output/formatters.rb +15 -4
  25. data/lib/hammer_cli_foreman/parameter.rb +13 -11
  26. data/lib/hammer_cli_foreman/partition_table.rb +17 -18
  27. data/lib/hammer_cli_foreman/puppet_class.rb +9 -9
  28. data/lib/hammer_cli_foreman/report.rb +38 -38
  29. data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
  30. data/lib/hammer_cli_foreman/smart_class_parameter.rb +36 -36
  31. data/lib/hammer_cli_foreman/smart_proxy.rb +22 -21
  32. data/lib/hammer_cli_foreman/subnet.rb +29 -31
  33. data/lib/hammer_cli_foreman/template.rb +45 -43
  34. data/lib/hammer_cli_foreman/user.rb +20 -23
  35. data/lib/hammer_cli_foreman/version.rb +1 -1
  36. data/locale/Makefile +64 -0
  37. data/locale/hammer-cli-foreman.pot +1573 -0
  38. data/locale/zanata.xml +29 -0
  39. data/test/unit/apipie_resource_mock.rb +44 -72
  40. data/test/unit/architecture_test.rb +1 -2
  41. data/test/unit/commands_test.rb +23 -21
  42. data/test/unit/common_parameter_test.rb +15 -10
  43. data/test/unit/compute_resource_test.rb +1 -2
  44. data/test/unit/credentials_test.rb +46 -0
  45. data/test/unit/data/1.4/foreman_api.json +10387 -0
  46. data/test/unit/domain_test.rb +2 -5
  47. data/test/unit/environment_test.rb +2 -3
  48. data/test/unit/exception_handler_test.rb +29 -4
  49. data/test/unit/fact_test.rb +0 -1
  50. data/test/unit/helpers/command.rb +20 -4
  51. data/test/unit/helpers/resource_disabled.rb +2 -2
  52. data/test/unit/host_test.rb +24 -12
  53. data/test/unit/hostgroup_test.rb +7 -8
  54. data/test/unit/image_test.rb +6 -7
  55. data/test/unit/location_test.rb +9 -5
  56. data/test/unit/media_test.rb +1 -9
  57. data/test/unit/model_test.rb +1 -3
  58. data/test/unit/operating_system_test.rb +7 -9
  59. data/test/unit/organization_test.rb +12 -6
  60. data/test/unit/output/formatters_test.rb +5 -0
  61. data/test/unit/partition_table_test.rb +1 -2
  62. data/test/unit/puppet_class_test.rb +2 -3
  63. data/test/unit/report_test.rb +1 -2
  64. data/test/unit/smart_class_parameter_test.rb +9 -4
  65. data/test/unit/smart_proxy_test.rb +1 -2
  66. data/test/unit/subnet_test.rb +2 -3
  67. data/test/unit/template_test.rb +23 -8
  68. data/test/unit/test_helper.rb +13 -0
  69. data/test/unit/test_output_adapter.rb +1 -1
  70. data/test/unit/user_test.rb +1 -2
  71. metadata +17 -7
@@ -2,20 +2,37 @@ require 'hammer_cli_foreman/smart_class_parameter'
2
2
 
3
3
  module HammerCLIForeman
4
4
 
5
- class Hostgroup < HammerCLI::AbstractCommand
5
+ module HostgroupUpdateCreateCommons
6
+
7
+ def request_params
8
+ params = method_options
9
+ params['hostgroup']['puppetclass_ids'] = option_puppetclass_ids
10
+ params
11
+ end
12
+
13
+ end
14
+
15
+ class Hostgroup < HammerCLIForeman::Command
16
+
17
+ resource :hostgroups
18
+
6
19
  class ListCommand < HammerCLIForeman::ListCommand
7
- resource ForemanApi::Resources::Hostgroup, "index"
8
20
 
9
21
  output do
10
- field :id, "Id"
11
- field :name, "Name"
12
- field :label, "Label"
13
- field :operatingsystem_id, "Operating System Id"
14
- field :subnet_id, "Subnet Id"
15
- field :domain_id, "Domain Id"
16
- field :environment_id, "Environment Id"
17
- field :puppetclass_ids, "Puppetclass Ids", Fields::List
18
- field :ancestry, "Ancestry"
22
+ field :id, _("Id")
23
+ field :name, _("Name")
24
+ field :label, _("Label")
25
+ field :operatingsystem_id, _("Operating System Id")
26
+ field :subnet_id, _("Subnet Id")
27
+ field :domain_id, _("Domain Id")
28
+ field :architecture_id, _("Architecture Id")
29
+ field :ptable_id, _("Partition Table Id")
30
+ field :medium_id, _("Medium Id")
31
+ field :puppet_ca_proxy_id, _("Puppet CA Proxy Id")
32
+ field :puppet_proxy_id, _("Puppet Master Proxy Id")
33
+ field :environment_id, _("Environment Id")
34
+ field :puppetclass_ids, _("Puppetclass Ids"), Fields::List
35
+ field :ancestry, _("Ancestry")
19
36
  end
20
37
 
21
38
  apipie_options
@@ -23,12 +40,11 @@ module HammerCLIForeman
23
40
 
24
41
 
25
42
  class InfoCommand < HammerCLIForeman::InfoCommand
26
- resource ForemanApi::Resources::Hostgroup, "show"
27
43
 
28
44
  identifiers :id
29
45
 
30
46
  output ListCommand.output_definition do
31
- collection :parameters, "Parameters" do
47
+ collection :parameters, _("Parameters") do
32
48
  field nil, nil, Fields::KeyValue
33
49
  end
34
50
  end
@@ -44,9 +60,13 @@ module HammerCLIForeman
44
60
 
45
61
  class CreateCommand < HammerCLIForeman::CreateCommand
46
62
 
47
- success_message "Hostgroup created"
48
- failure_message "Could not create the hostgroup"
49
- resource ForemanApi::Resources::Hostgroup, "create"
63
+ option "--puppetclass-ids", "PUPPETCLASS_IDS", " ",
64
+ :format => HammerCLI::Options::Normalizers::List.new
65
+
66
+ include HostgroupUpdateCreateCommons
67
+
68
+ success_message _("Hostgroup created")
69
+ failure_message _("Could not create the hostgroup")
50
70
 
51
71
  apipie_options
52
72
  end
@@ -54,11 +74,15 @@ module HammerCLIForeman
54
74
 
55
75
  class UpdateCommand < HammerCLIForeman::UpdateCommand
56
76
 
77
+ option "--puppetclass-ids", "PUPPETCLASS_IDS", " ",
78
+ :format => HammerCLI::Options::Normalizers::List.new
79
+
80
+ include HostgroupUpdateCreateCommons
81
+
57
82
  identifiers :id
58
83
 
59
- success_message "Hostgroup updated"
60
- failure_message "Could not update the hostgroup"
61
- resource ForemanApi::Resources::Hostgroup, "update"
84
+ success_message _("Hostgroup updated")
85
+ failure_message _("Could not update the hostgroup")
62
86
 
63
87
  apipie_options
64
88
  end
@@ -68,9 +92,8 @@ module HammerCLIForeman
68
92
 
69
93
  identifiers :id
70
94
 
71
- success_message "Hostgroup deleted"
72
- failure_message "Could not delete the hostgroup"
73
- resource ForemanApi::Resources::Hostgroup, "destroy"
95
+ success_message _("Hostgroup deleted")
96
+ failure_message _("Could not delete the hostgroup")
74
97
 
75
98
  apipie_options
76
99
  end
@@ -78,8 +101,8 @@ module HammerCLIForeman
78
101
 
79
102
  class PuppetClassesCommand < HammerCLIForeman::ListCommand
80
103
 
81
- command_name "puppet_classes"
82
- resource ForemanApi::Resources::Puppetclass
104
+ command_name "puppet-classes"
105
+ resource :puppetclasses
83
106
 
84
107
  identifiers :id
85
108
 
@@ -101,15 +124,15 @@ module HammerCLIForeman
101
124
 
102
125
  class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
103
126
 
104
- resource ForemanApi::Resources::Parameter
127
+ resource :parameters
105
128
 
106
- desc "Create or update parameter for a hostgroup."
129
+ desc _("Create or update parameter for a hostgroup.")
107
130
 
108
- option "--hostgroup-id", "HOSTGROUP_ID", "id of the hostgroup the parameter is being set for", :required => true
131
+ option "--hostgroup-id", "HOSTGROUP_ID", _("id of the hostgroup the parameter is being set for"), :required => true
109
132
 
110
- success_message_for :update, "Hostgroup parameter updated"
111
- success_message_for :create, "New hostgroup parameter created"
112
- failure_message "Could not set hostgroup parameter"
133
+ success_message_for :update, _("Hostgroup parameter updated")
134
+ success_message_for :create, _("New hostgroup parameter created")
135
+ failure_message _("Could not set hostgroup parameter")
113
136
 
114
137
  def base_action_params
115
138
  {
@@ -121,13 +144,13 @@ module HammerCLIForeman
121
144
 
122
145
  class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
123
146
 
124
- resource ForemanApi::Resources::Parameter
147
+ resource :parameters
125
148
 
126
- desc "Delete parameter for a hostgroup."
149
+ desc _("Delete parameter for a hostgroup.")
127
150
 
128
- option "--hostgroup-id", "HOSTGROUP_ID", "id of the hostgroup the parameter is being deleted for", :required => true
151
+ option "--hostgroup-id", "HOSTGROUP_ID", _("id of the hostgroup the parameter is being deleted for"), :required => true
129
152
 
130
- success_message "Hostgroup parameter deleted"
153
+ success_message _("Hostgroup parameter deleted")
131
154
 
132
155
  def base_action_params
133
156
  {
@@ -140,7 +163,7 @@ module HammerCLIForeman
140
163
  class SCParamsCommand < HammerCLIForeman::SmartClassParametersList
141
164
 
142
165
  apipie_options :without => [:host_id, :hostgroup_id, :puppetclass_id, :environment_id]
143
- option ['--id', '--name'], 'HOSTGROUP_ID', 'hostgroup id/name',
166
+ option ['--id', '--name'], 'HOSTGROUP_ID', _('hostgroup id/name'),
144
167
  :attribute_name => :option_hostgroup_id, :required => true
145
168
  end
146
169
 
@@ -150,5 +173,4 @@ module HammerCLIForeman
150
173
 
151
174
  end
152
175
 
153
- HammerCLI::MainCommand.subcommand 'hostgroup', "Manipulate hostgroups.", HammerCLIForeman::Hostgroup
154
-
176
+ HammerCLI::MainCommand.subcommand 'hostgroup', _("Manipulate hostgroups."), HammerCLIForeman::Hostgroup
@@ -0,0 +1,24 @@
1
+ require 'hammer_cli/i18n'
2
+
3
+ module HammerCLIForeman
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-foreman'
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+ HammerCLI::I18n.add_domain(HammerCLIForeman::I18n::LocaleDomain.new)
@@ -2,18 +2,18 @@ require 'hammer_cli_foreman/compute_resource'
2
2
 
3
3
  module HammerCLIForeman
4
4
 
5
- class Image < HammerCLI::Apipie::Command
5
+ class Image < HammerCLIForeman::Command
6
6
 
7
- resource ForemanApi::Resources::Image
7
+ resource :images
8
8
  command_name 'image'
9
- desc "View and manage compute resource's images"
9
+ desc _("View and manage compute resource's images")
10
10
 
11
11
 
12
12
  module ComputeResourceOptions
13
13
 
14
14
  def self.included(base)
15
- base.option "--compute-resource", "COMPUTE_RESOURCE_NAME", "Compute resource's name"
16
- base.option "--compute-resource-id", "COMPUTE_RESOURCE_ID", "Compute resource's id"
15
+ base.option "--compute-resource", "COMPUTE_RESOURCE_NAME", _("Compute resource's name")
16
+ base.option "--compute-resource-id", "COMPUTE_RESOURCE_ID", _("Compute resource's id")
17
17
  base.apipie_options :without => [:compute_resource_id, :id]
18
18
 
19
19
  base.validate_options do
@@ -29,11 +29,11 @@ module HammerCLIForeman
29
29
  include HammerCLIForeman::Image::ComputeResourceOptions
30
30
 
31
31
  output do
32
- field :id, "Id"
33
- field :name, "Name"
34
- field :operatingsystem_id, "Operating System Id", Fields::Id
35
- field :username, "Username"
36
- field :uuid, "UUID"
32
+ field :id, _("Id")
33
+ field :name, _("Name")
34
+ field :operatingsystem_id, _("Operating System Id"), Fields::Id
35
+ field :username, _("Username")
36
+ field :uuid, _("UUID")
37
37
  end
38
38
 
39
39
  def request_params
@@ -52,10 +52,10 @@ module HammerCLIForeman
52
52
 
53
53
 
54
54
  output ListCommand.output_definition do
55
- field :architecture_id, "Architecture Id", Fields::Id
56
- field :iam_role, "IAM role"
57
- field :created_at, "Created at", Fields::Date
58
- field :updated_at, "Updated at", Fields::Date
55
+ field :architecture_id, _("Architecture Id"), Fields::Id
56
+ field :iam_role, _("IAM role")
57
+ field :created_at, _("Created at"), Fields::Date
58
+ field :updated_at, _("Updated at"), Fields::Date
59
59
  end
60
60
 
61
61
  def request_params
@@ -69,15 +69,15 @@ module HammerCLIForeman
69
69
 
70
70
  class AvailableImagesCommand < HammerCLIForeman::ListCommand
71
71
 
72
- resource ForemanApi::Resources::ComputeResource, "available_images"
72
+ resource :compute_resources, :available_images
73
73
  command_name 'available'
74
- desc "Show images available for addition"
74
+ desc _("Show images available for addition")
75
75
 
76
76
  include HammerCLIForeman::Image::ComputeResourceOptions
77
77
 
78
78
  output do
79
- field :name, "Name"
80
- field :uuid, "UUID"
79
+ field :name, _("Name")
80
+ field :uuid, _("UUID")
81
81
  end
82
82
 
83
83
  def request_params
@@ -93,8 +93,8 @@ module HammerCLIForeman
93
93
 
94
94
  include HammerCLIForeman::Image::ComputeResourceOptions
95
95
 
96
- success_message "Image created"
97
- failure_message "Could not create the image"
96
+ success_message _("Image created")
97
+ failure_message _("Could not create the image")
98
98
 
99
99
  def request_params
100
100
  params = super
@@ -109,8 +109,8 @@ module HammerCLIForeman
109
109
  identifiers :id
110
110
  include HammerCLIForeman::Image::ComputeResourceOptions
111
111
 
112
- success_message "Image updated"
113
- failure_message "Could not update the image"
112
+ success_message _("Image updated")
113
+ failure_message _("Could not update the image")
114
114
 
115
115
  def request_params
116
116
  params = super
@@ -126,8 +126,8 @@ module HammerCLIForeman
126
126
  identifiers :id
127
127
  include HammerCLIForeman::Image::ComputeResourceOptions
128
128
 
129
- success_message "Image deleted"
130
- failure_message "Could not delete the image"
129
+ success_message _("Image deleted")
130
+ failure_message _("Could not delete the image")
131
131
 
132
132
  def request_params
133
133
  params = super
@@ -2,16 +2,16 @@ require 'hammer_cli_foreman/resource_supported_test'
2
2
 
3
3
  module HammerCLIForeman
4
4
 
5
- class Location < HammerCLI::Apipie::Command
5
+ class Location < HammerCLIForeman::Command
6
6
 
7
- resource ForemanApi::Resources::Location
7
+ resource :locations
8
8
 
9
9
  class ListCommand < HammerCLIForeman::ListCommand
10
10
  include HammerCLIForeman::ResourceSupportedTest
11
11
 
12
12
  output do
13
- field :id, "Id"
14
- field :name, "Name"
13
+ field :id, _("Id")
14
+ field :name, _("Name")
15
15
  end
16
16
 
17
17
  apipie_options
@@ -22,8 +22,8 @@ module HammerCLIForeman
22
22
  include HammerCLIForeman::ResourceSupportedTest
23
23
 
24
24
  output ListCommand.output_definition do
25
- field :created_at, "Created at", Fields::Date
26
- field :updated_at, "Updated at", Fields::Date
25
+ field :created_at, _("Created at"), Fields::Date
26
+ field :updated_at, _("Updated at"), Fields::Date
27
27
  end
28
28
 
29
29
  apipie_options
@@ -33,8 +33,8 @@ module HammerCLIForeman
33
33
  class CreateCommand < HammerCLIForeman::CreateCommand
34
34
  include HammerCLIForeman::ResourceSupportedTest
35
35
 
36
- success_message "Location created"
37
- failure_message "Could not create the location"
36
+ success_message _("Location created")
37
+ failure_message _("Could not create the location")
38
38
 
39
39
  apipie_options
40
40
  end
@@ -43,8 +43,8 @@ module HammerCLIForeman
43
43
  class UpdateCommand < HammerCLIForeman::UpdateCommand
44
44
  include HammerCLIForeman::ResourceSupportedTest
45
45
 
46
- success_message "Location updated"
47
- failure_message "Could not update the location"
46
+ success_message _("Location updated")
47
+ failure_message _("Could not update the location")
48
48
 
49
49
  apipie_options
50
50
  end
@@ -53,8 +53,8 @@ module HammerCLIForeman
53
53
  class DeleteCommand < HammerCLIForeman::DeleteCommand
54
54
  include HammerCLIForeman::ResourceSupportedTest
55
55
 
56
- success_message "Location deleted"
57
- failure_message "Could not delete the location"
56
+ success_message _("Location deleted")
57
+ failure_message _("Could not delete the location")
58
58
 
59
59
  apipie_options
60
60
  end
@@ -75,5 +75,5 @@ module HammerCLIForeman
75
75
 
76
76
  end
77
77
 
78
- HammerCLI::MainCommand.subcommand 'location', "Manipulate locations.", HammerCLIForeman::Location
78
+ HammerCLI::MainCommand.subcommand 'location', _("Manipulate locations."), HammerCLIForeman::Location
79
79
 
@@ -1,14 +1,14 @@
1
1
  module HammerCLIForeman
2
2
 
3
- class Medium < HammerCLI::Apipie::Command
3
+ class Medium < HammerCLIForeman::Command
4
4
 
5
- resource ForemanApi::Resources::Medium
5
+ resource :media
6
6
 
7
7
  class ListCommand < HammerCLIForeman::ListCommand
8
8
  output do
9
- field :id, "Id"
10
- field :name, "Name"
11
- field :path, "Path"
9
+ field :id, _("Id")
10
+ field :name, _("Name")
11
+ field :path, _("Path")
12
12
  end
13
13
 
14
14
  apipie_options
@@ -17,10 +17,15 @@ module HammerCLIForeman
17
17
 
18
18
  class InfoCommand < HammerCLIForeman::InfoCommand
19
19
  output ListCommand.output_definition do
20
- field :os_family, "OS Family"
21
- field :operatingsystem_ids, "OS IDs", Fields::List
22
- field :created_at, "Created at", Fields::Date
23
- field :updated_at, "Updated at", Fields::Date
20
+ field :os_family, _("OS Family")
21
+ field :operatingsystem_ids, _("OS IDs"), Fields::List
22
+ field :created_at, _("Created at"), Fields::Date
23
+ field :updated_at, _("Updated at"), Fields::Date
24
+ end
25
+
26
+ def extend_data(res)
27
+ res['operatingsystem_ids'] = res['operatingsystems'].map { |e| e["id"] } rescue []
28
+ res
24
29
  end
25
30
 
26
31
  apipie_options
@@ -29,8 +34,8 @@ module HammerCLIForeman
29
34
 
30
35
  class CreateCommand < HammerCLIForeman::CreateCommand
31
36
 
32
- success_message "Installation medium created"
33
- failure_message "Could not create the installation medium"
37
+ success_message _("Installation medium created")
38
+ failure_message _("Could not create the installation medium")
34
39
 
35
40
  apipie_options
36
41
 
@@ -39,8 +44,8 @@ module HammerCLIForeman
39
44
 
40
45
  class UpdateCommand < HammerCLIForeman::UpdateCommand
41
46
 
42
- success_message "Installation medium updated"
43
- failure_message "Could not update the installation media"
47
+ success_message _("Installation medium updated")
48
+ failure_message _("Could not update the installation media")
44
49
 
45
50
  apipie_options
46
51
 
@@ -49,8 +54,8 @@ module HammerCLIForeman
49
54
 
50
55
  class DeleteCommand < HammerCLIForeman::DeleteCommand
51
56
 
52
- success_message "Installation medium deleted"
53
- failure_message "Could not delete the installation media"
57
+ success_message _("Installation medium deleted")
58
+ failure_message _("Could not delete the installation media")
54
59
 
55
60
  apipie_options
56
61
  end
@@ -63,5 +68,5 @@ module HammerCLIForeman
63
68
 
64
69
  end
65
70
 
66
- HammerCLI::MainCommand.subcommand 'medium', "Manipulate installation media.", HammerCLIForeman::Medium
71
+ HammerCLI::MainCommand.subcommand 'medium', _("Manipulate installation media."), HammerCLIForeman::Medium
67
72