hammer_cli_foreman 0.0.4 → 0.0.5

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 (32) hide show
  1. checksums.yaml +7 -0
  2. data/lib/hammer_cli_foreman.rb +8 -1
  3. data/lib/hammer_cli_foreman/architecture.rb +10 -21
  4. data/lib/hammer_cli_foreman/associating_commands.rb +179 -0
  5. data/lib/hammer_cli_foreman/commands.rb +163 -6
  6. data/lib/hammer_cli_foreman/common_parameter.rb +4 -5
  7. data/lib/hammer_cli_foreman/compute_resource.rb +10 -16
  8. data/lib/hammer_cli_foreman/domain.rb +8 -12
  9. data/lib/hammer_cli_foreman/environment.rb +3 -9
  10. data/lib/hammer_cli_foreman/exception_handler.rb +3 -3
  11. data/lib/hammer_cli_foreman/fact.rb +42 -0
  12. data/lib/hammer_cli_foreman/host.rb +84 -18
  13. data/lib/hammer_cli_foreman/hostgroup.rb +30 -13
  14. data/lib/hammer_cli_foreman/location.rb +18 -15
  15. data/lib/hammer_cli_foreman/media.rb +11 -18
  16. data/lib/hammer_cli_foreman/model.rb +66 -0
  17. data/lib/hammer_cli_foreman/operating_system.rb +21 -21
  18. data/lib/hammer_cli_foreman/organization.rb +17 -15
  19. data/lib/hammer_cli_foreman/output.rb +2 -0
  20. data/lib/hammer_cli_foreman/output/fields.rb +11 -0
  21. data/lib/hammer_cli_foreman/output/formatters.rb +23 -0
  22. data/lib/hammer_cli_foreman/parameter.rb +24 -10
  23. data/lib/hammer_cli_foreman/partition_table.rb +13 -17
  24. data/lib/hammer_cli_foreman/puppet_class.rb +55 -0
  25. data/lib/hammer_cli_foreman/report.rb +97 -0
  26. data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
  27. data/lib/hammer_cli_foreman/smart_proxy.rb +5 -11
  28. data/lib/hammer_cli_foreman/subnet.rb +5 -11
  29. data/lib/hammer_cli_foreman/template.rb +15 -19
  30. data/lib/hammer_cli_foreman/user.rb +12 -15
  31. data/lib/hammer_cli_foreman/version.rb +1 -1
  32. metadata +25 -29
@@ -1,17 +1,18 @@
1
1
  require 'hammer_cli'
2
2
  require 'foreman_api'
3
3
  require 'hammer_cli_foreman/commands'
4
+ require 'hammer_cli_foreman/associating_commands'
4
5
  require 'hammer_cli_foreman/resource_supported_test'
5
6
 
6
7
  module HammerCLIForeman
7
8
 
8
- class Location < HammerCLI::AbstractCommand
9
+ class Location < HammerCLI::Apipie::Command
10
+
11
+ resource ForemanApi::Resources::Location
9
12
 
10
13
  class ListCommand < HammerCLIForeman::ListCommand
11
14
  include HammerCLIForeman::ResourceSupportedTest
12
- resource ForemanApi::Resources::Location, "index"
13
15
 
14
- heading "Locations"
15
16
  output do
16
17
  from "location" do
17
18
  field :id, "Id"
@@ -25,13 +26,11 @@ module HammerCLIForeman
25
26
 
26
27
  class InfoCommand < HammerCLIForeman::InfoCommand
27
28
  include HammerCLIForeman::ResourceSupportedTest
28
- resource ForemanApi::Resources::Location, "show"
29
29
 
30
- heading "Location info"
31
30
  output ListCommand.output_definition do
32
31
  from "location" do
33
- field :created_at, "Created at", HammerCLI::Output::Fields::Date
34
- field :updated_at, "Updated at", HammerCLI::Output::Fields::Date
32
+ field :created_at, "Created at", Fields::Date
33
+ field :updated_at, "Updated at", Fields::Date
35
34
  end
36
35
  end
37
36
 
@@ -43,7 +42,6 @@ module HammerCLIForeman
43
42
 
44
43
  success_message "Location created"
45
44
  failure_message "Could not create the location"
46
- resource ForemanApi::Resources::Location, "create"
47
45
 
48
46
  apipie_options
49
47
  end
@@ -54,7 +52,6 @@ module HammerCLIForeman
54
52
 
