hammer_cli_foreman 2.0.0 → 2.1.2
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.
- checksums.yaml +4 -4
- data/doc/developer_docs.md +1 -0
- data/doc/plugin.md +22 -0
- data/doc/release_notes.md +33 -0
- data/lib/hammer_cli_foreman.rb +9 -1
- data/lib/hammer_cli_foreman/api/connection.rb +1 -18
- data/lib/hammer_cli_foreman/api/oauth/authentication_code_grant.rb +7 -4
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +0 -1
- data/lib/hammer_cli_foreman/associating_commands.rb +33 -5
- data/lib/hammer_cli_foreman/audit.rb +7 -0
- data/lib/hammer_cli_foreman/auth.rb +6 -6
- data/lib/hammer_cli_foreman/bookmark.rb +50 -0
- data/lib/hammer_cli_foreman/command_extensions.rb +2 -0
- data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +13 -7
- data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +13 -7
- data/lib/hammer_cli_foreman/command_extensions/subnet.rb +25 -0
- data/lib/hammer_cli_foreman/command_extensions/user.rb +17 -0
- data/lib/hammer_cli_foreman/commands.rb +20 -11
- data/lib/hammer_cli_foreman/compute_resource.rb +15 -0
- data/lib/hammer_cli_foreman/compute_resource/ec2.rb +11 -0
- data/lib/hammer_cli_foreman/compute_resource/gce.rb +9 -0
- data/lib/hammer_cli_foreman/compute_resource/libvirt.rb +11 -0
- data/lib/hammer_cli_foreman/compute_resource/openstack.rb +7 -0
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +21 -9
- data/lib/hammer_cli_foreman/compute_resource/vmware.rb +15 -2
- data/lib/hammer_cli_foreman/hostgroup.rb +11 -19
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +32 -10
- data/lib/hammer_cli_foreman/id_resolver.rb +12 -11
- data/lib/hammer_cli_foreman/mail_notification.rb +31 -0
- data/lib/hammer_cli_foreman/operating_system.rb +1 -1
- data/lib/hammer_cli_foreman/option_builders.rb +70 -48
- data/lib/hammer_cli_foreman/option_sources.rb +1 -0
- data/lib/hammer_cli_foreman/option_sources/referenced_resource_id_params.rb +47 -0
- data/lib/hammer_cli_foreman/sessions.rb +1 -3
- data/lib/hammer_cli_foreman/subnet.rb +26 -15
- data/lib/hammer_cli_foreman/task_helper.rb +180 -0
- data/lib/hammer_cli_foreman/user.rb +7 -17
- data/lib/hammer_cli_foreman/user_mail_notification.rb +51 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/hammer_cli_foreman/virtual_machine.rb +55 -0
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/data/2.1/foreman_api.json +1 -0
- data/test/functional/associating_commands_test.rb +134 -30
- data/test/functional/bookmark_test.rb +193 -0
- data/test/functional/host_test.rb +27 -1
- data/test/functional/http_proxy_test.rb +1 -4
- data/test/functional/mail_notification_test.rb +57 -0
- data/test/functional/subnet/create_test.rb +28 -5
- data/test/functional/template_test.rb +2 -2
- data/test/functional/user_mail_notification_test.rb +89 -0
- data/test/functional/virtual_machine_test.rb +129 -0
- data/test/reports/TEST-Minitest-Result.xml +4344 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/audit_test.rb +1 -0
- data/test/unit/sessions_test.rb +2 -13
- metadata +28 -6
@@ -275,8 +275,8 @@ module HammerCLIForeman
|
|
275
275
|
record
|
276
276
|
end
|
277
277
|
|
278
|
-
def self.
|
279
|
-
super(
|
278
|
+
def self.command_names(*names)
|
279
|
+
super(*names) || %w(list index)
|
280
280
|
end
|
281
281
|
|
282
282
|
def execute
|
@@ -502,8 +502,8 @@ module HammerCLIForeman
|
|
502
502
|
end
|
503
503
|
end
|
504
504
|
|
505
|
-
def self.
|
506
|
-
super(
|
505
|
+
def self.command_names(*names)
|
506
|
+
super(*names) || %w(info show)
|
507
507
|
end
|
508
508
|
|
509
509
|
def send_request
|
@@ -565,8 +565,8 @@ module HammerCLIForeman
|
|
565
565
|
|
566
566
|
action :destroy
|
567
567
|
|
568
|
-
def self.
|
569
|
-
super(
|
568
|
+
def self.command_names(*names)
|
569
|
+
super(*names) || %w(delete destroy)
|
570
570
|
end
|
571
571
|
|
572
572
|
end
|
@@ -671,8 +671,12 @@ module HammerCLIForeman
|
|
671
671
|
|
672
672
|
def get_new_ids
|
673
673
|
ids = get_current_ids.map(&:to_s)
|
674
|
-
|
675
|
-
|
674
|
+
|
675
|
+
associated_identifiers = get_associated_identifiers
|
676
|
+
associated_identifier = get_associated_identifier
|
677
|
+
|
678
|
+
required_ids = associated_identifiers.nil? ? [] : associated_identifiers.map(&:to_s)
|
679
|
+
required_ids << associated_identifier.to_s unless associated_identifier.nil?
|
676
680
|
|
677
681
|
ids += required_ids
|
678
682
|
ids.uniq
|
@@ -683,7 +687,7 @@ module HammerCLIForeman
|
|
683
687
|
class RemoveAssociatedCommand < AssociatedCommand
|
684
688
|
|
685
689
|
def self.command_name(name=nil)
|
686
|
-
name = super(name) || (associated_resource ? "remove-"+associated_resource.singular_name : nil)
|
690
|
+
name = super(name) || (associated_resource ? "remove-" + associated_resource.singular_name : nil)
|
687
691
|
name.respond_to?(:gsub) ? name.gsub('_', '-') : name
|
688
692
|
end
|
689
693
|
|
@@ -694,9 +698,14 @@ module HammerCLIForeman
|
|
694
698
|
|
695
699
|
def get_new_ids
|
696
700
|
ids = get_current_ids.map(&:to_s)
|
697
|
-
required_id = get_associated_identifier.to_s
|
698
701
|
|
699
|
-
|
702
|
+
associated_identifiers = get_associated_identifiers
|
703
|
+
associated_identifier = get_associated_identifier
|
704
|
+
|
705
|
+
required_ids = associated_identifiers.nil? ? [] : associated_identifiers.map(&:to_s)
|
706
|
+
required_ids << associated_identifier.to_s unless associated_identifier.nil?
|
707
|
+
|
708
|
+
ids = ids.delete_if { |id| required_ids.include? id }
|
700
709
|
ids
|
701
710
|
end
|
702
711
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'hammer_cli_foreman/image'
|
2
|
+
require 'hammer_cli_foreman/virtual_machine'
|
2
3
|
require 'hammer_cli_foreman/compute_resource/register_compute_resources'
|
3
4
|
|
4
5
|
module HammerCLIForeman
|
@@ -223,7 +224,21 @@ module HammerCLIForeman
|
|
223
224
|
build_options
|
224
225
|
end
|
225
226
|
|
227
|
+
class AvailableVirtualMachinesCommand < HammerCLIForeman::ListCommand
|
228
|
+
action :available_virtual_machines
|
229
|
+
command_name 'virtual-machines'
|
230
|
+
|
231
|
+
output do
|
232
|
+
field :id, _("Id")
|
233
|
+
field :name, _("Name")
|
234
|
+
end
|
235
|
+
|
236
|
+
build_options
|
237
|
+
end
|
238
|
+
|
226
239
|
autoload_subcommands
|
240
|
+
subcommand 'virtual-machine', HammerCLIForeman::VirtualMachine.desc,
|
241
|
+
HammerCLIForeman::VirtualMachine
|
227
242
|
subcommand 'image', HammerCLIForeman::Image.desc, HammerCLIForeman::Image
|
228
243
|
end
|
229
244
|
|
@@ -15,6 +15,17 @@ module HammerCLIForeman
|
|
15
15
|
]
|
16
16
|
end
|
17
17
|
|
18
|
+
def provider_vm_specific_fields
|
19
|
+
[
|
20
|
+
Fields::Field.new(:label => _('DNS'), :path => [:dns_name]),
|
21
|
+
Fields::Field.new(:label => _('Type'), :path => [:flavor_id]),
|
22
|
+
Fields::Field.new(:label => _('State'), :path => [:state]),
|
23
|
+
Fields::Field.new(:label => _('Owner Id'), :path => [:ownerId]),
|
24
|
+
Fields::Field.new(:label => _('DNS Name'), :path => [:dns_name]),
|
25
|
+
Fields::Field.new(:label => _('Virtualization Type'), :path => [:virtualization_type])
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
18
29
|
def mandatory_resource_options
|
19
30
|
super + %i[region user password]
|
20
31
|
end
|
@@ -28,6 +28,15 @@ module HammerCLIForeman
|
|
28
28
|
]
|
29
29
|
end
|
30
30
|
|
31
|
+
def provider_vm_specific_fields
|
32
|
+
[
|
33
|
+
Fields::Field.new(:label => _('Machine Type'), :path => [:machine_type]),
|
34
|
+
Fields::Field.new(:label => _('Status'), :path => [:status]),
|
35
|
+
Fields::Field.new(:label => _('Description'), :path => [:description]),
|
36
|
+
Fields::Field.new(:label => _('Zone'), :path => [:zone])
|
37
|
+
]
|
38
|
+
end
|
39
|
+
|
31
40
|
def mandatory_resource_options
|
32
41
|
super + %I{project key_path zone}
|
33
42
|
end
|
@@ -41,6 +41,17 @@ module HammerCLIForeman
|
|
41
41
|
'nics_attributes'
|
42
42
|
end
|
43
43
|
|
44
|
+
def provider_vm_specific_fields
|
45
|
+
[
|
46
|
+
Fields::Field.new(:label => _('CPUs'), :path => [:cpus]),
|
47
|
+
Fields::Field.new(:label => _('Memory'), :path => [:memory_size]),
|
48
|
+
Fields::Field.new(:label => _('Status'), :path => [:state]),
|
49
|
+
Fields::Field.new(:label => _('OS Type'), :path => [:os_type]),
|
50
|
+
Fields::Field.new(:label => _('Domain Type'), :path => [:domain_type]),
|
51
|
+
Fields::Field.new(:label => _('Persistent'), :path => [:persistent])
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
44
55
|
def mandatory_resource_options
|
45
56
|
super + %i[url]
|
46
57
|
end
|
@@ -20,6 +20,13 @@ module HammerCLIForeman
|
|
20
20
|
def mandatory_resource_options
|
21
21
|
super + %i[url user password]
|
22
22
|
end
|
23
|
+
|
24
|
+
def provider_vm_specific_fields
|
25
|
+
[
|
26
|
+
Fields::Field.new(:label => _('State'), :path => [:state]),
|
27
|
+
Fields::Field.new(:label => _('Tenant Id'), :path => [:tenant_id])
|
28
|
+
]
|
29
|
+
end
|
23
30
|
end
|
24
31
|
|
25
32
|
HammerCLIForeman.register_compute_resource('openstack', OpenStack.new)
|
@@ -7,17 +7,19 @@ module HammerCLIForeman
|
|
7
7
|
|
8
8
|
def compute_attributes
|
9
9
|
[
|
10
|
-
['cluster',
|
11
|
-
['template',
|
12
|
-
['cores',
|
13
|
-
['sockets',
|
14
|
-
['memory',
|
10
|
+
['cluster', _('ID or name of cluster to use')],
|
11
|
+
['template', _('Hardware profile to use')],
|
12
|
+
['cores', _('Integer value, number of cores')],
|
13
|
+
['sockets', _('Integer value, number of sockets')],
|
14
|
+
['memory', _('Amount of memory, integer value in bytes')],
|
15
|
+
['display_type', _('Possible values: %s') % 'VNC, SPICE'],
|
16
|
+
['keyboard_layout', _('Possible values: %s. Not usable if display type is SPICE.') % 'ar, de-ch, es, fo, fr-ca, hu, ja, mk, no, pt-br, sv, da, en-gb, et, fr, fr-ch, is, lt, nl, pl, ru, th, de, en-us, fi, fr-be, hr, it, lv, nl-be, pt, sl, tr']
|
15
17
|
]
|
16
18
|
end
|
17
19
|
|
18
20
|
def host_attributes
|
19
21
|
[
|
20
|
-
['start', _('Boolean
|
22
|
+
['start', _('Boolean, set 1 to start the vm')]
|
21
23
|
]
|
22
24
|
end
|
23
25
|
|
@@ -33,9 +35,9 @@ module HammerCLIForeman
|
|
33
35
|
[
|
34
36
|
['size_gb', _('Volume size in GB, integer value')],
|
35
37
|
['storage_domain', _('ID or name of storage domain')],
|
36
|
-
['bootable', _('Boolean, only one volume can be bootable')],
|
37
|
-
['preallocate', _('Boolean, set
|
38
|
-
['wipe_after_delete', _('Boolean, set
|
38
|
+
['bootable', _('Boolean, set 1 for bootable, only one volume can be bootable')],
|
39
|
+
['preallocate', _('Boolean, set 1 to preallocate')],
|
40
|
+
['wipe_after_delete', _('Boolean, set 1 to wipe disk after delete')],
|
39
41
|
['interface', _('Disk interface name, must be ide, virto or virto_scsi')]
|
40
42
|
]
|
41
43
|
end
|
@@ -46,6 +48,16 @@ module HammerCLIForeman
|
|
46
48
|
]
|
47
49
|
end
|
48
50
|
|
51
|
+
def provider_vm_specific_fields
|
52
|
+
[
|
53
|
+
Fields::Field.new(:label => _('CPUs'), :path => [:cpu]),
|
54
|
+
Fields::Field.new(:label => _('Memory'), :path => [:memory]),
|
55
|
+
Fields::Field.new(:label => _('Status'), :path => [:status]),
|
56
|
+
Fields::Field.new(:label => _('Cores'), :path => [:cores]),
|
57
|
+
Fields::Field.new(:label => _('Type'), :path => [:type])
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
49
61
|
def mandatory_resource_options
|
50
62
|
super + %i[url user password datacenter]
|
51
63
|
end
|
@@ -18,8 +18,8 @@ module HammerCLIForeman
|
|
18
18
|
['firmware', 'automatic/bios/efi'],
|
19
19
|
['guest_id', _('Guest OS ID form VMware')],
|
20
20
|
['hardware_version', _('Hardware version ID from VMware')],
|
21
|
-
['memoryHotAddEnabled', _('Must be a 1 or 0, lets you add
|
22
|
-
['cpuHotAddEnabled', _('Must be a 1 or 0, lets you add
|
21
|
+
['memoryHotAddEnabled', _('Must be a 1 or 0, lets you add memory resources while the machine is on')],
|
22
|
+
['cpuHotAddEnabled', _('Must be a 1 or 0, lets you add CPU resources while the machine is on')],
|
23
23
|
['add_cdrom', _('Must be a 1 or 0, Add a CD-ROM drive to the virtual machine')],
|
24
24
|
['annotation', _('Annotation Notes')],
|
25
25
|
['scsi_controllers', [_('List with SCSI controllers definitions'),
|
@@ -67,6 +67,19 @@ module HammerCLIForeman
|
|
67
67
|
]
|
68
68
|
end
|
69
69
|
|
70
|
+
def provider_vm_specific_fields
|
71
|
+
[
|
72
|
+
Fields::Field.new(:label => _('CPUs'), :path => [:cpus]),
|
73
|
+
Fields::Field.new(:label => _('Memory'), :path => [:memory_mb]),
|
74
|
+
Fields::Field.new(:label => _('Power Status'), :path => [:power_state]),
|
75
|
+
Fields::Field.new(:label => _('Host Name'), :path => [:hostname]),
|
76
|
+
Fields::Field.new(:label => _('Connection Status'), :path => [:connection_status]),
|
77
|
+
Fields::Field.new(:label => _('Hardware Version'), :path => [:hardware_version]),
|
78
|
+
Fields::Field.new(:label => _('Path'), :path => [:path]),
|
79
|
+
Fields::Field.new(:label => _('Operating System'), :path => [:operatingsystem])
|
80
|
+
]
|
81
|
+
end
|
82
|
+
|
70
83
|
def mandatory_resource_options
|
71
84
|
super + %i[user password datacenter server]
|
72
85
|
end
|
@@ -15,10 +15,14 @@ module HammerCLIForeman
|
|
15
15
|
base.option "--puppet-ca-proxy", "PUPPET_CA_PROXY_NAME", _("Name of puppet CA proxy")
|
16
16
|
base.option "--puppet-proxy", "PUPPET_PROXY_NAME", _("Name of puppet proxy")
|
17
17
|
base.option "--parent", "PARENT_NAME", _("Name of parent hostgroup")
|
18
|
-
base.option "--root-pass", "ROOT_PASSWORD", _("Root password")
|
19
|
-
|
20
|
-
|
18
|
+
base.option ["--root-password", "--root-pass"], "ROOT_PASSWORD", _("Root password"),
|
19
|
+
deprecated: { '--root-pass' => _("Use --root-password instead") }
|
20
|
+
base.option ["--ask-root-password", "--ask-root-pass"], "ASK_ROOT_PW", "",
|
21
|
+
format: HammerCLI::Options::Normalizers::Bool.new,
|
22
|
+
deprecated: { '--ask-root-pass' => _("Use --ask-root-password instead") }
|
21
23
|
base.option "--subnet6", "SUBNET6_NAME", _("Subnet IPv6 name")
|
24
|
+
|
25
|
+
base.build_options without: %i[root_pass]
|
22
26
|
end
|
23
27
|
|
24
28
|
def self.ask_password
|
@@ -32,12 +36,8 @@ module HammerCLIForeman
|
|
32
36
|
params['hostgroup']["puppet_proxy_id"] ||= proxy_id(option_puppet_proxy) if option_puppet_proxy
|
33
37
|
params['hostgroup']["puppet_ca_proxy_id"] ||= proxy_id(option_puppet_ca_proxy) if option_puppet_ca_proxy
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
params['hostgroup']['puppetclass_ids'] = puppetclass_ids unless puppetclass_ids.nil?
|
38
|
-
|
39
|
-
params['hostgroup']['root_pass'] = option_root_pass if option_root_pass
|
40
|
-
params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_pass
|
39
|
+
params['hostgroup']['root_pass'] = option_root_password if option_root_password
|
40
|
+
params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_password
|
41
41
|
|
42
42
|
params['hostgroup']['subnet6_id'] = resolver.subnet_id('option_name' => option_subnet6) if option_subnet6
|
43
43
|
params
|
@@ -48,11 +48,6 @@ module HammerCLIForeman
|
|
48
48
|
def proxy_id(name)
|
49
49
|
resolver.smart_proxy_id('option_name' => name) if name
|
50
50
|
end
|
51
|
-
|
52
|
-
def puppet_class_ids(names)
|
53
|
-
resolver.puppetclass_ids('option_names' => names) if names
|
54
|
-
end
|
55
|
-
|
56
51
|
end
|
57
52
|
|
58
53
|
class Hostgroup < HammerCLIForeman::Command
|
@@ -87,7 +82,8 @@ module HammerCLIForeman
|
|
87
82
|
field nil, _("Parent"), Fields::SingleReference, :key => :parent, :hide_blank => true
|
88
83
|
field nil, _("Puppet CA Proxy"), Fields::SingleReference, :key => :puppet_ca_proxy
|
89
84
|
field nil, _("Puppet Master Proxy"), Fields::SingleReference, :key => :puppet_proxy
|
90
|
-
field nil, _("
|
85
|
+
field nil, _("Compute Profile"), Fields::SingleReference, :key => :compute_profile
|
86
|
+
field nil, _("Compute Resource"), Fields::SingleReference, :key => :compute_resource
|
91
87
|
label _('Network') do
|
92
88
|
field nil, _("Subnet ipv4"), Fields::SingleReference, :key => :subnet
|
93
89
|
field nil, _("Subnet ipv6"), Fields::SingleReference, :key => :subnet6
|
@@ -116,8 +112,6 @@ module HammerCLIForeman
|
|
116
112
|
success_message _("Hostgroup created.")
|
117
113
|
failure_message _("Could not create the hostgroup")
|
118
114
|
|
119
|
-
build_options
|
120
|
-
|
121
115
|
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
|
122
116
|
end
|
123
117
|
|
@@ -128,8 +122,6 @@ module HammerCLIForeman
|
|
128
122
|
success_message _("Hostgroup updated.")
|
129
123
|
failure_message _("Could not update the hostgroup")
|
130
124
|
|
131
|
-
build_options
|
132
|
-
|
133
125
|
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironment.new)
|
134
126
|
end
|
135
127
|
|
@@ -14,15 +14,22 @@ module HammerCLIForeman
|
|
14
14
|
base.option "--ask-root-password", "ASK_ROOT_PW", " ",
|
15
15
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
16
16
|
|
17
|
-
base.option
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
:
|
25
|
-
|
17
|
+
base.option '--puppet-proxy', 'PUPPET_PROXY_NAME', '',
|
18
|
+
referenced_resource: 'puppet_proxy',
|
19
|
+
aliased_resource: 'puppet_proxy'
|
20
|
+
base.option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', '',
|
21
|
+
referenced_resource: 'puppet_ca_proxy',
|
22
|
+
aliased_resource: 'puppet_ca_proxy'
|
23
|
+
base.option_family(
|
24
|
+
format: HammerCLI::Options::Normalizers::List.new,
|
25
|
+
aliased_resource: 'puppet-class',
|
26
|
+
description: 'Names/Ids of associated puppet classes'
|
27
|
+
) do
|
28
|
+
parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', '',
|
29
|
+
attribute_name: :option_puppetclass_ids
|
30
|
+
child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
|
31
|
+
attribute_name: :option_puppetclass_names
|
32
|
+
end
|
26
33
|
bme_options = {}
|
27
34
|
bme_options[:default] = 'true' if base.action.to_sym == :create
|
28
35
|
|
@@ -59,7 +66,7 @@ module HammerCLIForeman
|
|
59
66
|
|
60
67
|
def request_params
|
61
68
|
params = super
|
62
|
-
owner_id =
|
69
|
+
owner_id = owner_id(option_user_login, params['host']['owner_type'])
|
63
70
|
params['host']['owner_id'] ||= owner_id unless owner_id.nil?
|
64
71
|
|
65
72
|
puppet_proxy_id = proxy_id(option_puppet_proxy)
|
@@ -79,6 +86,14 @@ module HammerCLIForeman
|
|
79
86
|
params['host']['host_parameters_attributes'] ||= option_typed_parameters unless option_typed_parameters.nil?
|
80
87
|
params['host']['compute_attributes'] = option_compute_attributes || {}
|
81
88
|
|
89
|
+
compute_attributes = params['host']['compute_attributes']
|
90
|
+
compute_attributes['display'] = {} unless compute_attributes['display_type'].nil? && compute_attributes['keyboard_layout'].nil?
|
91
|
+
compute_attributes['display']['type'] = compute_attributes['display_type'] unless compute_attributes['display_type'].nil?
|
92
|
+
compute_attributes['display']['keyboard_layout'] = compute_attributes['keyboard_layout'] unless compute_attributes['keyboard_layout'].nil?
|
93
|
+
compute_attributes.delete('display_type')
|
94
|
+
compute_attributes.delete('keyboard_layout')
|
95
|
+
params['host']['compute_attributes'] = compute_attributes
|
96
|
+
|
82
97
|
if action == :update
|
83
98
|
params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list) unless option_volume_list.empty?
|
84
99
|
params['host']['interfaces_attributes'] = interfaces_attributes unless option_interface_list.empty?
|
@@ -119,6 +134,13 @@ module HammerCLIForeman
|
|
119
134
|
|
120
135
|
private
|
121
136
|
|
137
|
+
def owner_id(name, type = 'User')
|
138
|
+
return unless name
|
139
|
+
return resolver.user_id('option_login' => name) if type == 'User'
|
140
|
+
|
141
|
+
resolver.usergroup_id('option_name' => name)
|
142
|
+
end
|
143
|
+
|
122
144
|
def proxy_id(name)
|
123
145
|
resolver.smart_proxy_id('option_name' => name) if name
|
124
146
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module HammerCLIForeman
|
2
2
|
|
3
3
|
class Searchable
|
4
|
+
attr_reader :name, :description, :format
|
4
5
|
|
5
6
|
def initialize(name, description, options={})
|
6
7
|
@name = name
|
7
8
|
@description = description
|
8
9
|
@editable = options[:editable].nil? ? true : options[:editable]
|
9
10
|
@format = options[:format]
|
11
|
+
@parent = options[:parent]
|
10
12
|
end
|
11
13
|
|
12
|
-
attr_reader :name, :description
|
13
|
-
|
14
14
|
def plural_name
|
15
15
|
ApipieBindings::Inflector.pluralize(@name)
|
16
16
|
end
|
@@ -19,10 +19,9 @@ module HammerCLIForeman
|
|
19
19
|
@editable
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
23
|
-
@
|
22
|
+
def parent?
|
23
|
+
@parent
|
24
24
|
end
|
25
|
-
|
26
25
|
end
|
27
26
|
|
28
27
|
class Searchables
|
@@ -51,15 +50,17 @@ module HammerCLIForeman
|
|
51
50
|
:hostgroup => [ s_name(_("Hostgroup name")), s("title", _("Hostgroup title"), :editable => false) ],
|
52
51
|
# :image => [],
|
53
52
|
:interface => [],
|
54
|
-
:location => [ s(
|
55
|
-
s(
|
56
|
-
|
53
|
+
:location => [ s('name', _('Set the current location context for the request')),
|
54
|
+
s('title', _('Set the current location context for the request' ),
|
55
|
+
editable: false
|
56
|
+
)
|
57
57
|
],
|
58
58
|
:medium => [ s_name(_("Medium name")) ],
|
59
59
|
:model => [ s_name(_("Model name")) ],
|
60
|
-
:organization => [ s(
|
61
|
-
s(
|
62
|
-
|
60
|
+
:organization => [ s('name', _('Set the current organization context for the request')),
|
61
|
+
s('title', _('Set the current organization context for the request'),
|
62
|
+
editable: false
|
63
|
+
)
|
63
64
|
],
|
64
65
|
:operatingsystem => [ s("title", _("Operating system title"), :editable => false) ],
|
65
66
|
:override_value => [],
|