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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fd5cd72dd8217359f1f71719934fe9377086b17
4
- data.tar.gz: bd87b55ddf01d0ff6f043b459c95899f0b5b58da
3
+ metadata.gz: 4664c32a15e81c3db327542d918d9eaebf516e11
4
+ data.tar.gz: 324c167ab2dba9419c86d16bec1b59ab313df949
5
5
  SHA512:
6
- metadata.gz: babdcab332392d62a38d006d84fca84069dc66087b0915703f5325c6a1123612b1833f0a8b51402f3824ffe7f29a4fb48c026a798e3f0035c8babd807a3b446c
7
- data.tar.gz: ce713dc6633bf093ebbec501e97f8d33901079dfe9927c6d605f2d6fd95abc493d02210824fdd78c190b32dcb9a5697f0346aea0311e29e10d66c1833992c65a
6
+ metadata.gz: d5b642b1ba7581539d667ac94de9ed9cc27daaa194d4d26e5101b0983dba77ab3d184e628359d8b32c2e90b72b4c66624a322ce02dab081a01bb3fde6397e703
7
+ data.tar.gz: 62f07b9d348b8ec921380b17b900a26622dff382733ce28d1d52908a684bd303f40b9617a9f46b4681286482ce5840ac5dbfca1f15b9a387e905d70de8d4c045
@@ -1,7 +1,6 @@
1
1
  require 'hammer_cli'
2
2
  require 'hammer_cli/exit_codes'
3
-
4
- require 'foreman_api'
3
+ require 'apipie_bindings'
5
4
 
6
5
  module HammerCLIForeman
7
6
 
@@ -9,34 +8,47 @@ module HammerCLIForeman
9
8
  HammerCLIForeman::ExceptionHandler
10
9
  end
11
10
 
11
+ require 'hammer_cli_foreman/i18n'
12
+
12
13
  require 'hammer_cli_foreman/version'
13
14
  require 'hammer_cli_foreman/output'
14
- require 'hammer_cli_foreman/commands'
15
- require 'hammer_cli_foreman/associating_commands'
16
- require 'hammer_cli_foreman/parameter'
15
+ require 'hammer_cli_foreman/credentials'
17
16
  require 'hammer_cli_foreman/exception_handler'
18
- require 'hammer_cli_foreman/common_parameter'
19
-
20
- require 'hammer_cli_foreman/architecture'
21
- require 'hammer_cli_foreman/compute_resource'
22
- require 'hammer_cli_foreman/domain'
23
- require 'hammer_cli_foreman/environment'
24
- require 'hammer_cli_foreman/fact'
25
- require 'hammer_cli_foreman/host'
26
- require 'hammer_cli_foreman/hostgroup'
27
- require 'hammer_cli_foreman/location'
28
- require 'hammer_cli_foreman/media'
29
- require 'hammer_cli_foreman/model'
30
- require 'hammer_cli_foreman/operating_system'
31
- require 'hammer_cli_foreman/organization'
32
- require 'hammer_cli_foreman/partition_table'
33
- require 'hammer_cli_foreman/report'
34
- require 'hammer_cli_foreman/puppet_class'
35
- require 'hammer_cli_foreman/smart_proxy'
36
- require 'hammer_cli_foreman/smart_class_parameter'
37
- require 'hammer_cli_foreman/subnet'
38
- require 'hammer_cli_foreman/template'
39
- require 'hammer_cli_foreman/user'
17
+
18
+ begin
19
+ require 'hammer_cli_foreman/commands'
20
+ require 'hammer_cli_foreman/associating_commands'
21
+ require 'hammer_cli_foreman/parameter'
22
+ require 'hammer_cli_foreman/common_parameter'
23
+
24
+ require 'hammer_cli_foreman/architecture'
25
+ require 'hammer_cli_foreman/auth'
26
+ require 'hammer_cli_foreman/compute_resource'
27
+ require 'hammer_cli_foreman/domain'
28
+ require 'hammer_cli_foreman/environment'
29
+ require 'hammer_cli_foreman/fact'
30
+ require 'hammer_cli_foreman/host'
31
+ require 'hammer_cli_foreman/hostgroup'
32
+ require 'hammer_cli_foreman/location'
33
+ require 'hammer_cli_foreman/media'
34
+ require 'hammer_cli_foreman/model'
35
+ require 'hammer_cli_foreman/operating_system'
36
+ require 'hammer_cli_foreman/organization'
37
+ require 'hammer_cli_foreman/output/fields'
38
+ require 'hammer_cli_foreman/partition_table'
39
+ require 'hammer_cli_foreman/report'
40
+ require 'hammer_cli_foreman/puppet_class'
41
+ require 'hammer_cli_foreman/smart_proxy'
42
+ require 'hammer_cli_foreman/smart_class_parameter'
43
+ require 'hammer_cli_foreman/subnet'
44
+ require 'hammer_cli_foreman/template'
45
+ require 'hammer_cli_foreman/user'
46
+
47
+ rescue => e
48
+ handler = HammerCLIForeman::ExceptionHandler.new(:context => {}, :adapter => :base)
49
+ handler.handle_exception(e)
50
+ raise HammerCLI::ModuleLoadingError.new(e)
51
+ end
40
52
 
