From 71b7133e04e79b63fbd83d7cd9db54a1131203aa Mon Sep 17 00:00:00 2001 From: yifatmakias Date: Sun, 8 Mar 2020 12:21:01 +0200 Subject: [PATCH] Fixes #29254 - add display options to host creation on ovirt --- lib/hammer_cli_foreman/compute_resource/ovirt.rb | 12 +++++++----- .../hosts/common_update_options.rb | 8 ++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/hammer_cli_foreman/compute_resource/ovirt.rb b/lib/hammer_cli_foreman/compute_resource/ovirt.rb index 48f8900fd..8e723ed84 100644 --- a/lib/hammer_cli_foreman/compute_resource/ovirt.rb +++ b/lib/hammer_cli_foreman/compute_resource/ovirt.rb @@ -7,11 +7,13 @@ def name def compute_attributes [ - ['cluster', _('ID or name of cluster to use')], - ['template', _('Hardware profile to use')], - ['cores', _('Integer value, number of cores')], - ['sockets', _('Integer value, number of sockets')], - ['memory', _('Amount of memory, integer value in bytes')] + ['cluster', _('ID or name of cluster to use')], + ['template', _('Hardware profile to use')], + ['cores', _('Integer value, number of cores')], + ['sockets', _('Integer value, number of sockets')], + ['memory', _('Amount of memory, integer value in bytes')], + ['display_type', _('Possible values: %s') % 'VNC, SPICE'], + ['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'] ] end diff --git a/lib/hammer_cli_foreman/hosts/common_update_options.rb b/lib/hammer_cli_foreman/hosts/common_update_options.rb index 191285853..7ccf7fe14 100644 --- a/lib/hammer_cli_foreman/hosts/common_update_options.rb +++ b/lib/hammer_cli_foreman/hosts/common_update_options.rb @@ -79,6 +79,14 @@ def request_params params['host']['host_parameters_attributes'] ||= option_typed_parameters unless option_typed_parameters.nil? params['host']['compute_attributes'] = option_compute_attributes || {} + compute_attributes = params['host']['compute_attributes'] + compute_attributes['display'] = {} unless compute_attributes['display_type'].nil? && compute_attributes['keyboard_layout'].nil? + compute_attributes['display']['type'] = compute_attributes['display_type'] unless compute_attributes['display_type'].nil? + compute_attributes['display']['keyboard_layout'] = compute_attributes['keyboard_layout'] unless compute_attributes['keyboard_layout'].nil? + compute_attributes.delete('display_type') + compute_attributes.delete('keyboard_layout') + params['host']['compute_attributes'] = compute_attributes + if action == :update params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list) unless option_volume_list.empty? params['host']['interfaces_attributes'] = interfaces_attributes unless option_interface_list.empty?