hammer_cli_foreman 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of hammer_cli_foreman might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/hammer_cli_foreman.rb +8 -1
- data/lib/hammer_cli_foreman/architecture.rb +10 -21
- data/lib/hammer_cli_foreman/associating_commands.rb +179 -0
- data/lib/hammer_cli_foreman/commands.rb +163 -6
- data/lib/hammer_cli_foreman/common_parameter.rb +4 -5
- data/lib/hammer_cli_foreman/compute_resource.rb +10 -16
- data/lib/hammer_cli_foreman/domain.rb +8 -12
- data/lib/hammer_cli_foreman/environment.rb +3 -9
- data/lib/hammer_cli_foreman/exception_handler.rb +3 -3
- data/lib/hammer_cli_foreman/fact.rb +42 -0
- data/lib/hammer_cli_foreman/host.rb +84 -18
- data/lib/hammer_cli_foreman/hostgroup.rb +30 -13
- data/lib/hammer_cli_foreman/location.rb +18 -15
- data/lib/hammer_cli_foreman/media.rb +11 -18
- data/lib/hammer_cli_foreman/model.rb +66 -0
- data/lib/hammer_cli_foreman/operating_system.rb +21 -21
- data/lib/hammer_cli_foreman/organization.rb +17 -15
- data/lib/hammer_cli_foreman/output.rb +2 -0
- data/lib/hammer_cli_foreman/output/fields.rb +11 -0
- data/lib/hammer_cli_foreman/output/formatters.rb +23 -0
- data/lib/hammer_cli_foreman/parameter.rb +24 -10
- data/lib/hammer_cli_foreman/partition_table.rb +13 -17
- data/lib/hammer_cli_foreman/puppet_class.rb +55 -0
- data/lib/hammer_cli_foreman/report.rb +97 -0
- data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
- data/lib/hammer_cli_foreman/smart_proxy.rb +5 -11
- data/lib/hammer_cli_foreman/subnet.rb +5 -11
- data/lib/hammer_cli_foreman/template.rb +15 -19
- data/lib/hammer_cli_foreman/user.rb +12 -15
- data/lib/hammer_cli_foreman/version.rb +1 -1
- 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::
|
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",
|
34
|
-
field :updated_at, "Updated at",
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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::
|
8
|
+
class Medium < HammerCLI::Apipie::Command
|
8
9
|
|
9
|
-
|
10
|
-
resource ForemanApi::Resources::Medium, "index"
|
10
|
+
resource ForemanApi::Resources::Medium
|
11
11
|
|
12
|
-
|
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",
|
34
|
-
field :updated_at, "Updated at",
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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::
|
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",
|
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",
|
37
|
-
field :architecture_names, "Architectures",
|
38
|
-
field :ptable_names, "Partition tables",
|
39
|
-
field :config_template_names, "Config templates",
|
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,
|
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
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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::
|
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",
|
34
|
-
field :updated_at, "Updated at",
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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,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
|