41
53
  end
42
54
 
@@ -1,14 +1,14 @@
1
1
  module HammerCLIForeman
2
2
 
3
- class Architecture < HammerCLI::Apipie::Command
3
+ class Architecture < HammerCLIForeman::Command
4
4
 
5
- resource ForemanApi::Resources::Architecture
5
+ resource :architectures
6
6
 
7
7
  class ListCommand < HammerCLIForeman::ListCommand
8
8
 
9
9
  output do
10
- field :id, "Id"
11
- field :name, "Name"
10
+ field :id, _("Id")
11
+ field :name, _("Name")
12
12
  end
13
13
 
14
14
  apipie_options
@@ -18,9 +18,9 @@ module HammerCLIForeman
18
18
  class InfoCommand < HammerCLIForeman::InfoCommand
19
19
 
20
20
  output ListCommand.output_definition do
21
- field :operatingsystem_ids, "OS ids", Fields::List
22
- field :created_at, "Created at", Fields::Date
23
- field :updated_at, "Updated at", Fields::Date
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
24
  end
25
25
 
26
26
  apipie_options
@@ -28,24 +28,24 @@ module HammerCLIForeman
28
28
 
29
29
 
30
30
  class CreateCommand < HammerCLIForeman::CreateCommand
31
- success_message "Architecture created"
32
- failure_message "Could not create the architecture"
31
+ success_message _("Architecture created")
32
+ failure_message _("Could not create the architecture")
33
33
 
34
34
  apipie_options
35
35
  end
36
36
 
37
37
 
38
38
  class DeleteCommand < HammerCLIForeman::DeleteCommand
39
- success_message "Architecture deleted"
40
- failure_message "Could not delete the architecture"
39
+ success_message _("Architecture deleted")
40
+ failure_message _("Could not delete the architecture")
41
41
 
42
42
  apipie_options
43
43
  end
44
44
 
45
45
 
46
46
  class UpdateCommand < HammerCLIForeman::UpdateCommand
47
- success_message "Architecture updated"
48
- failure_message "Could not update the architecture"
47
+ success_message _("Architecture updated")
48
+ failure_message _("Could not update the architecture")
49
49
 
50
50
  apipie_options
51
51
  end
@@ -57,5 +57,5 @@ module HammerCLIForeman
57
57
 
58
58
  end
59
59
 
60
- HammerCLI::MainCommand.subcommand 'architecture', "Manipulate architectures.", HammerCLIForeman::Architecture
60
+ HammerCLI::MainCommand.subcommand 'architecture', _("Manipulate architectures."), HammerCLIForeman::Architecture
61
61
 
@@ -3,92 +3,92 @@ module HammerCLIForeman
3
3
 
4
4
  module Hostgroup
5
5
  class AddHostgroupCommand < HammerCLIForeman::AddAssociatedCommand
6
- associated_resource ForemanApi::Resources::Hostgroup
6
+ associated_resource :hostgroups
7
7
  apipie_options
8
8
  end
9
9
 
10
10
  class RemoveHostgroupCommand < HammerCLIForeman::RemoveAssociatedCommand
11
- associated_resource ForemanApi::Resources::Hostgroup
11
+ associated_resource :hostgroups
12
12
  apipie_options
13
13
  end
14
14
  end
15
15
 
16
16
  module Environment
17
17
  class AddEnvironmentCommand < HammerCLIForeman::AddAssociatedCommand
18
- associated_resource ForemanApi::Resources::Environment
18
+ associated_resource :environments
19
19
  apipie_options
20
20
  end
21
21
 
22
22
  class RemoveEnvironmentCommand < HammerCLIForeman::RemoveAssociatedCommand
23
- associated_resource ForemanApi::Resources::Environment
23
+ associated_resource :environments
24
24
  apipie_options
25
25
  end
26
26
  end
27
27
 
28
28
  module Domain
29
29
  class AddDomainCommand < HammerCLIForeman::AddAssociatedCommand
30
- associated_resource ForemanApi::Resources::Domain
30
+ associated_resource :domains
31
31
  apipie_options
32
32
  end
33
33
 