55
53
  success_message "Location updated"
56
54
  failure_message "Could not update the location"
57
- resource ForemanApi::Resources::Location, "update"
58
55
 
59
56
  apipie_options
60
57
  end
@@ -65,16 +62,22 @@ module HammerCLIForeman
65
62
 
66
63
  success_message "Location deleted"
67
64
  failure_message "Could not delete the location"
68
- resource ForemanApi::Resources::Location, "destroy"
69
65
 
70
66
  apipie_options
71
67
  end
72
68
 
73
- subcommand "list", "List locations.", HammerCLIForeman::Location::ListCommand
74
- subcommand "info", "Detailed info about an location.", HammerCLIForeman::Location::InfoCommand
75
- subcommand "create", "Create new location.", HammerCLIForeman::Location::CreateCommand
76
- subcommand "update", "Update an location.", HammerCLIForeman::Location::UpdateCommand
77
- subcommand "delete", "Delete an location.", HammerCLIForeman::Location::DeleteCommand
69
+ include HammerCLIForeman::AssociatingCommands::Hostgroup
70
+ include HammerCLIForeman::AssociatingCommands::Environment
71
+ include HammerCLIForeman::AssociatingCommands::Domain
72
+ include HammerCLIForeman::AssociatingCommands::Medium
73
+ include HammerCLIForeman::AssociatingCommands::Subnet
74
+ include HammerCLIForeman::AssociatingCommands::ComputeResource
75
+ include HammerCLIForeman::AssociatingCommands::SmartProxy
76
+ include HammerCLIForeman::AssociatingCommands::User
77
+ include HammerCLIForeman::AssociatingCommands::ConfigTemplate
78
+ include HammerCLIForeman::AssociatingCommands::Organization
79
+
80
+ autoload_subcommands
78
81
  end
79
82
 
80
83
  end
@@ -1,15 +1,15 @@
1
1
  require 'hammer_cli'
2
2
  require 'foreman_api'
3
3
  require 'hammer_cli_foreman/commands'
4
+ require 'hammer_cli_foreman/associating_commands'
4
5
 
5
6
  module HammerCLIForeman
6
7
 
7
- class Medium < HammerCLI::AbstractCommand
8
+ class Medium < HammerCLI::Apipie::Command
8
9
 
9
- class ListCommand < HammerCLIForeman::ListCommand
10
- resource ForemanApi::Resources::Medium, "index"
10
+ resource ForemanApi::Resources::Medium
11
11
 
12
- heading "Installation Media"
12
+ class ListCommand < HammerCLIForeman::ListCommand
13
13
  output do
14
14
  from "medium" do
15
15
  field :id, "Id"
@@ -23,15 +23,12 @@ module HammerCLIForeman
23
23
 
24
24
 
25
25
  class InfoCommand < HammerCLIForeman::InfoCommand
26
- resource ForemanApi::Resources::Medium, "show"
27
-
28
- heading "Medium info"
29
26
  output ListCommand.output_definition do
30
27
  from "medium" do
31
28
  field :os_family, "OS Family"
32
- field :operatingsystem_ids, "OS IDs"
33
- field :created_at, "Created at", HammerCLI::Output::Fields::Date
34
- field :updated_at, "Updated at", HammerCLI::Output::Fields::Date
29
+ field :operatingsystem_ids, "OS IDs", Fields::List
30
+ field :created_at, "Created at", Fields::Date
31
+ field :updated_at, "Updated at", Fields::Date
35
32
  end
36
33
  end
37
34
 
@@ -42,7 +39,6 @@ module HammerCLIForeman
42
39
 
43
40
  success_message "Installation medium created"
44
41
  failure_message "Could not create the installation medium"
45
- resource ForemanApi::Resources::Medium, "create"
46
42
 
47
43
  apipie_options
48
44
 
@@ -61,7 +57,6 @@ module HammerCLIForeman
61
57
 
62
58
  success_message "Installation medium updated"
63
59
  failure_message "Could not update the installation media"
64
- resource ForemanApi::Resources::Medium, "update"
65
60
 
66
61
  apipie_options
67
62
 
@@ -80,16 +75,14 @@ module HammerCLIForeman
80
75
 
81
76
  success_message "Installation medium deleted"
82
77
  failure_message "Could not delete the installation media"
83
- resource ForemanApi::Resources::Medium, "destroy"
84
78
 
85
79
  apipie_options
86
80
  end
