hammer_cli_foreman 0.0.11 → 0.0.12
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.
- checksums.yaml +4 -4
- data/lib/hammer_cli_foreman/architecture.rb +5 -9
- data/lib/hammer_cli_foreman/commands.rb +55 -0
- data/lib/hammer_cli_foreman/common_parameter.rb +2 -4
- data/lib/hammer_cli_foreman/compute_resource.rb +10 -14
- data/lib/hammer_cli_foreman/domain.rb +16 -17
- data/lib/hammer_cli_foreman/environment.rb +6 -10
- data/lib/hammer_cli_foreman/fact.rb +6 -8
- data/lib/hammer_cli_foreman/host.rb +59 -60
- data/lib/hammer_cli_foreman/hostgroup.rb +17 -16
- data/lib/hammer_cli_foreman/image.rb +11 -17
- data/lib/hammer_cli_foreman/location.rb +4 -8
- data/lib/hammer_cli_foreman/media.rb +7 -29
- data/lib/hammer_cli_foreman/model.rb +7 -11
- data/lib/hammer_cli_foreman/operating_system.rb +25 -22
- data/lib/hammer_cli_foreman/organization.rb +4 -8
- data/lib/hammer_cli_foreman/output/formatters.rb +3 -2
- data/lib/hammer_cli_foreman/parameter.rb +8 -9
- data/lib/hammer_cli_foreman/partition_table.rb +6 -10
- data/lib/hammer_cli_foreman/puppet_class.rb +12 -13
- data/lib/hammer_cli_foreman/report.rb +43 -47
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +6 -7
- data/lib/hammer_cli_foreman/smart_proxy.rb +11 -17
- data/lib/hammer_cli_foreman/subnet.rb +17 -21
- data/lib/hammer_cli_foreman/template.rb +27 -32
- data/lib/hammer_cli_foreman/user.rb +19 -27
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/test/unit/commands_test.rb +79 -0
- data/test/unit/output/formatters_test.rb +10 -0
- data/test/unit/test_output_adapter.rb +6 -1
- metadata +7 -5
@@ -11,17 +11,15 @@ module HammerCLIForeman
|
|
11
11
|
resource ForemanApi::Resources::Hostgroup, "index"
|
12
12
|
|
13
13
|
output do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
field :ancestry, "Ancestry"
|
24
|
-
end
|
14
|
+
field :id, "Id"
|
15
|
+
field :name, "Name"
|
16
|
+
field :label, "Label"
|
17
|
+
field :operatingsystem_id, "Operating System Id"
|
18
|
+
field :subnet_id, "Subnet Id"
|
19
|
+
field :domain_id, "Domain Id"
|
20
|
+
field :environment_id, "Environment Id"
|
21
|
+
field :puppetclass_ids, "Puppetclass Ids", Fields::List
|
22
|
+
field :ancestry, "Ancestry"
|
25
23
|
end
|
26
24
|
|
27
25
|
apipie_options
|
@@ -35,13 +33,12 @@ module HammerCLIForeman
|
|
35
33
|
|
36
34
|
output ListCommand.output_definition do
|
37
35
|
collection :parameters, "Parameters" do
|
38
|
-
field
|
36
|
+
field nil, nil, Fields::KeyValue
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
|
-
def
|
43
|
-
hostgroup =
|
44
|
-
hostgroup["parameters"] = HammerCLIForeman::Parameter.get_parameters resource_config, hostgroup
|
40
|
+
def extend_data(hostgroup)
|
41
|
+
hostgroup["parameters"] = HammerCLIForeman::Parameter.get_parameters(resource_config, :hostgroup, hostgroup)
|
45
42
|
hostgroup
|
46
43
|
end
|
47
44
|
|
@@ -107,6 +104,8 @@ module HammerCLIForeman
|
|
107
104
|
|
108
105
|
class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
|
109
106
|
|
107
|
+
resource ForemanApi::Resources::Parameter
|
108
|
+
|
110
109
|
desc "Create or update parameter for a hostgroup."
|
111
110
|
|
112
111
|
option "--hostgroup-id", "HOSTGROUP_ID", "id of the hostgroup the parameter is being set for", :required => true
|
@@ -125,6 +124,8 @@ module HammerCLIForeman
|
|
125
124
|
|
126
125
|
class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
|
127
126
|
|
127
|
+
resource ForemanApi::Resources::Parameter
|
128
|
+
|
128
129
|
desc "Delete parameter for a hostgroup."
|
129
130
|
|
130
131
|
option "--hostgroup-id", "HOSTGROUP_ID", "id of the hostgroup the parameter is being deleted for", :required => true
|
@@ -142,7 +143,7 @@ module HammerCLIForeman
|
|
142
143
|
class SCParamsCommand < HammerCLIForeman::SmartClassParametersList
|
143
144
|
|
144
145
|
apipie_options :without => [:host_id, :hostgroup_id, :puppetclass_id, :environment_id]
|
145
|
-
option ['--id', '--name'], 'HOSTGROUP_ID', 'hostgroup id/name',
|
146
|
+
option ['--id', '--name'], 'HOSTGROUP_ID', 'hostgroup id/name',
|
146
147
|
:attribute_name => :hostgroup_id, :required => true
|
147
148
|
end
|
148
149
|
|
@@ -32,13 +32,11 @@ module HammerCLIForeman
|
|
32
32
|
include HammerCLIForeman::Image::ComputeResourceOptions
|
33
33
|
|
34
34
|
output do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
field :uuid, "UUID"
|
41
|
-
end
|
35
|
+
field :id, "Id"
|
36
|
+
field :name, "Name"
|
37
|
+
field :operatingsystem_id, "Operating System Id", Fields::Id
|
38
|
+
field :username, "Username"
|
39
|
+
field :uuid, "UUID"
|
42
40
|
end
|
43
41
|
|
44
42
|
def request_params
|
@@ -57,12 +55,10 @@ module HammerCLIForeman
|
|
57
55
|
identifiers :id
|
58
56
|
|
59
57
|
output ListCommand.output_definition do
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
field :updated_at, "Updated at", Fields::Date
|
65
|
-
end
|
58
|
+
field :architecture_id, "Architecture Id", Fields::Id
|
59
|
+
field :iam_role, "IAM role"
|
60
|
+
field :created_at, "Created at", Fields::Date
|
61
|
+
field :updated_at, "Updated at", Fields::Date
|
66
62
|
end
|
67
63
|
|
68
64
|
def request_params
|
@@ -83,10 +79,8 @@ module HammerCLIForeman
|
|
83
79
|
include HammerCLIForeman::Image::ComputeResourceOptions
|
84
80
|
|
85
81
|
output do
|
86
|
-
|
87
|
-
|
88
|
-
field :uuid, "UUID"
|
89
|
-
end
|
82
|
+
field :name, "Name"
|
83
|
+
field :uuid, "UUID"
|
90
84
|
end
|
91
85
|
|
92
86
|
def request_params
|
@@ -14,10 +14,8 @@ module HammerCLIForeman
|
|
14
14
|
include HammerCLIForeman::ResourceSupportedTest
|
15
15
|
|
16
16
|
output do
|
17
|
-
|
18
|
-
|
19
|
-
field :name, "Name"
|
20
|
-
end
|
17
|
+
field :id, "Id"
|
18
|
+
field :name, "Name"
|
21
19
|
end
|
22
20
|
|
23
21
|
apipie_options
|
@@ -28,10 +26,8 @@ module HammerCLIForeman
|
|
28
26
|
include HammerCLIForeman::ResourceSupportedTest
|
29
27
|
|
30
28
|
output ListCommand.output_definition do
|
31
|
-
|
32
|
-
|
33
|
-
field :updated_at, "Updated at", Fields::Date
|
34
|
-
end
|
29
|
+
field :created_at, "Created at", Fields::Date
|
30
|
+
field :updated_at, "Updated at", Fields::Date
|
35
31
|
end
|
36
32
|
|
37
33
|
end
|
@@ -11,11 +11,9 @@ module HammerCLIForeman
|
|
11
11
|
|
12
12
|
class ListCommand < HammerCLIForeman::ListCommand
|
13
13
|
output do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
field :path, "Path"
|
18
|
-
end
|
14
|
+
field :id, "Id"
|
15
|
+
field :name, "Name"
|
16
|
+
field :path, "Path"
|
19
17
|
end
|
20
18
|
|
21
19
|
apipie_options
|
@@ -24,12 +22,10 @@ module HammerCLIForeman
|
|
24
22
|
|
25
23
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
26
24
|
output ListCommand.output_definition do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
field :updated_at, "Updated at", Fields::Date
|
32
|
-
end
|
25
|
+
field :os_family, "OS Family"
|
26
|
+
field :operatingsystem_ids, "OS IDs", Fields::List
|
27
|
+
field :created_at, "Created at", Fields::Date
|
28
|
+
field :updated_at, "Updated at", Fields::Date
|
33
29
|
end
|
34
30
|
|
35
31
|
end
|
@@ -42,15 +38,6 @@ module HammerCLIForeman
|
|
42
38
|
|
43
39
|
apipie_options
|
44
40
|
|
45
|
-
#FIXME: remove OS ids option and custom request_params once it's added to foreman's apipie docs
|
46
|
-
option "--operatingsystem-ids", "OSIDS", "os ids",
|
47
|
-
:format => HammerCLI::Options::Normalizers::List.new
|
48
|
-
|
49
|
-
def request_params
|
50
|
-
params = super
|
51
|
-
params['medium']['operatingsystem_ids'] = operatingsystem_ids
|
52
|
-
params
|
53
|
-
end
|
54
41
|
end
|
55
42
|
|
56
43
|
|
@@ -61,15 +48,6 @@ module HammerCLIForeman
|
|
61
48
|
|
62
49
|
apipie_options
|
63
50
|
|
64
|
-
#FIXME: remove OS ids option and custom request_params once it's added to foreman's apipie docs
|
65
|
-
option "--operatingsystem-ids", "OSIDS", "os ids",
|
66
|
-
:format => HammerCLI::Options::Normalizers::List.new
|
67
|
-
|
68
|
-
def request_params
|
69
|
-
params = super
|
70
|
-
params['medium']['operatingsystem_ids'] = operatingsystem_ids
|
71
|
-
params
|
72
|
-
end
|
73
51
|
end
|
74
52
|
|
75
53
|
|
@@ -11,12 +11,10 @@ module HammerCLIForeman
|
|
11
11
|
class ListCommand < HammerCLIForeman::ListCommand
|
12
12
|
|
13
13
|
output do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
field :hardware_model, "HW model"
|
19
|
-
end
|
14
|
+
field :id, "Id"
|
15
|
+
field :name, "Name"
|
16
|
+
field :vendor_class, "Vendor class"
|
17
|
+
field :hardware_model, "HW model"
|
20
18
|
end
|
21
19
|
|
22
20
|
apipie_options
|
@@ -26,11 +24,9 @@ module HammerCLIForeman
|
|
26
24
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
27
25
|
|
28
26
|
output ListCommand.output_definition do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
field :updated_at, "Updated at", Fields::Date
|
33
|
-
end
|
27
|
+
field :info, "Info"
|
28
|
+
field :created_at, "Created at", Fields::Date
|
29
|
+
field :updated_at, "Updated at", Fields::Date
|
34
30
|
end
|
35
31
|
|
36
32
|
end
|
@@ -12,14 +12,15 @@ module HammerCLIForeman
|
|
12
12
|
class ListCommand < HammerCLIForeman::ListCommand
|
13
13
|
|
14
14
|
output do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
field :
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
field :id, "Id"
|
16
|
+
field :_os_name, "Name", Fields::OSName
|
17
|
+
field :release_name, "Release name"
|
18
|
+
field :family, "Family"
|
19
|
+
end
|
20
|
+
|
21
|
+
def extend_data(os)
|
22
|
+
os["_os_name"] = os.select { |k, v| ["name", "major", "minor"].include? k }
|
23
|
+
os
|
23
24
|
end
|
24
25
|
|
25
26
|
apipie_options
|
@@ -31,25 +32,23 @@ module HammerCLIForeman
|
|
31
32
|
identifiers :id, :label
|
32
33
|
|
33
34
|
output ListCommand.output_definition do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
field :config_template_names, "Config templates", Fields::List
|
39
|
-
end
|
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
|
collection :parameters, "Parameters" do
|
41
|
-
field
|
40
|
+
field nil, nil, Fields::KeyValue
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
44
|
#FIXME: remove custom retrieve_data after the api has support for listing names
|
46
|
-
def
|
47
|
-
os =
|
48
|
-
os["
|
49
|
-
os["
|
50
|
-
os["
|
51
|
-
os["
|
52
|
-
os["parameters"] = HammerCLIForeman::Parameter.get_parameters
|
45
|
+
def extend_data(os)
|
46
|
+
os["_os_name"] = os.select { |k, v| ["name", "major", "minor"].include? k }
|
47
|
+
os["media_names"] = os["media"].collect{|m| m["medium"]["name"] } rescue []
|
48
|
+
os["architecture_names"] = os["architectures"].collect{|m| m["architecture"]["name"] } rescue []
|
49
|
+
os["ptable_names"] = os["ptables"].collect{|m| m["ptable"]["name"] } rescue []
|
50
|
+
os["config_template_names"] = os["config_templates"].collect{|m| m["config_template"]["name"] } rescue []
|
51
|
+
os["parameters"] = HammerCLIForeman::Parameter.get_parameters(resource_config, :operatingsystem, os)
|
53
52
|
os
|
54
53
|
end
|
55
54
|
|
@@ -126,6 +125,8 @@ module HammerCLIForeman
|
|
126
125
|
|
127
126
|
class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
|
128
127
|
|
128
|
+
resource ForemanApi::Resources::Parameter
|
129
|
+
|
129
130
|
desc "Create or update parameter for an operating system."
|
130
131
|
|
131
132
|
#FIXME: add option --os-label when api supports it
|
@@ -150,6 +151,8 @@ module HammerCLIForeman
|
|
150
151
|
|
151
152
|
class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
|
152
153
|
|
154
|
+
resource ForemanApi::Resources::Parameter
|
155
|
+
|
153
156
|
desc "Delete parameter for an operating system."
|
154
157
|
|
155
158
|
#FIXME: add option --os-label when api supports it
|
@@ -14,10 +14,8 @@ module HammerCLIForeman
|
|
14
14
|
include HammerCLIForeman::ResourceSupportedTest
|
15
15
|
|
16
16
|
output do
|
17
|
-
|
18
|
-
|
19
|
-
field :name, "Name"
|
20
|
-
end
|
17
|
+
field :id, "Id"
|
18
|
+
field :name, "Name"
|
21
19
|
end
|
22
20
|
|
23
21
|
apipie_options
|
@@ -28,10 +26,8 @@ module HammerCLIForeman
|
|
28
26
|
include HammerCLIForeman::ResourceSupportedTest
|
29
27
|
|
30
28
|
output ListCommand.output_definition do
|
31
|
-
|
32
|
-
|
33
|
-
field :updated_at, "Updated at", Fields::Date
|
34
|
-
end
|
29
|
+
field :created_at, "Created at", Fields::Date
|
30
|
+
field :updated_at, "Updated at", Fields::Date
|
35
31
|
end
|
36
32
|
|
37
33
|
end
|
@@ -8,6 +8,7 @@ module HammerCLIForeman::Output
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def format(os)
|
11
|
+
return nil if os.nil?
|
11
12
|
name = "%s %s" % [os[:name], os[:major]]
|
12
13
|
name += ".%s" % os[:minor] unless (!os.has_key?(:minor) || os[:minor].empty?)
|
13
14
|
name
|
@@ -15,13 +16,13 @@ module HammerCLIForeman::Output
|
|
15
16
|
end
|
16
17
|
|
17
18
|
class ServerFormatter < HammerCLI::Output::Formatters::FieldFormatter
|
18
|
-
|
19
|
+
|
19
20
|
def tags
|
20
21
|
[:flat]
|
21
22
|
end
|
22
23
|
|
23
24
|
def format(server)
|
24
|
-
"%s (%s)" % [server[:name], server[:url]]
|
25
|
+
"%s (%s)" % [server[:name], server[:url]] unless server.nil?
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -6,14 +6,13 @@ module HammerCLIForeman
|
|
6
6
|
|
7
7
|
module Parameter
|
8
8
|
|
9
|
-
def self.get_parameters(resource_config, resource)
|
10
|
-
resource_type = resource.keys.first
|
11
|
-
resource = resource[resource_type]
|
9
|
+
def self.get_parameters(resource_config, resource_type, resource)
|
12
10
|
params = {
|
13
11
|
resource_type.to_s+"_id" => resource["id"] || resource["name"]
|
14
12
|
}
|
15
13
|
|
16
|
-
ForemanApi::Resources::Parameter.new(resource_config).index(params)[0]
|
14
|
+
params = ForemanApi::Resources::Parameter.new(resource_config).index(params)[0]
|
15
|
+
HammerCLIForeman.collection_to_common_format(params)
|
17
16
|
end
|
18
17
|
|
19
18
|
class SetCommand < HammerCLI::Apipie::Command
|
@@ -47,8 +46,8 @@ module HammerCLIForeman
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def parameter_exist?
|
50
|
-
params = resource.call(:index, base_action_params)[0]
|
51
|
-
params.find { |p| p["
|
49
|
+
params = HammerCLIForeman.collection_to_common_format(resource.call(:index, base_action_params)[0])
|
50
|
+
params.find { |p| p["name"] == name }
|
52
51
|
end
|
53
52
|
|
54
53
|
def update_parameter
|
@@ -59,7 +58,7 @@ module HammerCLIForeman
|
|
59
58
|
}
|
60
59
|
}.merge base_action_params
|
61
60
|
|
62
|
-
resource.call(:update, params)
|
61
|
+
HammerCLIForeman.record_to_common_format(resource.call(:update, params))
|
63
62
|
end
|
64
63
|
|
65
64
|
def create_parameter
|
@@ -70,7 +69,7 @@ module HammerCLIForeman
|
|
70
69
|
}
|
71
70
|
}.merge base_action_params
|
72
71
|
|
73
|
-
resource.call(:create, params)
|
72
|
+
HammerCLIForeman.record_to_common_format(resource.call(:create, params))
|
74
73
|
end
|
75
74
|
|
76
75
|
end
|
@@ -95,7 +94,7 @@ module HammerCLIForeman
|
|
95
94
|
"id" => name
|
96
95
|
}.merge base_action_params
|
97
96
|
|
98
|
-
resource.call(:destroy, params)
|
97
|
+
HammerCLIForeman.record_to_common_format(resource.call(:destroy, params))
|
99
98
|
print_message success_message if success_message
|
100
99
|
HammerCLI::EX_OK
|
101
100
|
end
|
@@ -12,11 +12,9 @@ module HammerCLIForeman
|
|
12
12
|
class ListCommand < HammerCLIForeman::ListCommand
|
13
13
|
|
14
14
|
output do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
field :os_family, "OS Family"
|
19
|
-
end
|
15
|
+
field :id, "Id"
|
16
|
+
field :name, "Name"
|
17
|
+
field :os_family, "OS Family"
|
20
18
|
end
|
21
19
|
|
22
20
|
apipie_options
|
@@ -26,10 +24,8 @@ module HammerCLIForeman
|
|
26
24
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
27
25
|
|
28
26
|
output ListCommand.output_definition do
|
29
|
-
|
30
|
-
|
31
|
-
field :updated_at, "Updated at", Fields::Date
|
32
|
-
end
|
27
|
+
field :created_at, "Created at", Fields::Date
|
28
|
+
field :updated_at, "Updated at", Fields::Date
|
33
29
|
end
|
34
30
|
|
35
31
|
end
|
@@ -42,7 +38,7 @@ module HammerCLIForeman
|
|
42
38
|
|
43
39
|
|
44
40
|
def print_data(partition_table)
|
45
|
-
puts partition_table["
|
41
|
+
puts partition_table["layout"]
|
46
42
|
end
|
47
43
|
|
48
44
|
end
|