34
34
  class RemoveDomainCommand < HammerCLIForeman::RemoveAssociatedCommand
35
- associated_resource ForemanApi::Resources::Domain
35
+ associated_resource :domains
36
36
  apipie_options
37
37
  end
38
38
  end
39
39
 
40
40
  module Medium
41
41
  class AddMediumCommand < HammerCLIForeman::AddAssociatedCommand
42
- associated_resource ForemanApi::Resources::Medium
42
+ associated_resource :media
43
43
  apipie_options
44
44
  end
45
45
 
46
46
  class RemoveMediumCommand < HammerCLIForeman::RemoveAssociatedCommand
47
- associated_resource ForemanApi::Resources::Medium
47
+ associated_resource :media
48
48
  apipie_options
49
49
  end
50
50
  end
51
51
 
52
52
  module Subnet
53
53
  class AddSubnetCommand < HammerCLIForeman::AddAssociatedCommand
54
- associated_resource ForemanApi::Resources::Subnet
54
+ associated_resource :subnets
55
55
  apipie_options
56
56
  end
57
57
 
58
58
  class RemoveSubnetCommand < HammerCLIForeman::RemoveAssociatedCommand
59
- associated_resource ForemanApi::Resources::Subnet
59
+ associated_resource :subnets
60
60
  apipie_options
61
61
  end
62
62
  end
63
63
 
64
64
  module ComputeResource
65
65
  class AddComputeResourceCommand < HammerCLIForeman::AddAssociatedCommand
66
- associated_resource ForemanApi::Resources::ComputeResource
66
+ associated_resource :compute_resources
67
67
  apipie_options
68
68
  end
69
69
 
70
70
  class RemoveComputeResourceCommand < HammerCLIForeman::RemoveAssociatedCommand
71
- associated_resource ForemanApi::Resources::ComputeResource
71
+ associated_resource :compute_resources
72
72
  apipie_options
73
73
  end
74
74
  end
75
75
 
76
76
  module SmartProxy
77
77
  class AddSmartProxyCommand < HammerCLIForeman::AddAssociatedCommand
78
- associated_resource ForemanApi::Resources::SmartProxy
78
+ associated_resource :smart_proxies
79
79
  apipie_options
80
80
 
81
81
  def associated_resource_name
82
- "smart_proxy"
82
+ "smart-proxy"
83
83
  end
84
84
  end
85
85
 
86
86
  class RemoveSmartProxyCommand < HammerCLIForeman::RemoveAssociatedCommand
87
- associated_resource ForemanApi::Resources::SmartProxy
87
+ associated_resource :smart_proxies
88
88
  apipie_options
89
89
 
90
90
  def associated_resource_name
91
- "smart_proxy"
91
+ "smart-proxy"
92
92
  end
93
93
  end
94
94
  end
@@ -97,100 +97,106 @@ module HammerCLIForeman
97
97
  class AddUserCommand < HammerCLIForeman::AddAssociatedCommand
98
98
  associated_identifiers :id
99
99
 
100
- associated_resource ForemanApi::Resources::User
100
+ associated_resource :users
101
101
  apipie_options
102
+
103
+ success_message "The user has been associated"
104
+ failure_message "Could not associate the user"
102
105
  end
103
106
 
104
107
  class RemoveUserCommand < HammerCLIForeman::RemoveAssociatedCommand
105
108
  associated_identifiers :id
106
109
 
107
- associated_resource ForemanApi::Resources::User
110
+ associated_resource :users
108
111
  apipie_options
112
+
113
+ success_message "The user has been disassociated"
114
+ failure_message "Could not disassociate the user"
109
115
  end
110
116
  end
111
117
 
112
118
  module ConfigTemplate
113
119
  class AddConfigTemplateCommand < HammerCLIForeman::AddAssociatedCommand
114
- associated_resource ForemanApi::Resources::ConfigTemplate
120
+ associated_resource :config_templates
115
121
  apipie_options
116
122
  end
117
123
 
118
124
  class RemoveConfigTemplateCommand < HammerCLIForeman::RemoveAssociatedCommand
119
- associated_resource ForemanApi::Resources::ConfigTemplate
125
+ associated_resource :config_templates
120
126
  apipie_options
121
127
  end
122
128
  end
123
129
 
124
130
  module Organization
125
131
  class AddOrganizationCommand < HammerCLIForeman::AddAssociatedCommand
126
- associated_resource ForemanApi::Resources::Organization
132
+ associated_resource :organizations
127
133
  apipie_options
128
134
  end
129
135
 
130
136
  class RemoveOrganizationCommand < HammerCLIForeman::RemoveAssociatedCommand