87
81
 
88
- subcommand "list", "List installation media.", HammerCLIForeman::Medium::ListCommand
89
- subcommand "info", "Detailed info about an installation medium.", HammerCLIForeman::Medium::InfoCommand
90
- subcommand "create", "Create new installation medium.", HammerCLIForeman::Medium::CreateCommand
91
- subcommand "update", "Update an installation medium.", HammerCLIForeman::Medium::UpdateCommand
92
- subcommand "delete", "Delete an installation medium.", HammerCLIForeman::Medium::DeleteCommand
82
+
83
+ include HammerCLIForeman::AssociatingCommands::OperatingSystem
84
+
85
+ autoload_subcommands
93
86
  end
94
87
 
95
88
  end
@@ -0,0 +1,66 @@
1
+ require 'hammer_cli'
2
+ require 'foreman_api'
3
+ require 'hammer_cli_foreman/commands'
4
+
5
+ module HammerCLIForeman
6
+
7
+ class Model < HammerCLI::Apipie::Command
8
+
9
+ resource ForemanApi::Resources::Model
10
+
11
+ class ListCommand < HammerCLIForeman::ListCommand
12
+
13
+ output do
14
+ from "model" do
15
+ field :id, "Id"
16
+ field :name, "Name"
17
+ field :vendor_class, "Vendor class"
18
+ field :hardware_model, "HW model"
19
+ end
20
+ end
21
+
22
+ apipie_options
23
+ end
24
+
25
+
26
+ class InfoCommand < HammerCLIForeman::InfoCommand
27
+
28
+ output ListCommand.output_definition do
29
+ from "model" do
30
+ field :info, "Info"
31
+ field :created_at, "Created at", Fields::Date
32
+ field :updated_at, "Updated at", Fields::Date
33
+ end
34
+ end
35
+
36
+ end
37
+
38
+
39
+ class CreateCommand < HammerCLIForeman::CreateCommand
40
+ success_message "Hardware model created"
41
+ failure_message "Could not create the hardware model"
42
+
43
+ apipie_options
44
+ end
45
+
46
+ class DeleteCommand < HammerCLIForeman::DeleteCommand
47
+ success_message "Hardware model deleted"
48
+ failure_message "Could not delete the hardware model"
49
+ end
50
+
51
+
52
+ class UpdateCommand < HammerCLIForeman::UpdateCommand
53
+ success_message "Hardware model updated"
54
+ failure_message "Could not update the hardware model"
55
+
56
+ apipie_options
57
+ end
58
+
59
+
60
+ autoload_subcommands
61
+ end
62
+
63
+ end
64
+
65
+ HammerCLI::MainCommand.subcommand 'model', "Manipulate Foreman's hardware models.", HammerCLIForeman::Model
66
+
@@ -1,20 +1,21 @@
1
1
  require 'hammer_cli'
2
2
  require 'foreman_api'
3
3
  require 'hammer_cli_foreman/commands'
4
+ require 'hammer_cli_foreman/associating_commands'
4
5
 
5
6
  module HammerCLIForeman
6
7
 
7
- class OperatingSystem < HammerCLI::AbstractCommand
8
+ class OperatingSystem < HammerCLI::Apipie::Command
9
+
10
+ resource ForemanApi::Resources::OperatingSystem
8
11
 
9
12
  class ListCommand < HammerCLIForeman::ListCommand
10
- resource ForemanApi::Resources::OperatingSystem, "index"
11
13
 
12
- heading "Operating systems"
13
14
  output do
14
15
  from "operatingsystem" do
15
16
  field :id, "Id"
16
17
  end
17
- field :operatingsystem, "Name", HammerCLI::Output::Fields::OSName
18
+ field :operatingsystem, "Name", Fields::OSName
18
19
  from "operatingsystem" do
19
20
  field :release_name, "Release name"
20
21
  field :family, "Family"
@@ -26,20 +27,18 @@ module HammerCLIForeman
26
27
 
27
28
 
28
29
  class InfoCommand < HammerCLIForeman::InfoCommand
29
- resource ForemanApi::Resources::OperatingSystem, "show"
30
30
 
31
31
  identifiers :id, :label
32
32
 
33
- heading "Operating system info"
34
33
  output ListCommand.output_definition do
35
34
  from "operatingsystem" do
