hammer_cli_foreman 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +12 -1
- data/doc/configuration.md +13 -0
- data/lib/hammer_cli_foreman.rb +3 -0
- data/lib/hammer_cli_foreman/architecture.rb +9 -9
- data/lib/hammer_cli_foreman/associating_commands.rb +57 -34
- data/lib/hammer_cli_foreman/commands.rb +188 -101
- data/lib/hammer_cli_foreman/common_parameter.rb +7 -10
- data/lib/hammer_cli_foreman/compute_resource.rb +8 -11
- data/lib/hammer_cli_foreman/domain.rb +14 -40
- data/lib/hammer_cli_foreman/environment.rb +10 -15
- data/lib/hammer_cli_foreman/exceptions.rb +4 -0
- data/lib/hammer_cli_foreman/fact.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +76 -132
- data/lib/hammer_cli_foreman/hostgroup.rb +26 -61
- data/lib/hammer_cli_foreman/id_resolver.rb +163 -0
- data/lib/hammer_cli_foreman/image.rb +14 -50
- data/lib/hammer_cli_foreman/location.rb +35 -17
- data/lib/hammer_cli_foreman/media.rb +9 -16
- data/lib/hammer_cli_foreman/model.rb +6 -8
- data/lib/hammer_cli_foreman/operating_system.rb +129 -63
- data/lib/hammer_cli_foreman/organization.rb +36 -16
- data/lib/hammer_cli_foreman/output/fields.rb +10 -2
- data/lib/hammer_cli_foreman/output/formatters.rb +44 -18
- data/lib/hammer_cli_foreman/parameter.rb +45 -41
- data/lib/hammer_cli_foreman/partition_table.rb +9 -12
- data/lib/hammer_cli_foreman/puppet_class.rb +14 -14
- data/lib/hammer_cli_foreman/references.rb +122 -0
- data/lib/hammer_cli_foreman/report.rb +3 -6
- data/lib/hammer_cli_foreman/searchables_option_builder.rb +99 -0
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +17 -13
- data/lib/hammer_cli_foreman/smart_proxy.rb +18 -28
- data/lib/hammer_cli_foreman/subnet.rb +12 -13
- data/lib/hammer_cli_foreman/template.rb +10 -19
- data/lib/hammer_cli_foreman/user.rb +9 -28
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/hammer-cli-foreman.pot +828 -817
- data/test/unit/apipie_resource_mock.rb +33 -11
- data/test/unit/architecture_test.rb +7 -10
- data/test/unit/commands_test.rb +8 -9
- data/test/unit/common_parameter_test.rb +6 -8
- data/test/unit/compute_resource_test.rb +9 -12
- data/test/unit/data/1.5/foreman_api.json +14130 -0
- data/test/unit/domain_test.rb +19 -22
- data/test/unit/environment_test.rb +9 -11
- data/test/unit/fact_test.rb +5 -6
- data/test/unit/helpers/command.rb +115 -59
- data/test/unit/helpers/fake_searchables.rb +19 -0
- data/test/unit/host_test.rb +44 -33
- data/test/unit/hostgroup_test.rb +19 -26
- data/test/unit/id_resolver_test.rb +225 -0
- data/test/unit/image_test.rb +16 -18
- data/test/unit/location_test.rb +8 -10
- data/test/unit/media_test.rb +11 -13
- data/test/unit/model_test.rb +8 -10
- data/test/unit/operating_system_test.rb +23 -23
- data/test/unit/organization_test.rb +9 -10
- data/test/unit/output/formatters_test.rb +133 -20
- data/test/unit/partition_table_test.rb +12 -9
- data/test/unit/puppet_class_test.rb +3 -7
- data/test/unit/report_test.rb +3 -7
- data/test/unit/searchables_option_builder_test.rb +172 -0
- data/test/unit/smart_class_parameter_test.rb +5 -7
- data/test/unit/smart_proxy_test.rb +11 -12
- data/test/unit/subnet_test.rb +15 -16
- data/test/unit/template_test.rb +15 -12
- data/test/unit/test_helper.rb +1 -1
- data/test/unit/user_test.rb +9 -12
- metadata +536 -509
@@ -13,16 +13,16 @@ module HammerCLIForeman
|
|
13
13
|
field :value, _("Value")
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
build_options
|
17
17
|
end
|
18
18
|
|
19
|
-
class SetCommand < HammerCLIForeman::
|
19
|
+
class SetCommand < HammerCLIForeman::Command
|
20
20
|
|
21
21
|
command_name "set"
|
22
22
|
desc _("Set a global parameter.")
|
23
23
|
|
24
|
-
success_message_for :create, _("Created parameter [%{name}
|
25
|
-
success_message_for :update, _("Parameter [%{name}
|
24
|
+
success_message_for :create, _("Created parameter [%{name}] with value [%{value}].")
|
25
|
+
success_message_for :update, _("Parameter [%{name}] updated to [%{value}].")
|
26
26
|
|
27
27
|
option "--name", "NAME", _("parameter name"), :required => true
|
28
28
|
option "--value", "VALUE", _("parameter value"), :required => true
|
@@ -52,13 +52,10 @@ module HammerCLIForeman
|
|
52
52
|
|
53
53
|
|
54
54
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
55
|
+
success_message _("Global parameter [%{name}] deleted.")
|
56
|
+
failure_message _("Could not delete the global parameter [%{name}]")
|
55
57
|
|
56
|
-
|
57
|
-
|
58
|
-
success_message _("Global parameter [%{name}s] deleted.")
|
59
|
-
failure_message _("Could not delete the global parameter [%{name}s]")
|
60
|
-
|
61
|
-
apipie_options :without => :id
|
58
|
+
build_options :without => :id
|
62
59
|
end
|
63
60
|
|
64
61
|
autoload_subcommands
|
@@ -13,12 +13,11 @@ module HammerCLIForeman
|
|
13
13
|
field :provider, _("Provider")
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
build_options
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
20
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
21
|
-
|
22
21
|
PROVIDER_SPECIFIC_FIELDS = {
|
23
22
|
'ovirt' => [
|
24
23
|
Fields::Field.new(:label => _('UUID'), :path => ["compute_resource", "uuid"])
|
@@ -44,17 +43,17 @@ module HammerCLIForeman
|
|
44
43
|
field :url, _("Url")
|
45
44
|
field :description, _("Description")
|
46
45
|
field :user, _("User")
|
47
|
-
|
48
|
-
|
46
|
+
HammerCLIForeman::References.taxonomies(self)
|
47
|
+
HammerCLIForeman::References.timestamps(self)
|
49
48
|
end
|
50
49
|
|
51
50
|
def print_data(data)
|
52
51
|
provider = data["provider"].downcase
|
53
52
|
output_definition.fields.concat PROVIDER_SPECIFIC_FIELDS[provider]
|
54
|
-
|
53
|
+
super(data)
|
55
54
|
end
|
56
55
|
|
57
|
-
|
56
|
+
build_options
|
58
57
|
end
|
59
58
|
|
60
59
|
|
@@ -63,7 +62,7 @@ module HammerCLIForeman
|
|
63
62
|
success_message _("Compute resource created")
|
64
63
|
failure_message _("Could not create the compute resource")
|
65
64
|
|
66
|
-
|
65
|
+
build_options
|
67
66
|
|
68
67
|
validate_options do
|
69
68
|
all(:option_name, :option_url, :option_provider).required
|
@@ -72,20 +71,18 @@ module HammerCLIForeman
|
|
72
71
|
|
73
72
|
|
74
73
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
75
|
-
|
76
74
|
success_message _("Compute resource updated")
|
77
75
|
failure_message _("Could not update the compute resource")
|
78
76
|
|
79
|
-
|
77
|
+
build_options :without => :name
|
80
78
|
end
|
81
79
|
|
82
80
|
|
83
81
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
84
|
-
|
85
82
|
success_message _("Compute resource deleted")
|
86
83
|
failure_message _("Could not delete the compute resource")
|
87
84
|
|
88
|
-
|
85
|
+
build_options
|
89
86
|
end
|
90
87
|
|
91
88
|
|
@@ -11,7 +11,7 @@ module HammerCLIForeman
|
|
11
11
|
field :name, _("Name")
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
build_options
|
15
15
|
end
|
16
16
|
|
17
17
|
|
@@ -20,60 +20,48 @@ module HammerCLIForeman
|
|
20
20
|
output ListCommand.output_definition do
|
21
21
|
field :fullname, _("Description")
|
22
22
|
field :dns_id, _("DNS Id")
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
23
|
+
HammerCLIForeman::References.subnets(self)
|
24
|
+
HammerCLIForeman::References.taxonomies(self)
|
25
|
+
HammerCLIForeman::References.parameters(self)
|
26
|
+
HammerCLIForeman::References.timestamps(self)
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
record["parameters"] = HammerCLIForeman::Parameter.get_parameters(resource_config, :domain, record)
|
32
|
-
record
|
33
|
-
end
|
34
|
-
|
35
|
-
apipie_options
|
29
|
+
build_options
|
36
30
|
end
|
37
31
|
|
38
32
|
|
39
33
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
40
34
|
|
41
|
-
success_message _("Domain [%{name}
|
35
|
+
success_message _("Domain [%{name}] created")
|
42
36
|
failure_message _("Could not create the domain")
|
43
37
|
|
44
|
-
apipie_options :without => [:domain_parameters_attributes, :fullname]
|
45
38
|
option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
|
39
|
+
build_options :without => [:domain_parameters_attributes, :fullname]
|
46
40
|
end
|
47
41
|
|
48
42
|
|
49
43
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
50
44
|
|
51
|
-
success_message _("Domain [%{name}
|
45
|
+
success_message _("Domain [%{name}] updated")
|
52
46
|
failure_message _("Could not update the domain")
|
53
47
|
|
54
|
-
apipie_options :without => [:domain_parameters_attributes, :name, :id, :fullname]
|
55
48
|
option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
|
49
|
+
build_options :without => [:domain_parameters_attributes, :fullname]
|
56
50
|
end
|
57
51
|
|
58
52
|
|
59
53
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
60
54
|
|
61
|
-
success_message _("Domain [%{name}
|
55
|
+
success_message _("Domain [%{name}] deleted")
|
62
56
|
failure_message _("Could not delete the domain")
|
63
57
|
|
64
|
-
|
58
|
+
build_options
|
65
59
|
end
|
66
60
|
|
67
61
|
|
68
62
|
class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
|
69
|
-
|
70
|
-
resource :parameters
|
71
|
-
|
72
63
|
desc _("Create or update parameter for a domain.")
|
73
64
|
|
74
|
-
option "--domain-name", "DOMAIN_NAME", _("name of the domain the parameter is being set for")
|
75
|
-
option "--domain-id", "DOMAIN_ID", _("id of the domain the parameter is being set for")
|
76
|
-
|
77
65
|
success_message_for :update, _("Domain parameter updated")
|
78
66
|
success_message_for :create, _("New domain parameter created")
|
79
67
|
failure_message _("Could not set domain parameter")
|
@@ -83,23 +71,13 @@ module HammerCLIForeman
|
|
83
71
|
validator.any(:option_domain_name, :option_domain_id).required
|
84
72
|
end
|
85
73
|
|
86
|
-
|
87
|
-
{
|
88
|
-
"domain_id" => option_domain_id || option_domain_name
|
89
|
-
}
|
90
|
-
end
|
74
|
+
build_options
|
91
75
|
end
|
92
76
|
|
93
77
|
|
94
78
|
class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
|
95
|
-
|
96
|
-
resource :parameters
|
97
|
-
|
98
79
|
desc _("Delete parameter for a domain.")
|
99
80
|
|
100
|
-
option "--domain-name", "DOMAIN_NAME", _("name of the domain the parameter is being deleted for")
|
101
|
-
option "--domain-id", "DOMAIN_ID", _("id of the domain the parameter is being deleted for")
|
102
|
-
|
103
81
|
success_message _("Domain parameter deleted")
|
104
82
|
|
105
83
|
def validate_options
|
@@ -107,11 +85,7 @@ module HammerCLIForeman
|
|
107
85
|
validator.any(:option_domain_name, :option_domain_id).required
|
108
86
|
end
|
109
87
|
|
110
|
-
|
111
|
-
{
|
112
|
-
"domain_id" => option_domain_id || option_domain_name
|
113
|
-
}
|
114
|
-
end
|
88
|
+
build_options
|
115
89
|
end
|
116
90
|
|
117
91
|
autoload_subcommands
|
@@ -15,52 +15,47 @@ module HammerCLIForeman
|
|
15
15
|
field :name, _("Name")
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
build_options
|
19
19
|
end
|
20
20
|
|
21
21
|
|
22
22
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
23
|
-
|
24
23
|
output ListCommand.output_definition do
|
25
|
-
|
26
|
-
|
24
|
+
HammerCLIForeman::References.puppetclasses(self)
|
25
|
+
HammerCLIForeman::References.taxonomies(self)
|
26
|
+
HammerCLIForeman::References.timestamps(self)
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
build_options
|
30
30
|
end
|
31
31
|
|
32
32
|
|
33
33
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
34
|
-
|
35
34
|
success_message _("Environment created")
|
36
35
|
failure_message _("Could not create the environment")
|
37
36
|
|
38
|
-
|
37
|
+
build_options
|
39
38
|
end
|
40
39
|
|
41
40
|
|
42
41
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
43
|
-
|
44
42
|
success_message _("Environment updated")
|
45
43
|
failure_message _("Could not update the environment")
|
46
44
|
|
47
|
-
|
45
|
+
build_options
|
48
46
|
end
|
49
47
|
|
50
48
|
|
51
49
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
52
|
-
|
53
50
|
success_message _("Environment deleted")
|
54
51
|
failure_message _("Could not delete the environment")
|
55
52
|
|
56
|
-
|
53
|
+
build_options
|
57
54
|
end
|
58
55
|
|
59
56
|
class SCParamsCommand < HammerCLIForeman::SmartClassParametersList
|
60
|
-
|
61
|
-
|
62
|
-
option ['--id', '--name'], 'ENVIRONMENT_ID', _('environment id/name'),
|
63
|
-
:required => true, :attribute_name => :environment_id
|
57
|
+
parent_resource :environments
|
58
|
+
build_options
|
64
59
|
end
|
65
60
|
|
66
61
|
|
@@ -6,7 +6,7 @@ module HammerCLIForeman
|
|
6
6
|
|
7
7
|
resource :fact_values, :index
|
8
8
|
|
9
|
-
|
9
|
+
build_options
|
10
10
|
|
11
11
|
output do
|
12
12
|
field :host, _("Host")
|
@@ -14,17 +14,17 @@ module HammerCLIForeman
|
|
14
14
|
field :value, _("Value")
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def send_request
|
18
18
|
self.class.unhash_facts(super)
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.unhash_facts(
|
22
|
-
facts =
|
21
|
+
def self.unhash_facts(facts_collection)
|
22
|
+
facts = facts_collection.first.inject([]) do |list, (host, facts)|
|
23
23
|
list + facts.collect do |(fact, value)|
|
24
24
|
{ :host => host, :fact => fact, :value => value }
|
25
25
|
end
|
26
26
|
end
|
27
|
-
HammerCLI::Output::RecordCollection.new(facts, :meta =>
|
27
|
+
HammerCLI::Output::RecordCollection.new(facts, :meta => facts_collection.meta)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -9,20 +9,6 @@ module HammerCLIForeman
|
|
9
9
|
module CommonHostUpdateOptions
|
10
10
|
|
11
11
|
def self.included(base)
|
12
|
-
base.apipie_options :without => [:host_parameters_attributes, :environment_id, :architecture_id, :domain_id,
|
13
|
-
:puppet_proxy_id, :operatingsystem_id,
|
14
|
-
# - temporarily disabled params until we add support for boolean options to apipie -
|
15
|
-
:build, :managed, :enabled, :start,
|
16
|
-
# - temporarily disabled params until they are fixed in API
|
17
|
-
:puppet_class_ids, #3884
|
18
|
-
# - temporarily disabled params that will be removed from the api ------------------
|
19
|
-
:provision_method, :capabilities, :flavour_ref, :image_ref, :start,
|
20
|
-
:network, :cpus, :memory, :provider, :type, :tenant_id, :image_id,
|
21
|
-
# - avoids future conflicts as :root_pass is currently missing in the api docs
|
22
|
-
:root_pass,
|
23
|
-
# ----------------------------------------------------------------------------------
|
24
|
-
:compute_resource_id, :ptable_id] + base.declared_identifiers.keys
|
25
|
-
|
26
12
|
base.option "--environment-id", "ENVIRONMENT_ID", " "
|
27
13
|
base.option "--architecture-id", "ARCHITECTURE_ID", " "
|
28
14
|
base.option "--domain-id", "DOMAIN_ID", " "
|
@@ -30,7 +16,6 @@ module HammerCLIForeman
|
|
30
16
|
base.option "--operatingsystem-id", "OPERATINGSYSTEM_ID", " "
|
31
17
|
base.option "--partition-table-id", "PARTITION_TABLE_ID", " "
|
32
18
|
base.option "--compute-resource-id", "COMPUTE_RESOURCE", " "
|
33
|
-
base.option "--partition-table-id", "PARTITION_TABLE", " "
|
34
19
|
base.option "--puppetclass-ids", "PUPPETCLASS_IDS", " ",
|
35
20
|
:format => HammerCLI::Options::Normalizers::List.new
|
36
21
|
base.option "--root-password", "ROOT_PW", " "
|
@@ -58,6 +43,18 @@ module HammerCLIForeman
|
|
58
43
|
:format => HammerCLI::Options::Normalizers::KeyValueList.new
|
59
44
|
base.option "--provision-method", "METHOD", " ",
|
60
45
|
:format => HammerCLI::Options::Normalizers::Enum.new(['build', 'image'])
|
46
|
+
|
47
|
+
base.build_options :without => [
|
48
|
+
# - temporarily disabled params until they are fixed in API ------------------------
|
49
|
+
# issue #3884
|
50
|
+
:puppet_class_ids,
|
51
|
+
# - temporarily disabled params that will be removed from the api ------------------
|
52
|
+
:provision_method, :capabilities, :flavour_ref, :image_ref, :start,
|
53
|
+
:network, :cpus, :memory, :provider, :type, :tenant_id, :image_id,
|
54
|
+
# - avoids future conflicts as :root_pass is currently missing in the api docs
|
55
|
+
:root_pass,
|
56
|
+
# ----------------------------------------------------------------------------------
|
57
|
+
:ptable_id, :host_parameters_attributes]
|
61
58
|
end
|
62
59
|
|
63
60
|
def self.ask_password
|
@@ -126,21 +123,24 @@ module HammerCLIForeman
|
|
126
123
|
output do
|
127
124
|
field :id, _("Id")
|
128
125
|
field :name, _("Name")
|
129
|
-
field
|
130
|
-
field
|
126
|
+
field nil, _("Operating System"), Fields::SingleReference, :key => :operatingsystem
|
127
|
+
field nil, _("Host Group"), Fields::SingleReference, :key => :hostgroup
|
131
128
|
field :ip, _("IP")
|
132
129
|
field :mac, _("MAC")
|
133
130
|
end
|
134
131
|
|
135
|
-
|
132
|
+
build_options
|
136
133
|
end
|
137
134
|
|
138
135
|
|
139
136
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
140
137
|
|
141
138
|
def extend_data(host)
|
142
|
-
|
143
|
-
|
139
|
+
# FIXME: temporary fetching parameters until the api gets fixed.
|
140
|
+
# Noramlly they should come in the host's json.
|
141
|
+
# http://projects.theforeman.org/issues/5820
|
142
|
+
host["parameters"] = get_parameters(host["id"])
|
143
|
+
|
144
144
|
host["_bmc_interfaces"] =
|
145
145
|
host["interfaces"].select{|intfs| intfs["type"] == "Nic::BMC" } rescue []
|
146
146
|
host["_managed_interfaces"] =
|
@@ -148,12 +148,16 @@ module HammerCLIForeman
|
|
148
148
|
host
|
149
149
|
end
|
150
150
|
|
151
|
+
def get_parameters(host_id)
|
152
|
+
params = HammerCLIForeman.foreman_resource(:parameters).call(:index, :host_id => host_id)
|
153
|
+
HammerCLIForeman.collection_to_common_format(params)
|
154
|
+
end
|
155
|
+
|
151
156
|
output ListCommand.output_definition do
|
152
157
|
field :uuid, _("UUID")
|
153
158
|
field :certname, _("Cert name")
|
154
159
|
|
155
|
-
field
|
156
|
-
field :environment_id, _("Environment Id")
|
160
|
+
field nil, _("Environment"), Fields::SingleReference, :key => :environment
|
157
161
|
|
158
162
|
field :managed, _("Managed")
|
159
163
|
field :enabled, _("Enabled")
|
@@ -166,33 +170,27 @@ module HammerCLIForeman
|
|
166
170
|
field :sp_name, _("SP Name")
|
167
171
|
field :sp_ip, _("SP IP")
|
168
172
|
field :sp_mac, _("SP MAC")
|
169
|
-
field :sp_subnet, _("SP Subnet")
|
170
|
-
field :sp_subnet_id, _("SP Subnet Id")
|
171
173
|
|
172
|
-
field
|
173
|
-
|
174
|
+
field nil, _("SP Subnet"), Fields::SingleReference, :key => :sp_subnet
|
175
|
+
|
174
176
|
field :installed_at, _("Installed at"), Fields::Date
|
175
177
|
field :last_report, _("Last report"), Fields::Date
|
176
178
|
|
177
179
|
field :puppet_ca_proxy_id, _("Puppet CA Proxy Id")
|
178
|
-
field
|
179
|
-
field
|
180
|
+
field nil, _("Medium"), Fields::SingleReference, :key => :medium
|
181
|
+
field nil, _("Model"), Fields::SingleReference, :key => :model
|
180
182
|
field :owner_id, _("Owner Id")
|
181
|
-
field
|
182
|
-
field
|
183
|
+
field nil, _("Subnet"), Fields::SingleReference, :key => :subnet
|
184
|
+
field nil, _("Domain"), Fields::SingleReference, :key => :domain
|
183
185
|
field :puppet_proxy_id, _("Puppet Proxy Id")
|
184
186
|
field :owner_type, _("Owner Type")
|
185
|
-
field
|
186
|
-
field
|
187
|
-
field
|
188
|
-
field
|
187
|
+
field nil, _("Partition Table"), Fields::SingleReference, :key => :ptable
|
188
|
+
field nil, _("Architecture"), Fields::SingleReference, :key => :architecture
|
189
|
+
field nil, _("Image"), Fields::SingleReference, :key => :image
|
190
|
+
field nil, _("Compute Resource"), Fields::SingleReference, :key => :compute_resource
|
189
191
|
|
190
192
|
field :comment, _("Comment")
|
191
193
|
|
192
|
-
collection :parameters, _("Parameters") do
|
193
|
-
field nil, nil, Fields::KeyValue
|
194
|
-
end
|
195
|
-
|
196
194
|
collection :_bmc_interfaces, _("BMC Network Interfaces"), :hide_blank => true do
|
197
195
|
field :id, _("Id")
|
198
196
|
field :name, _("Name")
|
@@ -217,24 +215,24 @@ module HammerCLIForeman
|
|
217
215
|
field :subnet_name, _("Subnet Name")
|
218
216
|
end
|
219
217
|
|
218
|
+
HammerCLIForeman::References.parameters(self)
|
219
|
+
HammerCLIForeman::References.timestamps(self)
|
220
220
|
end
|
221
221
|
|
222
|
-
|
222
|
+
build_options
|
223
223
|
end
|
224
224
|
|
225
225
|
|
226
|
-
class StatusCommand <
|
227
|
-
|
228
|
-
identifiers :id, :name
|
229
|
-
|
226
|
+
class StatusCommand < HammerCLIForeman::SingleResourceCommand
|
230
227
|
command_name "status"
|
228
|
+
action :status
|
231
229
|
|
232
230
|
output do
|
233
231
|
field :status, _("Status")
|
234
232
|
field :power, _("Power")
|
235
233
|
end
|
236
234
|
|
237
|
-
def
|
235
|
+
def send_request
|
238
236
|
{
|
239
237
|
:status => get_status,
|
240
238
|
:power => get_power_status
|
@@ -243,7 +241,7 @@ module HammerCLIForeman
|
|
243
241
|
|
244
242
|
def get_status
|
245
243
|
params = {
|
246
|
-
'id' => get_identifier
|
244
|
+
'id' => get_identifier,
|
247
245
|
}
|
248
246
|
status = resource.call(:status, params)
|
249
247
|
status["status"]
|
@@ -251,19 +249,18 @@ module HammerCLIForeman
|
|
251
249
|
|
252
250
|
def get_power_status
|
253
251
|
params = {
|
254
|
-
'id' => get_identifier
|
252
|
+
'id' => get_identifier,
|
255
253
|
'power_action' => :state
|
256
254
|
}
|
257
255
|
status = resource.call(:power, params)
|
258
256
|
status["power"]
|
259
257
|
end
|
260
258
|
|
261
|
-
|
259
|
+
build_options
|
262
260
|
end
|
263
261
|
|
264
262
|
|
265
|
-
class PuppetRunCommand < HammerCLIForeman::
|
266
|
-
|
263
|
+
class PuppetRunCommand < HammerCLIForeman::SingleResourceCommand
|
267
264
|
command_name "puppetrun"
|
268
265
|
action :puppetrun
|
269
266
|
|
@@ -271,77 +268,54 @@ module HammerCLIForeman
|
|
271
268
|
print_message _('Puppet run triggered')
|
272
269
|
end
|
273
270
|
|
274
|
-
|
271
|
+
build_options
|
275
272
|
end
|
276
273
|
|
277
274
|
|
278
|
-
class FactsCommand < HammerCLIForeman::
|
279
|
-
|
275
|
+
class FactsCommand < HammerCLIForeman::AssociatedResourceListCommand
|
280
276
|
command_name "facts"
|
281
277
|
resource :fact_values, :index
|
282
|
-
|
283
|
-
|
284
|
-
apipie_options :without => declared_identifiers.keys
|
278
|
+
parent_resource :hosts
|
285
279
|
|
286
280
|
output do
|
287
281
|
field :fact, _("Fact")
|
288
282
|
field :value, _("Value")
|
289
283
|
end
|
290
284
|
|
291
|
-
def
|
292
|
-
|
293
|
-
params['host_id'] = get_identifier[0]
|
294
|
-
params
|
295
|
-
end
|
296
|
-
|
297
|
-
def retrieve_data
|
298
|
-
data = super
|
299
|
-
HammerCLIForeman::Fact::ListCommand.unhash_facts(data)
|
285
|
+
def send_request
|
286
|
+
HammerCLIForeman::Fact::ListCommand.unhash_facts(super)
|
300
287
|
end
|
301
288
|
|
289
|
+
build_options
|
302
290
|
end
|
303
291
|
|
304
292
|
|
305
|
-
class PuppetClassesCommand < HammerCLIForeman::
|
306
|
-
|
293
|
+
class PuppetClassesCommand < HammerCLIForeman::AssociatedResourceListCommand
|
307
294
|
command_name "puppet-classes"
|
308
|
-
resource :puppetclasses
|
309
|
-
|
310
|
-
identifiers :id, :name
|
295
|
+
resource :puppetclasses, :index
|
296
|
+
parent_resource :hosts
|
311
297
|
|
312
298
|
output HammerCLIForeman::PuppetClass::ListCommand.output_definition
|
313
299
|
|
314
|
-
def
|
300
|
+
def send_request
|
315
301
|
HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(super)
|
316
302
|
end
|
317
303
|
|
318
|
-
|
319
|
-
params = method_options
|
320
|
-
params['host_id'] = get_identifier[0]
|
321
|
-
params
|
322
|
-
end
|
323
|
-
|
324
|
-
apipie_options
|
304
|
+
build_options :without => [:host_id, :hostgroup_id, :environment_id]
|
325
305
|
end
|
326
306
|
|
327
307
|
|
328
|
-
class ReportsCommand < HammerCLIForeman::
|
329
|
-
|
330
|
-
identifiers :id, :name
|
331
|
-
|
308
|
+
class ReportsCommand < HammerCLIForeman::AssociatedResourceListCommand
|
332
309
|
command_name "reports"
|
333
|
-
resource :reports
|
334
|
-
|
310
|
+
resource :reports, :index
|
311
|
+
parent_resource :hosts
|
335
312
|
|
336
|
-
|
313
|
+
output HammerCLIForeman::Report::ListCommand.output_definition
|
337
314
|
|
338
|
-
|
339
|
-
'host.id = %s' % get_identifier[0].to_s
|
340
|
-
end
|
315
|
+
build_options
|
341
316
|
end
|
342
317
|
|
343
318
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
344
|
-
|
345
319
|
success_message _("Host created")
|
346
320
|
failure_message _("Could not create the host")
|
347
321
|
|
@@ -364,7 +338,6 @@ module HammerCLIForeman
|
|
364
338
|
|
365
339
|
|
366
340
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
367
|
-
|
368
341
|
success_message _("Host updated")
|
369
342
|
failure_message _("Could not update the host")
|
370
343
|
|
@@ -373,23 +346,16 @@ module HammerCLIForeman
|
|
373
346
|
|
374
347
|
|
375
348
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
376
|
-
|
377
349
|
success_message _("Host deleted")
|
378
350
|
failure_message _("Could not delete the host")
|
379
351
|
|
380
|
-
|
352
|
+
build_options
|
381
353
|
end
|
382
354
|
|
383
355
|
|
384
356
|
class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
|
385
|
-
|
386
|
-
resource :parameters
|
387
|
-
|
388
357
|
desc _("Create or update parameter for a host.")
|
389
358
|
|
390
|
-
option "--host-name", "HOST_NAME", _("name of the host the parameter is being set for")
|
391
|
-
option "--host-id", "HOST_ID", _("id of the host the parameter is being set for")
|
392
|
-
|
393
359
|
success_message_for :update, _("Host parameter updated")
|
394
360
|
success_message_for :create, _("New host parameter created")
|
395
361
|
failure_message _("Could not set host parameter")
|
@@ -399,23 +365,13 @@ module HammerCLIForeman
|
|
399
365
|
validator.any(:option_host_name, :option_host_id).required
|
400
366
|
end
|
401
367
|
|
402
|
-
|
403
|
-
{
|
404
|
-
"host_id" => option_host_id || option_host_name
|
405
|
-
}
|
406
|
-
end
|
368
|
+
build_options
|
407
369
|
end
|
408
370
|
|
409
371
|
|
410
372
|
class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
|
411
|
-
|
412
|
-
resource :parameters
|
413
|
-
|
414
373
|
desc _("Delete parameter for a host.")
|
415
374
|
|
416
|
-
option "--host-name", "HOST_NAME", _("name of the host the parameter is being deleted for")
|
417
|
-
option "--host-id", "HOST_ID", _("id of the host the parameter is being deleted for")
|
418
|
-
|
419
375
|
success_message _("Host parameter deleted")
|
420
376
|
|
421
377
|
def validate_options
|
@@ -423,17 +379,11 @@ module HammerCLIForeman
|
|
423
379
|
validator.any(:option_host_name, :option_host_id).required
|
424
380
|
end
|
425
381
|
|
426
|
-
|
427
|
-
{
|
428
|
-
"host_id" => option_host_id || option_host_name
|
429
|
-
}
|
430
|
-
end
|
382
|
+
build_options
|
431
383
|
end
|
432
384
|
|
433
385
|
|
434
|
-
class StartCommand <
|
435
|
-
|
436
|
-
identifiers :id, :name
|
386
|
+
class StartCommand < HammerCLIForeman::SingleResourceCommand
|
437
387
|
action :power
|
438
388
|
|
439
389
|
command_name "start"
|
@@ -446,19 +396,17 @@ module HammerCLIForeman
|
|
446
396
|
|
447
397
|
def request_params
|
448
398
|
params = method_options
|
449
|
-
params['id'] = get_identifier
|
399
|
+
params['id'] = get_identifier
|
450
400
|
params
|
451
401
|
end
|
452
402
|
|
453
|
-
|
403
|
+
build_options :without => :power_action
|
454
404
|
end
|
455
405
|
|
456
406
|
|
457
|
-
class StopCommand <
|
458
|
-
|
407
|
+
class StopCommand < HammerCLIForeman::SingleResourceCommand
|
459
408
|
option '--force', :flag, _("Force turning off a host")
|
460
409
|
|
461
|
-
identifiers :id, :name
|
462
410
|
action :power
|
463
411
|
|
464
412
|
command_name "stop"
|
@@ -482,16 +430,14 @@ module HammerCLIForeman
|
|
482
430
|
|
483
431
|
def request_params
|
484
432
|
params = method_options
|
485
|
-
params['id'] = get_identifier
|
433
|
+
params['id'] = get_identifier
|
486
434
|
params
|
487
435
|
end
|
488
436
|
|
489
|
-
|
437
|
+
build_options :without => :power_action
|
490
438
|
end
|
491
439
|
|
492
|
-
class RebootCommand <
|
493
|
-
|
494
|
-
identifiers :id, :name
|
440
|
+
class RebootCommand < HammerCLIForeman::SingleResourceCommand
|
495
441
|
action :power
|
496
442
|
|
497
443
|
command_name "reboot"
|
@@ -504,18 +450,16 @@ module HammerCLIForeman
|
|
504
450
|
|
505
451
|
def request_params
|
506
452
|
params = method_options
|
507
|
-
params['id'] = get_identifier
|
453
|
+
params['id'] = get_identifier
|
508
454
|
params
|
509
455
|
end
|
510
456
|
|
511
|
-
|
457
|
+
build_options :without => :power_action
|
512
458
|
end
|
513
459
|
|
514
460
|
class SCParamsCommand < HammerCLIForeman::SmartClassParametersList
|
515
|
-
|
516
|
-
|
517
|
-
option ['--id', '--name'], 'HOST_ID', _('host id/name'),
|
518
|
-
:attribute_name => :option_host_id, :required => true
|
461
|
+
parent_resource :hosts
|
462
|
+
build_options
|
519
463
|
end
|
520
464
|
|
521
465
|
autoload_subcommands
|