131
- associated_resource ForemanApi::Resources::Organization
137
+ associated_resource :organizations
132
138
  apipie_options
133
139
  end
134
140
  end
135
141
 
136
142
  module OperatingSystem
137
143
  class AddOSCommand < HammerCLIForeman::AddAssociatedCommand
138
- associated_resource ForemanApi::Resources::OperatingSystem
144
+ associated_resource :operatingsystems
139
145
 
140
146
  associated_identifiers :id
141
147
  apipie_options
142
148
 
143
- success_message "Operating system has been associated"
144
- failure_message "Could not associate the operating system"
149
+ success_message _("Operating system has been associated")
150
+ failure_message _("Could not associate the operating system")
145
151
  end
146
152
 
147
153
 
148
154
  class RemoveOSCommand < HammerCLIForeman::RemoveAssociatedCommand
149
- associated_resource ForemanApi::Resources::OperatingSystem
155
+ associated_resource :operatingsystems
150
156
 
151
157
  associated_identifiers :id
152
158
  apipie_options
153
159
 
154
- success_message "Operating system has been disassociated"
155
- failure_message "Could not disassociate the operating system"
160
+ success_message _("Operating system has been disassociated")
161
+ failure_message _("Could not disassociate the operating system")
156
162
  end
157
163
  end
158
164
 
159
165
  module Architecture
160
166
  class AddArchitectureCommand < HammerCLIForeman::AddAssociatedCommand
161
- associated_resource ForemanApi::Resources::Architecture
167
+ associated_resource :architectures
162
168
  apipie_options
163
169
 
164
- success_message "Architecture has been associated"
165
- failure_message "Could not associate the architecture"
170
+ success_message _("Architecture has been associated")
171
+ failure_message _("Could not associate the architecture")
166
172
  end
167
173
 
168
174
 
169
175
  class RemoveArchitectureCommand < HammerCLIForeman::RemoveAssociatedCommand
170
- associated_resource ForemanApi::Resources::Architecture
176
+ associated_resource :architectures
171
177
  apipie_options
172
178
 
173
- success_message "Architecture has been disassociated"
174
- failure_message "Could not disassociate the architecture"
179
+ success_message _("Architecture has been disassociated")
180
+ failure_message _("Could not disassociate the architecture")
175
181
  end
176
182
  end
177
183
 
178
184
  module PartitionTable
179
185
  class AddPartitionTableCommand < HammerCLIForeman::AddAssociatedCommand
180
- associated_resource ForemanApi::Resources::Ptable
186
+ associated_resource :ptables
181
187
  apipie_options
182
188
 
183
- success_message "Partition table has been associated"
184
- failure_message "Could not associate the partition table"
189
+ success_message _("Partition table has been associated")
190
+ failure_message _("Could not associate the partition table")
185
191
  end
186
192
 
187
193
 
188
194
  class RemovePartitionTableCommand < HammerCLIForeman::RemoveAssociatedCommand
189
- associated_resource ForemanApi::Resources::Ptable
195
+ associated_resource :ptables
190
196
  apipie_options
191
197
 
192
- success_message "Partition table has been disassociated"
193
- failure_message "Could not disassociate the partition table"
198
+ success_message _("Partition table has been disassociated")
199
+ failure_message _("Could not disassociate the partition table")
194
200
  end
195
201
  end
196
202
 
@@ -0,0 +1,49 @@
1
+ module HammerCLIForeman
2
+
3
+ class Auth < HammerCLI::AbstractCommand
4
+
5
+ class LoginCommand < HammerCLI::AbstractCommand
6
+ command_name "login"
7
+ desc _("Set credentials")
8
+
9
+ def execute
10
+ HammerCLIForeman.credentials.clear
11
+ HammerCLI::Connection.drop_all
12
+ HammerCLIForeman.credentials.username
13
+ HammerCLIForeman.credentials.password
14
+ HammerCLI::EX_OK
15
+ end
16
+ end
17
+
18
+ class LogoutCommand < HammerCLI::AbstractCommand
19
+ command_name "logout"
20
+ desc _("Wipe your credentials")
21
+
22
+ 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
26
+ print_message(_("Credentials deleted."))
27
+ HammerCLI::EX_OK
28
+ end
29
+ end
30
+
31
+ class InfoCommand < HammerCLI::AbstractCommand
32
+ command_name "status"
33
+ desc _("Information about current connections")
34
+
35
+ 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
41
+ HammerCLI::EX_OK
42
+ end
43
+ end
44
+
45
+ autoload_subcommands
46
+ end
47
+
48
+ HammerCLI::ShellMainCommand.subcommand 'auth', _("Foreman connection login/logout."), HammerCLIForeman::Auth
49
+ end