36
- field :media_names, "Installation media", HammerCLI::Output::Fields::List
37
- field :architecture_names, "Architectures", HammerCLI::Output::Fields::List
38
- field :ptable_names, "Partition tables", HammerCLI::Output::Fields::List
39
- field :config_template_names, "Config templates", HammerCLI::Output::Fields::List
35
+ field :media_names, "Installation media", Fields::List
36
+ field :architecture_names, "Architectures", Fields::List
37
+ field :ptable_names, "Partition tables", Fields::List
38
+ field :config_template_names, "Config templates", Fields::List
40
39
  end
41
40
  collection :parameters, "Parameters" do
42
- field :parameter, nil, HammerCLI::Output::Fields::KeyValue
41
+ field :parameter, nil, Fields::KeyValue
43
42
  end
44
43
  end
45
44
 
@@ -67,7 +66,6 @@ module HammerCLIForeman
67
66
 
68
67
  success_message "Operating system created"
69
68
  failure_message "Could not create the operating system"
70
- resource ForemanApi::Resources::OperatingSystem, "create"
71
69
 
72
70
  def request_params
73
71
  params = method_options
@@ -94,7 +92,6 @@ module HammerCLIForeman
94
92
 
95
93
  success_message "Operating system updated"
96
94
  failure_message "Could not update the operating system"
97
- resource ForemanApi::Resources::OperatingSystem, "update"
98
95
 
99
96
  def request_params
100
97
  params = method_options
@@ -115,13 +112,14 @@ module HammerCLIForeman
115
112
 
116
113
  success_message "Operating system deleted"
117
114
  failure_message "Could not delete the operating system"
118
- resource ForemanApi::Resources::OperatingSystem, "destroy"
119
115
 
120
116
  apipie_options
121
117
  end
122
118
 
123
119
  class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
124
120
 
121
+ desc "Create or update parameter for an operating system."
122
+
125
123
  #FIXME: add option --os-label when api supports it
126
124
  option "--os-id", "OS_ID", "id of the operating system the parameter is being set for"
127
125
 
@@ -144,6 +142,8 @@ module HammerCLIForeman
144
142
 
145
143
  class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
146
144
 
145
+ desc "Delete parameter for an operating system."
146
+
147
147
  #FIXME: add option --os-label when api supports it
148
148
  option "--os-id", "OS_ID", "id of the operating system the parameter is being deleted for"
149
149
  success_message "operating system parameter deleted"
@@ -160,13 +160,13 @@ module HammerCLIForeman
160
160
  end
161
161
  end
162
162
 
163
- subcommand "list", "List operating systems.", HammerCLIForeman::OperatingSystem::ListCommand
164
- subcommand "info", "Detailed info about an operating system.", HammerCLIForeman::OperatingSystem::InfoCommand
165
- subcommand "create", "Create new operating system.", HammerCLIForeman::OperatingSystem::CreateCommand
166
- subcommand "update", "Update an operating system.", HammerCLIForeman::OperatingSystem::UpdateCommand
167
- subcommand "delete", "Delete an operating system.", HammerCLIForeman::OperatingSystem::DeleteCommand
168
- subcommand "set_parameter", "Create or update parameter for an operating system.", HammerCLIForeman::OperatingSystem::SetParameterCommand
169
- subcommand "delete_parameter", "Delete parameter for an operating system.", HammerCLIForeman::OperatingSystem::DeleteParameterCommand
163
+
164
+ include HammerCLIForeman::AssociatingCommands::Architecture
165
+ include HammerCLIForeman::AssociatingCommands::ConfigTemplate
166
+ include HammerCLIForeman::AssociatingCommands::PartitionTable
167
+
168
+
169
+ autoload_subcommands
170
170
  end
171
171
 
172
172
  end
@@ -1,17 +1,18 @@
1
1
  require 'hammer_cli'
2
2
  require 'foreman_api'
3
3
  require 'hammer_cli_foreman/commands'
4
+ require 'hammer_cli_foreman/associating_commands'
4
5
  require 'hammer_cli_foreman/resource_supported_test'
5
6
 
6
7
  module HammerCLIForeman
7
8
 
8
- class Organization < HammerCLI::AbstractCommand
9
+ class Organization < HammerCLI::Apipie::Command
10
+
11
+ resource ForemanApi::Resources::Organization
9
12
 
10
13
  class ListCommand < HammerCLIForeman::ListCommand
11
14
  include HammerCLIForeman::ResourceSupportedTest
12
- resource ForemanApi::Resources::Organization, "index"
13
15
 
14
- heading "Organizations"
15
16
  output do
16
17
  from "organization" do
17
18
  field :id, "Id"
@@ -25,13 +26,11 @@ module HammerCLIForeman
25
26
 
26
27
  class InfoCommand < HammerCLIForeman::InfoCommand
27
28
  include HammerCLIForeman::ResourceSupportedTest
28
- resource ForemanApi::Resources::Organization, "show"
29
29
 
30
- heading "Organization info"
31
30
  output ListCommand.output_definition do
32
31
  from "organization" do
33
- field :created_at, "Created at", HammerCLI::Output::Fields::Date
34
- field :updated_at, "Updated at", HammerCLI::Output::Fields::Date
32
+ field :created_at, "Created at", Fields::Date
33
+ field :updated_at, "Updated at", Fields::Date
35
34
  end
36
35
  end
37
36
 
@@ -43,7 +42,6 @@ module HammerCLIForeman
43
42
 
44
43
  success_message "Organization created"
45
44
  failure_message "Could not create the organization"
46
- resource ForemanApi::Resources::Organization, "create"
47
45
 
48
46
  apipie_options
49
47
  end
@@ -54,7 +52,6 @@ module HammerCLIForeman
54
52
 
55
53
  success_message "Organization updated"
56
54
  failure_message "Could not update the organization"
57
- resource ForemanApi::Resources::Organization, "update"
58
55
 
59
56
  apipie_options
60
57
  end
@@ -65,16 +62,21 @@ module HammerCLIForeman
65
62
 
66
63
  success_message "Organization deleted"
67
64
  failure_message "Could not delete the organization"
68
- resource ForemanApi::Resources::Organization, "destroy"
69
65
 
70
66
  apipie_options
71
67
  end
72
68
 
73
- subcommand "list", "List organizations.", HammerCLIForeman::Organization::ListCommand
74
- subcommand "info", "Detailed info about an organization.", HammerCLIForeman::Organization::InfoCommand
75
- subcommand "create", "Create new organization.", HammerCLIForeman::Organization::CreateCommand
76
- subcommand "update", "Update an organization.", HammerCLIForeman::Organization::UpdateCommand
77
- subcommand "delete", "Delete an organization.", HammerCLIForeman::Organization::DeleteCommand
69
+ include HammerCLIForeman::AssociatingCommands::Hostgroup
70
+ include HammerCLIForeman::AssociatingCommands::Environment
71
+ include HammerCLIForeman::AssociatingCommands::Domain
72
+ include HammerCLIForeman::AssociatingCommands::Medium
73
+ include HammerCLIForeman::AssociatingCommands::Subnet
74
+ include HammerCLIForeman::AssociatingCommands::ComputeResource
75
+ include HammerCLIForeman::AssociatingCommands::SmartProxy
76
+ include HammerCLIForeman::AssociatingCommands::User
77
+ include HammerCLIForeman::AssociatingCommands::ConfigTemplate
78
+
79
+ autoload_subcommands
78
80
  end
79
81
 
80
82
  end
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), 'output/fields')
2
+ require File.join(File.dirname(__FILE__), 'output/formatters')
@@ -0,0 +1,11 @@
1
+ require 'hammer_cli'
2
+
3
+ module Fields
4
+
5
+ class OSName < DataField
6
+ end
7
+
8
+ class Server < DataField
9
+ end
10
+
11
+ end
@@ -0,0 +1,23 @@
1
+ module HammerCLIForeman::Output
2
+ module Formatters
3
+
4
+ class OSNameFormatter < HammerCLI::Output::Formatters::FieldFormatter
5
+ def format(os)
6
+ name = "%s %s" % [os[:name], os[:major]]
7
+ name += ".%s" % os[:minor] unless os[:minor].nil?
8
+ name
9
+ end
10
+ end
11
+
12
+ class ServerFormatter < HammerCLI::Output::Formatters::FieldFormatter
13
+ def format(server)
14
+ "%s (%s)" % [server[:name], server[:url]]
15
+ end
16
+ end
17
+
18
+ DEFAULT_FORMATTERS = HammerCLI::Output::Formatters::DEFAULT_FORMATTERS
19
+ DEFAULT_FORMATTERS.register_formatter(:OSName, OSNameFormatter.new)
20
+ DEFAULT_FORMATTERS.register_formatter(:Server, ServerFormatter.new)
21
+
22
+ end
23
+ end